T09 · Insecure Skill Coding Practices
Warning
- Location
- scripts/social_publisher.py:20
- Finding
- Reusable Authentication Cookies Stored in Plaintext Configuration## Vulnerability Details **File Location**: `SKILL.md:30-43`; `scripts/social_publisher.py:20, 42-49` **Vulnerability Type**: Plaintext storage of sensitive authentication credentials **Risk Level**: Medium ### Vulnerable Code `SKILL.md:30-43` instructs users to store reusable session cookies directly in a JSON file: ```json { "juejin": { "cookie": "your-juejin-cookie" }, "zhihu": { "cookie": "your-zhihu-cookie" }, "weibo": { "cookie": "your-weibo-cookie" } } ``` `scripts/social_publisher.py:20, 42-49` reads those plaintext credentials without validating file ownership or permissions: ```python CONFIG_FILE = W / "config/social-publisher.json" def load_config() -> dict: """Load configuration.""" if not CONFIG_FILE.exists(): return {} return json.loads(CONFIG_FILE.read_text(encoding="utf-8")) def get_cookie(platform: str) -> Optional[str]: """Get a platform cookie.""" config = load_config() return config.get(platform, {}).get("cookie") ``` ### Technical Analysis The documented configuration model stores long-lived social-media cookies as unencrypted JSON values. These cookies are bearer credentials: possession may be sufficient to perform authenticated actions under the associated account until the session expires or is revoked. The implementation reads the configuration without checking whether the file is owned by the expected user or protected by restrictive permissions. It also places the expected file under the project tree, increasing the chance that it may be copied with the workspace, included in backups, or accidentally committed to source control. Local encryption alone would not fully resolve this issue if the decryption key were stored beside the file. A platform keychain or dedicated secret manager is the preferred control. ### Attack Path 1. A user follows the documentation and saves active Juejin, Zhihu, or ...[truncated 1031 chars]
- Remediation
- ## Remediation Suggestions 1. Store cookies in an operating-system keychain, credential vault, or dedicated secret-management service rather than in the workspace. 2. If file-based storage must be supported, place the file outside the project tree and require permissions equivalent to `0600`. 3. Before reading the file, verify that it is owned by the current user, is a regular file rather than a symbolic link, and is not accessible by group or other users. 4. Add the configuration path to version-control ignore rules and warn users against placing credentials in repositories, shared workspaces, logs, or backups. 5. Prefer narrowly scoped, revocable platform tokens over full browser session cookies where supported. 6. Document credential revocation and rotation procedures. 7. Avoid printing cookies or including request headers in diagnostic logs.
