Skip to content

fix(security): sanitize user-supplied IDs to prevent path traversal#307

Open
warren618 wants to merge 1 commit into666ghj:mainfrom
warren618:fix/path-traversal-sanitize
Open

fix(security): sanitize user-supplied IDs to prevent path traversal#307
warren618 wants to merge 1 commit into666ghj:mainfrom
warren618:fix/path-traversal-sanitize

Conversation

@warren618
Copy link
Copy Markdown

Summary

Fixes #306

User-supplied simulation_id, project_id, report_id, and platform are passed directly to os.path.join(), enabling path traversal attacks.

Fix

Added validation in all _get_*_dir methods: reject any ID where os.path.basename(id) != id, which catches path separators and .. sequences.

Changes

  • backend/app/services/simulation_manager.py_get_simulation_dir + get_profiles
  • backend/app/models/project.py_get_project_dir
  • backend/app/services/report_agent.py_get_report_folder

3 files, 16 insertions, 4 deletions.

simulation_id, project_id, report_id, and platform parameters from
API requests are used directly in os.path.join() to construct file
paths. An attacker can use values like "../../etc" to read/write
files or create directories outside the intended data directory.

Added validation: reject any ID that differs from its os.path.basename(),
which catches path separators and traversal sequences.
@dosubot dosubot bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Mar 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Security: path traversal via unsanitized IDs in simulation, project, and report endpoints

1 participant