🐛 [BUG] - Implementation Standard - Unrecognized SA-Management PID Silently Returns Success

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

@Sushanth012 ci sta già lavorando.

Dal 26/8/2026.

  • #538 di @Sushanth012 — aperta

Valutazione

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

Direzione di ricerca

Inizia in src/core/crypto.c, in Crypto_SG_SA_MGMT, intorno alle righe 629–700 e segui il PID switch. Poi riproduci il frame fornito pid=0x8 per confermare lo stato di successo attuale. Aggiorna il percorso per i PID non riconosciuti in modo che restituisca un errore e verifica che la diagnostica rimanga corretta e che la riproduzione non riporti più lo stato 0. Controlla i dispatcher di service-group adiacenti solo se il tempo lo consente.

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

Descrizione

bug
Description

Bug Report: Unrecognized SA-Management PID Silently Returns Success

Summary

Field Value
Product NASA CryptoLib (SDLS Protocol Implementation)
Version 1.4.2
Component src/core/crypto.c — Crypto_SG_SA_MGMT
Issue The SA-management command dispatcher's default: case for an unrecognized Procedure Identification Field (PID) never sets an error status, so the function returns CRYPTO_LIB_SUCCESS from its initialized value
Bug Type Conformance
Severity Low-Medium
Impact A malformed or unsupported SA-management command is silently accepted rather than rejected — a ground segment sending a PID CryptoLib doesn't implement gets no indication the command was not processed

Description

Crypto_SG_SA_MGMT dispatches an incoming SA-management command by its pid field to one of
the PID_CREATE_SA/PID_SA_STATUS/etc. handlers. status is initialized to
CRYPTO_LIB_SUCCESS at function entry. The switch's default: case, reached for any pid
value outside the defined set, prints a debug diagnostic and breaks — it never assigns
status anything else — so the function returns success for a PDU it explicitly could not
interpret.

Affected Code

Crypto_SG_SA_MGMT (src/core/crypto.c:629-700)
int32_t Crypto_SG_SA_MGMT(uint8_t *ingest, TC_t *tc_frame)
{
    int status = CRYPTO_LIB_SUCCESS;
    switch (sdls_frame.tlv_pdu.hdr.pid)
    {
        case PID_CREATE_SA:
            status = sa_if->sa_create(tc_frame);
            break;
        // ... PID_DELETE_SA, PID_SETARSNW, PID_REKEY_SA, PID_EXPIRE_SA,
        //     PID_SETARSN, PID_START_SA, PID_STOP_SA, PID_READ_ARSN, PID_SA_STATUS ...
        default:
#ifdef PDU_DEBUG
            printf(KRED "Error: Crypto_PDU failed interpreting SA Procedure Identification Field! \n" RESET);
#endif
            break;   // status never set — still CRYPTO_LIB_SUCCESS from initialization
    }
    return status;
}

Reproduction Sequence (from the fuzzing logs)

Replaying the full multi-packet mismatch pcap (crypto_triage, -DDEBUG=ON); only the final
frame is needed to trigger the bug (the dispatch is stateless with respect to pid — earlier
frames just exercise other unrelated SA-management commands in the same fuzzer-generated
sequence):

# Direction Hex Meaning
8 ground → flight 002c100c0000000098cf70e150 TC frame, sg=0x1, pid=0x8 — not one of the defined PID_* values for the SA-management service group

Debug replay of that frame:

TLV PDU
	 sg         = 0x1
	 pid        = 0x8
	 pdu_len    = 0xcf70
	 data[0]    = 0x00

Error: Crypto_PDU failed interpreting SA Procedure Identification Field!
Status code: 0

CryptoLib prints its own diagnostic confirming it could not interpret the PID, then returns
Status code: 0 (success) anyway.

Suggested Fix

Assign a real error code in the default: branch instead of leaving status at its initialized
success value:

default:
#ifdef PDU_DEBUG
    printf(KRED "Error: Crypto_PDU failed interpreting SA Procedure Identification Field! \n" RESET);
#endif
    status = CRYPTO_LIB_ERROR;  // or a more specific "unrecognized PID" code
    break;

Worth checking whether the sibling dispatch functions for the other service groups (Key
Management, Monitoring & Control) have the same default:-falls-through-to-success shape, since
this looks like a copy-pasted dispatch pattern rather than something unique to SA management.


Discovered using the StratoFuzz protocol fuzzing framework.

Branch Name

dev

Reproduction steps
## Reproduction Sequence (from the fuzzing logs)

Replaying the full multi-packet mismatch pcap (`crypto_triage`, `-DDEBUG=ON`); only the final
frame is needed to trigger the bug (the dispatch is stateless with respect to `pid` — earlier
frames just exercise other unrelated SA-management commands in the same fuzzer-generated
sequence):

| # | Direction | Hex | Meaning |
|---|-----------|-----|---------|
| 8 | ground → flight | `002c100c0000000098cf70e150` | TC frame, `sg=0x1, pid=0x8` — not one of the defined `PID_*` values for the SA-management service group |

Debug replay of that frame:


TLV PDU
	 sg         = 0x1
	 pid        = 0x8
	 pdu_len    = 0xcf70
	 data[0]    = 0x00

Error: Crypto_PDU failed interpreting SA Procedure Identification Field!
Status code: 0


CryptoLib prints its own diagnostic confirming it could not interpret the PID, then returns
`Status code: 0` (success) anyway.
Screenshots

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.