Skip to content

Commit ca7383f

Browse files
ivgfujita
authored andcommitted
pkg/packet/bgp: fix flowspec parser to check the input length
case EC_SUBTYPE_FLOWSPEC_REDIRECT_IP6: ipv6 := net.IP(data[2:18]).String() localAdmin := binary.BigEndian.Uint16(data[18:20]) return NewRedirectIPv6AddressSpecificExtended(ipv6, localAdmin), nil Note that the `data` length is only checked for being at least 8 bytes, so any message with the given subtype but less than 20 bytes will crash the application.
1 parent 5693c58 commit ca7383f

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

Diff for: pkg/packet/bgp/bgp.go

+4
Original file line numberDiff line numberDiff line change
@@ -12708,6 +12708,10 @@ func parseGenericTransitiveExperimentalExtended(data []byte) (ExtendedCommunityI
1270812708
dscp := data[7]
1270912709
return NewTrafficRemarkExtended(dscp), nil
1271012710
case EC_SUBTYPE_FLOWSPEC_REDIRECT_IP6:
12711+
if len(data) < 20 {
12712+
return nil, NewMessageError(BGP_ERROR_UPDATE_MESSAGE_ERROR, BGP_ERROR_SUB_MALFORMED_ATTRIBUTE_LIST, nil, "not all extended community bytes for IPv6 FlowSpec are available")
12713+
}
12714+
1271112715
ipv6 := net.IP(data[2:18]).String()
1271212716
localAdmin := binary.BigEndian.Uint16(data[18:20])
1271312717
return NewRedirectIPv6AddressSpecificExtended(ipv6, localAdmin), nil

0 commit comments

Comments
 (0)