T09 · Insecure Skill Coding Practices
Error
- Location
- scripts/netdiag.py:1774
- Finding
- Configuration Validation Exposes Telegram Credentials<![CDATA[ ## Vulnerability Details **File Location**: `scripts/netdiag.py:1774-1775` **Vulnerability Type**: Sensitive credential disclosure through standard output **Risk Level**: High ### Vulnerable Code ```python print("valid") print(json.dumps(cfg, ensure_ascii=True, indent=2)) ``` ### Technical Analysis The `validate-config` command prints the complete merged configuration after successful validation. The configuration contains sensitive values including: - `telegram.bot_token` - `telegram.personal_chat_id` The output is not passed through the Skill's existing redaction functions. Consequently, validating a production configuration discloses the Telegram bot token in plaintext to standard output. This contradicts the otherwise enabled `logging.redact_sensitive_fields` protection. Standard output is commonly captured by CI/CD systems, orchestration tools, agent transcripts, terminal logging, and support diagnostics, making it an unsafe location for secrets. ### Attack Path 1. An operator creates a real configuration containing a valid Telegram bot token. 2. The operator or an automated job runs: ```bash python3 scripts/netdiag.py validate-config --config config.json ``` 3. The command prints the complete configuration, including the plaintext bot token. 4. The output is retained in a CI log, terminal recording, agent transcript, or support artifact. 5. A party with access to that retained output obtains the bot token. 6. The party uses the token to invoke Telegram Bot API methods available to that bot. ### Impact Assessment Disclosure grants possession of the bot credential rather than host-level privileges. An attacker may impersonate the bot, send messages, retrieve pending updates where API behavior and bot configuration permit it, inspect bot metadata, or otherwise exercise the Bot API permissions associated with the exposed token. The personal chat ID is also disclosed and may facilitate targeted misuse of the compromised bot. The ...[truncated 134 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Never print the complete merged configuration by default. 2. Return only a validation status and a list of non-sensitive configuration checks. 3. If configuration output is required, recursively redact at least: - `telegram.bot_token` - authentication headers - proxy credentials - cookies and secret tokens 4. Apply redaction regardless of `logging.redact_sensitive_fields`; validation output should not support plaintext secret display. 5. Add automated tests asserting that known token values never appear in stdout or stderr. 6. Document that any previously captured validation output must be removed and affected bot tokens rotated. A safer implementation would print only: ```python print("valid") print("Configuration passed validation; sensitive values were not displayed.") ``` ]]>
