Rekey SA binds a key that is not Active (no key-state check)

Aperta Adatta ai principianti
#562 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
65/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
c
Ambito
security

Direzione di ricerca

Leggi sa_rekey in src/sa/internal/sa_interface_inmemory.template.c e confronta la sua convalida delle chiavi con Crypto_Key_OTAR in src/core/crypto_key_mgmt.c. Verifica come il progetto testa gli errori di stato delle chiavi, quindi controlla che Rekey SA restituisca KEY_ID_ERROR per una chiave sconosciuta e KEY_STATE_INVALID per una chiave non in stato Active, accettando una chiave in stato Active.

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

Descrizione

bug
Description
Summary

CCSDS 355.1-B-1 sec. 3.3.3.3.2 requires the new key at Rekey SA to be in the Active state. On v1.5.1 (5b98c8b; v1.5.0 shares the code), sa_rekey stores the Encryption Key ID from the PDU without consulting the key's state, so it accepts a PreActivation key, a Deactivated key, or a key id that does not exist. A following Start SA then makes the SA Operational, but every frame fails at the transmit/receive path with KEY_STATE_INVALID (-61) because the bound key cannot be used: management reports SUCCESS while no traffic can flow.

The library already does the right check elsewhere: Crypto_Key_OTAR (src/core/crypto_key_mgmt.c:117-126) refuses non-Active keys, and the key directives themselves refuse wrong-state transitions (-59) and unknown ids (-47). sa_rekey simply lacks the equivalent guard.

Code site

sa_rekey, src/sa/internal/sa_interface_inmemory.template.c (ekid parse): stores ekid from the PDU with no key_if->get_key state check.

Impact

Conformance / robustness. An out-of-order EP flow can leave an SA reporting Operational while bound to an unusable key; management answers SUCCESS, data answers KEY_STATE_INVALID on every frame. No memory-safety issue.

Suggested fix

After parsing ekid, look the key up with key_if->get_key(ekid) and return KEY_ID_ERROR (-47) for an unknown id and KEY_STATE_INVALID (-61) for a non-Active key, exactly as Crypto_Key_OTAR does. Valid rekeys onto Active keys are unchanged. I have a compile-checked patch verified with a standalone C PoC and can open a PR or share the PoC on request.

Found with active automata learning (AutoSDLS) and confirmed with a standalone C PoC that uses none of that tooling.

Branch Name

No response

Reproduction steps
1. Build CryptoLib v1.5.1 (`5b98c8b`) with the in-memory SA interface.
2. Create an SA, and have a key whose state is not Active (PreActivation or Deactivated), or use a key id that does not exist.
3. Send a Rekey SA directive binding that key id to the SA.
4. Observe `sa_rekey` returns `CRYPTO_LIB_SUCCESS` and stores the ekid, with no key-state check.
5. Start the SA (it goes Operational), then send a frame: every frame fails with `KEY_STATE_INVALID` (-61), so management reports success while no traffic can flow.

A standalone C PoC reproducing this (independent of the discovery tooling) is available on request.
Screenshots
![DESCRIPTION](LINK.png)
Logs

OS

Linux

Lingua principale
C
Stelle
178
Fork
70
Merge medio
1h 32m
PR unite (30g)
1

Preparare l'ambiente

  • Nessun Dockerfile né file Docker Compose
  • Ha un modello di pull request
  • Nessuna guida per i contributori

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 nasa/CryptoLib

Tutte le issue di nasa/CryptoLib

Issue simili

Altre issue su C

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.