Skip to content

fix: read symlinks on direct binds - #194

Merged
ferdingler merged 4 commits into
strands-agents:mainfrom
ferdingler:fix/direct-bind-readlink
Nov 6, 2026
Merged

ferdingler merged 4 commits into
strands-agents:mainfrom
ferdingler:fix/direct-bind-readlink

Conversation

@ferdingler

@ferdingler ferdingler commented Nov 2, 2026 •

Copy link
Copy Markdown
Collaborator

Description

readlink failed on any path under a direct bind, even for a plain relative symlink sitting right inside it. It only looked in the in-memory filesystem, which can't see into a host-backed directory, so an agent working in a bound project couldn't tell where a link points.

Now readlink reads the link on the host, with the same check the other host operations use to stay inside the bind, and prints the link text as is, so relative, absolute and dangling targets come back exactly like bash shows them. A non-link or a missing path still exits 1, and paths that aren't on a direct bind behave as before. Unlike bash, a parent directory that is a symlink pointing outside the bind is still refused.

Evidence of how this is fixed in Box

Strands Box carries a vendored copy of Shell and already fixed this the same way, so this PR matches it completely: readlink on a bind, and the UPSTREAM.md note.

Related Issues

None.

Documentation PR

None.

Type of Change

Bug fix

Testing

I compared the output with bash for each kind of link target, a link read from a relative directory, a regular file and a missing path, and they all match now. The new tests fail on main and the full suites pass, and when I broke the containment on purpose the escape test caught it. I ran this on Linux only, and the tests are Unix-only because they create symlinks.

  • I ran the relevant test suites for the bindings I touched (cargo test --workspace --all-targets, pytest tests/python, npm test)
  • If I touched Rust, I ran cargo fmt and cargo clippy

Checklist

  • I have read the CONTRIBUTING document
  • I have reviewed and understand every line of code in this PR, including any generated by AI tools, and I can explain why it works
  • My change is focused and reasonably small; I have split unrelated work into separate PRs
  • I have added any necessary tests that prove my fix is effective or my feature works
  • I have updated the documentation accordingly
  • I have added an appropriate example to the documentation to outline the feature, or no new docs are needed
  • My changes generate no new warnings
  • Any dependent changes have been merged and published

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

readlink on a path under a direct bind failed with "not a directory",
because read_link only walked the in-memory tree. It now resolves the
parent through the bind (with the same containment check as the other
host operations) and reads the last component without following it, so
it prints the stored link text, including relative and dangling targets.
@ferdingler
ferdingler requested a review from a team as a code owner November 2, 2026 18:11
ferdingler and others added 3 commits November 2, 2026 14:28
Accept the last path component only when it is one ordinary host file
name. Refuse a name that holds a path prefix, a separator, or a parent
component, before it joins the checked parent.

Test: bind_direct_readlink_reads_only_one_host_name_on_windows.
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