Skip to content

feat: add followSymlinks option to restrict symlink traversal (#297) - #316

Open
vaibhavmashal wants to merge 1 commit into
pillarjs:masterfrom
vaibhavmashal:feat/follow-symlinks-option
Open

feat: add followSymlinks option to restrict symlink traversal (#297)#316
vaibhavmashal wants to merge 1 commit into
pillarjs:masterfrom
vaibhavmashal:feat/follow-symlinks-option

Conversation

@vaibhavmashal

Copy link
Copy Markdown

Fixes #297

Description

This PR introduces the \ ollowSymlinks\ option (defaulting to \ rue\ for backwards compatibility).

When \ ollowSymlinks: false\ is configured, canonical paths are resolved via \ s.realpath\ and validated to ensure the target does not escape the configured
oot\ directory. If a symbolic link points outside
oot, the request is rejected with a \403 Forbidden\ error.

Changes

  • Added \ ollowSymlinks\ boolean option to \SendStream\ (default: \ rue).
  • In \SendStream.prototype.send, perform canonical realpath checks against root when \ ollowSymlinks === false.
  • Added unit tests in \ est/send.js\ covering symlinks within and outside root, default values, and regular file serving.

Copilot AI lite review requested due to automatic review settings September 6, 2026 15:23

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

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.

add followSymlinks option to restrict symlink traversal

2 participants