PKCS#12 bundles written world-readable with a fixed, disclosed password

Aperta
#682 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
Mezza giornata
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
cryptography, go
Ambito
security

Direzione di ricerca

The file write and the hardcoded password both sit in cert.go: look at the pkcs12.Encode call and the ioutil.WriteFile call that uses mode 0644. Reproduce by running mkcert -pkcs12 in a directory and checking the resulting file's mode, then check how existing mkcert tests cover the PKCS#12 path. Done means the output file is not world-readable under a standard umask, and the password decision is documented or resolved by the maintainers.

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

Descrizione

Affected versions: confirmed on master HEAD, commit 1c1dc4ed27ed5936046b6398d39cab4d657a2d8e.

Summary

Running mkcert -pkcs12 <name> generates a certificate and private key, packages them into a PKCS#12 bundle encrypted with the literal, hardcoded password changeit, and writes the file with mode 0644. Under a standard 022/0002 umask this leaves the file world-readable. Since the decryption password is both constant and printed directly to the operator's terminal, file-permission confidentiality is the only actual protection on the embedded private key, and that protection is defeated by the mode the tool itself requests.

Details

cert.go:

domainCert, _ := x509.ParseCertificate(cert)
pfxData, err := pkcs12.Encode(rand.Reader, priv, domainCert, []*x509.Certificate{m.caCert}, "changeit")
fatalIfErr(err, "failed to generate PKCS#12")
...
err = ioutil.WriteFile(p12File, pfxData, 0644)
fatalIfErr(err, "failed to save PKCS#12")

ioutil.WriteFile requests mode 0644 regardless of whether the process umask would have allowed something tighter, and preserves an existing file's mode on overwrite. The password is not user-configurable and is announced to the operator every time mkcert runs, so any other local user who can read the file can decrypt it immediately.

Steps To Reproduce

(available upon request)

Impact

  • Any local user who can read a .p12 file produced by mkcert -pkcs12 (shared /tmp, a world-readable home directory, a CI artifact, a backup, a misconfigured shared host) can recover the certificate's private key with zero additional effort, using only publicly documented tooling and the password mkcert itself discloses.
  • Limited to the issued development certificate's key, not the CA root key.
  • Severity is tempered by -pkcs12 being opt-in and by the output needing to land in a directory traversable by another user, but neither of those preconditions is unusual in CI, shared dev boxes, or containers.
Lingua principale
Go
Stelle
59.8k
Fork
3.3k
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

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 FiloSottile/mkcert

Tutte le issue di FiloSottile/mkcert

Issue simili

Altre issue su Go

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.