CVE-2015-9243: Unsafe Merging of CORS Configuration Conflict in hapi

hapi Updated 02 Oct 2025

Summary

01/09/2020
Yes i
Moderate
Not published

CVE-2015-9243: Unsafe Merging of CORS Configuration Conflict in hapi. Affects hapi versions < 11.1.4. Fixed in 11.1.4. How to fix ↓

Free scan

Check if this vulnerability affects your application

Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.

Check my app free

No signup required · Results in about 60 seconds

Upload your dependency manifest or SBOM

Drag & drop your file here or

Java Javascript PHP Python Go Rust Ruby Dart C/C++ Elixir CycloneDX SPDX

Upload a supported dependency manifest or SBOM. No installation or source-code access required.

See supported files and SBOM formats
SBOM sbom.json · bom.json · bom.xml · *.spdx.json · *.cdx.json · *.cdx.xml
Java pom.xml · gradle.lockfile · buildscript-gradle.lockfile
Javascript package-lock.json · yarn.lock · pnpm-lock.yaml
PHP composer.lock
Python poetry.lock · requirements.txt · Pipfile.lock
Go go.mod
Rust Cargo.lock
Ruby Gemfile.lock
Dart pubspec.lock
C/C++ conan.lock
Elixir mix.lock
Enter your work email to receive your report link.

Verify your email to view the full report and start 30 days of continuous monitoring. No credit card required.

Sponsored MarkAI Find prospects already talking about the problem you solve AI watches the communities your customers use to find qualified prospects, then alerts you when a conversation is worth joining. See MarkAI

Background

The hapi package is a rich framework for building applications and services in Node.js. It provides a robust set of features for handling HTTP requests, routing, and other server-side functionalities. However, versions prior to 11.1.4 are susceptible to a vulnerability that allows route-level CORS configuration to override connection-level or server-level CORS defaults. This can lead to less restrictive CORS permissions than intended, potentially exposing the application to cross-origin attacks.

Vulnerability Detail

The vulnerability in hapi arises from the incorrect merging of CORS configuration settings. When configuring CORS at the route level, the settings should be combined with the existing connection-level or server-level CORS defaults. However, prior to version 11.1.4, hapi overrides the defaults with the route-level configuration, resulting in less restrictive CORS permissions. This can allow malicious actors to bypass intended access controls and perform unauthorized actions on behalf of authenticated users. The vulnerability is classified as CWE-284, indicating a weakness in the application's CORS implementation.

How To Fix

Latest published version: 18.1.0 as of 22 Oct 2026

npm install hapi@18.1.0

Upgrading to it may include breaking changes; the version below is the minimum fixed release for this vulnerability.

If you need the minimum change

11.1.4

This is the first release that contains the fix.

npm install hapi@11.1.4

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Workaround

If updating hapi is not immediately feasible, a temporary workaround can be implemented by manually merging the route-level CORS configuration with the connection-level or server-level defaults. This can be achieved by modifying the code responsible for setting up the CORS configuration. Here is an example of how the merging can be done:

const Hapi = require('hapi');

const server = new Hapi.Server();

// Set up connection-level CORS defaults
server.connection({
  routes: {
    cors: {
      origin: ['https://example.com'],
      headers: ['Authorization'],
      additionalHeaders: ['X-Custom-Header'],
      credentials: true
    }
  }
});

// Set up route-level CORS configuration
server.route({
  method: 'GET',
  path: '/api/data',
  config: {
    cors: {
      origin: ['https://example.com', 'https://api.example.com'],
      headers: ['Authorization', 'Content-Type'],
      additionalHeaders: ['X-Custom-Header'],
      credentials: true
    }
  },
  handler: (request, reply) => {
    // Route handler implementation
  }
});

// Manually merge route-level CORS configuration with connection-level defaults
const mergedCorsConfig = Object.assign({}, server.connections[0].settings.routes.cors, server.connections[0].table()[0].settings.cors);

// Apply the merged CORS configuration to the route
server.connections[0].table()[0].settings.cors = mergedCorsConfig;

Conclusion

In conclusion, the hapi package prior to version 11.1.4 is vulnerable to an unsafe merging of CORS configuration, which can result in less restrictive CORS permissions than intended. To mitigate this vulnerability, it is crucial to update hapi to version 11.1.4 or later. If immediate updating is not possible, the provided workaround can be implemented. For further assistance or support in vulnerability remediation, please contact DevNack.com.

See every vulnerability recorded for hapi →

Share this vulnerability

FAQ

hapi is a powerful framework for building applications and services in Node.js. It provides a wide range of features for handling HTTP requests, routing, and other server-side functionalities.

CORS stands for Cross-Origin Resource Sharing. It is a mechanism that allows web browsers to make cross-origin HTTP requests, enabling web applications to interact with resources from different domains. CORS helps enforce security policies to prevent unauthorized access and protect against cross-origin attacks.

If your application is using hapi versions prior to 11.1.4 and has route-level CORS configuration, this vulnerability can lead to less restrictive CORS permissions than intended. This can potentially allow malicious actors to bypass access controls and perform unauthorized actions on behalf of authenticated users.

The recommended fix is to update hapi to version 11.1.4 or later. This ensures that route-level CORS configuration is properly merged with the connection-level or server-level defaults. Updating the package can be done by running the command 'npm install hapi@11.1.4'.

If updating hapi is not immediately feasible, a temporary workaround can be implemented by manually merging the route-level CORS configuration with the connection-level or server-level defaults. Refer to the 'workaround' section for code examples and instructions.

Related vulnerabilities

Recent vulnerabilities recorded for hapi.

How To Fix

Latest published version: 18.1.0 as of 22 Oct 2026

npm install hapi@18.1.0

Upgrading to it may include breaking changes; the version below is the minimum fixed release for this vulnerability.

If you need the minimum change

11.1.4

This is the first release that contains the fix.

npm install hapi@11.1.4

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Subscribe to Vulert on Telegram
Daily digest of new CVEs, critical and high severity, affected packages and fixes — plus a weekly roundup.
Join the channel →
Help improve this record
Report an issue or send feedback