MEDIUM 6.1

CVE-2026-59895: Hono cx() HTML Injection in Server-Side Rendering

Hono, a JavaScript framework for building web applications, contains a flaw in its CSS class composition utility (cx() function) that fails to properly sanitize user-supplied class names during server-side rendering. When untrusted input is passed as a class attribute in JSX, an attacker can break out of the attribute context and inject arbitrary HTML markup into the rendered page. This occurs because the function marks its output as safe HTML without actually escaping the input strings. The vulnerability affects Hono versions 4.0.0 through 4.12.26 and has been patched in version 4.12.27.

Source data · NVD / CISA · public domain

CVSS
3.1 · 6.1 MEDIUM · CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N
Weaknesses (CWE)
CWE-116, CWE-79
Affected products
1 configuration(s)
Published / Modified
2026-07-08 / 2026-07-10

NVD description (verbatim)

Hono is a Web application framework that provides support for any JavaScript runtime. From 4.0.0 before 4.12.27, cx() in hono/css composes class names from plain strings but marks the result as already escaped without HTML-escaping the input, allowing untrusted className values used in a JSX class attribute during server-side rendering to break out of the attribute and inject arbitrary markup. This issue is fixed in version 4.12.27.

3 reference(s) · View on NVD →

SEC.co analysis · AI-assisted, reviewed against source

Technical summary

The cx() function in the hono/css module composes multiple class name strings into a single class attribute value. The vulnerability stems from a logic error where the function concatenates untrusted className inputs but then flags the result as pre-escaped HTML (using a trusted markup marker) without performing any HTML entity encoding on those inputs. During server-side rendering, JSX processes the class attribute using this marked-safe string directly, bypassing normal escaping mechanisms. An attacker who controls className values—such as through user input, database records, or API responses—can inject sequences like " onload="alert(1) or other HTML/JavaScript payloads that break out of the attribute context and execute in the rendered document.

Business impact

Applications using Hono for server-side rendering with untrusted class name sources face reflected or stored cross-site scripting (XSS) risk. If user input flows into JSX className attributes without sanitization, attackers can inject scripts that execute in end-user browsers, potentially stealing session cookies, performing unauthorized actions on behalf of victims, redirecting users, or defacing content. The severity is medium rather than high because successful exploitation requires user interaction (clicking a link with malicious parameters or visiting a compromised page) and depends on how the application architecture sources className values. However, any publicly-exposed Hono application that renders user-controlled strings as class names is at risk.

Affected systems

The vulnerability affects Hono framework versions 4.0.0 through 4.12.26 inclusive. Any application using those versions and employing the cx() utility from hono/css with untrusted or user-supplied className inputs during server-side rendering is vulnerable. This includes applications that pass user input, query parameters, form data, or other external sources into JSX className attributes.

Exploitability

Exploitation is straightforward if an application passes untrusted input to cx() in a JSX class attribute. An attacker can craft a className string containing quote characters followed by HTML event handlers or tag closures (e.g., '" onmouseover="alert(1)') that break attribute boundaries and inject executable markup. The attack requires user interaction (visiting a malicious link or viewing injected content) but no special privileges, authentication, or complex environment setup. The network vector and low complexity make this readily exploitable in real-world scenarios where class names derive from user input.

Remediation

Immediately upgrade Hono to version 4.12.27 or later, which properly escapes input passed to cx() before marking it as safe HTML. Additionally, implement input validation and sanitization at the application layer: validate className values against a whitelist of expected class names, reject or sanitize user-supplied strings before passing them to cx(), and consider using Content Security Policy (CSP) headers to limit the impact of any injected scripts. Review your application code for all places where cx() or similar utilities receive untrusted input.

Patch guidance

Update the Hono dependency to version 4.12.27 or any later release. If using a package manager such as npm, yarn, or pnpm, run `npm install hono@latest` (or equivalent for your manager) and rebuild your application. Verify the updated version is active in your lock file and perform a test build to ensure no compatibility breaks. For pinned or locked dependencies, explicitly update the version constraint to >=4.12.27 before re-installing.

Detection guidance

Search your codebase for uses of cx() from hono/css, particularly in JSX components that receive className props or values from external sources (environment variables, API responses, user input, database queries). Monitor server-side rendering logs and HTTP responses for suspicious class attribute values containing quotes, event handlers, or script tags. Use static analysis tools or linters configured to flag instances where cx() is called with unsanitized variables. Additionally, review Content Security Policy violation reports or browser XSS filter logs for patterns indicating markup injection attempts.

Why prioritize this

Although rated CVSS 6.1 (MEDIUM), this vulnerability warrants high priority for any public-facing Hono application that renders untrusted input. The combination of low attack complexity, no authentication requirement, network vector, and broad potential impact (confidentiality and integrity compromise through XSS) makes it practically dangerous. The fix is straightforward (a version upgrade), and the risk window is significant for unpatched systems. Prioritize patching systems that expose user-controlled input through web interfaces.

Risk score, explained

The CVSS 6.1 score reflects a network-accessible flaw requiring user interaction, affecting confidentiality and integrity but not availability. The scope is marked as changed (affecting resources beyond the vulnerable component), elevating severity beyond the base impact. However, the score is not higher because XSS vulnerabilities typically require user interaction (clicking a link, viewing content) and the damage is limited to the victim's session rather than server-wide compromise. Organizations should treat this as a medium-to-high priority based on their attack surface and the presence of untrusted class name sources in their Hono applications.

Frequently asked questions

Does this vulnerability affect Hono 3.x or earlier versions?

No. The vulnerability was introduced in version 4.0.0. If your application runs Hono 3.x or earlier, you are not affected by CVE-2026-59895. However, you should verify your installed version before concluding you are safe.

What if our application never passes user input to cx() class names?

If your application only uses cx() with static, hardcoded class names or class names derived entirely from internal logic without any external input, the vulnerability does not apply to your system. However, audit your code carefully to confirm no code path introduces untrusted input through environment variables, configuration, or dynamic data sources.

Is there a workaround if we cannot upgrade immediately?

As a temporary measure, sanitize all className values before passing them to cx(). For example, validate className strings against a strict whitelist of allowed class names, or manually escape quotes and special characters. Additionally, deploy or strengthen Content Security Policy headers to restrict inline script execution. However, upgrading to 4.12.27 is the proper fix and should be prioritized.

Does this affect client-side rendering or only server-side rendering?

The vulnerability specifically impacts server-side rendering (SSR) because the flaw involves the marked-safe HTML output being injected directly into the rendered markup. Client-side rendering may present different risks depending on how the cx() result is used, but SSR applications are the primary focus of this advisory.

This advisory is provided for informational purposes to help organizations assess and mitigate CVE-2026-59895. The information is derived from official vendor advisories and public disclosures. Organizations should independently verify all patch versions, compatibility notes, and deployment procedures against vendor documentation before applying updates. SEC.co does not provide guarantee of accuracy for third-party vendor data or real-time vulnerability intelligence. Always consult official Hono release notes and security advisories for authoritative guidance. Testing patches in a non-production environment before broad deployment is strongly recommended. Source: NVD (public-domain), retrieved 2026-08-17. Analysis generated by SEC.co (claude-haiku-4-5).