Skip to content

Redaction misses passwords in connection-string URLs (DATABASE_URL, REDIS_URL, ...) #168

Closed

Description

@MRX-72

Summary

The redaction pass (docksec/redact.py) that masks secrets before file content is sent to the LLM does not mask passwords embedded in connection-string URLs (scheme://user:password@host). Because keys like DATABASE_URL, REDIS_URL, MONGO_URI, AMQP_URL, and SMTP_URL do not match the secret-key list, and the password inside the URL matches none of the value-shaped patterns, the password is sent to the configured LLM provider in clear text.

URLs with embedded credentials are one of the most common ways secrets appear in Dockerfiles and compose files, so this is a meaningful leak for a tool whose stated purpose is to keep those secrets from leaving the machine.

Steps to reproduce

from docksec.redact import redact_content

print(redact_content("ENV DATABASE_URL=postgres://admin:s3cr3tPass@db:5432/app"))

Expected behavior

The password is masked, e.g. postgres://admin:[REDACTED-BY-DOCKSEC]@db:5432/app, so it never reaches the LLM. The scheme, user, and host can stay visible so the model can still flag that a credential is present.

Actual behavior

('ENV DATABASE_URL=postgres://admin:s3cr3tPass@db:5432/app', 0)

The value is returned unchanged with a redaction count of 0. The password s3cr3tPass would be sent to the provider. Same result for redis://:pw@, mongodb://root:pw@, amqp://user:pw@, and smtp://user:pw@.

Environment

  • OS: macOS 26.3
  • Python: 3.14
  • DockSec: current main

I have a fix and tests ready and would like to be assigned.

Activity

  1. added a commit that references this issue on Sep 15, 2026
    718c56a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions