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 1
1
import http from 'http' ;
2
- import url from 'url' ;
3
2
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" ) ;
6
5
7
6
// BAD: `target` is controlled by the attacker
8
7
http . get ( 'https://' + target + ".example.com/data/" , res => {
Original file line number Diff line number Diff line change 1
1
import http from 'http' ;
2
- import url from 'url' ;
3
2
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" ) ;
6
5
7
- var subdomain ;
6
+ let subdomain ;
8
7
if ( target === 'EU' ) {
9
8
subdomain = "europe"
10
9
} else {
You can’t perform that action at this time.
0 commit comments