Skip to content

fix: harden buy page, cache, headers, and create recipients after audit - #64

Merged
r0ohafza merged 3 commits into
mainfrom
fix/audit-followups
Aug 24, 2026
Merged

fix: harden buy page, cache, headers, and create recipients after audit#64
r0ohafza merged 3 commits into
mainfrom
fix/audit-followups

Conversation

@r0ohafza

Copy link
Copy Markdown
Collaborator

Changed user flows

  • /buy: the ?offering= address is checked against the factory's OfferingCreated scan before the page renders. Unknown address → "Unknown offering" notice with no approve/pay UI; scan failure → "Could not verify offering, refresh to retry"; otherwise unchanged. First visit in a fresh browser waits on the same listing scan / already performs.
  • /create: on submit, the proceeds address and every holder address are checked for ERC-1155 receiver support (bytecode + ERC-165 IERC1155Receiver). A contract without the hook flags the field ("This contract can't receive ERC-1155 units. Use a wallet address or a Safe.") and blocks the deploy; EOAs and Safes pass. No wallet prompt is issued before the check.
  • All pages: listings no longer wedge on a malformed cached item; a dedupeKey throw falls back to a full rescan, matching the documented corrupt-cache behavior.
  • Hosting: vercel.json now sends a Content-Security-Policy (frame-ancestors 'none', self scripts, Google Fonts, Alchemy, Base RPC, WalletConnect relay/verify/api hosts), Referrer-Policy, X-Content-Type-Options, X-Frame-Options. Needs a preview-deploy console check; local dev/preview don't apply Vercel headers.
  • Docs: contracts.md states that revenue must go to the token, never payoutSplit, and explains the placeholder-recipient window during Funding.

Test coverage changed

  • Buy-page factory gate: tests/pact-flow.spec.ts public buy, private claim, and failed-round refund flows now pass through the gate against the anvil factory (existing specs, unchanged).
  • Cache fallback: new unit test cachedScan rescans when a cached item has no dedupe key in src/lib/chain/offerings.test.ts.
  • Receiver check: EOA path covered by the existing e2e create flow. Contract-recipient rejection and the Safe pass-through are manual (not yet exercised).
  • CSP headers: manual, on a Vercel preview deploy.

Validation

  • npm run typecheck
  • npm test
  • npm run test:contracts
  • npm run test:e2e
  • Manual browser review, when user-facing behavior changed

Full npm run validate result:

typecheck, lint, unit (82), forge (87), e2e (11) all pass. format:check was run on the touched files only; the untracked audit scratch directory in the working tree is not part of this branch.

E2E impact override: buy-app.tsx and create-app.tsx changed without spec changes. The buy gate is on the path of every existing buy/claim/refund spec, which all pass; the create receiver check is a pre-deploy read that the existing create spec exercises on the EOA path. Contract-recipient rejection needs a manual check.

Follow-ups from the security audit that don't change contract behavior:

- buy page verifies ?offering= against the factory's OfferingCreated scan
  before rendering anything that approves or pays
- a listing-cache item the dedupe key can't read now triggers a full
  rescan instead of throwing on every load
- vercel.json ships a CSP (frame-ancestors 'none', self scripts, Base RPC,
  Alchemy, Google Fonts, WalletConnect hosts), Referrer-Policy, nosniff
- /create checks the proceeds address and every holder for ERC-1155
  receiver support so a hook-less contract fails in the form, not at mint
  or close
- contracts.md: revenue goes to the token, never payoutSplit, and why
@vercel

vercel Bot commented Aug 24, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
pact Ready Ready Preview Aug 24, 2026 10:35pm

Request Review

@r0ohafza
r0ohafza marked this pull request as ready for review August 24, 2026 22:30
@r0ohafza
r0ohafza merged commit 0c88070 into main Aug 24, 2026
5 checks passed
@r0ohafza
r0ohafza deleted the fix/audit-followups branch August 24, 2026 22:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant