T09 · Insecure Skill Coding Practices
Error
- Location
- cli.py:22
- Finding
- TOTP Secret Exposure Through Command-Line Arguments<![CDATA[ ## Vulnerability Details **File Location**: `cli.py:22-24` (the insecure usage is also documented in `SKILL.md:15-16`) **Vulnerability Type**: Sensitive information exposure through process arguments and shell history **Risk Level**: High ### Vulnerable Code ```python add = sub.add_parser("add", help="Add or update an account") add.add_argument("label", help="Account label, e.g. email@domain.com") add.add_argument("secret", help="Base32 secret key") ``` The documented invocation reinforces this insecure interface: ```text - Add/update an account: - `python3 cli.py add <label> <base32-secret> --issuer <issuer> --digits 6 --period 30` ``` ### Technical Analysis The application accepts a TOTP seed as a positional command-line argument. Command-line arguments are not an appropriate channel for authentication secrets because they may be exposed through: - Shell history files. - Process inspection utilities while the command is running. - Operating-system process accounting or auditing. - Terminal session recording and command telemetry. - Diagnostic logs that capture executed command lines. A TOTP seed is a long-lived credential rather than a single-use code. Anyone who obtains it can generate future valid codes for the associated account, subject only to the configured time period and clock synchronization. ### Attack Path 1. A user follows the documented command and runs `python3 cli.py add account BASE32_SECRET`. 2. The shell records the complete command in its history, or a local process-monitoring facility captures the process arguments. 3. An attacker with access to that history, telemetry, or process information extracts the Base32 seed. 4. The attacker imports the seed into another TOTP implementation. 5. The attacker generates valid current and future TOTP codes and uses them with separately obtained account credentials. ### Impact Assessment Successful exploitation discloses the second-factor seed for the account being added. The a ...[truncated 316 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions - Remove the TOTP secret positional argument from the CLI. - Prompt for the secret using `getpass.getpass()` so input is neither echoed nor included in process arguments. - For automation, accept the secret through a protected file descriptor or standard input, while clearly warning users not to place it directly in shell command text. - If file-based import is supported, verify restrictive ownership and permissions before reading the secret. - Update `SKILL.md` to document the protected input workflow and remove examples containing a secret argument. - Warn existing users to clear affected shell history securely and rotate any TOTP seeds previously entered on the command line. - Add automated tests confirming that parsed command-line arguments no longer contain the secret. ]]>
