Skip to content

Commit

Permalink
add reaper patch
Browse files Browse the repository at this point in the history
  • Loading branch information
xordux authored and rikenm1 committed Oct 24, 2024
1 parent df3bf49 commit a9c15a1
Showing 1 changed file with 87 additions and 0 deletions.
87 changes: 87 additions & 0 deletions SPECS/reaper/CVE-2024-45590.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
From 58b0b02d2501825235a1c1c2598171513621df45 Mon Sep 17 00:00:00 2001
From: Rohit Rawat <[email protected]>
Date: Wed, 25 Sep 2024 12:35:30 +0000
Subject: [PATCH] CVE-2024-45590: Set default depth limit to 32

---
.../body-parser/lib/types/urlencoded.js | 37 +++++++++++++++----
1 file changed, 30 insertions(+), 7 deletions(-)

diff --git a/src/ui/node_modules/body-parser/lib/types/urlencoded.js b/src/ui/node_modules/body-parser/lib/types/urlencoded.js
index b2ca8f16..886a3ce2 100644
--- a/src/ui/node_modules/body-parser/lib/types/urlencoded.js
+++ b/src/ui/node_modules/body-parser/lib/types/urlencoded.js
@@ -55,6 +55,9 @@ function urlencoded (options) {
: opts.limit
var type = opts.type || 'application/x-www-form-urlencoded'
var verify = opts.verify || false
+ var depth = typeof opts.depth !== 'number'
+ ? Number(opts.depth || 32)
+ : opts.depth

if (verify !== false && typeof verify !== 'function') {
throw new TypeError('option verify must be function')
@@ -118,7 +121,8 @@ function urlencoded (options) {
encoding: charset,
inflate: inflate,
limit: limit,
- verify: verify
+ verify: verify,
+ depth: depth
})
}
}
@@ -133,12 +137,20 @@ function extendedparser (options) {
var parameterLimit = options.parameterLimit !== undefined
? options.parameterLimit
: 1000
+
+ var depth = typeof options.depth !== 'number'
+ ? Number(options.depth || 32)
+ : options.depth
var parse = parser('qs')

if (isNaN(parameterLimit) || parameterLimit < 1) {
throw new TypeError('option parameterLimit must be a positive number')
}

+ if(isNaN(depth) || depth < 0) {
+ throw new TypeError('option depth must be a zero or a positive number')
+ }
+
if (isFinite(parameterLimit)) {
parameterLimit = parameterLimit | 0
}
@@ -156,12 +168,23 @@ function extendedparser (options) {
var arrayLimit = Math.max(100, paramCount)

debug('parse extended urlencoding')
- return parse(body, {
- allowPrototypes: true,
- arrayLimit: arrayLimit,
- depth: Infinity,
- parameterLimit: parameterLimit
- })
+ try {
+ return parse(body, {
+ allowPrototypes: true,
+ arrayLimit: arrayLimit,
+ depth: depth,
+ strictDepth: true,
+ parameterLimit: parameterLimit
+ })
+ } catch (err) {
+ if (err instanceof RangeError) {
+ throw createError(400, 'The input exceeded the depth', {
+ type: 'querystring.parse.rangeError'
+ })
+ } else {
+ throw err
+ }
+ }
}
}

--
2.39.4

0 comments on commit a9c15a1

Please sign in to comment.