T09 · Insecure Skill Coding Practices
Warning
- Location
- SKILL.md:63
- Finding
- SQL Credentials Exposed Through Command-Line Arguments<![CDATA[ ## Vulnerability Details **File Location**: `SKILL.md`, lines 63–72 **Vulnerability Type**: Plaintext credential exposure through process arguments **Risk Level**: Medium ### Vulnerable Code ```bash # SQL Authentication sqlcmd -S "$SQL_SERVER" -U "$SQL_USER" -P "$SQL_PASSWORD" -d "$SQL_DATABASE" # Named instance + specific database sqlcmd -S "$SQL_SERVER" -U "$SQL_USER" -P "$SQL_PASSWORD" -d "$SQL_DATABASE" # Run a diagnostic script sqlcmd -S "$SQL_SERVER" -U "$SQL_USER" -P "$SQL_PASSWORD" -d master -i scripts/top-slow-queries.sql # Run with output to file sqlcmd -S "$SQL_SERVER" -U "$SQL_USER" -P "$SQL_PASSWORD" -d master -i scripts/wait-stats.sql -o results.txt -s "," -W ``` Equivalent vulnerable command patterns also appear in `README.md` and later workflow examples in `SKILL.md`. ### Technical Analysis The password is initially obtained from the `SQL_PASSWORD` environment variable, but the shell expands it before starting `sqlcmd`. Consequently, the plaintext password becomes part of the process argument vector through the `-P` option. Depending on the operating system, process isolation configuration, audit policy, and monitoring software, command-line arguments may be observable through: - Process-enumeration interfaces and administrative tools - Endpoint monitoring or application-performance monitoring agents - Process-creation audit records - Shell tracing such as `set -x` - Diagnostic captures, crash reports, or support bundles - Parent processes that record child-process arguments Using an environment variable does not mitigate this issue when its value is subsequently expanded into a command-line argument. ### Attack Path 1. A user follows the documented SQL Authentication workflow. 2. The shell expands `$SQL_PASSWORD` into the `sqlcmd -P` argument. 3. The plaintext password is placed in the running process's argument vector. 4. A local account, privileged monitoring component, audit collector, or process-inspection mechanism c ...[truncated 965 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Prefer integrated authentication and remove the password from the command entirely: ```bash sqlcmd -S "$SQL_SERVER" -E -d "$SQL_DATABASE" ``` 2. When SQL Authentication is unavoidable, use the supported `SQLCMDPASSWORD` environment variable without supplying the `-P` argument: ```bash export SQLCMDPASSWORD="$SQL_PASSWORD" sqlcmd -S "$SQL_SERVER" -U "$SQL_USER" -d "$SQL_DATABASE" unset SQLCMDPASSWORD ``` 3. Replace every documented `-P "$SQL_PASSWORD"` example in `SKILL.md`, `README.md`, and associated workflows. 4. Use a secrets manager or short-lived credential mechanism rather than persistent passwords. 5. Assign the SQL login only the permissions required for the selected workflow. Diagnostic accounts should not receive schema, restore, or server-administration permissions. 6. Disable shell tracing around secret-handling commands and configure monitoring systems to redact SQL credentials and environment variables. 7. Rotate any credentials that may previously have been exposed through process telemetry, audit logs, command history, or support bundles. ]]>
