Skip to content

Protect Netlify execution ledger writes#69

Closed
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/critical-bug-investigation-7be2
Closed

Protect Netlify execution ledger writes#69
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/critical-bug-investigation-7be2

Conversation

@cursor

@cursor cursor Bot commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Reject unauthenticated POST requests in the Netlify execution ledger function before connecting to shared storage
  • Mirror the existing server-only EXECUTION_LEDGER_WRITE_TOKEN authorization pattern used by the Vercel-style API handler

Bug and Impact

Netlify rewrites /api/execution-ledger to netlify/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 lint passed with existing fast-refresh warnings
  • npm run build passed with existing chunk-size warning
  • npx tsc --noEmit -p tsconfig.json passed
  • Direct TypeScript check of netlify/functions/execution-ledger.ts passed
  • Runtime smoke test confirmed an unauthenticated forged POST returns 403
Open in Web View Automation 

Co-authored-by: Ian Alloway <ianalloway@usf.edu>
@netlify

netlify Bot commented Jun 13, 2026

Copy link
Copy Markdown

Deploy Preview for aiadvantagea ready!

Name Link
🔨 Latest commit 45e70e3
🔍 Latest deploy log https://app.netlify.com/projects/aiadvantagea/deploys/6a2d3a526f66a0000895fbf5
😎 Deploy Preview https://deploy-preview-69--aiadvantagea.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@ianalloway ianalloway marked this pull request as ready for review June 18, 2026 15:59
Copilot AI review requested due to automatic review settings June 18, 2026 15:59

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@ianalloway

Copy link
Copy Markdown
Owner

Merged via PR #73 which incorporated these changes.

@ianalloway ianalloway closed this Jun 18, 2026
@ianalloway ianalloway deleted the cursor/critical-bug-investigation-7be2 branch June 18, 2026 15:59

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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)) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

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.

3 participants