Skip to content

πŸ›‘οΈ Sentinel: [CRITICAL] Fix Path Traversal in session storage#4

Merged
badMade merged 4 commits into
mainfrom
sentinel-path-traversal-9468504043063696261
Apr 29, 2026
Merged

πŸ›‘οΈ Sentinel: [CRITICAL] Fix Path Traversal in session storage#4
badMade merged 4 commits into
mainfrom
sentinel-path-traversal-9468504043063696261

Conversation

@badMade

@badMade badMade commented Apr 10, 2026

Copy link
Copy Markdown
Owner

🚨 Severity: CRITICAL
πŸ’‘ Vulnerability: Path Traversal in session ID loading/saving operations. Both Python and Rust implementations interpolated the session_id directly into file paths without validation.
🎯 Impact: An attacker could supply malicious session IDs (e.g. ../../../etc/passwd or /tmp/evil) to read or write arbitrary files on the local filesystem outside the designated session directories.
πŸ”§ Fix: Added validation logic (validate_session_id in Python and is_valid_session_id in Rust) to reject session IDs containing path separators (/, \) or directory traversal sequences (., ..).
βœ… Verification: Verified by running Python and Rust tests (e.g. pytest and cargo 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

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.
@google-labs-jules

Copy link
Copy Markdown

πŸ‘‹ 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 @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

Comment thread rust/crates/runtime/src/session_control.rs
Comment thread rust/crates/runtime/src/session_control.rs
Comment thread src/session_store.py
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@badMade

badMade commented Apr 22, 2026

Copy link
Copy Markdown
Owner Author

@copilot resolve the merge conflicts in this pull request

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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 in save_session / load_session.
  • Add is_valid_session_id() in Rust and enforce it in SessionStore::create_handle and create_managed_session_handle_for, adjusting call sites for the new Result return.
  • 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.

Comment thread rust/crates/runtime/src/session_control.rs
Comment thread rust/crates/runtime/src/session_control.rs
Comment thread src/session_store.py
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>
@badMade

badMade commented Apr 23, 2026

Copy link
Copy Markdown
Owner Author

@codex Code Review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

πŸ’‘ 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".

Comment thread rust/crates/api/src/providers/anthropic.rs Outdated
@badMade

badMade commented Apr 23, 2026

Copy link
Copy Markdown
Owner Author

@claude code review

@badMade

badMade commented Apr 23, 2026

Copy link
Copy Markdown
Owner Author

@codex code review

@badMade

badMade commented Apr 23, 2026

Copy link
Copy Markdown
Owner Author

@copilot, resolve the merge conflicts in this pull request.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

πŸ’‘ 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".

Comment thread rust/crates/api/src/providers/anthropic.rs Outdated
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>
Copilot AI review requested due to automatic review settings April 23, 2026 23:18
@badMade badMade review requested due to automatic review settings April 23, 2026 23:18

Copilot AI commented Apr 23, 2026

Copy link
Copy Markdown

@copilot resolve the merge conflicts in this pull request

Resolved in commit 256e404. The merge conflicts in 4 files have been fixed:

  • rust/crates/api/src/providers/anthropic.rs β€” used main's count_tokens-first preflight approach
  • rust/crates/runtime/src/session.rs β€” used main's std::io::Error::other() API
  • rust/crates/runtime/src/session_control.rs β€” kept the security validation (Result return type) while removing the conflicting #[must_use] from main
  • rust/crates/rusty-claude-cli/src/main.rs β€” 4 conflicts resolved (compact var, sessions_dir import, clippy allow, semicolon)

All Rust and Python tests pass.

@copilot, resolve the merge conflicts in this pull request.

Resolved in commit 256e404. All 4 merge conflicts have been fixed and the branch now merges cleanly with main. All tests (Rust + Python) pass.

@badMade badMade merged commit 598b5a2 into main Apr 29, 2026
4 checks passed
@badMade badMade deleted the sentinel-path-traversal-9468504043063696261 branch April 29, 2026 07:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants