T09 · Insecure Skill Coding Practices
Error
- Location
- scripts/main.py:410
- Finding
- Full-Account Authentication Cookies Stored in a Plaintext Project File<![CDATA[ ## Vulnerability Details **File Location**: `scripts/main.py:410-418`; related configuration at `config.json:1-5` **Vulnerability Type**: Plaintext storage of sensitive authentication credentials **Risk Level**: High ### Vulnerable Code ```python # Read configuration config_path = os.path.join(os.path.dirname(__file__), '..', 'config.json') try: with open(config_path, 'r') as f: config = json.load(f) except: config = {} bduss = config.get('bduss', os.getenv('BAIDU_BDUSS', '')) stoken = config.get('stoken', os.getenv('BAIDU_STOKEN', '')) ``` The distributed configuration file provides plaintext fields for these credentials: ```json { "bduss": "", "stoken": "", "default_save_path": "~/Downloads/BaiduNetdisk" } ``` ### Technical Analysis The Skill supports loading the Baidu `BDUSS` and `STOKEN` authentication cookies directly from `config.json`, an ordinary file stored in the project directory. These cookies are documented as granting complete access to the user's Baidu Netdisk account. The implementation does not: - Integrate with an operating-system credential store or another protected secret-management facility. - Validate that `config.json` has restrictive file permissions. - Warn or refuse to operate when the credential file is readable by other local users. - Include evidence of source-control exclusion for the populated configuration file. Consequently, credentials can be exposed through accidental source-control commits, project archives, backups, permissive filesystem permissions, or other local processes with access to the project directory. The credentials are subsequently sent as cookies only to fixed HTTPS endpoints under `pan.baidu.com`. That network transmission is necessary for the declared authenticated Netdisk functionality and does not, by itself, indicate credential exfiltration. The vulnerability is the supported plaintext-at-rest workflow. ### Attack Path 1. A user places valid `BDUSS` and `STOKEN ...[truncated 1011 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Remove file-based credential storage from the default configuration workflow. 2. Prefer an operating-system credential store or a dedicated secret-management service. 3. If environment variables remain supported, make them the documented fallback for development rather than encouraging populated project files. 4. Distribute a credential-free `config.example.json` instead of a credential-bearing `config.json`. 5. Add `config.json` and other local secret files to `.gitignore`. 6. If file-based storage must remain available: - Require owner-only permissions, such as mode `0600` on Unix-like systems. - Check permissions before reading the file and reject insecure configurations. - Avoid placing the file inside the source tree. 7. Document credential rotation and immediate session revocation procedures. 8. Use a dedicated test account with minimal valuable data where possible. ]]>
