Non-deterministic wildcard secret selection

Offen
#723 2 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

Dieses Issue hat noch niemand übernommen.

  • #724 von @locker95 — ohne Merge geschlossen

Bewertung

Schwierigkeit
2/5
Geschätzter Aufwand
1-3 Stunden
Anfängerfreundlichkeit
35/100
Issue-Typ
Bug
Klarheit
Klar beschrieben
Aktivitätsstatus
Veraltet
Tech-Stack
docker, go
Bereich
backend, security

Rechercherichtung

Read plugin.go and run.go around the “First match wins” handling, then compare how wildcard matches are selected with the sorting in testing.go. Reproduce the issue with the commands in the report; done means repeated runs consistently select the intended first match, with coverage that catches nondeterministic ordering.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

Wildcard secrets with 2+ matches randomly inject the wrong secret ~1 in 8 times.

The docs recommend a docker/db/<env>/password layout, and docker pass run --help uses se://*/password as the wildcard example and says the "first match is used".

Steps to reproduce:

docker pass set app/dev/pw=test
docker pass set app/prod/pw=qcXU9Yt7jWy0YV8FAAk1kDh89JPh4r3F

for i in $(seq 100); do docker run --rm -e DB_PASSWORD='se://app/*/pw' alpine printenv DB_PASSWORD; done
#   14 test
#   86 qcXU9Yt7jWy0YV8FAAk1kDh89JPh4r3F

Compose inherits this with --scale, or multiple deploy.replicas: with multiple environment::

cat > compose.yaml <<EOF
services:
  app:
    image: alpine
    command: printenv DB_PASSWORD
    environment:
      DB_PASSWORD: se://app/*/pw
EOF
docker compose up --scale app=100

I believe the cause is in plugin.go and run.go under a // For now: First match wins. The 1/8 split reminds me of Go's swiss-mapping on small sets, not a race condition.

Introduced by #666 (spooky!) which flagged this as a critical/high/security finding "non-deterministic secret selection"

Not caught by testing.go because it sorts the results.

Vorherrschende Sprache
Go
Sterne
97
Forks
23
Ø Merge
2 Std. 1 Min.
Gemergte PRs (30 T.)
33

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus docker/secrets-engine

Alle Issues in docker/secrets-engine

Ähnliche Issues

Weitere Issues zu Go

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.