Skip to content

🛡️ Sentinel: [CRITICAL] Fix path traversal in session stores#6

Open
badMade wants to merge 6 commits into
mainfrom
sentinel-fix-session-path-traversal-8720343771462187537
Open

🛡️ Sentinel: [CRITICAL] Fix path traversal in session stores#6
badMade wants to merge 6 commits into
mainfrom
sentinel-fix-session-path-traversal-8720343771462187537

Conversation

@badMade
Copy link
Copy Markdown
Owner

@badMade badMade commented Apr 11, 2026

This PR fixes a CRITICAL path traversal vulnerability in how session IDs are stored on disk. By failing to validate the session_id string before forming the persistence path, it was possible to read or overwrite arbitrary JSON files across the filesystem.

  • Added a validation check (validate_session_id) in src/session_store.py that raises a ValueError for directory traversal markers.
  • Added a similar validate_session_id check in rust/crates/runtime/src/session_control.rs returning a SessionControlError::Format.
  • Propagated Result return types in the Rust code up through create_handle and into local usages within the workspace codebase.
  • Logged the pattern and fix securely to .jules/sentinel.md as part of Sentinel's defensive practices.

Verification:

  • The tests ran and were verified: PYTHONPATH=. python3 -m pytest tests/ and cargo test --workspace on the rust package all passing.
  • Custom ad-hoc validation test confirmed rejection.

PR created automatically by Jules for task 8720343771462187537 started by @badMade

🚨 Severity: CRITICAL
💡 Vulnerability: Python `session_store.py` and Rust `session_control.rs` use the `session_id` to read and write local files (`{session_id}.json`) without validation. A malicious input string containing `../../` allows an attacker to read or overwrite arbitrary `.json` files on the filesystem.
🎯 Impact: This path traversal vulnerability could lead to information disclosure or data destruction if a manipulated session reference is processed.
🔧 Fix: Added strict string validation checks (`validate_session_id`) inside the data access patterns in Python (`save_session`, `load_session`) and Rust (`create_handle`, `resolve_managed_path`) to reject inputs containing path separators (`/`, `\`) or traversal elements (`.`, `..`).
✅ Verification: Python and Rust tests continue to pass and specifically test scripts constructed for `../../../tmp/file` inputs are now safely rejected by both data planes.
@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.

🚨 Severity: CRITICAL
💡 Vulnerability: Python `session_store.py` and Rust `session_control.rs` use the `session_id` to read and write local files (`{session_id}.json`) without validation. A malicious input string containing `../../` allows an attacker to read or overwrite arbitrary `.json` files on the filesystem.
🎯 Impact: This path traversal vulnerability could lead to information disclosure or data destruction if a manipulated session reference is processed.
🔧 Fix: Added strict string validation checks (`validate_session_id`) inside the data access patterns in Python (`save_session`, `load_session`) and Rust (`create_handle`, `resolve_managed_path`) to reject inputs containing path separators (`/`, `\`) or traversal elements (`.`, `..`).
✅ Verification: Python and Rust tests continue to pass and specifically test scripts constructed for `../../../tmp/file` inputs are now safely rejected by both data planes.
Copy link
Copy Markdown

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

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 by implementing session ID validation in both the Rust and Python components. The changes introduce a validate_session_id function that checks for illegal characters and sequences before performing filesystem operations. Feedback suggests strengthening the validation logic by using a whitelist of allowed characters (alphanumeric, hyphens, and underscores) instead of the current blacklist approach to ensure better security and robustness.

Comment thread rust/crates/runtime/src/session_control.rs Outdated
Comment thread src/session_store.py Outdated
@badMade
Copy link
Copy Markdown
Owner Author

badMade commented Apr 22, 2026

@copilot code review

@badMade
Copy link
Copy Markdown
Owner Author

badMade commented Apr 22, 2026

@claude code review

Copilot AI and others added 2 commits April 22, 2026 22:44
Copy link
Copy Markdown

Copilot AI commented Apr 22, 2026

@copilot code review

Completed review pass on this PR: checked recent CI (including the earlier failed run), re-ran local validation (cargo fmt --all --check, cargo clippy --workspace --all-targets -- -D warnings, cargo test --workspace, and python3 -m unittest -q tests.test_porting_workspace), and ran parallel Code Review + CodeQL. No additional code changes were needed for the fix. Commit: c63af07

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Addresses a path traversal vulnerability where unvalidated session_id values were used to construct on-disk session file paths in both the Python and Rust session stores.

Changes:

  • Added validate_session_id in src/session_store.py and enforced it on save/load.
  • Added SessionStore::validate_session_id in Rust and propagated validation/error handling through create_handle and resolve_managed_path.
  • Added a Sentinel note documenting the vulnerability and prevention guidance.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
src/session_store.py Adds session ID validation before forming <dir>/<session_id>.json paths.
rust/crates/runtime/src/session_control.rs Adds session ID validation and switches create_handle to return Result with validation enforced.
.jules/sentinel.md Documents the vulnerability and recommended prevention approach.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread .jules/sentinel.md
Comment thread rust/crates/runtime/src/session_control.rs
Comment thread rust/crates/runtime/src/session_control.rs Outdated
Comment thread src/session_store.py Outdated
@badMade
Copy link
Copy Markdown
Owner Author

badMade commented Apr 23, 2026

@codex Code Review

@chatgpt-codex-connector
Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@badMade
Copy link
Copy Markdown
Owner Author

badMade commented Apr 23, 2026

@codex Code Review

@badMade
Copy link
Copy Markdown
Owner Author

badMade commented Apr 23, 2026

@codex code review

Copy link
Copy Markdown

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

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: c63af0755a

ℹ️ 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 src/session_store.py Outdated
Comment thread rust/crates/runtime/src/session_control.rs Outdated
@badMade
Copy link
Copy Markdown
Owner Author

badMade commented Apr 29, 2026

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

Copilot AI and others added 2 commits April 29, 2026 08:25
…path-traversal-8720343771462187537

# Conflicts:
#	.jules/sentinel.md
#	rust/crates/runtime/src/session_control.rs

Co-authored-by: badMade <106821302+badMade@users.noreply.github.com>
Agent-Logs-Url: https://github.com/badMade/claw-code/sessions/4f913af6-1b3d-48c5-ac25-c30b4b994868

Co-authored-by: badMade <106821302+badMade@users.noreply.github.com>
Copy link
Copy Markdown

Copilot AI commented Apr 29, 2026

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

Resolved and pushed. I merged origin/main into this PR branch, fixed the conflicts in rust/crates/runtime/src/session_control.rs and .jules/sentinel.md, cleaned up duplicated .port_sessions/ ignore entry, and re-ran validation (python3 -m unittest discover -q tests, Rust fmt/clippy/tests). Commit: b59843a. No UI changes were involved, so there is no screenshot.

@badMade
Copy link
Copy Markdown
Owner Author

badMade commented Apr 30, 2026

@copilot, make changes based on:

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

See: #6 (comment)

Copy link
Copy Markdown

Copilot AI commented Apr 30, 2026

@copilot code review

Completed a fresh review pass on commit b59843a: checked Actions runs (including the older failed run and newer action_required/no-job runs), verified no merge conflicts in branch state, and re-ran local validation (cargo fmt --all --check, cargo clippy --workspace --all-targets -- -D warnings, cargo test --workspace, and python3 -m unittest discover -q tests). No additional code changes were needed.

Copy link
Copy Markdown

Copilot AI commented Apr 30, 2026

@copilot, make changes based on:

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
...

The linked note is only a Codex quota/error message, not code-review feedback, so it doesn’t provide actionable code changes to apply. I rechecked this PR state at b59843a and there are no additional issues to fix from that source. If you want specific changes, please share concrete review findings and I’ll apply them.

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.

3 participants