Protect Netlify execution ledger writes#69
Conversation
Co-authored-by: Ian Alloway <ianalloway@usf.edu>
✅ Deploy Preview for aiadvantagea ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
Merged via PR #73 which incorporated these changes. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 45e70e382f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| } | ||
|
|
||
| export const handler = async (event: NetlifyEvent) => { | ||
| if (event.httpMethod === "POST" && !isWriteAuthorized(event)) { |
There was a problem hiding this comment.
Restore a server-side path for ledger writes
On Netlify, /api/* is redirected to this function, and the only in-repo ledger writer I found is the browser call in src/lib/executionLedgerStore.ts, which sends only Content-Type. With this new check, normal board syncs now always get 403 because the server-only EXECUTION_LEDGER_WRITE_TOKEN cannot be safely attached from the browser, so the shared proof ledger stops accumulating rows and silently falls back to per-browser storage. Add a trusted server-side writer/proxy before enforcing the token on this endpoint.
Useful? React with 👍 / 👎.
Summary
EXECUTION_LEDGER_WRITE_TOKENauthorization pattern used by the Vercel-style API handlerBug and Impact
Netlify rewrites
/api/execution-ledgertonetlify/functions/execution-ledger.ts, which accepted public browser POSTs. A forged request could poison the shared proof ledger with fake outcomes that would then be served to users and hydrated into local IndexedDB.Root Cause
The hardened token check existed in
api/execution-ledger.ts, but the production Netlify handler did not implement it.Validation
npm run lintpassed with existing fast-refresh warningsnpm run buildpassed with existing chunk-size warningnpx tsc --noEmit -p tsconfig.jsonpassednetlify/functions/execution-ledger.tspassed403