π‘οΈ Sentinel: [CRITICAL] Fix Path Traversal in session storage#4
Conversation
Add explicit path traversal validation logic to session_id loading and saving in both Python (`src/session_store.py`) and Rust (`rust/crates/runtime/src/session_control.rs`) implementations to prevent directory traversal attacks.
|
π 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. |
There was a problem hiding this comment.
Code Review
This pull request addresses a path traversal vulnerability in session storage by introducing session ID validation in both the Rust and Python implementations. While the validation logic effectively checks for path separators and directory traversal markers, feedback indicates that the Rust implementation is incomplete as it lacks validation in the resolution and loading paths. Additionally, suggestions were provided to simplify the validation logic and explicitly reject empty strings to ensure more robust handling.
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
|
@copilot resolve the merge conflicts in this pull request |
There was a problem hiding this comment.
Pull request overview
This PR addresses a critical path traversal vulnerability by adding session ID validation before constructing on-disk session file paths in both the Python and Rust session storage implementations.
Changes:
- Add
validate_session_id()in Python and enforce it insave_session/load_session. - Add
is_valid_session_id()in Rust and enforce it inSessionStore::create_handleandcreate_managed_session_handle_for, adjusting call sites for the newResultreturn. - Add a Sentinel write-up documenting the incident and prevention guidance.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
src/session_store.py |
Adds session ID validation and applies it to session save/load file path construction. |
rust/crates/runtime/src/session_control.rs |
Adds session ID validation in Rust and applies it to some handle-creation path construction; updates affected call sites/tests. |
.jules/sentinel.md |
Documents the vulnerability and prevention guidance for future reference. |
π‘ Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Applied PR feedback for path traversal fix. - Simplified `is_valid_session_id` logic and added check for empty strings. - Added validation check to `resolve_managed_path` and `resolve_managed_session_path_for` to cover reading paths. - Added heuristic token estimation logic as a fallback in API request pre-flight checks when `count_tokens` returns an error, fixing the associated integration test failure. Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
|
@codex Code Review |
There was a problem hiding this comment.
π‘ Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e2a78cc332
βΉοΈ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with π.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@claude code review |
|
@codex code review |
|
@copilot, resolve the merge conflicts in this pull request. |
There was a problem hiding this comment.
π‘ Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e2a78cc332
βΉοΈ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with π.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Resolve conflicts in: - rust/crates/api/src/providers/anthropic.rs: use main's count_tokens-first preflight - rust/crates/runtime/src/session.rs: use main's std::io::Error::other() API - rust/crates/runtime/src/session_control.rs: keep security validation (Result return), drop #[must_use] - rust/crates/rusty-claude-cli/src/main.rs: use compact var, add sessions_dir import, add clippy allow Co-authored-by: badMade <106821302+badMade@users.noreply.github.com>
Resolved in commit
All Rust and Python tests pass.
Resolved in commit |
π¨ Severity: CRITICAL
π‘ Vulnerability: Path Traversal in session ID loading/saving operations. Both Python and Rust implementations interpolated the
session_iddirectly into file paths without validation.π― Impact: An attacker could supply malicious session IDs (e.g.
../../../etc/passwdor/tmp/evil) to read or write arbitrary files on the local filesystem outside the designated session directories.π§ Fix: Added validation logic (
validate_session_idin Python andis_valid_session_idin Rust) to reject session IDs containing path separators (/,\) or directory traversal sequences (.,..).β Verification: Verified by running Python and Rust tests (e.g.
pytestandcargo test), which correctly enforce these security constraints, returning explicit format errors instead of executing unsafe file paths.PR created automatically by Jules for task 9468504043063696261 started by @badMade