nps: Basic auth ==, tunnel passwords unsalted MD5, secrets serialized to disk
Summary
nps compares HTTP Basic credentials with ==, hashes tunnel passwords as unsalted MD5 for lookup, and serializes tunnel and web-admin passwords in cleartext into its data files. Compromise of the data directory gives near-instant offline recovery of every tunnel secret.
Most important one is timing-compare lib/common/util.go:71, Don't underestimate timing attacks, They are fully exploitable in the real world.
https://en.wikipedia.org/wiki/Timing_attack
Details
Verified against current master (2026-09-24).
// lib/common/util.go:71
pair[0] == user && pair[1] == passwd // Basic auth, == compare
// lib/crypt/crypt.go:60 consumed at lib/file/db.go:127
func Md5(...) // unsalted MD5 lookup key
crypt.Md5(value.(*Tunnel).Password) == p
// lib/file/file.go:164,176 -> json.Marshal(obj)
// Tunnel.Password and Client.WebPassword lack json:"-" (lib/file/obj.go:50,137)Found by my static analyzer (ghoul):
bug_type: timing-compare lib/common/util.go:71
bug_type: weak-crypto lib/crypt/crypt.go:60
bug_type: marshal-secret-leak lib/file/file.go:164,176Impact
CWE-208/916/312: tunnel and web-admin credential recovery from the data directory (or backups of it); timing oracle on the Basic auth gate. nps is a publicly exposed proxy, so recovered secrets hand over tunnels. CVSS: 6.6 (CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:N)
Internal Tracking ID: KF-202635218
Source: ehang-io/nps