Skip to content

bug: path traversal in GET /code-sync/drift component query param #3427

@mrveiss

Description

@mrveiss

Summary

GET /code-sync/drift?component=<value> passes the user-supplied component parameter directly into Path(root) / component without any allowlist or boundary check.

Affected files:

  • autobot-slm-backend/services/drift_checker.pyget_default_source_dir() / get_default_deployed_dir()
  • autobot-slm-backend/api/code_sync.py/drift endpoint

Reproduction

GET /code-sync/drift?component=../../etc

Path("/opt/autobot/code_source") / "../../etc" resolves to /opt/etc, allowing an authenticated caller to checksum files outside the intended deployed root.

Fix

Add an explicit allowlist of permitted component names (e.g. {"autobot-slm-backend", "autobot-slm-frontend", "autobot-backend"}) in get_default_source_dir / get_default_deployed_dir, and raise HTTPException(400) for any value not in the set. Alternatively, resolve the final path with Path.resolve() and assert it is a subdirectory of the root.

Introduced in

Commit 0dba8915bfeat(slm): add deployed-vs-source drift detection to code-sync (#2834)

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions