T09 · Insecure Skill Coding Practices
- Location
scripts/db_schema.py:65- Finding
Database Credentials Exposed Through Command-Line Arguments and Schema Output
- Content
View full analysis
Vulnerability Details
File Location:
SKILL.md:15-18;scripts/db_schema.py:65-72
Vulnerability Type: Credential exposure through process arguments and plaintext logging
Risk Level: MediumVulnerable code snippets:
SKILL.md:15-18bash # PostgreSQL python3 skills/sql-db-toolkit/scripts/db_query.py --conn "postgresql://user:pass@host:5432/db" --sql "SELECT table_name FROM information_schema.tables"scripts/db_schema.py:65-72python def inspect_generic(conn_str): """Generic schema inspection using SQL standard queries.""" import importlib if conn_str.startswith('postgresql://'): pg = importlib.import_module('psycopg2') conn = pg.connect(conn_str) output = [f"Connection: {conn_str}"] c = conn.cursor()Technical Analysis
The documented interface encourages users to provide a database connection URL containing a username and password through the
--conncommand-line argument. Command-line arguments may be captured by shell history, process-monitoring utilities, job runners, audit systems, Agent transcripts, or CI/CD logs.The schema inspection implementation compounds this exposure by copying the complete connection string into its output without redacting the password. Any destination that collects standard output can consequently retain reusable database credentials.
Attack Path
- A user follows the documented example and invokes a script with a credential-bearing PostgreSQL URL in
--conn. - The invocation is retained in shell history or observed through process inspection or execution logging.
- When
db_schema.pyis used, the full URL is also written to standard output. - Another local user, log reader, transcript consumer, or monitoring-system operator obtains the username and password.
- The exposed credentials are reused to connect directly to the database.
Impact Assessment
Successful ...[truncated 451 chars]
- A user follows the documented example and invokes a script with a credential-bearing PostgreSQL URL in
- Remediation
View remediation
Remediation Suggestions
- Do not recommend credential-bearing connection URLs directly in command-line arguments.
- Accept secrets through protected environment variables, an interactive password prompt, a permission-restricted configuration file, or a platform secret manager.
- Parse connection URLs before display and replace passwords with a fixed redaction marker such as
***. - Avoid printing connection strings unless explicitly requested by a diagnostic option; even then, print only non-sensitive fields such as database type, host, port, and database name.
- Update documentation to use placeholders and explain secure secret provisioning.
- Ensure CI/CD and Agent execution systems mask database secrets in arguments and logs.
- Rotate any credentials that may already have been recorded in process, transcript, or shell-history logs.
