Skip to content

fix(path-validation): resolve symlinks in assertWithinDir#184

Open
Sertug17 wants to merge 1 commit into
base:mainfrom
Sertug17:fix/path-validation-symlinks
Open

fix(path-validation): resolve symlinks in assertWithinDir#184
Sertug17 wants to merge 1 commit into
base:mainfrom
Sertug17:fix/path-validation-symlinks

Conversation

@Sertug17

Copy link
Copy Markdown

path.resolve() does not follow symbolic links. If a symlink exists inside
the allowed directory pointing outside (e.g., deployments/mainnet/link → /etc),
assertWithinDir passes the check but subsequent file reads access the external path.

Replace path.resolve() with fs.realpathSync() to resolve symlinks before
validating the path boundary. This matches the pattern already used correctly in
task origin validate.ts (which calls fs.realpath() before assertWithinDir).

Affected callers that now get symlink protection:
- install-deps/route.ts:56
- upgrade-config/route.ts:49
- validation-service.ts:37,41,124,129
- state-diff.ts:90

path.resolve() does not follow symlinks, allowing a symlink inside
the allowed directory pointing outside to bypass the path traversal
check. Use fs.realpathSync() to resolve symlinks first.
@cb-heimdall

Copy link
Copy Markdown
Collaborator

🟡 Heimdall Review Status

Requirement Status More Info
Reviews 🟡 0/1
Denominator calculation
Show calculation
1 if user is bot 0
1 if user is external 0
2 if repo is sensitive 0
From .codeflow.yml 1
Additional review requirements
Show calculation
Max 0
0
From CODEOWNERS 0
Global minimum 0
Max 1
1
1 if commit is unverified 1
Sum 2

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