Redaction bypasses secrets in interpolation defaults and mixed values
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 483
- Forks
- 97
- Avg merge
- 3d 7h
- Merged PRs (30d)
- 4
Description
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in docksec/redact.py at redact_content and _is_placeholder(), then trace how secret-key assignments are classified. Add regression coverage for Compose defaults, mixed interpolation and literal values, quoted pure placeholders, and command substitutions. Done means only a complete ${VARIABLE} reference bypasses masking while literal secret material is redacted.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- security
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 88/100