Skip to content

WASI preview 1: symlinks aren't handled correctly #49107

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
uhyo opened this issue Aug 11, 2023 · 1 comment · Fixed by nodejs/uvwasi#224
Closed

WASI preview 1: symlinks aren't handled correctly #49107

uhyo opened this issue Aug 11, 2023 · 1 comment · Fixed by nodejs/uvwasi#224

Comments

@uhyo
Copy link

uhyo commented Aug 11, 2023

Version

v19.8.1, v20.5.1

Platform

Darwin uhyo 21.6.0 Darwin Kernel Version 21.6.0: Mon Aug 22 20:19:52 PDT 2022; root:xnu-8020.140.49~2/RELEASE_ARM64_T6000 arm64

Subsystem

No response

What steps will reproduce the bug?

Reproduction repo: https://github.com/uhyo/node-wasi-symlink-bug

Some of filesystem APIs (including path_open) cannot handle symbolic links correctly. Consider below file structure:

.
├── Cargo.toml
└── dir
    └── link -> ../Cargo.toml

Create a WASM binary that tries to open ./dir/link with path_open. Pre-opening the current directory (.) should be enough for the program to work, but with Node.js' WASI implementation it fails with a "Capabilities insufficient" error.

How often does it reproduce? Is there a required condition?

always (sorry, not tested on other platforms than my Mac)

What is the expected behavior? Why is that the expected behavior?

The program should be able to read the contents of dir/link (symlinked to Cargo.toml).

What do you see instead?

Call to path_open fails with error code 76 (notcapable).

Additional information

  • Reproduction steps and more details are available in the reproduction repostitory.
  • Looking at the implementation, the logic for following symlinks doesn't take the location of the link into consideration. Content of ./dir/link (../Cargo.toml) should be treated as relative to ./dir, but is actually treated as relative to the current directory.
@shqld
Copy link

shqld commented Aug 14, 2023

@uhyo I made a PR that fixes the issue in uvwasi (not so sure that it's the correct way to fix this though). You may want to track it. nodejs/uvwasi#224

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 a pull request may close this issue.

2 participants