Summary
DockSec's pre-LLM redaction treats every secret-key value that starts with ${ or $( as a safe placeholder. As a result, literal secret material in a Compose default value or after an interpolation is left unchanged and can be sent to the configured LLM provider.
Reproduction
from docksec.redact import redact_content
redact_content("ENV DB_PASSWORD=${DB_PASSWORD:-hunter2}\n")
# ('ENV DB_PASSWORD=${DB_PASSWORD:-hunter2}\n', 0)
redact_content("ENV DB_PASSWORD=${USER}:hunter2\n")
# ('ENV DB_PASSWORD=${USER}:hunter2\n', 0)
Both values contain literal secret material but are returned unchanged.
Cause
_is_placeholder() uses str.startswith() after stripping quotes. This identifies mixed values and Compose parameter-expansion defaults as placeholders even though they are not pure environment-variable references.
Expected behavior
Only a complete variable reference such as ${DB_PASSWORD} should bypass redaction. Secret-key assignments containing default values, suffixes, or command substitutions should be masked before the content leaves the machine.
Suggested fix
Use a full match for a pure ${VARIABLE} reference and add regression coverage for Compose defaults, mixed interpolation/literal values, quoted placeholders, and command substitutions.
Summary
DockSec's pre-LLM redaction treats every secret-key value that starts with
${or$(as a safe placeholder. As a result, literal secret material in a Compose default value or after an interpolation is left unchanged and can be sent to the configured LLM provider.Reproduction
Both values contain literal secret material but are returned unchanged.
Cause
_is_placeholder()usesstr.startswith()after stripping quotes. This identifies mixed values and Compose parameter-expansion defaults as placeholders even though they are not pure environment-variable references.Expected behavior
Only a complete variable reference such as
${DB_PASSWORD}should bypass redaction. Secret-key assignments containing default values, suffixes, or command substitutions should be masked before the content leaves the machine.Suggested fix
Use a full match for a pure
${VARIABLE}reference and add regression coverage for Compose defaults, mixed interpolation/literal values, quoted placeholders, and command substitutions.