π‘οΈ Sentinel: [HIGH] Fix TOCTOU vulnerability in state snapshots#116
π‘οΈ Sentinel: [HIGH] Fix TOCTOU vulnerability in state snapshots#116bdqnghi wants to merge 4 commits into
Conversation
Replaces the predictable .json.tmp file paths in `state_snapshot.rs` with randomized ones using `uuid::Uuid::new_v4()`, and enforces secure `0o600` file permissions on creation (`O_EXCL`) to mitigate TOCTOU and symlink exploitation vectors. Co-authored-by: bdqnghi <11867551+bdqnghi@users.noreply.github.com>
|
π Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a π emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
Addresses clippy failures in CI that blocked the previous state snapshots fix PR. Used `sort_by_key` with `std::cmp::Reverse` instead of `sort_by`, and leveraged the `?` operator for cleaner `Option` unwrapping to satisfy `-D warnings`. Co-authored-by: bdqnghi <11867551+bdqnghi@users.noreply.github.com>
Addresses clippy failures in CI that blocked the previous state snapshots fix PR. Used `sort_by_key` with `std::cmp::Reverse` instead of `sort_by`, and leveraged the `?` operator for cleaner `Option` unwrapping to satisfy `-D warnings`. Co-authored-by: bdqnghi <11867551+bdqnghi@users.noreply.github.com>
Addresses clippy failures in CI that blocked the previous state snapshots fix PR. Used `sort_by_key` with `std::cmp::Reverse` instead of `sort_by`, and leveraged the `?` operator for cleaner `Option` unwrapping to satisfy `-D warnings`. Co-authored-by: bdqnghi <11867551+bdqnghi@users.noreply.github.com>
π¨ Severity: HIGH
π‘ Vulnerability: Insecure temporary file creation and incorrect default permissions in
state_snapshot.rs. Writing state snapshots usingstd::fs::writeor without restricted creation permissions leaves a brief TOCTOU window and exposes sensitive session data to other users on the system via the defaultumask. Predictable filenames like.json.tmpalso invite symlink attacks.π― Impact: A malicious local user could exploit the symlink attack to overwrite arbitrary files, or simply read the sensitive snapshot data due to the missing permission constraints.
π§ Fix: Implemented atomic secure file creation using
std::fs::OpenOptionswith.create_new(true)and.mode(0o600)(on Unix) to enforce strict ownership and prevent TOCTOU race conditions. Filenames are also now randomized usinguuid::Uuid::new_v4().β Verification: Run
cargo test --workspaceto ensure snapshots continue to function, and verify logic correctly leveragesuuidfor randomization and atomic rename.PR created automatically by Jules for task 13766765161458642849 started by @bdqnghi