T09 · Insecure Skill Coding Practices
Error
- Location
- pipeline-cli.yaml:30
- Finding
- Incomplete Redaction Patterns Can Leak Sensitive Credentials<![CDATA[ ## Vulnerability Details **File Location**: `pipeline-cli.yaml:30-48`; mirrored in `pipeline-mcp.yaml:33-51` **Vulnerability Type**: Incomplete sensitive-data sanitization **Risk Level**: High ### Vulnerable Code ```yaml # Password patterns let text = $text.re_replace_all("(?i)(password|passwd|pwd)\\s*[=:]\\s*[^\\s,;\"']+", "$1=***REDACTED***") # Token/API key patterns let text = $text.re_replace_all("(?i)(token|api[_-]?key|apikey|access[_-]?key|secret[_-]?key)\\s*[=:]\\s*[^\\s,;\"']+", "$1=***REDACTED***") # Bearer tokens let text = $text.re_replace_all("(?i)bearer\\s+[a-zA-Z0-9._-]+", "Bearer ***REDACTED***") # AWS keys let text = $text.re_replace_all("AKIA[0-9A-Z]{16}", "***AWS_KEY_REDACTED***") # Generic secret patterns let text = $text.re_replace_all("(?i)(secret|auth|credential|private[_-]?key)\\s*[=:]\\s*[^\\s,;\"']+", "$1=***REDACTED***") # JWT tokens (three base64 sections separated by dots) let text = $text.re_replace_all("eyJ[a-zA-Z0-9_-]*\\.eyJ[a-zA-Z0-9_-]*\\.[a-zA-Z0-9_-]+", "***JWT_REDACTED***") ``` The MCP pipeline contains the same effective patterns: ```yaml # Password patterns let text = $text.re_replace_all("(?i)(password|passwd|pwd)\\s*[=:]\\s*[^\\s,;\"']+", "$1=***REDACTED***") # Token/API key patterns let text = $text.re_replace_all("(?i)(token|api[_-]?key|apikey|access[_-]?key|secret[_-]?key)\\s*[=:]\\s*[^\\s,;\"']+", "$1=***REDACTED***") # Bearer tokens let text = $text.re_replace_all("(?i)bearer\\s+[a-zA-Z0-9._-]+", "Bearer ***REDACTED***") # AWS keys let text = $text.re_replace_all("AKIA[0-9A-Z]{16}", "***AWS_KEY_REDACTED***") # Generic secret patterns let text = $text.re_replace_all("(?i)(secret|auth|credential|private[_-]?key)\\s*[=:]\\s*[^\\s,;\"']+", "$1=***REDACTED***") # JWT tokens let text = $text.re_replace_all("eyJ[a-zA-Z0-9_-]*\\.eyJ[a-zA-Z0-9_-]*\\.[a-zA-Z0-9_-]+", "***JWT_REDACTED***") ``` ### Technical Analysis The password, token, and generic-secret expressions assume that a sensitive key is fol ...[truncated 2531 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Parse structured formats such as JSON rather than applying regular expressions to serialized data. Recursively redact values whose normalized keys match the sensitive-key policy. 2. Add patterns that safely support single-quoted and double-quoted keys and values, escaped characters, and values containing whitespace or punctuation. 3. Preserve the complete secret boundary when redacting multiline or delimited values instead of stopping at the first space, comma, or semicolon. 4. Introduce a fail-closed or warning mechanism for malformed and uncertain input. The result should indicate when complete sanitization cannot be guaranteed. 5. Calculate `redactions` from the number of successful replacements rather than the output-length difference. 6. Implement the declared `patterns` input and `patterns_matched` output, or remove them from `skill.yaml` so callers do not rely on unsupported controls. 7. Add regression tests covering: - JSON and nested JSON fields - Single-quoted and double-quoted values - Secrets containing spaces, commas, semicolons, slashes, and Unicode - Escaped quotes - Multiline credentials - Authorization-header variants - Near-match and partial-match cases 8. Apply the same corrected implementation and tests to both CLI and MCP pipelines to prevent divergent security behavior. ]]>
