Fix critical path traversal vulnerability in bridge.py that allows attackers to write to arbitrary filesystem locations outside the intended BASE directory. The current validation checks if the path string starts with BASE before resolving relative paths, enabling bypass via ../../ sequences.
Lines 32-33 in bridge.py:
fp=os.path.join(BASE,body["path"].lstrip("/"))
if not fp.startswith(BASE):self.send_response(403);self.end_headers();returnAttack vector:
../../etc/passwdos.path.join("/home/ubuntu/scidex", "../../etc/passwd") → "/home/ubuntu/scidex/../../etc/passwd"/home/etc/passwd when accessedEvidence: Service crashed on 2026-04-02 00:39:38 with:
PermissionError: [Errno 13] Permission denied: '/home/ubuntu/scidex/../../etc'fp = os.path.realpath(os.path.join(BASE, body["path"].lstrip("/")))
if not fp.startswith(os.path.realpath(BASE)):
self.send_response(403)
self.end_headers()
return../../etc/passwd → 403../../../etc/hosts → 403scripts/bridge.py, and prior commits for this task are not ancestors of origin/main.Path.resolve().relative_to(), which blocks sibling-prefix and symlink escapes after resolution.__main__ so the path validator can be imported by tests without starting the bridge service.tests/test_bridge_path_validation.py covering legitimate in-base paths, parent traversal, absolute paths, and symlink escape into a sibling directory.bridge.py compatibility entrypoint because the deployed scidex-bridge.service still invokes /home/ubuntu/scidex/bridge.py while the maintained implementation lives in scripts/bridge.py.Evidence run on 2026-04-24:
git show origin/main:scripts/bridge.py confirms resolve_upload_path uses Path.resolve().relative_to() — the secure pattern.git show origin/main:bridge.py confirms compatibility entrypoint delegates to scripts/bridge.py.git show origin/main:tests/test_bridge_path_validation.py confirms all 5 test cases exist.python3 -m pytest tests/test_bridge_path_validation.py -v → 5 passed (parent traversal blocked, absolute paths blocked, symlink escape blocked, legitimate paths allowed, no-shell subprocess verified).698ed86b2 (Squash merge: orchestra/task/126b98c0-senate-db-health-check-10-abandons)Summary: Path traversal vulnerability fully fixed. resolve_upload_path() uses pathlib.Path.resolve().relative_to() to resolve all symlinks and relative sequences before validation, blocking all documented bypass techniques. All 5 security tests pass on main.
{
"requirements": {
"coding": 9,
"safety": 10
},
"completion_shas": [
"40c9e5d5d8d839f4d986a12c2731edc6566b1fc1"
],
"completion_shas_checked_at": "2026-04-21T01:39:11.364942+00:00"
}