Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

mcf: `PasswordHash::push_base64` with empty input produces an invalid hash

Aperta
#2,471 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
45/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
rust
Ambito
cryptography

Direzione di ricerca

Start at mcf::PasswordHash::push_base64 and compare its empty-input behavior with push_str and push_displayable. Reproduce the empty-salt path described through pbkdf2 0.13, then determine which API behavior preserves valid MCF strings and add coverage showing that empty input cannot produce an unparsable PasswordHash.

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

Descrizione

mcf::PasswordHash is documented as a valid MCF string, and PasswordHashRef::new_unchecked relies on that. push_base64 is infallible, though, and with an empty slice it appends a bare $:

let mut h = mcf::PasswordHash::from_id("6").unwrap();
h.push_base64(b"", mcf::Base64::Crypt);
assert_eq!(h.as_str(), "$6$");
mcf::PasswordHash::new(h.as_str()); // Err(DelimiterInvalid)

h.push_str("tail").unwrap();      // "$6$$tail"
mcf::PasswordHash::new(h.as_str()); // Err(FieldInvalid)
h.fields().collect::<Vec<_>>();    // ["", "tail"]: an empty Field, which Field::new rejects

The other push methods already reject this: push_str("") and push_displayable("") return Err(FieldInvalid).

A real path to it: pbkdf2 0.13's MCF hasher calls push_base64(salt, ...). hash_password_customized with an empty salt then returns a PasswordHash that can't be stored and parsed back.

Possible fixes, which change the API differently, so I'm asking rather than sending a PR:

  1. Make push_base64 return Result<()> and reject empty input, like push_str (breaking).
  2. Add a fallible try_push_base64 and document that push_base64 requires non-empty input.
  3. Panic on empty input, so the invariant can't be broken silently.

Happy to send a PR for whichever you prefer.

This issue was produced by AI agents (Claude) and reviewed by me before submission.

Lingua principale
Rust
Stelle
341
Fork
193
Merge medio
1g 15h
PR unite (30g)
21

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 RustCrypto/formats

Tutte le issue di RustCrypto/formats

Issue simili

Altre issue su Rust

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.