Skip to content

Commit

Permalink
fix: Added smaller-than-null check for __depth hardening code
Browse files Browse the repository at this point in the history
  • Loading branch information
cure53 committed May 8, 2024
1 parent 1e52026 commit b20ce99
Show file tree
Hide file tree
Showing 9 changed files with 13 additions and 11 deletions.
4 changes: 2 additions & 2 deletions dist/purify.cjs.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/purify.cjs.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/purify.es.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -1312,7 +1312,7 @@ function createDOMPurify() {
* Remove an element if nested too deeply to avoid mXSS
* or if the __depth might have been tampered with
*/
if (shadowNode.__depth >= MAX_NESTING_DEPTH || numberIsNaN(shadowNode.__depth)) {
if (shadowNode.__depth >= MAX_NESTING_DEPTH || shadowNode.__depth < 0 || numberIsNaN(shadowNode.__depth)) {
_forceRemove(shadowNode);
}

Expand Down Expand Up @@ -1453,7 +1453,7 @@ function createDOMPurify() {
* Remove an element if nested too deeply to avoid mXSS
* or if the __depth might have been tampered with
*/
if (currentNode.__depth >= MAX_NESTING_DEPTH || numberIsNaN(currentNode.__depth)) {
if (currentNode.__depth >= MAX_NESTING_DEPTH || currentNode.__depth < 0 || numberIsNaN(currentNode.__depth)) {
_forceRemove(currentNode);
}

Expand Down
2 changes: 1 addition & 1 deletion dist/purify.es.mjs.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/purify.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/purify.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/purify.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/purify.min.js.map

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions src/purify.js
Original file line number Diff line number Diff line change
Expand Up @@ -1433,6 +1433,7 @@ function createDOMPurify(window = getGlobal()) {
*/
if (
shadowNode.__depth >= MAX_NESTING_DEPTH ||
shadowNode.__depth < 0 ||
numberIsNaN(shadowNode.__depth)
) {
_forceRemove(shadowNode);
Expand Down Expand Up @@ -1590,6 +1591,7 @@ function createDOMPurify(window = getGlobal()) {
*/
if (
currentNode.__depth >= MAX_NESTING_DEPTH ||
currentNode.__depth < 0 ||
numberIsNaN(currentNode.__depth)
) {
_forceRemove(currentNode);
Expand Down

0 comments on commit b20ce99

Please sign in to comment.