Provide a secure_getenv() equivalent
Nobody has claimed this yet.
- Dominant language
- Markdown
- Stars
- 6.6k
- Forks
- 1.7k
- Avg merge
- 16h 14m
- Merged PRs (30d)
- 1
Description
Glibc provides a non-standard function secure_getenv() (manpage, glibc manual). It is the same as getenv(), except that it returns NULL if "secure execution" is required. See the manpage for the exact definition but in short, if the executable is setuid or similar.
I think Rust should expose a similar function in the standard library. Here's an example scenario (I haven't tried it out, so I might have it wrong):
- A setuid binary.
- The binary depends on a crate. The binary calls a function from the crate before dropping privileges.
- The function in the crate needs to write a temporary file, so to be nice it tries to use the conventional
TMPDIRenvironment variable to pick the directory first. - Evil user does
TMPDIR=/root/.ssh/ ./binary.
If the library uses getenv, then the user managed to trick the binary into writing stuff into /root/.ssh which is a security hazard. If the library uses secure_getenv, then at least this case is prevented.
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 by reading the linked glibc secure_getenv() manpage and manual section, then review this RFC issue's proposed setuid scenario. Define the Rust standard-library API, its secure-execution behavior, and supported platforms, with the security expectations documented and reviewed as the done criteria.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- security
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100