@@ -138,6 +138,71 @@ describe('Vulnerabilities', () => {
138138 ) ;
139139 } ) ;
140140
141+ it ( 'denies creating global config with polluted data' , async ( ) => {
142+ const headers = {
143+ 'Content-Type' : 'application/json' ,
144+ 'X-Parse-Application-Id' : 'test' ,
145+ 'X-Parse-Master-Key' : 'test' ,
146+ } ;
147+ const params = {
148+ method : 'PUT' ,
149+ url : 'http://localhost:8378/1/config' ,
150+ json : true ,
151+ body : {
152+ params : {
153+ welcomeMesssage : 'Welcome to Parse' ,
154+ foo : { _bsontype : 'Code' , code : 'shell' } ,
155+ } ,
156+ } ,
157+ headers,
158+ } ;
159+ const response = await request ( params ) . catch ( e => e ) ;
160+ expect ( response . status ) . toBe ( 400 ) ;
161+ const text = JSON . parse ( response . text ) ;
162+ expect ( text . code ) . toBe ( Parse . Error . INVALID_KEY_NAME ) ;
163+ expect ( text . error ) . toBe (
164+ 'Prohibited keyword in request data: {"key":"_bsontype","value":"Code"}.'
165+ ) ;
166+ } ) ;
167+
168+ it ( 'denies direct database write wih prohibited keys' , async ( ) => {
169+ const Config = require ( '../lib/Config' ) ;
170+ const config = Config . get ( Parse . applicationId ) ;
171+ const user = {
172+ objectId : '1234567890' ,
173+ username : 'hello' ,
174+ password : 'pass' ,
175+ _session_token : 'abc' ,
176+ foo : { _bsontype : 'Code' , code : 'shell' } ,
177+ } ;
178+ await expectAsync ( config . database . create ( '_User' , user ) ) . toBeRejectedWith (
179+ new Parse . Error (
180+ Parse . Error . INVALID_KEY_NAME ,
181+ 'Prohibited keyword in request data: {"key":"_bsontype","value":"Code"}.'
182+ )
183+ ) ;
184+ } ) ;
185+
186+ it ( 'denies direct database update wih prohibited keys' , async ( ) => {
187+ const Config = require ( '../lib/Config' ) ;
188+ const config = Config . get ( Parse . applicationId ) ;
189+ const user = {
190+ objectId : '1234567890' ,
191+ username : 'hello' ,
192+ password : 'pass' ,
193+ _session_token : 'abc' ,
194+ foo : { _bsontype : 'Code' , code : 'shell' } ,
195+ } ;
196+ await expectAsync (
197+ config . database . update ( '_User' , { _id : user . objectId } , user )
198+ ) . toBeRejectedWith (
199+ new Parse . Error (
200+ Parse . Error . INVALID_KEY_NAME ,
201+ 'Prohibited keyword in request data: {"key":"_bsontype","value":"Code"}.'
202+ )
203+ ) ;
204+ } ) ;
205+
141206 it ( 'denies creating a hook with polluted data' , async ( ) => {
142207 const express = require ( 'express' ) ;
143208 const bodyParser = require ( 'body-parser' ) ;
0 commit comments