Skip to content

Commit

Permalink
Improve security
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky committed Mar 20, 2022
1 parent fe89049 commit 3799749
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/config/normalize/lib/wild_wild_path/iterate/expand.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,23 @@ const expandToken = function ({ queryArray, value, path }, index, opts) {
const token = queryArray[index]
const missingReturn = handleMissingValue(value, token, opts.classes)
const childEntriesA = iterateToken(token, missingReturn, opts)
return childEntriesA.map(
({ value: childValue, prop, missing: missingEntry }) => ({
return childEntriesA
.filter(isAllowedProp)
.map(({ value: childValue, prop, missing: missingEntry }) => ({
queryArray,
value: childValue,
path: [...path, prop],
missing: missingReturn.missing || missingEntry,
}),
)
}))
}

const isAllowedProp = function ({ prop }) {
return !FORBIDDEN_PROPS.has(prop)
}

// Forbidden to avoid prototype pollution attacks
const FORBIDDEN_PROPS = new Set(['__proto__', 'prototype', 'constructor'])

const iterateToken = function (
token,
{ tokenType, missing: missingParent, value },
Expand Down

0 comments on commit 3799749

Please sign in to comment.