fix(auth): remove synthetic-admin bypass (Brief 2 of fix-auth-bypass) #8
No reviewers
Labels
No labels
agent-context-drift
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: rstillwell/deckhearth#8
Loading…
Reference in a new issue
No description provided.
Delete branch "brief/fix-auth-bypass/2-remove-admin-bypass"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Convoy
fix-auth-bypass/ Brief 2 of 5. This is the keystone PR of the convoy — it closes AGENTS.md gotcha #2 (the actual auth bypass). PR #6 (Brief 1) only renamed the secret; this PR removes the bypass behavior.lib/permission-middleware.js::getUserFromRequestno longer returns a hardcoded{ userId: 1, email: 'admin@tcgvault.com', role: 'admin' }when theAuthorizationheader is missing or malformed. It now returnsnull, and the 24 callers acrosspages/api/correctly handle the null per theif (!user) return res.status(401)pattern documented in.cursor/rules/auth-and-permissions.mdc.pages/api/auth/verify.jsno-token branch returns 401 instead of fetching the seed admin row viaWHERE email = 'admin@tcgvault.com'. The admin-record leak side of the same bypass is closed.NODE_ENV === 'development'env-gate. Noconsole.warn. No commented-out fallback "for later." The bypass is gone, period. If a developer needs an authenticated session locally, they log in.Files changed
lib/permission-middleware.js— 4-line synthetic admin block → 1-linereturn null;pages/api/auth/verify.js— 12-line no-token admin-fetch branch → 3-line 401 responseNet diff: 2 files, +2 / −16 LOC.
Test plan
npm run buildexits 0npm run lintmatches baseline (128 problems / 81 errors / 47 warnings); zero new lint issuesgit grep -E \"userId: 1|admin@tcgvault\.com\"againstlib/+pages/returns ZERO hits (onlyscripts/setup-neon-db.jsstill seeds that email, which is out of scope — gotcha #4'sdrop-public-setupconvoy)git grep \"Development mode\" -- 'lib/' 'pages/'returns ZERO hitsgetUserFromRequestverified to handlenullcorrectly with theif (!user) return res.status(401)shape — except the one in Known follow-up belowcurl -X GET https://<preview>/api/users/search?q=foo(no Authorization header) returns 401, not admin data.curl -X GET https://<preview>/api/auth/verifyreturns 401, not the admin record.⚠️ Known follow-up (NOT addressed in this PR, intentional)
pages/api/collections/[identifier]/cards.jsPOST/PUT/DELETE handlers dereferenceuser.userIdwithout a null guard. Previously masked by the synthetic admin (anonymous-write-as-admin on collections owned byuserId: 1was the security hole). After this PR, those handlers degrade to NPE → 500 instead of a clean 401.if (!user) return res.status(401)...to each of the three handlers). I'll dispatch this as a separate small patch after this PR merges. It does NOT block this PR — the bypass is closed; the cosmetic 500-vs-401 is a strict improvement over the previous status quo (anonymous-write-as-admin).Pre-merge requirements
JWT_SECRETrequirement already satisfied — Brief 1 has merged.)/api/auth/loginto use admin features. The fallback that previously let unauthenticated admin actions through is gone.Out of scope (intentionally — see convoy plan)
cards.js→ small follow-up PR after this mergespages/api/admin/index.jsusesverifyTokendirectly (notgetUserFromRequest) — unaffected by this briefgetUserFromRequestreturnsnullfor the 4 unauthenticated shapes → Brief 5admin@tcgvault.com/admin123default seed → gotcha #4,drop-public-setupconvoyAudit cohort
Reviewer dispatch follows post-push. No UI surface → design-system + a11y + browser-smoke auditors do not run.
🤖 Pipeline metadata: convoy=fix-auth-bypass, brief=2, depends_on=[1], audit=reviewer-only
Made with Cursor
The latest updates on your projects. Learn more about Vercel for GitHub.
Pipeline Health
Build + CI gates
Build runs on Vercel; this CI runs lint and schema-map drift only (no duplicate build).
Role reports
See individual comments above for details. This rollup updates automatically.