T05 · Unauthorized Access and Privilege Escalation
- Location
scripts/analyst_agent.py:145- Finding
API-Controlled Path Traversal Allows Unauthorized Local JSON File Reads
- Content
View full analysis
- Remediation
View remediation
list: if not re.fullmatch(r"[A-Za-z0-9_-]+", key): log("WARNING: Rejected invalid score key") return [] scores_dir = ( WORKSPACE / "projects" / "hybrid-control-plane" / "data" / "scores" ).resolve() score_file = (scores_dir / f"{key}.json").resolve() if score_file.parent != scores_dir: log("WARNING: Rejected score path outside score directory") return [] try: with score_file.open() as f: records = json.load(f) if not isinstance(records, list): return [] return [ round(float(record["score"]), 4) for record in records[-10:] if isinstance(record, dict) and "score" in record ] except (FileNotFoundError, OSError, ValueError, TypeError, json.JSONDecodeError): return [] ``` ]]>
