Skip to content

fix(prerender): only refuse .. as a whole path segment - #4738

Merged
pi0 merged 1 commit into
mainfrom
fix/dotdot
Oct 7, 2026
Merged

pi0 merged 1 commit into
mainfrom
fix/dotdot

Conversation

@danielroe

Copy link
Copy Markdown
Member

🔗 Linked issue

❓ Type of change

  • 📖 Documentation (updates to the documentation, readme, or JSdoc annotations)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • 👌 Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

📚 Description

noticed this when prerendering an og-image of the form /_og/s/c_Landing,title_One+API+for+every+code+forge,description_Work+with+issues+...+through+one+typed+API..png. it rendered fine but was skipped because it contained .. but I think this was only meant to avoid writing relative paths to disk (?)

so this PR only skips rendering paths when .. is an entire path segment

📝 Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@danielroe
danielroe requested a review from pi0 as a code owner October 6, 2026 15:53
@vercel

vercel Bot commented Oct 6, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
nitro.build Ready Ready Preview Oct 6, 2026 3:53pm UTC

Request Review

@coderabbitai

coderabbitai Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 7b8c1db8-83ac-4e0d-82f2-7b6b63a644bf
📥 Commits

Reviewing files that changed from the base of the PR and between d631065 and f45388a.

📒 Files selected for processing (2)
  • src/prerender/prerender.ts
  • test/unbundled/unbundled.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

The prerender disk-write check now rejects routes with exact .. segments separated by either slash style. A test verifies that filenames containing .. within a segment are written, while traversal routes do not produce normalized output files.

Changes

Prerender route validation

Layer / File(s) Summary
Route check and test
src/prerender/prerender.ts, test/unbundled/unbundled.test.ts
canWriteToDisk rejects exact .. segments split on / or \. The test checks that /api/hello..png is written with the expected ID and that traversal routes do not produce normalized output files.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to f4538

The changed check preserves traversal protection while allowing filenames containing ..; no identified issue currently blocks merging.

Security Architecture Review

Security architecture risk: 🔵 Low · up to f4538

Exact traversal segments remain blocked, and no new exploitable path was established. However, containment for every newly accepted filename shape is not fully verified, particularly across base-path transformations and Windows filesystem behavior.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The relevant authority is filesystem access in the invoking prerender process. Intended writes target its configured public output directory. If containment failed, exposure would depend on that process's filesystem permissions and application-specific route influence; cross-tenant or deployed-request reachability is not established.

Trust Boundaries and Controls

  • observed — Route strings derived from configuration or rendered responses cross into filesystem naming. URI decoding occurs before the write gate, so encoded dots become visible to the exact-segment check. Query-bearing routes and exact .. segments remain ineligible for writing; the final joined path must also pass the existing public-directory prefix check.

Hardening Proposals

  • proposed — Consider enforcing delimiter-aware containment on the final destination after base-path removal and hook processing, with explicit treatment of supported filesystem normalization rules. This would strengthen an existing boundary rather than establish that this PR introduced a vulnerability.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title follows Conventional Commits format with the fix type, the prerender scope, and a concise summary of the change.
Description check ✅ Passed The description explains the prerendering bug and states that the fix rejects .. only when it forms a complete path segment.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 2 files.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@pkg-pr-new

pkg-pr-new Bot commented Oct 6, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/nitro@4738

commit: f45388a

@pi0
pi0 merged commit 2d6006c into main Oct 7, 2026
15 checks passed
@pi0
pi0 deleted the fix/dotdot branch October 7, 2026 04:49

This branch was successfully deployed

1 active deployment
Preview — f45388a1 Deployed Oct 6, 2026 by vercel[bot]
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.

2 participants