#Directory traversal attacks
17 messages · Page 1 of 1 (latest)
Would using canonicalize then starts_with work 
The canonicalize is definitely needed to prevent escape by using a symlink
Nah, because canonicalize fails if the path doesn't exist
What do you want to do in that case 
Let's say I'm extracting a zip file or something, to some/directory/
I want to ensure some/directory/{user_input_path} doesn't leave some/directory
Oh, so your taking the path to make?
Not a path to read
Ya
How about concat it with the root then run https://lib.rs/crates/path-clean on it then check it stays in the same root folder with starts with?
Yeah, I think that'll do, thank you
I kind of expected the OS to provide some sort of help with this
You could setup a fully sandboxed filesystem but that seems like more work than you probably need
https://docs.rs/cap-std/latest/cap_std/ for the non-OS but
A capability-based API modeled after std.
bit heavy