-
Notifications
You must be signed in to change notification settings - Fork 672
Security T1330839 - DevExtreme(devextreme-dist@26.1.3) - Potential Prototype Pollution (CWE-1321) #34091
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
dmlvr
wants to merge
10
commits into
DevExpress:26_1
Choose a base branch
from
dmlvr:26_1_T1330839
base: 26_1
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+139
−0
Open
Security T1330839 - DevExtreme(devextreme-dist@26.1.3) - Potential Prototype Pollution (CWE-1321) #34091
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
565b2a2
prevent prototype pollution via unsafe path
dmlvr 9239cd3
fix by copilot's review
dmlvr bfbe0b7
Merge branch '26_1' into 26_1_T1330839
dmlvr fcee1db
remove extre unsafe checking
dmlvr ee4429b
Merge branch '26_1_T1330839' of github.com:dmlvr/DevExtreme into 26_1…
dmlvr 36866cb
fix by Copilot's review
dmlvr 1ab7b73
refactoring
dmlvr 82503a3
fix by review
dmlvr bd4eaa1
error - updating text and call
dmlvr 065affc
update tests for new error calling
dmlvr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,7 @@ import { | |
| compileGetter as GETTER, | ||
| compileSetter as SETTER | ||
| } from 'core/utils/data'; | ||
| import errors from 'core/errors'; | ||
| import variableWrapper from 'core/utils/variable_wrapper'; | ||
|
|
||
| const mockVariableWrapper = { | ||
|
|
@@ -480,6 +481,119 @@ QUnit.module('setter', () => { | |
| }); | ||
|
|
||
|
|
||
| QUnit.module('prototype pollution protection', { | ||
| beforeEach: function() { | ||
| sinon.spy(errors, 'log'); | ||
| }, | ||
| afterEach: function() { | ||
| errors.log.restore(); | ||
| delete Object.prototype['pp_dx']; | ||
| delete Object.prototype['pp_dx2']; | ||
| } | ||
| }, () => { | ||
|
|
||
| test('compileSetter logs error and skips assignment for __proto__ path fragment (T1330839)', function(assert) { | ||
| const obj = {}; | ||
| SETTER('__proto__.pp_dx')(obj, 'yes', { functionsAsIs: true }); | ||
|
|
||
| assert.strictEqual(errors.log.calledWith('E0123', 'compileSetter', '__proto__'), true, 'should log E0123 for __proto__'); | ||
| assert.strictEqual(obj.pp_dx, undefined, 'target object must not be modified'); | ||
| assert.strictEqual(({}).pp_dx, undefined, 'Object.prototype must not be polluted'); | ||
| }); | ||
|
|
||
| test('compileSetter logs error and skips assignment for constructor path fragment (T1330839)', function(assert) { | ||
| const obj = {}; | ||
| SETTER('constructor.prototype.pp_dx')(obj, 'yes', { functionsAsIs: true }); | ||
|
|
||
| assert.strictEqual(errors.log.calledWith('E0123', 'compileSetter', 'constructor'), true, 'should log E0123 for constructor'); | ||
| assert.strictEqual(obj.pp_dx, undefined, 'target object must not be modified'); | ||
| assert.strictEqual(({}).pp_dx, undefined, 'Object.prototype must not be polluted'); | ||
| }); | ||
|
|
||
| test('compileSetter logs error and skips assignment for prototype path fragment (T1330839)', function(assert) { | ||
| const fn = function() {}; | ||
| SETTER('prototype.pp_dx')(fn, 'yes', { functionsAsIs: true }); | ||
|
|
||
| assert.strictEqual(errors.log.calledWith('E0123', 'compileSetter', 'prototype'), true, 'should log E0123 for prototype'); | ||
| assert.strictEqual(fn.pp_dx, undefined, 'function object must not be modified'); | ||
| assert.strictEqual(fn.prototype.pp_dx, undefined, 'function prototype must not be modified'); | ||
| }); | ||
|
|
||
| test('compileSetter works normally for safe paths (T1330839)', function(assert) { | ||
| const obj = { a: { b: 1 } }; | ||
| SETTER('a.b')(obj, 42); | ||
|
|
||
| assert.strictEqual(obj.a.b, 42, 'safe paths must still work'); | ||
| assert.strictEqual(errors.log.called, false, 'should not log for safe paths'); | ||
| }); | ||
|
|
||
| test('compileSetter blocks unsafe fragment written in bracket notation (T1330839)', function(assert) { | ||
| const obj = {}; | ||
| SETTER('a[constructor][prototype].pp_dx')(obj, 'yes', { functionsAsIs: true }); | ||
|
|
||
| assert.strictEqual(errors.log.calledWith('E0123', 'compileSetter', 'constructor'), true, 'should log E0123 for constructor in bracket notation'); | ||
| assert.strictEqual(({}).pp_dx, undefined, 'Object.prototype must not be polluted'); | ||
| }); | ||
|
|
||
| test('compileSetter blocks unsafe fragment in non-first position (T1330839)', function(assert) { | ||
| const obj = { a: { b: {} } }; | ||
| SETTER('a.b.__proto__')(obj, { pp_dx: 'yes' }, { functionsAsIs: true }); | ||
|
|
||
| assert.strictEqual(errors.log.calledWith('E0123', 'compileSetter', '__proto__'), true, 'should log E0123 for __proto__ in non-first position'); | ||
| assert.strictEqual(obj.a.b.pp_dx, undefined, 'nested object must not inherit a polluted property'); | ||
| assert.strictEqual(({}).pp_dx, undefined, 'Object.prototype must not be polluted'); | ||
| }); | ||
|
|
||
| test('compileGetter logs error and returns undefined for __proto__ path fragent (T1330839)', function(assert) { | ||
| const result = GETTER('__proto__.pp_dx')({}); | ||
|
|
||
| assert.strictEqual(errors.log.calledWith('E0123', 'compileGetter', '__proto__'), true, 'should log E0123 for __proto__'); | ||
| assert.strictEqual(result, undefined, 'getter must return undefined for __proto__'); | ||
| }); | ||
|
|
||
| test('compileGetter logs error and returns undefined for constructor path fragment (T1330839)', function(assert) { | ||
| const result = GETTER('constructor.prototype')(function() {}); | ||
|
|
||
| assert.strictEqual(errors.log.calledWith('E0123', 'compileGetter', 'constructor'), true, 'should log E0123 for constructor'); | ||
| assert.strictEqual(result, undefined, 'getter must return undefined for constructor'); | ||
| }); | ||
|
|
||
| test('compileGetter logs error and returns undefined for prototype path fragment (T1330839)', function(assert) { | ||
| const result = GETTER('prototype.pp_dx')(function() {}); | ||
|
|
||
| assert.strictEqual(errors.log.calledWith('E0123', 'compileGetter', 'prototype'), true, 'should log E0123 for prototype'); | ||
| assert.strictEqual(result, undefined, 'getter must return undefined for prototype'); | ||
| }); | ||
|
|
||
| test('combineGetters logs error and skips __proto__ fragment, returns safe fields (T1330839)', function(assert) { | ||
| const obj = { safe: 'value' }; | ||
| const result = GETTER(['__proto__.pp_dx', 'safe'])(obj); | ||
|
|
||
| assert.strictEqual(errors.log.calledWith('E0123', 'compileGetter', '__proto__'), true, 'should log E0123 for __proto__'); | ||
| assert.strictEqual(({}).pp_dx, undefined, 'Object.prototype must not be polluted'); | ||
| assert.deepEqual(result, { safe: 'value' }, 'safe field must still be returned'); | ||
| }); | ||
|
|
||
| test('combineGetters logs error and skips constructor fragment, returns safe fields (T1330839)', function(assert) { | ||
| const obj = { safe: 'value' }; | ||
| const result = GETTER(['constructor.prototype.pp_dx', 'safe'])(obj); | ||
|
|
||
| assert.strictEqual(errors.log.calledWith('E0123', 'compileGetter', 'constructor'), true, 'should log E0123 for constructor'); | ||
| assert.strictEqual(({}).pp_dx, undefined, 'Object.prototype must not be polluted'); | ||
| assert.deepEqual(result, { safe: 'value' }, 'safe field must still be returned'); | ||
| }); | ||
|
|
||
| test('combineGetters logs error and skips unsafe paths even if intermediate values break early (with defaultValue) (T1330839)', function(assert) { | ||
| const obj = { a: null, safe: 'value' }; | ||
| const result = GETTER(['a.constructor.prototype.pp_dx2', 'safe'])(obj, { defaultValue: 'default' }); | ||
|
|
||
| assert.strictEqual(errors.log.calledWith('E0123', 'compileGetter', 'constructor'), true, 'should log E0123 for constructor'); | ||
| assert.strictEqual(({}).pp_dx2, undefined, 'Object.prototype must not be polluted'); | ||
| assert.deepEqual(result, { safe: 'value' }, 'safe field must still be returned'); | ||
| }); | ||
| }); | ||
|
|
||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. added |
||
|
|
||
| QUnit.module('setter with wrapped variables', { | ||
| beforeEach: function() { | ||
| variableWrapper.inject(mockVariableWrapper); | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
}
return function (obj, options) {
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated