* 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().
* 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
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.
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.
* 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
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.
- 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.
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.
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").
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.
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).
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.
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.
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)
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
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.
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.
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.