Tainted flow: 'path' from os.environ.get (line 13, credential/environment) → open (file write)
Medium
- Category
- Data Flow
- Content
def save_memory(agent_id: str, data: dict): path = os.path.join(MEMORY_PATH, f"{agent_id}.json") with open(path, "w", encoding="utf-8") as f: json.dump(data, f, indent=2, ensure_ascii=False) def load_memory(agent_id: str):- Confidence
- 95% confidence
- Finding
- The file path used for persistence is derived from an environment-controlled base directory and an unsanitized agent_id. If agent_id contains path traversal sequences or absolute-path tricks, the code can read or write files outside the intended memory directory, and the environment variable can further redirect storage to unsafe locations. In a local-first agent framework that persists state automatically, this expands the blast radius because agent-controlled identifiers may be influenced by untrusted inputs.
