Image pull ignores X-Registry-Auth when the JSON has null fields, so Testcontainers (docker-java) pulls from private registries get 401

Aperta
#654 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
Mezza giornata
Idoneità per principianti
70/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
docker, rust

Direzione di ricerca

Start where the POST /images/create handler reads X-Registry-Auth and the AuthConfig struct that decodes it; the current code drops the whole header when any JSON field is null. Reproduce with the curl command in the issue, and compare a body with identitytoken: "" against one with null. Treat null/missing fields as empty values, pass the username/password through to the registry token request, and add a test for the docker-java-shaped payload so a successful pull returns a digest.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Kiri version and system

0.2.2 on macOS 26.7.3 (Apple silicon)

What you did

Ran a Testcontainers (Java, docker-java) suite whose images come from a private registry that needs a login. Testcontainers gets the credentials from DOCKER_AUTH_CONFIG / the osxkeychain helper, and docker-java sends them on POST /images/create as X-Registry-Auth. docker-java always serialises the full AuthConfig, so the fields it doesn't use are JSON null:

{"username":"me","password":"…","serveraddress":"registry.example.com",
 "identitytoken":null,"registrytoken":null,"email":null,"stackOrchestrator":null}

The same thing reproduced with curl against Kiri's socket:

auth=$(printf '{"username":"%s","password":"%s","serveraddress":"registry.example.com","identitytoken":null,"email":null}' "$REG_USER" "$REG_PASS" | base64 | tr '+/' '-_' | tr -d '=\n')
curl -s --unix-socket ~/.kiri/run/docker.sock -H "X-Registry-Auth: $auth" \
  -X POST 'http://localhost/v1.47/images/create?fromImage=registry.example.com/private/image&tag=1.0'
What happened
… docker login registry.example.com (https://registry.example.com/…/v2/token returned HTTP 401: unauthorized: incorrect username or password)"}}

The registry sees the pull as anonymous. Sending the same JSON with "identitytoken":"","email":"" instead of null pulls the image:

{"status":"Digest: sha256:…"}
{"status":"Status: Downloaded newer image for registry.example.com/private/image:1.0"}

Leaving the null fields out also works, and so does docker pull with the CLI, because the CLI omits empty fields.

What you expected instead

Docker Engine treats a null field as empty and uses the username/password, so the same request pulls the image on Docker Desktop and Rancher Desktop (dockerd). Kiri should decode null the same way rather than dropping the whole header.

Anything else

Happens every time, with any null field in the header. It breaks every Testcontainers-for-Java pull from a private registry on Kiri (images already in Kiri are fine, because Testcontainers skips the pull).

Workaround: pre-pull the images with the docker CLI (docker pull registry.example.com/…) before running the tests.

Lingua principale
Rust
Stelle
7.5k
Fork
329
Merge medio
14h 18m
PR unite (30g)
204

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di libracoder/kiri

Tutte le issue di libracoder/kiri

Issue simili

Altre issue su Rust

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.