Skip to content

security: fix path traversal in collaborative scanner session loading#30

Merged
zakirkun merged 1 commit into
zakirkun:mainfrom
JULIANDEV21989:security/fix-path-traversal-collab-scanner
May 7, 2026
Merged

security: fix path traversal in collaborative scanner session loading#30
zakirkun merged 1 commit into
zakirkun:mainfrom
JULIANDEV21989:security/fix-path-traversal-collab-scanner

Conversation

@JULIANDEV21989

Copy link
Copy Markdown
Contributor

Summary

  • _load_session() used unsanitized session_id in file path construction
  • A crafted session ID like ../../etc/config could read arbitrary .json files from the operator's filesystem
  • Added strict validation: session IDs must be exactly 16 lowercase hex characters

Security Impact

  • CWE-22: Path Traversal
  • Before: _load_session("../../etc/something") would attempt to read data/sessions/../../etc/something.json
  • After: Any session_id not matching ^[a-f0-9]{16}$ is rejected with a warning

Changes

  • modules/collaboration/collaborative_scanner.py: Added _validate_session_id() static method, applied before file path construction in _load_session()

Test plan

  • Verify valid 16-char hex session IDs load correctly
  • Verify ../../etc/passwd as session_id returns None and logs warning
  • Verify session creation + join + load roundtrip still works

🤖 Generated with Claude Code

…ive scanner

The `_load_session()` method constructed a file path by interpolating the
`session_id` parameter directly into `Path('data/sessions') / f"{session_id}.json"`
without any validation. A malicious session ID containing path traversal
characters (e.g., `../../etc/config`) could read arbitrary `.json` files
from the operator's filesystem.

This commit:
- Adds `_validate_session_id()` that enforces the expected format: exactly
  16 lowercase hex characters (matching `_generate_session_id()` output)
- Rejects any session_id that doesn't match, with a warning log
- Prevents path traversal by ensuring no `/`, `\`, `..`, or other
  filesystem metacharacters can appear in the session_id

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.

2 participants