T09 · Insecure Skill Coding Practices
Error
- Location
- scripts/vault.py:102
- Finding
- Plaintext secrets are accepted through command-line arguments<![CDATA[ ## Vulnerability Details **File Location**: `SKILL.md:15-17`; `scripts/vault.py:102-108` **Vulnerability Type**: Plaintext secret exposure through process arguments **Risk Level**: High ### Vulnerable Code ```markdown ### 1. Store a Secret Encrypt and save a new credential. - **Usage**: `python3 $WORKSPACE/skills/mema-vault/scripts/vault.py set <service> <user> <password> [--meta "info"]` ``` ```python add_p = subparsers.add_parser("set") add_p.add_argument("service") add_p.add_argument("username") add_p.add_argument("password") add_p.add_argument("--meta", default="") ``` ### Technical Analysis The vault accepts the plaintext password as a positional command-line argument. Command-line arguments can be exposed through shell history, terminal logging, process-monitoring utilities, operating-system process metadata, and automation logs. This handling contradicts the security objective of a credential vault because the secret may be disclosed before encryption occurs. Encryption of the database does not protect copies of the password retained by the shell or exposed through process inspection. ### Attack Path 1. A user invokes the documented `set` command and includes a plaintext credential in the command line. 2. The shell may retain the complete command in its history. 3. While the process is running, a local process with sufficient visibility may inspect its arguments. 4. Terminal capture, process monitoring, CI output, or shell-history access reveals the plaintext password. 5. The attacker can reuse the credential against the associated service. ### Impact Assessment A local user or monitoring process may obtain the complete plaintext credential supplied to the vault. The resulting privileges are those granted by the exposed credential and may extend beyond the local machine to databases, APIs, or other services represented by the secret. ]]>
- Remediation
- <![CDATA[ ## Remediation Suggestions - Remove the positional `password` argument. - Prompt interactively using `getpass.getpass()` so the password is not echoed or placed in process arguments. - For automation, accept the secret through a protected file descriptor or standard input only when explicitly requested. - Warn users against placing secrets directly in shell commands. - Update `SKILL.md` so its examples use the secure input mechanism. - Review deployment and CI logs for previously exposed credentials and rotate any affected secrets. ]]>
