@adonisjs/http-server: AdonisJS HTTP Server: Uncontrolled Resource Consumption and Inefficient Regular Expression Complexity
What fixes it
- 9.1.1@adonisjs/http-server, npmGitHub
npm install @adonisjs/http-server@9.1.1 - 8.2.2@adonisjs/http-server, npmGitHub
npm install @adonisjs/http-server@8.2.2
A fixed version on one release line is not the upgrade target for every line. Check your exact version and any vendor backports.
Description
Description
A Regular Expression Denial of Service vulnerability in the built-in AdonisJS slug route matcher may allow a remote attacker to block the Node.js event loop using a specially crafted URL.
This affects applications using router.matchers.slug() on a route parameter reachable by an attacker.
Details
The regular expression used by router.matchers.slug() contains adjacent greedy quantifiers with overlapping character classes:
/^[^\s-_](?!.*?[-_]{2,})([a-z0-9-\\]{1,})[^\s]*[^-_\s]$/When the matcher receives a long string ending with a character rejected by the final assertion, the regular expression engine must evaluate many possible ways of dividing the input between the overlapping quantifiers before determining that it does not match.
This results in quadratic execution time. Testing measured an approximate complexity of O(n^1.98).
Route matchers are evaluated against attacker-controlled URL segments during routing. Therefore, an unauthenticated attacker can trigger the vulnerable expression by sending a request to a route configured as follows:
router
.get('/posts/:slug', handler)
.where('slug', router.matchers.slug())Routing occurs before route and group middleware. As a result, authentication or rate-limiting middleware attached to the affected route may not prevent exploitation.
The vulnerability is limited to routes that explicitly use the built-in slug matcher.
Impact
Exploitation requires an application to expose a route using router.matchers.slug() with an attacker-controlled parameter.
A specially crafted request can cause excessive CPU consumption and block the Node.js event loop. While the expression is being evaluated, the process cannot serve other requests, including requests to unrelated routes or health-check endpoints.
Only a small number of requests may be required to consume the capacity of a worker. Reverse-proxy request-line limits reduce the maximum processing time of an individual request but do not fully mitigate the vulnerability.
Patches
Fixes targeting v6 and v7 have been published below.
Users should upgrade to a version that includes the following fix:
- https://github.com/adonisjs/http-server/releases/tag/v9.1.1
- https://github.com/adonisjs/http-server/releases/tag/v8.2.2
Text from GitHub Advisory Database
Affected versions 6
- @adonisjs/http-server, npm>= 9.0.0, < 9.1.1GitHub
- @adonisjs/http-server, npm<= 8.2.1GitHub
- http-serveraffected: < 8.2.2CVE List
- http-serveraffected: >= 9.0.0, < 9.1.1CVE List
- @adonisjs/http-server, npmfrom 9.0.0, fixed in 9.1.1OSV
- @adonisjs/http-server, npmfrom first release, fixed in 8.2.2OSV
References 6
- github.com/adonisjs/http-server/commit/86af38ca861528f673dcac6a4806197de038d1f7Fixvia CVE List
- github.com/adonisjs/http-server/commit/d8c749aa9f66d5d214bad1cad727264aef4be727Fixvia CVE List
- github.com/adonisjs/http-server/releases/tag/v8.2.2Fixvia CVE List
- github.com/adonisjs/http-server/releases/tag/v9.1.1Fixvia CVE List
- github.com/adonisjs/http-server/security/advisories/GHSA-524c-h47v-m3h8Advisoryvia CVE List
- github.com/advisories/GHSA-524c-h47v-m3h8Advisoryvia GitHub