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

Abierto
#682 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
Medio día
Aptitud para principiantes
35/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
cryptography, go
Área
security

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.
Lenguaje dominante
Go
Estrellas
59.8k
Forks
3.3k
Métricas de merge de PR
Sin PR fusionados en 30 d

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de FiloSottile/mkcert

Todos los issues de FiloSottile/mkcert

Issues similares

Más issues de Go

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.