Skip to content

fs: fix host-backed symlink race escapes - #814

Merged
ewhauser merged 2 commits into
mainfrom
ewhauser/fix-fs-symlink-races
Mar 30, 2026
Merged

ewhauser merged 2 commits into
mainfrom
ewhauser/fix-fs-symlink-races

Conversation

@ewhauser

Copy link
Copy Markdown
Owner

Summary

Fix the host-backed filesystem TOCTOU breakout paths used by the reported read and write exploits.

What changed

  • route host-backed read-only and read-write path resolution through a rooted resolver that validates containment and then performs the actual access inside the same rooted namespace
  • preserve support for in-root absolute symlink targets while rejecting paths that resolve outside the configured root
  • add race regression tests that repeatedly swap a final path component between a regular file and an out-of-root symlink during reads and writes

Why

The previous implementation validated a host pathname with EvalSymlinks and then reopened the path afterward. That left a race window where the final component could be replaced between validation and use, allowing reads or writes to escape the configured root.

Impact

This closes the proven breakout for both WithWorkspace/HostFS reads and ReadWriteDirectoryFileSystem writes.

Validation

  • go test ./fs -run 'TestHostFSDoesNotReadThroughRacedFinalSymlink|TestReadWriteFSDoesNotWriteThroughRacedFinalSymlink' -count=1
  • go test ./fs
  • go test .
  • make lint

@ewhauser
ewhauser marked this pull request as ready for review March 30, 2026 23:11
@ewhauser ewhauser changed the title [codex] fs: fix host-backed symlink race escapes fs: fix host-backed symlink race escapes Mar 30, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5efffcaddb

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread fs/root_resolve_posix.go Resolved
@ewhauser
ewhauser merged commit b15e7c7 into main Mar 30, 2026
16 checks passed
@ewhauser
ewhauser deleted the ewhauser/fix-fs-symlink-races branch March 30, 2026 23:45
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.

1 participant