File write vulnerability if username contains `../`
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 589
- Forks
- 27
- PR merge metrics
- No merged PRs in 30d
Description
I set my username on client A to ../../home/jess/.ssh and used ?send authorized_keys.
This then wrote the contents of authorized_keys to the actual authorized_keys on the target machine.
I haven't tested it with a malicious filename, but I assume that has the same problem.
A mitigation would be to check that the path you're writing to is under the temp directory, and replace / with some other character when writing.
Also, when creating the file, it should be checked that it doesn't exist (See https://doc.rust-lang.org/std/fs/struct.OpenOptions.html#method.create_new )
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the ?send authorized_keys file-transfer path and reproduce the username ../../home/jess/.ssh case described in the issue. Consult Rust's OpenOptions::create_new documentation while tracing how the destination path is built; done means writes remain under the temporary directory, path separators cannot escape it, and existing files are rejected.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- cli, security
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100