T09 · Insecure Skill Coding Practices
- Location
src/encrypt.py:94- Finding
Encryption Key Disclosed Through Standard Output
- Content
View full analysis
Vulnerability Details
File Location:
src/encrypt.py:94-103
Vulnerability Type: Cryptographic secret disclosure
Risk Level: HighVulnerable Code
python if __name__ == "__main__": manager = EncryptManager() key = manager.load_or_create_key() print(f"密钥:{key.decode()}") # 测试加密解密 test_data = "这是测试数据".encode('utf-8') encrypted = manager.encrypt_data(test_data) print(f"加密后:{encrypted}")This executable path is invoked by the documented initialization workflow in
README.md:21-25andDEPLOYMENT.md:53-54. It is also called byrun.sh:36-42when no key exists:bash if [ ! -f "$HOME/.virtual_user/.key" ]; then echo "生成新密钥..." python3 src/encrypt.py else echo "✅ 密钥已存在" fiTechnical Analysis
The script prints the complete Fernet key immediately after loading or creating it. This key protects the entire scenario database. Standard output may be retained in CI/CD logs, terminal recordings, agent execution transcripts, deployment logs, or centralized logging systems.
Fernet encryption remains cryptographically sound only while the key is secret. Printing the key defeats the confidentiality expected from encrypting
scenario_library.json.enc.The Base64 operation used by
encrypt_datais not itself an exfiltration mechanism, and no network transmission sink was identified. The vulnerability is the explicit disclosure of the underlying encryption key.Attack Path
- A user follows the documented initialization procedure or starts the Skill through
run.sh. - If the key does not exist,
src/encrypt.pycreates it under~/.virtual_user/.key. - The same key is printed to standard output.
- The output is captured in a deployment log, CI log, terminal transcript, or agent history.
- An attacker who can access that output and the encrypted scenario file reconstructs the Fernet cipher and decrypts all records.
Impact Assessment
An attacker who obtains the disclosed key an ...[truncated 379 chars]
- A user follows the documented initialization procedure or starts the Skill through
- Remediation
View remediation
Remediation Suggestions
- Remove every statement that prints, logs, serializes, or returns the encryption key.
- Move encryption demonstrations into isolated unit tests that use ephemeral, test-only keys.
- Change the initialization path so it reports only whether key creation succeeded.
- Review CI, deployment, shell, and agent logs for historical key exposure.
- Rotate any key that may already have been printed, then re-encrypt the database with the new key.
- Store production keys in an operating-system keyring or managed secret store where practical.
- Add automated tests that fail if log output contains the key or other cryptographic material.
