diff options
| author | Dirk Engling <erdgeist@erdgeist.org> | 2026-11-28 21:05:13 +0100 |
|---|---|---|
| committer | Dirk Engling <erdgeist@erdgeist.org> | 2026-11-28 21:05:13 +0100 |
| commit | 70485a0ecf6b1ae9520deb4af0490fdb48643836 (patch) | |
| tree | 53585c4881a8e55fc993d06482b1e328481bad2b /src | |
| parent | 1853a6c5bdc8acb0ebef904e7c6cbf101cbe7eea (diff) | |
Prevent amplification attacks, only send id mis-match errors for sensible packets lengths
Diffstat (limited to 'src')
| -rw-r--r-- | src/ot_udp.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/ot_udp.c b/src/ot_udp.c index 7a05b61..609089b 100644 --- a/src/ot_udp.c +++ b/src/ot_udp.c | |||
| @@ -161,8 +161,13 @@ int handle_udp6(int64_t serversocket, struct ot_workstruct *ws) { | |||
| 161 | match, return an error packet */ | 161 | match, return an error packet */ |
| 162 | udp_make_connectionid(connid, remoteip, 1); | 162 | udp_make_connectionid(connid, remoteip, 1); |
| 163 | if (memcmp(request + UDP_REQUEST_CONNECTION_ID_OFFSET, connid, sizeof(connid))) { | 163 | if (memcmp(request + UDP_REQUEST_CONNECTION_ID_OFFSET, connid, sizeof(connid))) { |
| 164 | udp_send_error(serversocket, ws, "Connection ID missmatch.", remoteip, remoteport); | 164 | static const char err_idmiss[] = "Connection ID missmatch."; |
| 165 | stats_issue_event(ws, EVENT_CONNID_MISSMATCH, FLAG_UDP, ws->reply_size); | 165 | |
| 166 | /* Nobody has vouched for this address yet, so it is not sent more | ||
| 167 | than was sent in its name */ | ||
| 168 | if (byte_count >= UDP_REPLY_HEADER_SIZE + sizeof(err_idmiss)) | ||
| 169 | udp_send_error(serversocket, ws, err_idmiss, remoteip, remoteport); | ||
| 170 | stats_issue_event(ws, EVENT_CONNID_MISSMATCH, FLAG_UDP, byte_count); | ||
| 166 | return 1; | 171 | return 1; |
| 167 | } | 172 | } |
| 168 | } | 173 | } |
