Skip to content

Commit fe9651f

Browse files
committed
fix(sbi/processor): trim inline comments per #61 review
@roundspring2003 asked across PRs for terse one-liner inline comments and to move technical context to the commit message and PR body. Drop the multi-line RFC/threat-model notes inline and keep one-liners. Background: * RFC 5448 §3 fixes the EAP-AKA' packet layout: 5-byte EAP header, 1-byte Subtype, 2 reserved bytes, then attribute TLVs starting at offset 3 of the post-header slice. * A crafted NAS AuthenticationResponse carrying a 5-byte EAP payload (type field only) made eapPkt[5:] empty and data[0] panicked the AUSF (free5gc/free5gc#982). * Each attribute is a 2-byte header (type, length/4) followed by value bytes. Without the truncated-header check, data[i+1] ran off the end on a payload missing the second header byte (free5gc/free5gc#983). Signed-off-by: SAY-5 <SAY-5@users.noreply.github.com>
1 parent 452bec8 commit fe9651f

1 file changed

Lines changed: 2 additions & 8 deletions

File tree

internal/sbi/processor/ue_authentication.go

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -713,11 +713,7 @@ func decodeEapAkaPrime(eapPkt []byte) (*ausf_context.EapAkaPrimePkt, error) {
713713
var attrLen int
714714
var decodeAttr ausf_context.EapAkaPrimeAttribute
715715
attributes := make(map[uint8]ausf_context.EapAkaPrimeAttribute)
716-
// A well-formed EAP-AKA' packet has at least a 5-byte EAP header plus
717-
// a 1-byte Subtype plus 2 reserved bytes (RFC 5448 §3) before the
718-
// attribute TLVs begin at offset 3. A crafted NAS AuthenticationResponse
719-
// carrying a 5-byte EAP payload (type field only) made eapPkt[5:] an
720-
// empty slice and data[0] panicked (free5gc/free5gc#982).
716+
// Bounds-check the EAP header before slicing.
721717
if len(eapPkt) < 6 {
722718
return nil, fmt.Errorf("EAP-AKA' packet too short: got %d bytes, need at least 6", len(eapPkt))
723719
}
@@ -727,9 +723,7 @@ func decodeEapAkaPrime(eapPkt []byte) (*ausf_context.EapAkaPrimePkt, error) {
727723

728724
// decode attributes
729725
for i := 3; i < dataLen; i += attrLen {
730-
// Each attribute is a 2-byte header (type, length/4) followed by
731-
// value bytes. Reject truncated headers instead of letting
732-
// data[i+1] run off the end (free5gc/free5gc#983).
726+
// Bounds-check the 2-byte attribute header.
733727
if i+1 >= dataLen {
734728
return nil, fmt.Errorf("EAP-AKA' attribute header truncated at offset %d", i)
735729
}

0 commit comments

Comments
 (0)