Skip to main content
Vulnerability Database/CVE-2024-23340

CVE-2024-23340: Hono Node-server Path Traversal Vulnerability

CVE-2024-23340 is a path traversal vulnerability in Hono Node-server caused by improper URL resolution of double dots in request paths. This article covers technical details, affected versions, security impact, and mitigation strategies.

Published:

Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

Sources: National Vulnerability Database, CISA KEV, Exploit-DB

CVE-2024-23340 Overview

CVE-2024-23340 is a path traversal vulnerability in @hono/node-server, an adapter that runs Hono applications on Node.js. Starting in version 1.3.0, the adapter implements a custom Request object whose url property does not resolve .. segments. When applications use serveStatic, this behavior allows unresolved double-dot sequences such as http://localhost/static/../foo.txt to reach file-serving logic. Clients that do not normalize paths before sending requests can traverse outside the intended static directory. The flaw is categorized under CWE-22: Improper Limitation of a Pathname to a Restricted Directory. Version 1.4.1 resolves the issue by normalizing paths before use.

Critical Impact

Attackers using non-normalizing HTTP clients can read files outside the configured static directory served by serveStatic, exposing sensitive application and system data.

Affected Products

  • @hono/node-server versions 1.3.0 through 1.4.0
  • Hono applications deployed on Node.js using serveStatic
  • Node.js services exposing static content through the affected adapter

Discovery Timeline

  • 2024-01-22 - CVE-2024-23340 published to NVD
  • 2026-06-17 - Last updated in NVD database

Technical Details for CVE-2024-23340

Vulnerability Analysis

The @hono/node-server package provides a Node.js adapter for the Hono web framework. Since version 1.3.0, the adapter constructs its own Request object rather than relying on the standard WHATWG URL semantics. The custom implementation returns the raw request URL without resolving .. segments. A request to http://localhost/static/../foo.txt therefore produces a url string containing the literal double dots. Downstream code in serveStatic consumes this unresolved path when locating files on disk.

Modern browsers and recent curl versions normalize URLs on the client before transmission, so they do not trigger the issue. Clients that forward raw paths, such as custom HTTP libraries, scripted scanners, or proxies, send the unresolved sequence directly to the server. The server then attempts to serve files relative to the attacker-controlled path, enabling directory traversal.

Root Cause

The root cause is missing path normalization in the custom Request implementation in src/request.ts. The standard Request API resolves relative segments, but the adapter preserves the raw URL. The serveStatic handler trusts this unresolved value when constructing the filesystem path.

Attack Vector

An unauthenticated remote attacker sends an HTTP request containing .. sequences in the URL path targeting a route handled by serveStatic. If the client does not pre-normalize the path, the server resolves the file relative to the static root with the double dots intact, returning content from a parent directory.

typescript
// Security patch in src/request.ts - fix(request): handle "double dots" in URL (#124)
 import type { IncomingMessage } from 'node:http'
 import type { Http2ServerRequest } from 'node:http2'
+import { resolve } from 'node:path'
 import { Readable } from 'node:stream'

 const newRequestFromIncoming = (

Source: GitHub Commit dd9b9a9. The patch imports resolve from node:path and applies path resolution to the incoming URL before it is exposed through the Request object.

Detection Methods for CVE-2024-23340

Indicators of Compromise

  • HTTP access log entries containing .. sequences in URL paths targeting routes bound to serveStatic
  • Successful 200 OK responses to requests with /../ segments outside the declared static directory
  • Outbound responses returning files such as .env, package.json, or system configuration files from static routes

Detection Strategies

  • Inspect Node.js application logs and reverse proxy logs for unresolved .. segments in request URIs reaching the Hono adapter
  • Deploy web application firewall (WAF) rules that flag path traversal patterns including URL-encoded variants such as %2e%2e%2f
  • Perform dependency inventory scans to identify @hono/node-server versions between 1.3.0 and 1.4.0 in production builds

Monitoring Recommendations

  • Alert on repeated 200-status responses to requests containing ../ on endpoints served by serveStatic
  • Monitor file access telemetry for reads outside the configured static root by the Node.js process
  • Track egress of sensitive files such as credentials or configuration artifacts over HTTP response bodies

How to Mitigate CVE-2024-23340

Immediate Actions Required

  • Upgrade @hono/node-server to version 1.4.1 or later across all affected deployments
  • Audit application routes to identify where serveStatic is exposed and confirm the static root does not include sensitive files
  • Review access logs for prior exploitation attempts containing .. sequences on static routes

Patch Information

The fix is published in @hono/node-server version 1.4.1. The maintainers applied commit dd9b9a9, which imports resolve from node:path and normalizes the URL path within the custom Request constructor. See the GHSA-rjq5-w47x-x359 advisory for additional detail.

Workarounds

  • Remove calls to serveStatic and serve static assets through a hardened reverse proxy such as nginx that normalizes paths
  • Place a WAF or proxy in front of the Node.js service to reject requests containing .. or encoded traversal sequences
  • Restrict the directory passed to serveStatic so that traversal cannot reach sensitive files until the upgrade is applied
bash
# Upgrade the vulnerable adapter to the fixed release
npm install @hono/node-server@^1.4.1
npm ls @hono/node-server

Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

Sources: National Vulnerability Database, CISA KEV, Exploit-DB

Experience the Most Advanced Cybersecurity Platform

See how the world’s most intelligent, autonomous cybersecurity platform can protect your organization today and into the future.