Skip to content

fix(security): prevent path traversal and symlink attacks in IndexExportJob#3080

Merged
marevol merged 1 commit intomasterfrom
fix/index-export-path-traversal
Mar 15, 2026
Merged

fix(security): prevent path traversal and symlink attacks in IndexExportJob#3080
marevol merged 1 commit intomasterfrom
fix/index-export-path-traversal

Conversation

@marevol
Copy link
Contributor

@marevol marevol commented Mar 15, 2026

Summary

  • Strip . and .. path components and normalize resolved paths in buildFilePath() to prevent directory traversal attacks
  • Validate that resolved file paths stay within the export base directory, falling back to _invalid/ directory for malicious URLs
  • Add symlink traversal prevention in exportDocument() by resolving real paths and using NOFOLLOW_LINKS when writing files
  • Add comprehensive tests for path traversal and symlink attack scenarios

Test plan

  • Verify existing IndexExportJobTest tests pass
  • Verify new path traversal prevention tests pass (dot-dot, encoded, backslash variants)
  • Verify new symlink traversal prevention tests pass (intermediate dir symlink, leaf file symlink)

🤖 Generated with Claude Code

@marevol marevol self-assigned this Mar 15, 2026
@marevol marevol added this to the 15.6.0 milestone Mar 15, 2026
…ortJob

Add path traversal prevention by stripping `.` and `..` components, normalizing
resolved paths, and validating they stay within the export base directory.
Add symlink traversal prevention by resolving real paths and using
NOFOLLOW_LINKS when writing files.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@marevol marevol force-pushed the fix/index-export-path-traversal branch from 9c82773 to eb124d8 Compare March 15, 2026 08:59
@marevol marevol merged commit 3eaad60 into master Mar 15, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant