Skip to content
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

Add some warnings to std::env::current_exe #33526

Merged
merged 2 commits into from
Jul 20, 2016
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/libstd/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,21 @@ pub fn temp_dir() -> PathBuf {
/// that can fail for a good number of reasons. Some errors can include, but not
/// be limited to, filesystem operations failing or general syscall failures.
///
/// # Security
///
/// This function should be used with care, as its incorrect usage can cause
/// security problems. Specifically, as with many operations invovling files and
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"invovling"

/// paths, you can introduce a race condition. It goes like this:
///
/// 1. You get the path to the current executable using `current_exe()`, and
/// store it in a variable binding.
/// 2. Time passes. A malicious actor removes the current executable, and
/// replaces it with a malicious one.
/// 3. You then use the binding to try to open that file.
///
/// You expected to be opening the current executable, but you're now opening
/// something completely different.
///
/// # Examples
///
/// ```
Expand Down