BFD should implement receive validation and discriminator checks

Aperta
#860 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à
Tranquilla
Stack tecnologico
rust
Ambito
networking

Direzione di ricerca

Inizia da bfd::packet::Control::from_bytes() e segui il percorso di ricezione fino alla macchina a stati; esamina i test di sessione che usano Control::default() come traffico di handshake. Usa RFC 5880 §6.8.6 per definire l’ordine di convalida richiesto. Il lavoro è completato quando ogni pacchetto malformato elencato viene rifiutato, i fixture validi usano discriminators diversi da zero e i pacchetti rifiutati non modificano timer, contatori, parametri remoti o lo stato della sessione.

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

Descrizione

bfd Bug mgd needs testing rust

The following is an issue identified by AI when I asked it to do an adversarial code review of #795. This was pre-existing in the sync/pthread impl, which is why it was not addressed as part of the async swap-out.

Problem

bfd::packet::Control::from_bytes() currently validates only that:

  • the UDP payload contains at least 24 bytes; and
  • Detect Mult is nonzero.

The receive path accepts packets that RFC 5880 §6.8.6 requires us to
discard, including packets with:

  • a version other than 1;
  • a Length field smaller than the mandatory header;
  • a Length field larger than the UDP payload;
  • a zero My Discriminator;
  • an unmatched Your Discriminator;
  • the Multipoint bit set;
  • the Authentication bit set despite authentication not being in use;
  • both Poll and Final set.

After parsing, packets are initially selected by source IP and passed to
the state machine. The state machine updates remote parameters, resets
the receive deadline, and may transition state before any
session-dependent discriminator validation occurs.

Impact

A malformed or stale packet from the configured source IP can:

  • bring a Down session Up;
  • force an Up session Down;
  • indefinitely refresh the receive deadline;
  • replace the learned remote discriminator;
  • change transmission behavior through forged timer or Demand fields.

The unit tests currently reinforce part of this behavior:
Control::default() has my_discriminator = 0, and session tests use
such packets as normal handshake traffic.

Required behavior

Implement the ordered validation from RFC 5880 §6.8.6.

Structural checks should include:

  • Version == 1;
  • valid advertised Length relative to authentication and UDP payload;
  • Detect Mult != 0;
  • Multipoint == 0;
  • Poll and Final are not both set;
  • reject Authentication-present packets while authentication is not
    configured/supported.

Session-dependent checks should include:

  • My Discriminator != 0;
  • nonzero Your Discriminator selects or matches the local session;
  • zero Your Discriminator is accepted only for Down or AdminDown initial
    packets;
  • invalid packets must not update timers, remote parameters, counters
    that represent accepted packets, or session state.

Receive-side TTL/Hop-Limit validation for single-hop sessions is tracked
separately in #656.

Testing

  • Replace zero-discriminator handshake fixtures with valid packets.
  • Add one rejection test for each RFC validation rule.
  • Verify discarded packets do not reset the detection deadline.
  • Verify an incorrect nonzero Your Discriminator cannot alter session
    state.
  • Verify a zero Your Discriminator with Init or Up is discarded.

References

  • RFC 5880 §6.3: discriminator-based demultiplexing
  • RFC 5880 §6.5: Poll Sequence
  • RFC 5880 §6.8.6: reception of BFD Control packets
  • #656: single-hop TTL/Hop-Limit validation
Lingua principale
Rust
Stelle
100
Fork
8
Merge medio
2g 1h
PR unite (30g)
18

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 oxidecomputer/maghemite

Tutte le issue di oxidecomputer/maghemite

Issue simili

Altre issue su Rust

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.