-
Notifications
You must be signed in to change notification settings - Fork 6
Verify token removal from /proc/self/environ and /proc/self/task/*/environ after unsetenv #746
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
Changes from all commits
d4c5950
8179263
28faea3
056a606
472a5a3
e9db1e0
5dced33
11fbca1
de79441
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -19,6 +19,12 @@ use std::ffi::{CStr, CString}; | |||||||||||||||||||||||||||||
| use std::ptr; | ||||||||||||||||||||||||||||||
| use std::sync::Mutex; | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| // External declaration of the environ pointer | ||||||||||||||||||||||||||||||
| // This is a POSIX standard global that points to the process's environment | ||||||||||||||||||||||||||||||
| extern "C" { | ||||||||||||||||||||||||||||||
| static mut environ: *mut *mut c_char; | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| /// Maximum number of tokens we can track | ||||||||||||||||||||||||||||||
| const MAX_TOKENS: usize = 100; | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
|
|
@@ -196,6 +202,52 @@ fn format_token_value(value: &str) -> String { | |||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| /// Check if a token still exists in the process environment | ||||||||||||||||||||||||||||||
| /// | ||||||||||||||||||||||||||||||
| /// This function verifies whether unsetenv() successfully cleared the token | ||||||||||||||||||||||||||||||
| /// by directly checking the process's environ pointer. This works correctly | ||||||||||||||||||||||||||||||
| /// in both chroot and non-chroot modes (reading /proc/self/environ fails in | ||||||||||||||||||||||||||||||
| /// chroot because it shows the host's procfs, not the chrooted process's state). | ||||||||||||||||||||||||||||||
| fn check_task_environ_exposure(token_name: &str) { | ||||||||||||||||||||||||||||||
|
Comment on lines
+205
to
+211
|
||||||||||||||||||||||||||||||
| /// Check if a token still exists in the process environment | |
| /// | |
| /// This function verifies whether unsetenv() successfully cleared the token | |
| /// by directly checking the process's environ pointer. This works correctly | |
| /// in both chroot and non-chroot modes (reading /proc/self/environ fails in | |
| /// chroot because it shows the host's procfs, not the chrooted process's state). | |
| fn check_task_environ_exposure(token_name: &str) { | |
| /// Check if a token still exists in the process environment (process-level check) | |
| /// | |
| /// This function verifies whether unsetenv() successfully cleared the token | |
| /// by directly checking the process's environ pointer. This works correctly | |
| /// in both chroot and non-chroot modes (reading /proc/self/environ fails in | |
| /// chroot because it shows the host's procfs, not the chrooted process's state). | |
| fn check_process_environ_exposure(token_name: &str) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The README now says the library "checks and logs warnings" for
/proc/PID/task/TID/environexposure, but the implementation added insrc/lib.rsonly scans the processenvironpointer and does not read/proc/.../environat all. Please either implement the/proc/*/task/*/environchecks, or update this section to avoid over-claiming the verification coverage.