T09 · Insecure Skill Coding Practices
- Location
debug.md:9- Finding
Unredacted SQL Parameter Logging May Expose Sensitive Data
- Content
View full analysis
Vulnerability Details
File Location:
debug.md, line 9
Vulnerability Type: Sensitive data exposure through application logs
Risk Level: MediumVulnerable Instruction:
markdown 1. **Read the actual statement, not the intent.** For ORM-generated SQL, turn on query logging and copy the emitted text; for dynamic SQL, log the final string with parameters bound.Technical Analysis
The instruction recommends logging a dynamically constructed SQL statement after its parameters have been bound. Bound values may contain passwords, authentication tokens, personal data, financial information, tenant identifiers, or other confidential application data.
This conflicts with the safer practice of logging the parameterized SQL template while redacting or omitting values. Although
security.mdwarns against logging parameters for statements that touch identified personal-data columns, that narrower warning does not adequately constrain the unconditional instruction indebug.md. Sensitive columns may also be unclassified, and secrets can occur outside formally designated personal-data fields.Logs commonly have broader access and longer retention than production database records. They may also be copied into centralized logging platforms, support bundles, backups, or development systems. Consequently, binding values into logged SQL can create an additional persistent copy of sensitive information.
Attack Path
- An application handles an attacker-controlled or otherwise sensitive value as a SQL parameter.
- An operator follows the debugging instruction and enables logging of the final SQL string with bound parameters.
- The sensitive value is serialized into an application log, database log, or centralized observability platform.
- A user or attacker with access to logs—but not necessarily direct access to the production database—retrieves the exposed value.
- If the value is a credential or token, ...[truncated 656 chars]
- Remediation
View remediation
Remediation Suggestions
Replace the instruction with a safe-by-default requirement to log only the parameterized statement template, duration, query identifier, and call site.
Recommended replacement:
markdown For dynamic SQL, log the parameterized statement template without bound values. If parameter inspection is strictly necessary during a bounded debugging session, use an explicit allowlist and structured redaction. Never log passwords, tokens, connection strings, personal data, or encryption material.Additional hardening measures:
- Redact sensitive values in both application and database log formatters.
- Use an allowlist of explicitly non-sensitive diagnostic fields rather than attempting to maintain a denylist.
- Limit verbose query logging to development or a short, authorized diagnostic window.
- Apply least-privilege access controls to logging and observability systems.
- Define short retention periods for diagnostic logs and securely delete expired records.
- Prevent production query logs from being copied into development systems or support bundles without sanitization.
- Add automated tests that verify credentials, tokens, connection strings, and designated personal-data fields are redacted.
