Skip to content

Commit d18e52e

Browse files
Lukas Sismisvictorjulien
Lukas Sismis
authored andcommitted
decode-udp: Allow shorter UDP packets than the remaining payload length
If the packet is shorter than IP payload length we no longer flag it as an invalid UDP packet. UDP packet can be therefore shorter than IP payload. Keyword "udp.hlen_invalid" became outdated as we no longer flag short UDP packets as invalid. Redmine ticket: OISF#5693
1 parent ba99241 commit d18e52e

File tree

3 files changed

+18
-6
lines changed

3 files changed

+18
-6
lines changed

rules/decoder-events.rules

-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ alert pkthdr any any -> any any (msg:"SURICATA TCP option invalid length"; decod
6767
alert pkthdr any any -> any any (msg:"SURICATA TCP duplicated option"; decode-event:tcp.opt_duplicate; classtype:protocol-command-decode; sid:2200037; rev:2;)
6868
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;)
6969
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;)
70-
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;)
7170
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;)
7271
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;)
7372
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;)

src/decode-udp.c

-5
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,6 @@ static int DecodeUDPPacket(ThreadVars *t, Packet *p, const uint8_t *pkt, uint16_
5656
return -1;
5757
}
5858

59-
if (unlikely(len != UDP_GET_LEN(p))) {
60-
ENGINE_SET_INVALID_EVENT(p, UDP_HLEN_INVALID);
61-
return -1;
62-
}
63-
6459
SET_UDP_SRC_PORT(p,&p->sp);
6560
SET_UDP_DST_PORT(p,&p->dp);
6661

src/detect-engine-event.c

+18
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,14 @@ static int DetectEngineEventMatch (DetectEngineThreadCtx *det_ctx,
110110
SCReturnInt(0);
111111
}
112112

113+
static bool OutdatedEvent(const char *raw)
114+
{
115+
if (strcmp(raw, "decoder.udp.hlen_invalid") == 0) {
116+
return true;
117+
}
118+
return false;
119+
}
120+
113121
/**
114122
* \brief This function is used to parse decoder events options passed via decode-event: keyword
115123
*
@@ -161,6 +169,16 @@ static DetectEngineEventData *DetectEngineEventParse (const char *rawstr)
161169
if (de->event == STREAM_REASSEMBLY_OVERLAP_DIFFERENT_DATA) {
162170
StreamTcpReassembleConfigEnableOverlapCheck();
163171
}
172+
173+
if (OutdatedEvent(rawstr)) {
174+
if (SigMatchStrictEnabled(DETECT_DECODE_EVENT)) {
175+
SCLogError("decode-event keyword no longer supports event \"%s\"", rawstr);
176+
goto error;
177+
} else {
178+
SCLogWarning("decode-event keyword no longer supports event \"%s\"", rawstr);
179+
}
180+
}
181+
164182
return de;
165183

166184
error:

0 commit comments

Comments
 (0)