SOL-DEPYLER-002 // depyler
Hardened Path Validation for MCP File Tools
Emit canonicalized root-bound path validation in Rust preventing directory traversal across transpiled file utilities.
Measured delta: 0 directory traversal bypasses (SEC-PATH-001 verified)
Before (Failing Anti-Pattern)
def unsafe_join(root, rel):
return root + "/" + rel # vulnerable to ../../etc/passwd traversal
After (Verified Code)
def safe_join(root: str, rel: str) -> str:
if ".." in rel or rel.startswith("/"):
raise ValueError("path escapes root")
return f"{root}/{rel}"
Verification Contract
schema: depyler.contract.v1 security: reject_parent_traversal: true reject_absolute_rel: true
Verified CLI Command & Output
$ depyler transpile --strict-sec safe_join.py -o safe_join.rs depyler: security contract SEC-PATH-001 VERIFIED (0 traversal bypasses)