fix: security fixes from P3 trilhas audit + upgrade Next.js to 16.2.10#79
Draft
caimanoliveira wants to merge 3 commits into
Draft
fix: security fixes from P3 trilhas audit + upgrade Next.js to 16.2.10#79caimanoliveira wants to merge 3 commits into
caimanoliveira wants to merge 3 commits into
Conversation
- Upgrade Next.js 16.2.0 → 16.2.10 to patch 14 CVEs (middleware bypass, DoS, XSS, cache poisoning — GHSA-q4gf, GHSA-3g8h, GHSA-ffhc, et al.) - Fix IDOR in /api/exportar-star: bind query to authenticated user's mentorado_id before fetching mentorado_trilhas (no ownership check existed) - Fix silent crash: add null guard in getEtapa() for unknown trilhaSlug (trilha.etapas.find would throw TypeError on undefined) - Fix silent upsert failures in saveResposta and completeEtapa: propagate DB errors instead of silently continuing with stale completion state - Add .max() limits to starBuilderRespostaSchema fields (2000 chars each) and bancoPerguntasRespostaSchema.favoritas (max 200 items) to prevent unbounded DB writes and PDF memory exhaustion
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
….gitignore node_modules/.package-lock.json was accidentally tracked in git. Remove it from tracking since node_modules/ is already gitignored. Add *.tsbuildinfo so TypeScript build artifacts do not appear as untracked files after running next build.
Python 3.9 is no longer available on GitHub Actions ubuntu-latest runners (available: 3.10–3.14). Bump to 3.12 and update actions from deprecated checkout@v2 / setup-python@v1 (Node 20) to checkout@v4 / setup-python@v5.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
wsuninitialized memory disclosure./api/exportar-star: the route was queryingmentorado_trilhasfiltered only bytrilha_slug, with no check that the row belonged to the authenticated user'smentorado_id. Added a lookup of the caller'smentoradorecord and applied.eq('mentorado_id', mentorado.id)to the query.getEtapa(): accessing.etapason an undefinedtrilha(from an unknown slug) caused an uncaughtTypeError(HTTP 500). Added a null guard that returnsnullbefore the property access, consistent with the existinggetTrilhaSafepattern.saveRespostaandcompleteEtapa: both server actions were ignoring the Supabase error return from.upsert(). A DB constraint violation or RLS denial would silently drop the write and then run completion logic against stale data. Now both propagate the error viathrow.starBuilderRespostaSchemafields capped at 2000 chars each and record keys at 100 chars;bancoPerguntasRespostaSchema.favoritascapped at 200 items. Prevents unbounded DB writes and PDF renderer memory exhaustion.What was audited
No commits in the last 24 hours. This PR covers the security and correctness findings from an automated audit of the P3 trilhas feature landed in PR #1 (merged 2026-04-18).
Remaining known issues (not fixed here)
/api/exportar-pdfuses a service-role client withselect("*")after a single ownership check — defense-in-depth improvement, no active exploit.submitPlanoAcaoInputhardcodes.length(3)instead of readingn_acoesfrom etapa config — mismatch only matters if a trilha is configured withn_acoes ≠ 3.as unknown as Configdouble-cast — TypeScript safety improvement, not a runtime risk.completeEtapa/submitPlanoAcaois non-atomic (TOCTOU) — benign for the current usage pattern (last write wins with same timestamp direction).postcss < 8.5.10moderate CVE remains in Next.js's own vendored copy — no upstream fix available without downgrading Next.js to a breaking version.Generated by Claude Code