File tree Expand file tree Collapse file tree 3 files changed +21
-1
lines changed Expand file tree Collapse file tree 3 files changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,10 @@ Unreleased
10
10
* Add ` base ` arg to
11
11
[ ` int ` filter] ( https://mozilla.github.io/nunjucks/templating.html#int ) .
12
12
* Move ` chokidar ` to ` peerDependencies ` and mark it ` optional ` in ` peerDependenciesMeta ` .
13
+ * Fix prototype pollution issue for template variables. Merge of
14
+ [ #1330 ] ( https://github.com/mozilla/nunjucks/pull/1330 ) ; fixes
15
+ [ #1331 ] ( https://github.com/mozilla/nunjucks/issues/1331 ) . Thanks
16
+ [ ChenKS12138] ( https://github.com/ChenKS12138 ) !
13
17
14
18
3.2.2 (Jul 20 2020)
15
19
-------------------
Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ var supportsIterators = (
12
12
// variables, for example.
13
13
class Frame {
14
14
constructor ( parent , isolateWrites ) {
15
- this . variables = { } ;
15
+ this . variables = Object . create ( null ) ;
16
16
this . parent = parent ;
17
17
this . topLevel = false ;
18
18
// if this is true, writes (set) should never propagate upwards past
Original file line number Diff line number Diff line change 110
110
111
111
finish ( done ) ;
112
112
} ) ;
113
+
114
+ it ( 'should not read variables property from Object.prototype' , function ( done ) {
115
+ var payload = 'function(){ return 1+2; }()' ;
116
+ var data = { } ;
117
+ Object . getPrototypeOf ( data ) . payload = payload ;
118
+
119
+ render ( '{{ payload }}' , data , {
120
+ noThrow : true
121
+ } , function ( err , res ) {
122
+ expect ( err ) . to . equal ( null ) ;
123
+ expect ( res ) . to . equal ( payload ) ;
124
+ } ) ;
125
+ delete Object . getPrototypeOf ( data ) . payload ;
126
+
127
+ finish ( done ) ;
128
+ } ) ;
113
129
} ) ;
114
130
} ( ) ) ;
You can’t perform that action at this time.
0 commit comments