CVE-2024-43787: Hono Hono CSRF Middleware Can Be Vulnerability
LOWCVE-2024-43787 is a LOW (CVSS 5.0) hono csrf middleware can be vulnerability (CWE-352: Cross-Site Request Forgery (CSRF)) affecting Hono libraries in the npm ecosystem. The issue involves hono csrf middleware can be bypassed using crafted content-type header. Remediation is available by upgrading affected packages to version 4.5.8.
CVE-2024-43787 at a Glance
Security Impact
CVSS: 5.0
The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:U/C:L/I:L/A:L).
How to Fix CVE-2024-43787
To remediate this vulnerability, upgrade all affected Hono dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.
npm install hono@4.5.8
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
npm ls hono
How to Check if You Are Affected
To determine whether your Node.js application is affected by CVE-2024-43787, inspect your project dependencies using npm:
npm ls hono
Analyze the terminal output to locate any version of Hono in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 4.5.8), your application is affected.
Note: The npm ls hono command inspects dependencies declared in your package.json and lockfile; it does not perform automated runtime dynamic scanning.
Technical Details
Vulnerability Mechanism & Technical Analysis
This vulnerability is classified under CWE-352: Cross-Site Request Forgery (CSRF), where the web application does not, or cannot, sufficiently verify whether a request was intentionally provided by the user who sent the request, which could have originated from an unauthorized actor. In Hono, 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
CVE-2024-43787 Affected Hono Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
hono
|
npm |
< 4.5.8
|
4.5.8
|
References
Frequently Asked Questions
What is CVE-2024-43787?
Which Hono versions are affected?
What version fixes CVE-2024-43787?
Is hono affected?
What is the CVSS score of CVE-2024-43787?
What CWE is associated with CVE-2024-43787?
How can I check npm dependencies for CVE-2024-43787?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-rpfr-3m35-5vx5",
"modified" : "2024-11-18T16:27:06Z",
"published" : "2024-08-22T16:41:08Z",
"aliases" : [ "CVE-2024-43787" ],
"summary" : "Hono CSRF middleware can be bypassed using crafted Content-Type header",
"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<html>\n <head>\n <title>CSRF Test</title>\n <script defer>\n document.addEventListener(\"DOMContentLoaded\", () => {\n document.getElementById(\"btn\").addEventListener(\"click\", async () => {\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 </script>\n </head>\n <body>\n <h1>CSRF Test</h1>\n <button id=\"btn\">Click me!</button>\n </body>\n</html>\n```\n\n### Impact\n\nBypass csrf protection implemented with hono csrf middleware.\n\n### Discussion\n\nI'm 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",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:U/C:L/I:L/A:L"
}, {
"type" : "CVSS_V4",
"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"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "npm",
"name" : "hono"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "4.5.8"
} ]
} ]
} ],
"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"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-352" ],
"severity" : "LOW",
"github_reviewed" : true,
"github_reviewed_at" : "2024-08-22T16:41:08Z",
"nvd_published_at" : "2024-08-22T15:15:16Z"
}
}