~/blog/cleartext-credentials-sensor
Listening for Passwords on My Own Network

Every public site in my lab has a valid certificate, and every browser shows a padlock. So I assumed nothing sensitive crossed the network in clear. That was an assumption, not a measurement. As a pentester I would never accept it from a client, so I built something to measure it.
The result is cleartext-watch, a few hundred lines of Python that listen on the network and report any password, token or session cookie they can read. It ran for one evening before it found four of them.
What it has to do, and what it must not
The requirements were short:
- report credentials, tokens and session cookies sent unencrypted, by email and push, and show them on a dashboard;
- never log the secret itself, because a sensor that copies passwords into a log has made the problem worse;
- not read torrent traffic, package downloads or FTP data. Those are large, they are not mine to read, and they would bury the findings;
- no new container. It has to live on machines that already see the traffic.
Where to listen
In a Proxmox lab almost everything crosses the hypervisor. Each container has a veth interface on the host, and the LAN bridge carries everything that comes from outside. So the main sensor runs on the Proxmox host, on every veth<CT>i0 plus the LAN bridge.
Two places are invisible from there:
| Sensor | Interfaces | Why it’s needed |
|---|---|---|
| Proxmox host | every container veth + the LAN bridge |
container to container, container to LAN/internet, inbound DNAT |
| wifi-ap | tun0 |
WiFi clients’ traffic is plaintext only before the VPN tunnel encrypts it |
| dev-box | eth0, wlan0 |
a laptop on the LAN whose own traffic never touches the hypervisor |
Read only what a client sends
The privacy and volume requirements come down to one observation: credentials travel from client to server. Responses (downloads, apt packages, video streams, FTP data) travel back to the client’s ephemeral port, which is above 32768 on Linux.
So a kernel BPF filter passes only TCP packets that carry data to a destination port below 32768, and drops the rest before Python sees them:
tcp and dst portrange 1-32767 and tcp[tcpflags] & tcp-push != 0
and not dst port (22 or 443 or 465 or 993 or 995 or 8006 or 9200)
and not (host 10.99.99.13 and not dst port (21 or 23 or 25 or 80 or 110 or 143 or 389))
The last line handles the media server. Torrent peers use arbitrary ports, so its traffic with the internet is only inspected on the classic cleartext login ports. UDP is only read towards private addresses (syslog, SNMP, RADIUS, TFTP).
The filter is compiled with tcpdump -ddd and attached to an AF_PACKET socket. Python parses about five packets a second on the hypervisor, in 15 MB of RAM. A packet seen on three interfaces (container veth, bridge, destination veth) is deduplicated on a key built from the TCP sequence number, length and a CRC of the payload, with no addresses, so NAT doesn’t defeat it.
What it looks for
| Severity | Detections |
|---|---|
| high (password) | HTTP Basic auth, password/secret/totp form or JSON fields, FTP/POP3 USER+PASS, IMAP LOGIN, SMTP AUTH PLAIN/LOGIN, LDAP simple bind, Telnet, Redis AUTH, Postgres cleartext password, SNMP community, private keys, AWS keys |
| medium (token/session) | Bearer and other Authorization schemes, API-key headers, Cookie (names only), secret-looking URL parameters, secrets inside cleartext syslog, Postgres/MySQL without TLS |
Each finding becomes one syslog line, at most once per 24 hours per finding:
cleartext-watch: FINDING sensor=proxmox severity=high kind=http_auth_basic
src=10.99.99.11 src_host=web-proxy dst=10.99.99.10 dst_host=mon-srv dport=2586
http_host=ntfy.example.com path=/alerts/json user=admin ack=no
There is a user name, a cookie name and a URL path. There is no password, token value or cookie value. A --selftest mode runs thirteen cases and checks that no secret appears in any output. The lines go through the usual pipeline to Loki, where three Grafana rules watch them: credentials (critical), token or session (warning), and sensor down.
The first night: four findings
All four were the same pattern:
| What crossed in clear | Hop |
|---|---|
| the push app’s Basic-auth login | web-proxy → mon-srv (ntfy) |
| the media server’s API token | web-proxy → media-srv (Jellyfin) |
| the homelab dashboard’s session cookie (and, at login, password + TOTP) | web-proxy → mon-srv |
| an AI web UI’s session cookie | web-proxy → dev-box, across the home LAN |
TLS ended at the reverse proxy. From there, each request went to its backend as plain HTTP. The padlock was true for the browser-to-proxy leg and said nothing about the rest.
How exposed was each hop? The ones inside the hypervisor stay in the host kernel: a container can’t sniff another container’s unicast traffic, and the Proxmox MAC filter stops spoofing. Reading them takes root on the host or a compromised proxy. The fourth hop is different. It crosses the physical LAN, where any device that can ARP-spoof could read it.
The fix was an internal CA and verified TLS on every hop. It has its own post.
The scanner that looked like a leak
The next morning the dashboard showed six critical findings: HTTP Basic auth with users admin, user, helpdeskIntegrationUser and 230DT, sent to the hypervisor’s port 80.
They came from an exploit scanner on the internet: about 1,500 requests in ten minutes, trying F5 BIG-IP, SolarWinds Web Help Desk default accounts, Qlik, CrushFTP and SharePoint. The proxy’s catch-all server answered every one with 444 (connection closed), so nothing reached an application. But those were credentials in clear on my network, and the sensor reported them correctly.
They weren’t my secrets, though. The fix was to classify by direction. When the source is a public address that isn’t mine and the destination is mine, the finding gets severity=attack direction=inbound. It is logged and shown, and the alert rules ignore it.
The more useful lesson was elsewhere: why was that scanner never banned? 1,500 exploit attempts is exactly what CrowdSec’s HTTP scenarios exist for. The reverse proxy’s CrowdSec agent turned out to have the same dead hub I had found on the public server in October. It had read 234,000 nginx lines and matched none of them. A sensor built to find leaked passwords found a broken IDS.
Other false positives
- Torrent UDP to port 1812 looked like RADIUS. A peer happened to use that port. UDP is now inspected only towards private addresses, and a RADIUS finding needs a valid RADIUS header.
- sudo’s
PWD=/home/...in syslog matched thepwdpattern. It’s the working directory. Apwdvalue starting with/is ignored. - Grafana’s identity lookups (
display?key=access-policy:<uid>) in the proxy’s access log looked like a key in a URL. That exact shape is skipped. - An IPTV provider’s stream URLs carry
?token=. That one is real but third-party and not mine to fix, so it is acknowledged: still logged withack=yes, never alerted.
Pitfalls
- Don’t log what you detect. Write the kind, the endpoints and the name, never the value. Test that with cases that contain a recognisable fake secret.
- Filter in the kernel, not in Python. “Client to server, below port 32768” removes downloads, streams and FTP data before userspace sees a byte, which takes care of both privacy and CPU.
- Deduplicate across interfaces without addresses. One packet crosses
veth, bridge andveth, and NAT rewrites the addresses on the way. - Per-packet matching misses split headers. There is no TCP reassembly. A header split across two segments can be missed, which is acceptable for a sensor and not for a guarantee.
- Inbound credentials are attacks, not leaks. Classify by direction before alerting, or every scanner becomes a critical alert.
- Your sensor will find more than it looks for. The best finding of the week wasn’t a leak at all.