File tree 2 files changed +6
-7
lines changed
2 files changed +6
-7
lines changed Original file line number Diff line number Diff line change @@ -44,7 +44,9 @@ export default class SyncFetchScriptBuilder {
44
44
null ,
45
45
4
46
46
) } ;
47
- const request = sendRequest(\`${ request . url . href } \`, options, (incomingMessage) => {
47
+ const request = sendRequest(${ JSON . stringify (
48
+ request . url . href
49
+ ) } , options, (incomingMessage) => {
48
50
let data = Buffer.alloc(0);
49
51
incomingMessage.on('data', (chunk) => {
50
52
data = Buffer.concat([data, Buffer.from(chunk)]);
Original file line number Diff line number Diff line change @@ -252,8 +252,7 @@ describe('SyncFetch', () => {
252
252
it ( 'Should not allow to inject code into scripts executed using child_process.execFileSync().' , ( ) => {
253
253
browserFrame . url = 'https://localhost:8080/' ;
254
254
255
- const url =
256
- "https://localhost:8080/`+require('child_process').execSync('id')+`/'+require('child_process').execSync('id')+'" ;
255
+ const url = `https://localhost:8080/\`+require('child_process').execSync('id')+\`/'+require('child_process').execSync('id')+'/?key="+require('child_process').execSync('id')+"` ;
257
256
const responseText = 'test' ;
258
257
259
258
mockModule ( 'child_process' , {
@@ -267,7 +266,7 @@ describe('SyncFetch', () => {
267
266
expect ( args [ 1 ] ) . toBe (
268
267
SyncFetchScriptBuilder . getScript ( {
269
268
url : new URL (
270
- " https://localhost:8080/%60 +require('child_process').execSync('id')+%60 /'+require('child_process').execSync('id')+'"
269
+ ` https://localhost:8080/\` +require('child_process').execSync('id')+\` /'+require('child_process').execSync('id')+'/?key="+require('child_process').execSync('id')+"`
271
270
) ,
272
271
method : 'GET' ,
273
272
headers : {
@@ -280,11 +279,9 @@ describe('SyncFetch', () => {
280
279
body : null
281
280
} )
282
281
) ;
283
- // new URL() will convert ` into %60
284
- // By using ` for the URL string within the script, we can prevent the script from being injected
285
282
expect (
286
283
args [ 1 ] . includes (
287
- `\` https://localhost:8080/%60+require('child_process').execSync('id')+%60/'+require('child_process').execSync('id')+'\` `
284
+ `" https://localhost:8080/%60+require('child_process').execSync('id')+%60/'+require('child_process').execSync('id')+'/?key=%22+require(%27child_process%27).execSync(%27id%27)+%22" `
288
285
)
289
286
) . toBe ( true ) ;
290
287
expect ( options ) . toEqual ( {
You can’t perform that action at this time.
0 commit comments