T05 · Unauthorized Access and Privilege Escalation
- Location
scripts/offline_chat.py:231- Finding
Model-Triggered Arbitrary Local File Disclosure
- Content
View full analysis
> — the system will feed content back.""" ``` ```python def read_file(filepath): path = Path(filepath).expanduser().resolve() if not path.exists(): return {"error": f"File not found: {filepath}"} try: content = path.read_text(encoding="utf-8") return {"content": content, "size": len(content)} except Exception as e: return {"error": str(e)} ``` ```python if "/api/read" in first: try: req = json.loads(body) result = read_file(req.get("path", "")) resp = json.dumps(result, ensure_ascii=False) conn.sendall(f"HTTP/1.1 200 OK\r\nContent-Type: application/json; charset=utf-8\r\nContent-Length: {len(resp.encode())}\r\n\r\n{resp}".encode()) except Exception as e: err = json.dumps({"error": str(e)}, ensure_ascii=False) conn.sendall(f"HTTP/1.1 500 OK\r\nContent-Type: application/json; charset=utf-8\r\nContent-Length: {len(err.encode())}\r\n\r\n{err}".encode()) return ``` The browser also automatically interprets a model-generated directive and submits it to this endpoint: ```javascript let read_match=d.content.match(/<>/); if(read_match){ let fp=read_match[1].trim(); let fr=await fetch("/api/read",{ method:"POST", headers:{"Content-Type":"application/json"}, body:JSON.stringify({path:fp}) }); let fd=await fr.json(); if(fd.content){ let truncated=fd.content.length>4000 ? fd.content.substring(0,4000)+"\n... [truncated, ...[truncated 2893 chars]- Remediation
View remediation
