T09 · Insecure Skill Coding Practices
Error
- Location
- scripts/main.py:45
- Finding
- Database Password Exposure Through Command-Line Arguments<![CDATA[ ## Vulnerability Details **File Location**: `scripts/main.py:45`, `scripts/main.py:171-187`; documented usage at `SKILL.md:80-86` **Vulnerability Type**: Plaintext sensitive data exposure through process arguments and shell history **Risk Level**: High ### Vulnerable Code ```python parser.add_argument("--password", help="Database password.") ``` ```python if args.url: url = args.url username = args.user or "" raw_password = args.password or "" # Detect "${VAR_NAME}", "${env:VAR_NAME}", "$env:VAR_NAME", or plain "VAR_NAME" m = _re.match(r"^\$\{(?:env:)?(\w+)\}$", raw_password) if m: password_env_var = m.group(1) password = os.environ.get(password_env_var, "") elif _re.match(r"^\$env:(\w+)$", raw_password, _re.IGNORECASE): password_env_var = _re.match(r"^\$env:(\w+)$", raw_password, _re.IGNORECASE).group(1) password = os.environ.get(password_env_var, "") elif _re.match(r"^[A-Z_][A-Z0-9_]*$", raw_password.upper()) and not _re.match(r"^\d", raw_password): password_env_var = raw_password password = os.environ.get(password_env_var, "") elif raw_password: password = raw_password ``` The documented configuration method also explicitly recommends the command-line option: ```bash python scripts/main.py \ --url "jdbc:mysql://host:3306/db" \ --user "admin" \ --password "${DB_PASS}" \ --query "SELECT 1" ``` ### Technical Analysis The CLI accepts a database password directly in `argv`. When a literal password is supplied, it can be retained in shell history and may be visible through process-inspection facilities while the command is running. Although shell expansion of `"${DB_PASS}"` avoids placing the variable name in the resulting command, it substitutes the secret before process creation. The expanded password therefore still becomes a process argument. This exposure is not necessary for the Skill's database functionality. Passwords can instead be obtaine ...[truncated 1133 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions - Remove or strongly discourage literal passwords in `--password`. - Add an option such as `--password-env DB_PASS` that accepts only an environment-variable name. - For interactive use, obtain the password with `getpass.getpass()` rather than `input()` or a command-line argument. - Support protected secret files or inherited file descriptors for automated deployments. - If backward compatibility requires `--password`, emit a prominent warning when the argument contains a literal value. - Update all documentation to avoid examples that expand secrets directly into command-line arguments. - Clear password references as soon as practical after the connection has been established. ]]>
