Package: chkrootkit
Version: 0.58b-5+b8
Severity: normal
Tags: upstream
Dear Maintainer,
The 'bindshell' test in chkrootkit produced a false "Potential bindshell
installed: infected ports: 511" warning. Root cause: the detection regex
matches a hexadecimal fragment of an IPv6 address as if it were a port
number, not an actual open port.
-- What happened --
chkrootkit-daily reported:
Checking `bindshell'... WARNING
WARNING: Potential bindshell installed: infected ports: 511
No service was listening on TCP port 511 (verified independently via
`ss -tlnp`, `/proc/net/tcp` and `/proc/net/tcp6`), and rkhunter run on the
same host found no rootkit. The alert was a false positive.
-- Root cause --
bindshell() in /usr/sbin/chkrootkit builds the following command
(abbreviated, PORT list includes 511):
${netstat} -an | ${egrep} "^(tcp.*LIST|udp).*[.:]${P}[^0-9.:]"
On this system ${netstat} resolves to `ss` (via _chk_netstat_or_ss), so
the actual command is `ss -an`. One of the lines produced by `ss -an` is
the IPv6 link-local socket used by ntpd for NTP (UDP/123) on a VPN tun
interface, using a kernel-generated RFC 7217 "stable-privacy" address:
udp UNCONN 0 0 [fe80::947d:511e:d141:daaf]%tun0:123
[::]:*
The regex `[.:]511[^0-9.:]` matches the substring ":511e" inside the IPv6
address literal (the hex group "511e"), because the character following
"511" (the letter 'e') satisfies [^0-9.:]. The alternation's "udp" branch
matches at the start of the line, so the whole pattern succeeds even
though there is no port 511 anywhere in the socket's actual port fields.
This is a different failure mode from the port-reuse false positives
already documented in README.FALSE-POSITIVES ("use of well-known ports",
e.g. mosh). In that case a legitimate service really is listening on one
of the flagged port numbers. Here, no port is involved at all - a
hexadecimal fragment of an unrelated IPv6 address is being misread as a
decimal port number. This will reproduce on any IPv6-enabled interface
(tun/tap, wireguard, VPN, etc. with a stable-privacy or any address
whose lower 32-64 bits happen to spell one of the hardcoded PORT values
in decimal), independent of which service happens to be listening - in
this instance it was ntpd on an OpenVPN tun0 interface, chosen by the
kernel's address-generation algorithm, not by any user configuration.
-- Suggested fix --
The bindshell() check should restrict matching to the actual port field
of the socket line rather than grepping the whole line as free text.
With `ss -an`, the local/peer address and port are given as
address:port (IPv4) or [address]:port (IPv6) in a single column; the
port is the substring after the *last* colon in that column, not any
colon. A regex anchored to match only after a closing bracket (for IPv6)
or dotted-quad (for IPv4), immediately before end-of-field/whitespace,
would avoid matching digits embedded inside the IPv6 address itself, e.g.
something along the lines of:
${egrep} "^(tcp.*LIST|udp)[^[]*(\]:| [0-9.]+:)${P}([[:space:]]|$)"
(illustrative only - not tested against every netstat/ss output variant
chkrootkit has to support). Alternatively, parsing with awk on the
address:port column specifically (splitting on the last ':') would be
more robust than a single egrep over the whole line.
-- How to reproduce --
On a host with an IPv6-capable interface, assign (or wait for the kernel
to autogenerate, e.g. via RFC 7217 stable-privacy addressing) a link-local
or global IPv6 address containing one of the hardcoded PORT values from
bindshell() as a hex substring immediately after a ':' and immediately
before a non-hex-boundary character, e.g. an address containing ":511e:"
for port 511, or ":1008:"-like patterns for port 1008, etc., on an
interface with any UDP or TCP listener (even just the normal NTP/mDNS/
etc. sockets most systems already have). Run chkrootkit; the bindshell
check will flag the corresponding port even though nothing is listening
on it.
-- System Information:
Debian Release: 13.8
APT prefers stable-updates
APT policy: (500, 'stable-updates'), (500, 'stable-security'), (500,
'stable')
Architecture: amd64 (x86_64)
Kernel: Linux 6.12.118+deb13-amd64 (SMP w/8 CPU threads; PREEMPT)
Locale: LANG=C.UTF-8, LC_CTYPE=C.UTF-8 (charmap=UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled
Versions of packages chkrootkit depends on:
ii binutils 2.44-3
ii libc6 2.41-12+deb13u5
ii procps 2:4.0.4-9
Versions of packages chkrootkit recommends:
ii bsd-mailx [mailx] 8.1.2-0.20220412cvs-1.1
ii cron [cron-daemon] 3.0pl1-197
ii dma [mail-transport-agent] 0.13-1+b2
ii iproute2 6.15.0-1
ii net-tools 2.10-1.3
ii systemd-sysv 257.13-1~deb13u1
chkrootkit suggests no packages.
-- no debconf information