Hello,

Pre-authentication NULL-pointer dereference in cntlm, confirmed on master
793df79 (reports 0.94.1) and present in Debian 0.94.0+dfsg-2.

Where:  headers_recv(), http.c:229-231 (master) / http.c:232-235 (Debian)
Type:   CWE-476 -> crash / DoS, unauthenticated
CVSS:   AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H = 7.5 (gateway mode); AV:L =
6.2 (default localhost)

A proxy request whose absolute-URI authority starts with '[' but has no ']'
reaches:
    if (host[0] == '[') { tok = strchr(host, ']'); *tok = 0; ...
strchr returns NULL and *tok = 0 writes through NULL. This is in the
request-line parser, before any authentication. cntlm is threaded, so one
crash kills the whole process and drops all clients.

Reproduction (container, loopback), after building master and running under
gdb:
    printf 'GET http://[x/ HTTP/1.1\r\n\r\n' | nc 127.0.0.1 3128
-> SIGSEGV at http.c:231 `*tok = 0` in headers_recv (from proxy_thread); no
credentials sent. I can share the container PoC.

Fix: null-check strchr(host, ']') before dereferencing; reject on missing
']'.

Thanks in advance,
Ing. Maximiliano Sebastián Quiroga

Reply via email to