T05 · Unauthorized Access and Privilege Escalation
- Location
scripts/soul_guardian.py:199- Finding
Policy Paths Can Escape the Workspace and Access Arbitrary Files
- Content
View full analysis
list[dict[str, str]]: """Return list of effective targets to consider. For entries with {path, mode}: direct file. For entries with {pattern, mode}: expands via globbing relative to root. Note: We keep it simple and only expand within workspace root. """ targets: list[dict[str, str]] = [] entries = policy.get("targets", []) for ent in entries: mode = ent.get("mode") if mode not in ("restore", "alert", "ignore"): continue if "path" in ent: p = Path(ent["path"]) targets.append({"path": p.as_posix(), "mode": mode}) continue pat = ent.get("pattern") if not pat: continue for match in root.glob(pat): if match.is_dir(): continue rel = relpath_str(match, root) targets.append({"path": rel, "mode": mode}) dedup: dict[str, str] = {} for t in targets: dedup[t["path"]] = t["mode"] return [{"path": p, "mode": m} for p, m in sorted(dedup.items())] def approved_snapshot_path(state: GuardianState, rel_path: str) -> Path: # Preserve relative structure under approved/. return state.approved_dir / Path(rel_path) ``` The resulting path is subsequently used without a workspace containment check: ```python relp = t["path"] mode = t["mode"] if mode == "ignore": continue abs_path = WORKSPACE_ROOT / relp if not abs_path.exists(): continue refuse_symlink(abs_path) ``` The same construction is used during drift detection and restoration: ```python def detect_drift_for( state: GuardianState, baselines: dict[str, Any], relp: ...[truncated 2962 chars]- Remediation
View remediation
