Skip to content

fix(security): add path traversal protection to render file serving#621

Open
hobostay wants to merge 1 commit intoheygen-com:mainfrom
hobostay:fix/path-traversal-render-file
Open

fix(security): add path traversal protection to render file serving#621
hobostay wants to merge 1 commit intoheygen-com:mainfrom
hobostay:fix/path-traversal-render-file

Conversation

@hobostay
Copy link
Copy Markdown

@hobostay hobostay commented May 5, 2026

Summary

  • Add path traversal protection to the /projects/:id/renders/file/* endpoint
  • The filename extracted from the URL was joined with rendersDir without validation, allowing ../../ sequences to serve arbitrary files

Details

Affected file: packages/core/src/studio-api/routes/render.ts (lines 180-187)

A request to /projects/1/renders/file/../../etc/passwd would resolve to a file outside the renders directory.

Test plan

  • Verify normal render file downloads still work
  • Verify paths containing .. are rejected with 403

🤖 Generated with Claude Code

The /projects/:id/renders/file/* endpoint served files by joining
rendersDir with the URL filename without validating the resolved
path stays within rendersDir. A request to
/renders/file/../../etc/passwd would serve arbitrary files.

Add a ".." check on the filename and verify the resolved path
starts with the renders directory.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Copy link
Copy Markdown
Collaborator

@jrusso1020 jrusso1020 left a comment

Choose a reason for hiding this comment

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

Verified — render.ts:186 currently does join(rendersDir, filename) with zero containment check, and existsSync will happily resolve ../../etc/passwd. The two-layer defense (literal .. rejection + startsWith(resolve(rendersDir)) containment) closes it. Worth noting this matches the pattern used in files.ts (isSafePath) — consider extracting to a shared helper in a follow-up, but not blocking. LGTM.

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