Environment variables can be read from procfs unless a new process is started.
use birdcage::{Birdcage, Sandbox};
use std::{env, fs};
fn main() {
Birdcage::new().lock().unwrap();
assert_eq!(env::var_os("SECRET"), None);
let environ = fs::read_to_string("/proc/self/environ").unwrap();
assert!(!environ.contains("SECRET"), "ENVIRON CONTAINS SECRET:\n{environ}");
}
$ SECRET=test cargo run
thread 'main' panicked at src/main.rs:10:5:
ENVIRON CONTAINS SECRET:
[truncated]
The simplest solution would be relying on the ptrace isolation and always spawning a new process by changing birdcage's API to create a new command. With an additional PID namespace the guarantees could be even further reinforced.
{ "nvd_published_at": null, "cwe_ids": [ "CWE-200" ], "severity": "MODERATE", "github_reviewed": true, "github_reviewed_at": "2023-12-01T22:46:37Z" }