« Back to the Da Slop Pit Forum

attacker controlled format string in PAN-OS captive portal NTLM authentication

Posted by rqu69

posted

Forum: Da Slop Pit Group

greetings fellow scene queens, emo wolf girls, and sloppy ghosts. today i have a special treat for you (and no, this time it's not a bottle of piss).

after writing an exploit for CVE-2019-1579, a format string bug in globalprotect, i wrote a tool to look for format string bugs using ghidra. i ran this script against a few dozen libraries and executables, and as it turns out, there are a lot of format string issues in pan-os.

one of the more interesting vulnerabilities i found with this script was in panmodule.so. panmodule.so is a native library which is called by a lot of php scripts, so a format string vulnerability likely means remote code execution. when i ran my script on a panmodule.so, i immediately got a hit telling me that there was a suspicious call to pan_slog in the handleNTLMMsg function. pan_slog writes to the syslog, and accepts format string arguments, so if i can control that format string i'd be a very happy ghost. 

data from a few variables are snprintf

the format string argument for pan_slog comes from encodebuf, which is constructed using outbuf, keystr, and vsysstr. vsysstr is passed as an argument to handleNTLMMsg, and the only restriction on it is that is has to return 1 when passed to strtol, keystr is an address returned by inet_ntop, and outbuf comes is the user\password provided by the user.

outbuf is constructed using a format string that combines the user and domain into a single string

username and domain sound like user-controllable values, so at this point i told my wife (clipsley) to buy a nice bottle of champissgne to celebrate my new 0w0day.

knowing that this function would likely be called by php, i used a 1337 reverse engineering tool (grep -r) to find that this function is called in /var/appweb/cp/php/browser_challenge.php, and is used by the captive portal. we also seem to have full control over all of the parameters, including vsysstr. the $http_authorization variable holds the value of the http authorization header, which (for ntlm) contains the base64 encoded ntlm messages.

$ret = handleNTLMMsg($_SERVER['HTTP_USER_AGENT'],
                     $remote_host,
                     $http_authorization,
                     $_SERVER['SERVER_PROTOCOL'],
                     $_REQUEST['vsys'],
                     $_REQUEST['url'],
                     new php_string_argout());


long story short, if you do ntlm authentication with a malicious username/domain name/vsys parameter, you'll trigger a format string bug when ntlm authentication fails after the type 3 message.

oh yeah btw this doesnt work on new devices. anything after around pan-os 9.0 has FORTIFY_SOURCE enabled, so pan_slog uses __vasprintf_chk instead of vasprintf, which makes exploiting this bug impossible on newer devices. oops. probably should have mentioned that up front. oh well xD just because 8.1 is eol doesn't mean it's not still around


Report Topic

6 Replies

Sort Replies:

Reply by hyp

posted

i read this in a public restroom 


Report Reply

Reply by yung innanet

posted

Wow! GlobalProtect seems like really good VPN to keep safe, me! online!

Where do I sign up to get this protection????


Report Reply

Reply by rqu69

posted

you can sign up for global protection at trojan brands dot com


Report Reply

Reply by yuu

posted

Gr8 work babey. Paul O. Altoid here to say "pan_slog on my hog && write 2 syslog" -- make sure to tell your catgirl %p%s%p%s%p%s for me ;)


Report Reply

Reply by rqu69

posted

thanks paul, what a kind and thoughtful reply to my Post.
i tried to tell my catgirl %p%s%p%s%p%s but she said "0x7fff01a836c84D��0x7f25caa9a7380x7f25caac8120��AWL�=�," and then i tried again and she said "Segmentation fault (core dumped)" and she has been sleeping ever since. do you have any advice on how to debug this issue?


Report Reply

Reply by rqu69

posted

zomg palowo altowo just gave me a CVE xD

this sloppy code is now CVE-2024-3834

if you're a #thrunter interested in vulnz, make sure to sign up for a free spacehey account to stay 2 years ahead of the curve ;3


Report Reply