T09 · Insecure Skill Coding Practices
- Location
scripts/main.py:329- Finding
Plaintext Storage of Full-Account Session Credentials and Broken Environment Fallback
- Content
View full analysis
Vulnerability Details
File Location:
config.json:1-5,scripts/main.py:329-341,SKILL.md:40-47,README.md:23-31
Vulnerability Type: Plaintext sensitive credential storage
Risk Level: MediumVulnerable Code
config.json:1-5:json { "bduss": "", "stoken": "", "default_save_path": "~/Downloads/BaiduNetdisk" }scripts/main.py:329-341:python # 读取配置 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', '')) if not bduss or not stoken:SKILL.md:40-47:json { "bduss": "your_bduss_here", "stoken": "your_stoken_here", "default_save_path": "~/Downloads/BaiduNetdisk" }Technical Analysis
The documentation encourages users to place Baidu
BDUSSandSTOKENsession credentials in a repository-local plaintext JSON file. These are highly sensitive session credentials with broad access to the user's Baidu Netdisk account.Although environment variables are documented as a safer alternative, the fallback implementation is defective when the shipped configuration retains empty strings. Python's
dict.get(key, default)returns the existing empty string rather than evaluating the environment-variable default. Consequently, settingBAIDU_BDUSSandBAIDU_STOKENalone does not work while the corresponding empty keys remain inconfig.json.The credentials are transmitted only to fixed HTTPS endpoints under
pan.baidu.com, which is necessary for the declared functionality and is not evidence of unrelated exfiltration. The vulnerability concerns their local storage and handling before transmission.Attack Path
- A user follows the installation documentation and writes valid
BDUSSand ` ...[truncated 1159 chars]
- A user follows the installation documentation and writes valid
- Remediation
View remediation
Remediation Suggestions
-
Correct the fallback logic so empty configuration values do not override environment variables:
python bduss = config.get('bduss') or os.getenv('BAIDU_BDUSS', '') stoken = config.get('stoken') or os.getenv('BAIDU_STOKEN', '') -
Prefer a platform secret manager or the host framework's secret-injection mechanism over repository-local files.
-
Replace the distributed
config.jsonwith a non-secretconfig.example.json. -
Add the real credential file to
.gitignoreand any package-publication exclusion list. -
If file-based secrets must be supported, verify that the file is owned by the current user and has restrictive permissions, such as mode
0600on supported platforms. -
Reject symlinked or unexpectedly located configuration files where practical.
-
Avoid printing credentials or including them in exception messages and diagnostic logs.
-
Document credential revocation and rotation procedures for users who suspect exposure.
-
