Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pr 8341 and payload len fix/v3 #8404

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions etc/schema.json
Expand Up @@ -4710,6 +4710,9 @@
},
"pkt_too_small": {
"type": "integer"
},
"len_invalid": {
"type": "integer"
}
},
"additionalProperties": false
Expand Down
1 change: 1 addition & 0 deletions rules/decoder-events.rules
Expand Up @@ -68,6 +68,7 @@ alert pkthdr any any -> any any (msg:"SURICATA TCP duplicated option"; decode-ev
alert pkthdr any any -> any any (msg:"SURICATA UDP packet too small"; decode-event:udp.pkt_too_small; classtype:protocol-command-decode; sid:2200038; rev:2;)
alert pkthdr any any -> any any (msg:"SURICATA UDP header length too small"; decode-event:udp.hlen_too_small; classtype:protocol-command-decode; sid:2200039; rev:2;)
alert pkthdr any any -> any any (msg:"SURICATA UDP invalid header length"; decode-event:udp.hlen_invalid; classtype:protocol-command-decode; sid:2200040; rev:2;)
alert pkthdr any any -> any any (msg:"SURICATA UDP invalid length field in the header"; decode-event:udp.len_invalid; classtype:protocol-command-decode; sid:2200220; rev:2;)
alert pkthdr any any -> any any (msg:"SURICATA SLL packet too small"; decode-event:sll.pkt_too_small; classtype:protocol-command-decode; sid:2200041; rev:2;)
alert pkthdr any any -> any any (msg:"SURICATA Ethernet packet too small"; decode-event:ethernet.pkt_too_small; classtype:protocol-command-decode; sid:2200042; rev:2;)
alert pkthdr any any -> any any (msg:"SURICATA PPP packet too small"; decode-event:ppp.pkt_too_small; classtype:protocol-command-decode; sid:2200043; rev:2;)
Expand Down
4 changes: 4 additions & 0 deletions src/decode-events.c
Expand Up @@ -270,6 +270,10 @@ const struct DecodeEvents_ DEvents[] = {
"decoder.udp.hlen_invalid",
UDP_HLEN_INVALID,
},
{
"decoder.udp.len_invalid",
UDP_LEN_INVALID,
},

/* SLL EVENTS */
{
Expand Down
1 change: 1 addition & 0 deletions src/decode-events.h
Expand Up @@ -103,6 +103,7 @@ enum {
UDP_PKT_TOO_SMALL, /**< udp packet smaller than minimum size */
UDP_HLEN_TOO_SMALL, /**< udp header smaller than minimum size */
UDP_HLEN_INVALID, /**< invalid len of upd header */
UDP_LEN_INVALID, /**< packet len in header is invalid */

/* SLL EVENTS */
SLL_PKT_TOO_SMALL, /**< sll packet smaller than minimum size */
Expand Down
6 changes: 3 additions & 3 deletions src/decode-udp.c
Expand Up @@ -56,16 +56,16 @@ static int DecodeUDPPacket(ThreadVars *t, Packet *p, const uint8_t *pkt, uint16_
return -1;
}

if (unlikely(len != UDP_GET_LEN(p))) {
ENGINE_SET_INVALID_EVENT(p, UDP_HLEN_INVALID);
if (unlikely(UDP_GET_LEN(p) < UDP_HEADER_LEN)) {
ENGINE_SET_INVALID_EVENT(p, UDP_LEN_INVALID);
return -1;
}

SET_UDP_SRC_PORT(p,&p->sp);
SET_UDP_DST_PORT(p,&p->dp);

p->payload = (uint8_t *)pkt + UDP_HEADER_LEN;
p->payload_len = len - UDP_HEADER_LEN;
p->payload_len = UDP_GET_LEN(p) - UDP_HEADER_LEN;

p->proto = IPPROTO_UDP;

Expand Down
3 changes: 3 additions & 0 deletions src/detect-engine-event.c
Expand Up @@ -160,6 +160,9 @@ static DetectEngineEventData *DetectEngineEventParse (const char *rawstr)

if (de->event == STREAM_REASSEMBLY_OVERLAP_DIFFERENT_DATA) {
StreamTcpReassembleConfigEnableOverlapCheck();
} else if (de->event == UDP_HLEN_INVALID) {
SCLogWarning("Rule uses decode-event \"udp.hlen_invalid\" which will be deprecated in "
"Suricata 8.0");
}
return de;

Expand Down