T09 · Insecure Skill Coding Practices
- Location
references/agent_template.py:69- Finding
Configurable State Path Enables Arbitrary File Overwrite and Unsafe Temporary-File Access
- Content
View full analysis
Optional[Dict]: """Load state""" if self.state_persistence == 'file': try: with open(self.state_file, 'r') as f: return json.load(f) except FileNotFoundError: return None elif self.state_persistence == 'memory': return getattr(self, '_memory_state', None) return None ``` ### Technical Analysis The agent accepts `state_file` directly from its configuration and passes that path to `open()` for reading and writing. It does not constrain the path to an application-controlled directory, canonicalize and validate it, reject symbolic links, or enforce restrictive file permissions. The default path is under the shared `/tmp` directory. Although the randomly generated UUID makes casual prediction difficult, the implementation does not use secure temporary-file primitives or atomic creation. A caller able to supply configuration can bypass the random default entirely and select an arbitrary path. Opening the state file in `w` mode follows symbolic links ...[truncated 1674 chars]- Remediation
View remediation
