Commit graph

4573 commits

Author SHA1 Message Date
Vitaly Lavrov
30a757801e Fix after merge 2026-11-20 14:45:29 +03:00
Vitaly Lavrov
f84512cd2a Merge commit '6d2476c31b' into flow_info-4 2026-11-20 12:56:46 +03:00
Vitaly Lavrov
842798e990 Merge commit '6a85dd290a' into flow_info-4 2026-11-20 12:48:58 +03:00
Vitaly Lavrov
ad0f93c339 Merge commit 'b6bddaf79b' into flow_info-4 2026-11-20 12:44:45 +03:00
Vitaly Lavrov
a0b3a6fbee Merge commit '6b38c1c258' into flow_info-4 2026-11-20 12:42:41 +03:00
Vitaly Lavrov
4d3cb23dc8 Merge commit 'b17e3ae776' into flow_info-4 2026-11-20 12:36:39 +03:00
Vitaly Lavrov
a6f5031574 Merge commit 'ca9d819151' into flow_info-4 2026-11-20 12:35:21 +03:00
Vitaly Lavrov
c2b9a0f952 Merge commit 'd015ae84de' into flow_info-4 2026-11-20 12:33:01 +03:00
Vitaly Lavrov
20fb399023 Merge commit 'cdad1fce08' into flow_info-4 2026-11-20 12:31:37 +03:00
Vitaly Lavrov
b47b075978 Merge commit 'e5f8ec9541' into flow_info-4 2026-11-20 12:25:59 +03:00
Vitaly Lavrov
4e45ade429 Small changes.
Changed implementation for risks 28 (Malicious Fingerprint)
and 29 (Malicious SSL Cert/SHA1 Fingerprint).
Use files /proc/net/xt_ndpi/hash_{ja4,sha1}

Changed option ndpi_flow_opt.

Read INSTALL.
2026-11-18 15:35:13 +03:00
Ivan Nardi
6d2476c31b DNS: fixes 2026-11-16 09:35:23 +01:00
Ivan Nardi
bb583c6dc9 HTTP: improve detection of Connectivity-Checks flows 2026-11-15 17:36:06 +01:00
Luca
f267cef424 Improved DNS dissection 2026-11-15 07:20:07 +01:00
John Earle
614f59a932
Merge commit from fork
* Kerberos: clamp the reply prefix copy to the buffer size (GHSA-3pvq-vj37-hfqg)

The reply-buffering branch of krb_process_packet() allocated
ndpi_min(kerberos_len, KRB_MAX_BUF_LEN)+4 bytes for pktbuf but then copied
payload_len+4 bytes into it. When 12000 < payload_len < kerberos_len <
1048576 the copy exceeds the clamped buffer, overflowing the heap with
attacker-controlled data (reachable via a Kerberos-classified TCP flow and a
crafted >12KB single-segment reply). pktbuf_currlen is u_int16_t, so the
unclamped payload_len+4 was also truncated on store.

Clamp both the copy length and pktbuf_currlen to pktbuf_maxlen, keeping only
the prefix the buffer can hold -- which is sufficient for the incremental
KRB_PARSE_PREFIX parsing performed just above. Verified under AddressSanitizer:
the PoC that previously overflowed now runs clean, and normal Kerberos traffic
still classifies.

* Kerberos: add a test for the reply prefix overflow (GHSA-3pvq-vj37-hfqg)

A TGS-REP whose padata keeps the client name out of a single 15000-byte
segment: the reply is buffered in a 12004-byte buffer. Without the fix,
AddressSanitizer reports a heap-buffer-overflow (WRITE of size 15004) in
krb_process_packet().
2026-11-13 18:21:19 +01:00
Ivan Nardi
4421ae2cc9
Fix CI failures (#3327)
* Update WebattackRCE.pcap.out to the new "Known Proto on Non Std
  Port" risk description
* Windows: add missing MAX_NUM_TLS_MONITORED_BLOCKS define
* Mingw: avoid %zu in printf formats; with GCC 13 and mingw-w64 13
  headers (Ubuntu 26.04) it is rejected by -Wformat
* Python: switch from 3.9 (not available on Ubuntu 26.04) to 3.14
  and explicitly install setuptools
2026-11-13 17:38:19 +01:00
Alfredo Cardigliano
9f8e80ebf9
Extend Known Proto on Non Std Port description to include both ports (and proto) (#3326) 2026-11-13 16:27:27 +01:00
Ivan Nardi
15a686dbfa
HTTP: handle Byte Order Marks when checking for suspicious content (#3325)
Text bodies starting with a UTF-8 BOM (EF BB BF) were flagged as
NDPI_HTTP_SUSPICIOUS_CONTENT, since the check accepts only ASCII bytes.
Skip the UTF-8 BOM and check the text after it.

UTF-16 text can't be validated with an ASCII check: if the body starts
with a UTF-16 (LE/BE) BOM, consider it as acceptable.
2026-11-12 20:03:07 +01:00
Ivan Nardi
db103fd80c TLS: extend list of non-suspicious extensions 2026-11-12 18:34:41 +01:00
Luca Deri
5d9724ca04 HTTP subprotocols are not set only in case HTTP returns a positive response.
This is to avoid that probing attempts create invalid protocol detection
2026-11-12 12:47:04 +01:00
Ivan Nardi
51ca71649c
HTTP: skip chunk-size line when checking for suspicious content (#3323)
With "Transfer-Encoding: chunked", the body starts with the chunk-size
line, so the human-readable content check was inspecting "<hex>\r\n"
instead of the actual payload. This reported wrong bytes in the risk
info (e.g. "610D0A1F"), missed non-printable data when the chunk size
had 2+ digits, and flagged valid gzip-compressed chunked bodies.

For chunked responses, skip the chunk-size line (and any extension)
before running the check.
2026-11-12 12:35:10 +01:00
Ivan Nardi
64b1ad9e6c
utests: fix TLS blocks initializers, stale malware domain and TLS results (#3324)
TLS: remove leftover debug printf in handleTLSBlockStat().
2026-11-12 12:34:46 +01:00
Raja Muhammad Awais
0bff3aa1ae
SSH: fix obsolete cipher detection and KEX metadata reuse (#3319)
Co-authored-by: RajaMuhammadAwais <1.19938988e+08+RajaMuhammadAwais@users.noreply.github.com>
2026-11-12 09:13:33 +01:00
Luca Deri
2ed880c637 Implemented TLS block export in monitoring mode 2026-11-11 07:44:04 +01:00
Ivan Nardi
0bcc7e82e6
PROFINET/IO: improve detection over DCERPC (#3322)
* Move PROFINET/IO detection into the DCERPC dissector: match the
  PROFINET/IO interface UUIDs (Device, Controller, Supervisor,
  ParameterServer) and the full object UUID prefix, and recognize the
  Endpoint Mapper lookups for PROFINET/IO interfaces. Remove the
  standalone PROFINET/IO dissector,
* After a generic EPM classification, look for PROFINET/IO calls in the
  next packets of the flow
* Add UDP 34964 as PROFINET/IO default port and don't trigger the
  `NDPI_KNOWN_PROTOCOL_ON_NON_STANDARD_PORT` flow risk for PROFINET/IO:
  responses and following calls use dynamic ports
* Fix the byte order check of the connectionless DCERPC fragment length
2026-11-10 17:07:30 +01:00
Alfredo Cardigliano
c8d10df833
Fix Discord detection with request retransmission (#3321) 2026-11-10 11:16:59 +01:00
Ivan Nardi
95fc30c2bf
Protobuf: fix false positive on payloads parsed only partially (#3320)
The "weak" detection path (>= 4 packets, >= 2 elements, no LEN fields
required) didn't check that the whole payload had been parsed: the
dissector stops after PROTOBUF_MAX_ELEMENTS elements and returns a
non-zero offset anyway.

Require the parsed bytes to cover the entire payload on that path.

Add the trace to false_positives.pcapng.
2026-11-09 21:40:29 +01:00
Alfredo Cardigliano
a2b54f8293 Reduce severity of TCP Issues to reduce noise (Probing Attempt is also set when it's about security) 2026-11-09 11:15:53 +01:00
Luca Deri
ed59c1fcda Enhanced FTP detection 2026-11-07 12:37:04 +01:00
Luca
b0a2310906 Implements detection of CVE-2026-98432 2026-11-06 19:04:28 +01:00
Alfredo Cardigliano
cfbf5fe45d
Do not trigger Known Proto on Non Std Port for mail protocols (e.g. STARTTLS flows on port 25, SMTP expected but protocol nogotiated to SMTPS) (#3318) 2026-11-06 17:30:32 +01:00
Raja Muhammad Awais
8a07936f2a
SSH: match negotiated algorithms by exact name (#3311) 2026-11-06 17:14:06 +01:00
Ivan Nardi
96a07277c0 TLS: better flow risk info 2026-11-06 16:54:48 +01:00
Ivan Nardi
2005d3af4f Bittorrent: avoid Known Proto on Non Std Port flow risk 2026-11-06 16:12:21 +01:00
Ivan Nardi
b6bddaf79b
Kerberos: add helpers to describe and serialize the metadata (#3317)
- ndpi_kerberos_msg_type2str(), ndpi_kerberos_name_type2str(),
  ndpi_kerberos_error2str() (RFC 4120, RFC 4556, RFC 6113 error codes),
  ndpi_kerberos_s4u2str()
- ndpi_kerberos_reply_ok(): the KDC issued the ticket (AS-REP/TGS-REP)
- ndpi_kerberos_reply_error(): name of the error of a KRB-ERROR reply
- ndpi_kerberos_client_name(): "user@realm", or "host$@realm" for a
  machine; an enterprise name ending with the realm is used as it is,
  otherwise its '@' are escaped ("user\@upn.suffix@realm")
- ndpi_kerberos2json(): used by ndpi_dpi2json() (same output)

ndpiReader uses them, and prints the name of the error code.
2026-11-05 19:46:37 +01:00
Ivan Nardi
4eec73db6e
Kerberos: commit metadata to the shared union only after classification (GHSA-hp25-h2r7-vw5r) (#3316)
The write-before-classify ordering was introduced by commit b20123478
("Kerberos: rework dissector and export request/response metadata");
before it the dissector classified first and wrote metadata afterwards.

Add tests/pcap/pocs.pcapng (the merged SMBv23 and SIP reproductions) as a
regression test.
2026-11-05 14:32:21 +01:00
Ivan Nardi
3805b93ca9 Kerberos: export the short name of the machine of host/ldap principals
The name of a machine was exported in two forms: "ws1" from its account
name ("WS1$") and "ws1.corp.local" from a "host/ws1.corp.local" principal.
Now only the short one, i.e. the first label of the name, unless it is an
IPv4 address (e.g. "host/10.1.2.3").
2026-11-05 13:28:09 +01:00
Ivan Nardi
e1973d0797 DNS: don't start the extra dissection with max_packets_extra_dissection 0
With dns,max_packets_extra_dissection set to 0 the extra dissection was
started anyway and it never ended (max_extra_packets_to_check 0 is never
reached), instead of being disabled.
2026-11-05 13:28:09 +01:00
Ivan Nardi
f02c482839 Kerberos: add the kerberos,max_packets_extra_dissection parameter
The number of packets to wait for the reply, after a request (default 16,
as before). With 0 the reply is not dissected: no extra dissection is
started at all (with max_extra_packets_to_check 0 it would never end).
2026-11-05 13:28:09 +01:00
Ivan Nardi
c1c245002e Kerberos: same buffer limit (12000 bytes) for requests and replies
A single limit to the bytes buffered per flow: requests longer than it are
not reassembled (as before), replies are buffered only up to it. The worst
case per flow is unchanged and a larger padata fits before the client name.
2026-11-05 13:28:09 +01:00
Ivan Nardi
fb1310a80b Kerberos: parse only the beginning of large TCP replies
The whole reply was reassembled, up to KRB_MAX_MSG_LEN (12000) bytes and
within 5 extra packets, counting also the ACKs of the client: replies
larger than about 6KB (e.g. with the PAC of a user in many groups) were
lost, i.e. no client name and no reply type for the flow.

The needed fields (crealm and cname) are at the beginning of the reply,
before the ticket: now the reply is parsed up to the first incomplete
field. Usually the first segment is enough (no buffer at all); otherwise
(large padata, as with PKINIT, small segments, the record marker in its
own segment) only the first KRB_MAX_PREFIX_LEN (8192) bytes are buffered,
waiting for up to KRB_MAX_EXTRA_PACKETS (16) packets.

The requests are unchanged (whole message, up to KRB_MAX_MSG_LEN).

New test: kerberos-large-reply.pcap (synthetic): replies up to 48000
bytes (Windows MaxTokenSize), with and without ACKs, record marker alone,
cname in the 4th segment, large padata, padata larger than the limit.
2026-11-05 13:28:09 +01:00
Ivan Nardi
21184d1a50 Kerberos: keep UTF-8 names and report truncated names
Names and realm were copied byte by byte: any non-ASCII byte was replaced
by '?' (e.g. "josé" became "jos??") and a name longer than the buffer was
silently truncated, i.e. exported as a different, wrong, name.

Now:
- valid UTF-8 is kept as is (only ASCII is lowercased); control characters
  and invalid bytes are still replaced by '?'
- a multi-byte character is never split
- the new flags hostname_truncated, domain_truncated and
  username_truncated report a truncated name
- the buffers are larger (hostname 64, domain 64, username 96), to fit long
  enterprise names and realms (still within the protos union)
2026-11-05 13:28:09 +01:00
Ivan Nardi
30aae910ed Kerberos: export S4U (S4U2Self and S4U2Proxy) requests
With S4U (MS-SFU) a service requests a ticket on behalf of a user: the
client name of the reply is the user, but the client of the flow is the
service. Without knowing it, the users of the metadata bind the user to
the host of the service.

Export it in the new field "s4u", set for the first TGS-REQ with:
- PA-FOR-USER (129) or PA-S4U-X509-USER (130): S4U2Self
- the cname-in-addl-tkt KDC option: S4U2Proxy (constrained delegation);
  additional tickets without this option are user-to-user
2026-11-05 13:28:09 +01:00
Ivan Nardi
5e46f85b98 Kerberos: don't export service principals as usernames; export the name type
With a client name of two components, only "host/x" and "ldap/x" were
handled (the second component is the machine): for any other service
principal (e.g. "nfs/server.corp.local" or "HTTP/web.corp.local", used by
logins with a keytab) the service was exported as the username ("nfs",
"http"). Now neither the username nor the hostname are set.

Export also the name type of the client name (e.g. 1 principal, 2/3
service, 6 X.500, 10 enterprise, -128 MS principal), so that the users of
the metadata can tell what kind of name it is.
2026-11-05 13:28:09 +01:00
Ivan Nardi
78eab27911 Kerberos: export the client name and realm of the reply
Names and realm were taken from the first message carrying them, usually
the request, that is set by the client: e.g. the realm of an AS-REQ can be
the short name of the domain ("CORP" instead of "CORP.LOCAL") and the
client name an enterprise principal ("alice@corp.com" instead of "alice").

The crealm and cname of the first successful reply (AS-REP/TGS-REP), set
by the KDC, now replace the ones of the request; requests and KRB-ERROR
still keep the first values seen. When the name is replaced, both the
username and the hostname are reset, as only one of them is set.
2026-11-05 13:28:09 +01:00
Ivan Kapranov
4a2a7611ad
TLS: added decode of ML-DSA sig algs (#3308) 2026-11-05 13:02:55 +01:00
Ivan Nardi
6b38c1c258
serializer: reject over-length strings instead of truncating (GHSA-q2gg-6j82-vwj5) (#3310)
ndpi_serialize_string_string() computed the value length with strlen()
and passed it into the u_int16_t value_len parameter of
ndpi_serialize_string_string_len(), silently truncating any value longer
than 65535 bytes (mod 65536). Fail with -1 instead.

Add serializerCsvMaxLengthUnitTest() covering the longest representable
value, rejection of an over-length value, and that the serializer stays
usable afterwards.
2026-11-03 17:36:56 +01:00
Luca Deri
679f31085f Various JSON/CSV serialization/.deserialization fixes 2026-11-03 14:08:31 +01:00
Ivan Nardi
f6caffea17
serializer: fix 16-bit wrap in the string size of the deserializer (#3309) 2026-11-03 11:07:51 +01:00
mmanoj
7393261e88
dns: harden any-port UDP detection (#3246) 2026-11-02 20:03:42 +01:00