Skip to content

Commit e4c7db8

Browse files
committed
fix(sbi/processor): bounds-check decodeEapAkaPrime before slice/index access
Closes free5gc/free5gc#1030. Short eapPayload bytes panicked the AUSF /eap-session callback. Signed-off-by: SAY-5 <say.apm35@gmail.com>
1 parent cf2aba6 commit e4c7db8

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

internal/sbi/processor/ue_authentication.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -724,12 +724,18 @@ func decodeEapAkaPrime(eapPkt []byte) (*ausf_context.EapAkaPrimePkt, error) {
724724
var attrLen int
725725
var decodeAttr ausf_context.EapAkaPrimeAttribute
726726
attributes := make(map[uint8]ausf_context.EapAkaPrimeAttribute)
727+
if len(eapPkt) < 6 {
728+
return nil, fmt.Errorf("EAP-AKA' packet too short: %d bytes", len(eapPkt))
729+
}
727730
data := eapPkt[5:]
728731
decodePkt.Subtype = data[0]
729732
dataLen := len(data)
730733

731734
// decode attributes
732735
for i := 3; i < dataLen; i += attrLen {
736+
if i+1 >= dataLen {
737+
return nil, fmt.Errorf("EAP-AKA' attribute header truncated at offset %d", i)
738+
}
733739
attrType := data[i]
734740
attrLen = int(data[i+1]) * 4
735741
if attrLen == 0 {

0 commit comments

Comments
 (0)