CVE-2017-16013: Denial of Service via malformed accept-encoding header in hapi
Summary
CVE-2017-16013: Denial of Service via malformed accept-encoding header in hapi. Affects hapi versions >= 15.0.0, < 16.1.1. Fixed in 16.1.1. 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 an open-source framework for building applications and services in Node.js. It provides a robust set of features for handling HTTP requests, routing, and server-side logic. However, versions of hapi prior to 16.1.1 are vulnerable to a Denial of Service (DoS) attack when a malformed accept-encoding header is received. This vulnerability can lead to crashes or the event loop being locked, impacting the availability of the application.
Vulnerability Detail
The vulnerability arises from a lack of proper input validation in the handling of the accept-encoding header. When a malformed header is encountered, it triggers a crash or locks the event loop, causing the application to become unresponsive. An attacker can exploit this vulnerability by sending specially crafted requests with malformed accept-encoding headers, leading to a DoS condition. The impact of this vulnerability can range from temporary service disruption to a complete application outage.
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
16.1.1
This is the first release that contains the fix.
npm install hapi@16.1.1
Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →
Workaround
If updating to the latest version of hapi is not immediately feasible, a temporary workaround can be implemented by adding input validation for the accept-encoding header. This can be done by inspecting the header value and ensuring it conforms to the expected format before further processing. Here is an example of how this can be achieved in Node.js:
const Hapi = require('hapi');
const server = new Hapi.Server();
server.connection({
port: 3000,
routes: {
validate: {
headers: {
'accept-encoding': Joi.string().regex(/^gzip, deflate, br$/)
}
}
}
});
// Rest of the server setup and route handling
Conclusion
In conclusion, the hapi package prior to version 16.1.1 is vulnerable to a Denial of Service attack when a malformed accept-encoding header is received. To mitigate this vulnerability, it is crucial to update the package to the latest version or implement the provided workaround. For further assistance or support in vulnerability remediation, please contact DevNack.com.
See every vulnerability recorded for hapi →
FAQ
hapi is an open-source framework for building applications and services in Node.js. It provides a rich set of features for handling HTTP requests, routing, and server-side logic.
A Denial of Service attack is a malicious attempt to disrupt the normal functioning of a system or network, making it unavailable to its intended users.
An attacker can exploit this vulnerability by sending specially crafted requests with malformed accept-encoding headers, causing the application to crash or become unresponsive.
The impact of this vulnerability can range from temporary service disruption to a complete application outage, depending on the severity of the DoS condition triggered.
To fix this vulnerability, update the hapi package to version 16.1.1 or later by running the command: npm install hapi@16.1.1
Related vulnerabilities
Recent vulnerabilities recorded for hapi.
Follow Vulert in Google
Get more Vulert vulnerability and dependency-security updates in Google Search and AI results.