Redaction bypasses secrets in interpolation defaults and mixed values

Open Beginner friendly
#170 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
88/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
python
Domain
security

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.

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.

Dominant language
Python
Stars
483
Forks
97
Avg merge
3d 7h
Merged PRs (30d)
4

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from OWASP/DockSec

All issues in OWASP/DockSec

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.