T09 · Insecure Skill Coding Practices
- Location
scripts/wenshu_search.py:38- Finding
Account Identifier Stored Without Restrictive File Permissions
- Content
View full analysis
Vulnerability Details
File Location:
scripts/wenshu_search.py, lines 38-56
Vulnerability Type: Unprotected local storage of sensitive account information
Risk Level: MediumVulnerable Code
python _CONFIG_FILE = Path(__file__).parent / ".wenshu_config.json" def _load_config(): if _CONFIG_FILE.exists(): try: return json.loads(_CONFIG_FILE.read_text(encoding="utf-8")) except Exception: return None return None def _save_config(cfg: dict): safe_cfg = dict(cfg) safe_cfg["PASSWORD"] = "********" _CONFIG_FILE.write_text( json.dumps(safe_cfg, ensure_ascii=False, indent=2), encoding="utf-8" )The configuration passed to
_save_config()includes the registered account identifier underUSERNAME. Although the password is replaced with a mask, the account identifier—documented as a registered mobile number—is written in plaintext to.wenshu_config.json.Technical Analysis
Path.write_text()creates the configuration file using permissions derived from the process umask. The code does not explicitly require owner-only permissions. Under a permissive umask or shared project directory, other local users may be able to read the registered mobile number and search configuration.Placing the file beside the script also increases the possibility of accidental disclosure through source-control commits, project archives, shared directories, or backups. The password masking is appropriate but does not protect the remaining account information.
The file is used only to remember configuration and therefore does not require access by users other than the account running the Skill. Broader access would exceed the minimum privileges necessary for the declared functionality.
Attack Path
- A victim runs the Skill, causing
.wenshu_config.jsonto be created beside the script. - The host has a permissi ...[truncated 906 chars]
- A victim runs the Skill, causing
- Remediation
View remediation
Remediation Suggestions
- Store configuration in a user-private platform configuration directory rather than beside the script.
- Create the file with owner-only permissions, such as mode
0600on POSIX systems. - Write through a securely created temporary file and atomically replace the destination.
- Avoid retaining the mobile number unless persistent login convenience is explicitly enabled by the user.
- Consider storing the account identifier in an operating-system credential manager.
- Add
.wenshu_config.jsonto source-control ignore rules and warn users not to include it in shared archives. - Validate permissions when loading an existing configuration and reject or warn about files readable by other users.
