Skip to content

Path traversal: repo base-name derivation lets a "..git" target resolve to "..", causing rmtree of a directory outside the scoped temp dir #1133

Description

@FabioLeitao

Summary

derive_repo_base_name strips a trailing .git suffix from a target URL/path and passes the result through sanitize_name, which only strips characters outside [A-Za-z0-9._-] — dots are preserved. A target string ending in ..git therefore derives a base name of literally .. (parent-directory reference).

Impact

The derived base name is used to build clone_path = temp_dir / dest_name, and the destination is rmtree'd before cloning. A crafted target string ending in ..git can make Strix delete a directory outside the intended per-scan temp folder — e.g. a sibling directory of temp_dir — rather than the scoped clone destination.

Where

strix/interface/utils.py:

  • sanitize_name (regex [^A-Za-z0-9._-]-) preserves dots, so .. survives.
  • derive_repo_base_name strips .git suffix then calls sanitize_name, producing .. for a ..git-suffixed input.
  • The resulting dest_name is joined under temp_dir and rmtree'd before clone.

Suggested fix

  • After deriving the base name, explicitly reject (or normalize away) ./.. and any name that isn't a plain relative path component — e.g. if dest_name in {"", ".", ".."} or "/" in dest_name or "\\" in dest_name: raise.
  • Alternatively, resolve clone_path and assert it is still a direct child of temp_dir (clone_path.resolve().parent == temp_dir.resolve()) before doing anything destructive like rmtree.

Flagging alongside the other two findings from the same pass over strix/interface/utils.py.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions