[PR #8727] fix(security): prevent path traversal via symlinks in File.read and File.list #12844

Open
opened 2026-02-16 18:17:44 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/8727

State: open
Merged: No


This PR fixes a security issue where File.read and File.list could follow symlinks outside the project directory due to lexical path checks. This allows potential path traversal. The code now resolves real paths and verifies containment before access.

Fixes:
Fixes #8313

What changed:

Updated File.read to use fs.promises.realpath() before reading.

Updated File.list to resolve paths before listing.

Added regression tests under packages/opencode/test/security/symlink.test.ts.

**Original Pull Request:** https://github.com/anomalyco/opencode/pull/8727 **State:** open **Merged:** No --- This PR fixes a security issue where File.read and File.list could follow symlinks outside the project directory due to lexical path checks. This allows potential path traversal. The code now resolves real paths and verifies containment before access. Fixes: Fixes #8313 What changed: Updated File.read to use fs.promises.realpath() before reading. Updated File.list to resolve paths before listing. Added regression tests under packages/opencode/test/security/symlink.test.ts.
yindo added the pull-request label 2026-02-16 18:17:44 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#12844