Feature: Path containment startswith bypass prevention (issue #7478 / PR #7801) AS a security engineer I WANT path containment checks to use semantic comparison instead of string prefix matching SO THAT sibling-directory prefix-collision attacks cannot bypass sandbox isolation Background: Given a temporary sandbox directory "/tmp/sandbox" # ---- PathMapper _is_under prefix collision prevention (#7478) ---- @tdd_issue @tdd_issue_7478 Scenario: PathMapper rejects sibling-prefix path traversal via relpath containment Given I have a PathMapper with host_root "/tmp/sandbox" and container_root "/workspace" And a sibling directory with a name that is a prefix of the sandbox root When I check whether host path is safe from prefix collision Then the prefix collision check should return ``False`` @tdd_issue @tdd_issue_7478 Scenario: PathMapper correctly identifies legitimate child paths Given I have a PathMapper with host_root "/tmp/sandbox" and container_root "/workspace" When I check whether "/tmp/sandbox/src/main.py" is a host path Then the host containment result should be true @tdd_issue @tdd_issue_7478 Scenario: PathMapper correctly identifies root equality Given I have a PathMapper with host_root "/tmp/sandbox" and container_root "/workspace" When I check whether "/tmp/sandbox" is a host path Then the host containment result should be true @tdd_issue @tdd_issue_7478 Scenario: PathMapper rejects sibling-prefix escape path Given I have a PathMapper with host_root "/tmp/sandbox" and container_root "/workspace" And a file "escape-evil.txt" with content "malicious" at "/tmp/sandbox-escape/escape-evil.txt" When I check whether "/tmp/sandbox-escape/escape-evil.txt" is a host path Then the host containment result should be false @tdd_issue @tdd_issue_7478 Scenario: PathMapper maps root path exactly (no relative component) Given I have a PathMapper with host_root "/tmp/sandbox" and container_root "/workspace" When I map the host path "/tmp/sandbox" to container Then the mapped path should be "/workspace" @tdd_issue @tdd_issue_7478 Scenario: PathMapper maps a child path correctly through relpath Given I have a PathMapper with host_root "/tmp/sandbox" and container_root "/workspace" When I map the host path "/tmp/sandbox/src/main.py" to container Then the mapped path should be "/workspace/src/main.py"