File tree Expand file tree Collapse file tree 2 files changed +5
-7
lines changed
javascript/ql/src/Security/CWE-918/examples Expand file tree Collapse file tree 2 files changed +5
-7
lines changed Original file line number Diff line number Diff line change 11import http from 'http' ;
2- import url from 'url' ;
32
4- var server = http . createServer ( function ( req , res ) {
5- var target = url . parse ( req . url , true ) . query . target ;
3+ const server = http . createServer ( function ( req , res ) {
4+ const target = new URL ( req . url , "http://example.com" ) . searchParams . get ( " target" ) ;
65
76 // BAD: `target` is controlled by the attacker
87 http . get ( 'https://' + target + ".example.com/data/" , res => {
Original file line number Diff line number Diff line change 11import http from 'http' ;
2- import url from 'url' ;
32
4- var server = http . createServer ( function ( req , res ) {
5- var target = url . parse ( req . url , true ) . query . target ;
3+ const server = http . createServer ( function ( req , res ) {
4+ const target = new URL ( req . url , "http://example.com" ) . searchParams . get ( " target" ) ;
65
7- var subdomain ;
6+ let subdomain ;
87 if ( target === 'EU' ) {
98 subdomain = "europe"
109 } else {
You can’t perform that action at this time.
0 commit comments