CVE-2015-9243: Unsafe Merging of CORS Configuration Conflict in hapi
Summary
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 ↓
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.
No signup required · Results in about 60 seconds
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 →
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.
References
Related vulnerabilities
Recent vulnerabilities recorded for hapi.