T09 · Insecure Skill Coding Practices
- Location
sluice/detectors.py:110- Finding
Incomplete Private-Key Block Redaction Exposes Key Material
- Content
View full analysis
Vulnerability Details
File Location:
sluice/detectors.py:110-116
Vulnerability Type: Incomplete sensitive-data redaction
Risk Level: HighVulnerable Code
python Detector( "private_key_block", "high", re.compile( r"-----BEGIN (?:RSA |EC |DSA |OPENSSH |PGP )?PRIVATE KEY-----" ), "private-key-block", ),Redaction in
sluice/core.py:104-112replaces only the span returned by this detector:python out = [] cursor = 0 for f in findings: out.append(text[cursor:f.start]) out.append(template.format(label=f.label)) cursor = f.end out.append(text[cursor:]) return "".join(out)Technical Analysis
The private-key detector matches only the opening marker, such as:
text -----BEGIN OPENSSH PRIVATE KEY-----It does not include the encoded key body or the corresponding closing marker in the finding span. Because
redact()replaces exactly the matched span, output can retain nearly all sensitive key material:text [redacted:private-key-block] <encoded private-key body> -----END OPENSSH PRIVATE KEY-----Removing the opening marker does not cryptographically invalidate or protect the underlying key material. An observer can restore the standard header or otherwise parse the retained encoded data.
The existing detector test confirms only that the opening marker is detected. It does not verify that the complete key body is removed during redaction.
Attack Path
- An outbound draft or generated message contains a PEM, OpenSSH, or supported private-key block.
- An agent invokes
sluice redactas recommended before sending or publishing the content. - The detector reports a high-severity finding whose span covers only the opening marker.
- The redaction routine replaces that marker but preserves the key body and closing marker.
- The downstream publishing, email, chat, or queueing command send ...[truncated 860 chars]
- Remediation
View remediation
Remediation Suggestions
- Change the detector to match the complete private-key block, from the opening marker through the corresponding closing marker, including multiline key data.
- Ensure the opening and closing key types correspond rather than accepting unrelated terminators.
- Bound the multiline match to prevent excessive scanning and define explicit handling for malformed or unterminated blocks.
- Consider redacting from a recognized opening marker to the matching closing marker; for an unterminated block, conservatively redact through the end of the input.
- Add tests covering complete RSA, EC, DSA, OpenSSH, PGP, and generic private-key blocks.
- Add assertions that redacted output contains neither the encoded body nor either key marker.
- Add malformed and unterminated-block tests to prevent partial disclosure regressions.
- Retain the high severity and default blocking behavior for scan mode. Avoid treating detection of only a header as sufficient evidence that redaction is safe.
