r/programming • u/guest271314 • Dec 15 '24
Proof of concept showcasing how a WASM program can access files outside node:wasi's preopens dir
https://github.com/humodz/node-wasi-preopens-escape
31
Upvotes
52
u/Ok-Pace-8772 Dec 15 '24
OP why are writing like you're on crack?
110
u/borland Dec 15 '24 edited Dec 15 '24
Downvoting this one. It requires co-ordination with a privileged helper that can swap files for symlinks at exact times. If you're going to write a privileged helper to do that, you can just write a TCP or named pipe server and get the helper to do your dirty work; it's not node's fault that your system was already compromised!
46
u/anxxa Dec 15 '24
Cool, so it's a TOCTOU that requires coordination with an external program. I guess it'd be useful for a scenario where someone is running a privileged process with attacker-controlled WASM. Or if the WASM for some reason allows for file exfil and its process has privileges to access the target file but the coordinating process does not.
🤷♂️
46
u/Levalis Dec 15 '24
I’m not convinced this is a node bug. Any program under the same situation would have the same issue. If you need a privileged helper program to enable the attack, I’m pretty sure Linux would not consider this a vulnerability as well. Interesting find nonetheless, it speaks to the dangers of following symlinks…
-1
u/rav3lcet Dec 15 '24
Okay but why is divine a verb
-3
u/guest271314 Dec 15 '24
https://www.reddit.com/r/javascript/comments/1hb31zr/comment/m1q9ten/
https://github.com/WebAssembly/wasi-filesystem/blob/main/path-resolution.md
(Emphasis added)
-37
u/[deleted] Dec 15 '24
Could be a feature.
I distinctly dislike that there is no trivial way to access local files via javascript and a webpage, assuming the user gave explicit permission to do so. I need precisely that for my local system. (I don't want to use node either, for various reasons, so I am stuck with vanilla javascript.)
0
u/[deleted] Dec 15 '24
[deleted] — view deleted comment