ax(ueps): guard tagValue index access against zero-length TLV values
A malformed frame with length 0 for any single-byte tag (TagVersion, TagCurrentLayer, TagTargetLayer, TagIntent) or fewer than 2 bytes for TagThreatScore caused a runtime panic (index out of range) on untrusted input. Added len(tagValue) bounds checks in ReadAndVerify before each tagValue[0] and Uint16 access to eliminate the panic path. Co-Authored-By: Charon <charon@lethean.io>
This commit is contained in:
parent
bac107b377
commit
3ef84c6166
1 changed files with 15 additions and 5 deletions
|
|
@ -61,15 +61,25 @@ func ReadAndVerify(reader *bufio.Reader, sharedSecret []byte) (*ParsedPacket, er
|
|||
|
||||
switch tagType {
|
||||
case TagVersion:
|
||||
packetHeader.Version = tagValue[0]
|
||||
if len(tagValue) >= 1 {
|
||||
packetHeader.Version = tagValue[0]
|
||||
}
|
||||
case TagCurrentLayer:
|
||||
packetHeader.CurrentLayer = tagValue[0]
|
||||
if len(tagValue) >= 1 {
|
||||
packetHeader.CurrentLayer = tagValue[0]
|
||||
}
|
||||
case TagTargetLayer:
|
||||
packetHeader.TargetLayer = tagValue[0]
|
||||
if len(tagValue) >= 1 {
|
||||
packetHeader.TargetLayer = tagValue[0]
|
||||
}
|
||||
case TagIntent:
|
||||
packetHeader.IntentID = tagValue[0]
|
||||
if len(tagValue) >= 1 {
|
||||
packetHeader.IntentID = tagValue[0]
|
||||
}
|
||||
case TagThreatScore:
|
||||
packetHeader.ThreatScore = binary.BigEndian.Uint16(tagValue)
|
||||
if len(tagValue) >= 2 {
|
||||
packetHeader.ThreatScore = binary.BigEndian.Uint16(tagValue)
|
||||
}
|
||||
case TagHMAC:
|
||||
hmacSignature = tagValue
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue