Skip to content

Commit bff084f

Browse files
JeanMecheatscott
authored andcommitted
refactor(core): harden change store access
This prevents any attack through prototype polution.
1 parent 7d92cc8 commit bff084f

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

packages/core/src/render3/features/ng_onchanges_feature.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88

99
import {InputSignalNode} from '../../authoring/input/input_signal_node';
1010
import {OnChanges} from '../../change_detection/lifecycle_hooks';
11+
import {SimpleChange, SimpleChanges} from '../../change_detection/simple_change';
1112
import {assertString} from '../../util/assert';
1213
import {EMPTY_OBJ} from '../../util/empty';
1314
import {applyValueToInputField} from '../apply_value_input_field';
1415
import {DirectiveDef, DirectiveDefFeature} from '../interfaces/definition';
15-
import {SimpleChange, SimpleChanges} from '../../change_detection/simple_change';
1616

1717
/**
1818
* The NgOnChangesFeature decorates a component with support for the ngOnChanges
@@ -112,7 +112,9 @@ function ngOnChangesSetInput<T>(
112112
const SIMPLE_CHANGES_STORE = '__ngSimpleChanges__';
113113

114114
function getSimpleChangesStore(instance: any): null | NgSimpleChangesStore {
115-
return instance[SIMPLE_CHANGES_STORE] || null;
115+
return Object.hasOwn(instance, SIMPLE_CHANGES_STORE)
116+
? instance[SIMPLE_CHANGES_STORE] || null
117+
: null;
116118
}
117119

118120
function setSimpleChangesStore(instance: any, store: NgSimpleChangesStore): NgSimpleChangesStore {

0 commit comments

Comments
 (0)