T09 · Insecure Skill Coding Practices
- Location
scripts/main.py:17- Finding
URL Mapping Data Is Stored Without Explicitly Restrictive Permissions
- Content
View full analysis
Dict[str, Dict[str, Any]]: """Load URL mappings from JSON file""" ensure_config_dir() if not DATA_FILE.exists(): return {} try: with open(DATA_FILE, 'r') as f: return json.load(f) except (json.JSONDecodeError, IOError): return {} def save_mappings(mappings: Dict[str, Dict[str, Any]]): """Save URL mappings to JSON file""" ensure_config_dir() with open(DATA_FILE, 'w') as f: json.dump(mappings, f, indent=2) ``` ### Technical Analysis The application creates `~/.url-shortener` and `mappings.json` without specifying restrictive permissions. Consequently, their modes are determined by the process umask. Under common configurations, the directory may be created as `0755` and the file as `0644`, allowing other local users to traverse the directory and read the mapping database. The database can contain URLs, descriptions, tags, timestamps, click counts, and last-accessed information. URLs may also contain sensitive query parameters, internal hostnames, private document identifiers, or authentication tokens. The implementation also opens an existing path directly without validating that it is a regular file owned by the current user. It therefore does not protect the storage operation against an existing symbolic link or unexpectedly permissive pre-existing file. ### Attack Path 1. A victim runs the CLI and creates or imports one or more URL mappings. 2. `ensure_config_dir()` creates the configuration directory using permissions inherited from the victim's umask. 3. `save ...[truncated 1140 chars]- Remediation
View remediation
