Tighten turbopack chunk filename allowlist regex#8048
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. 2 Skipped Deployments
|
Dependency Review✅ No vulnerabilities found.Snapshot WarningsEnsure that dependencies are being submitted on PR branches and consider enabling retry-on-snapshot-warnings. See the documentation for more information and troubleshooting advice. Scanned FilesNone |
1deb7a6 to
aaa6b28
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. ❌ Your project status has failed because the head coverage (84.96%) is below the target coverage (85.00%). You can increase the head coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## main #8048 +/- ##
==========================================
- Coverage 84.97% 84.96% -0.01%
==========================================
Files 633 633
Lines 41633 41659 +26
Branches 4869 4879 +10
==========================================
+ Hits 35376 35397 +21
- Misses 5149 5152 +3
- Partials 1108 1110 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
aaa6b28 to
8162ef5
Compare
Code Review: ENG-3597 — Tighten turbopack chunk filename allowlist regexPR: #8048 🚨 Critical Issues (Must Fix)1. Stale comment referencing old regex (main.py:68)The comment on line 68 still describes the old regex pattern: # Turbopack (Next.js 16+) chunk filenames can embed ".." before the extension,
# e.g. "0y3j4e~tvxaz..js". These are benign static assets, not traversal.But the regex on line 70 has been broadened. The comment on lines 69–73 (the new block) is correct, but the original comment is now misleading and contradictory. It should be removed or merged with the new comment block. Fix: Remove lines 68–69 (the old comment) since lines 69–73 already fully describe the pattern.
|
- Use fullmatch() instead of match() for explicitness - Add minimal a..b trailing-segment test case - Flag changelog entry as high-risk
|
Thanks @rayharnett! Walking through the items:
All changes pushed in 96cdcf0. |
Ticket ENG-3597 - follow-up to #8018
Description Of Changes
#8018 introduced
TURBOPACK_CHUNK_REto keep turbopack-emitted admin-ui chunk names (which embed..) from being rejected by the catch-all path-traversal guard insanitise_url_path. The original regex (^[\w~-]+\.\.[a-z]+$) was too narrow: real turbopack chunks have dots both before and after the literal..(e.g.0~9kfdw7..yey.js,0te-shorr2._..js,turbopack-0bk8.vt1kbb2..js), and #8022 had to revert turbopack to webpack to dodge the breakage. This branch reverts that revert and broadens the regex empirically.The new pattern
^[\w~-][\w~.-]*\.\.[\w~.-]+$matches the full turbopack chunk alphabet (word chars,~,.,-) and just forbids a leading dot, so traversal payloads (..,..foo,../etc/passwd,..%2f...) still fall through to the existing guard.To make sure this isn't another whack-a-mole iteration, I sampled chunk filenames across 10 builds spanning 9 distinct turbopack-era source states (every commit between #7956 and HEAD that touched
clients/admin-ui/src):..The regex's character class is now closed over turbopack's actual chunk alphabet, so future rebuilds can't introduce
/,%, or other path-relevant characters without a fundamental change to turbopack's naming scheme.Code Changes
clients/admin-ui/package.json: drop the--webpackpin frombuild/dev/analyze/build:test/build:vercel/exportscripts; remove the now-stale//webpack-flagcomment. Re-enables turbopack across the board.src/fides/api/main.py: broadenTURBOPACK_CHUNK_REand update the surrounding comment to describe the alphabet and the leading-dot rule.tests/ops/util/test_api_router.py: extend the parametrized fixtures with the new turbopack chunk shapes (0~9kfdw7..yey.js,abc-123..part.min.js,0te-shorr2._..js,a.b.c..js).Steps to Confirm
git checkoutthis branch andcd clients/admin-ui && rm -rf .next && npm run build. Confirm it builds with turbopack (no--webpackflag)./_next/static/chunks/<some-chunk-with-dotdot>.jsfrom the built output. Should serve 200, not redirect to/.curl -i 'http://localhost:8080/../../../../../../etc/passwd'. Should still be caught by the guard and redirected to the admin index.pytest tests/ops/util/test_api_router.py::TestApiRouter -k sanit(or just-k turbopack) — new fixtures should pass alongside the traversal-rejection cases.Pre-Merge Checklist
CHANGELOG.mdupdatedmaindowngrade()migration is correct and works