File tree Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change 7878 "why-is-node-running" : " ^3.2.2"
7979 },
8080 "dependencies" : {
81- "@fastify/reply-from" : " ^12.4 .0" ,
81+ "@fastify/reply-from" : " ^12.5 .0" ,
8282 "fast-querystring" : " ^1.1.2" ,
8383 "fastify-plugin" : " ^5.1.0" ,
8484 "ws" : " ^8.18.3"
Original file line number Diff line number Diff line change @@ -846,6 +846,27 @@ async function run () {
846846 t . assert . strictEqual ( body , `this is "variable-api" endpoint with id 123 and query params ${ queryParams } ` )
847847 } )
848848
849+ test ( 'check against traversal attempts' , async t => {
850+ const server = Fastify ( )
851+ server . register ( proxy , {
852+ upstream : `http://localhost:${ origin . server . address ( ) . port } /bar/` ,
853+ preHandler ( _ , reply ) {
854+ reply . from ( '/foo/%2E%2E/bar' )
855+ }
856+ } )
857+
858+ await server . listen ( { port : 0 } )
859+ t . after ( ( ) => server . close ( ) )
860+
861+ {
862+ const response = await fetch ( `http://localhost:${ server . server . address ( ) . port } /%2e%2e` )
863+ t . assert . strictEqual ( response . status , 400 )
864+ const text = await response . json ( )
865+ t . assert . strictEqual ( text . error , 'Bad Request' )
866+ t . assert . strictEqual ( text . message , 'source/request contain invalid characters' )
867+ }
868+ } )
869+
849870 test ( 'manual from call via fromParameters' , async t => {
850871 const server = Fastify ( )
851872 server . register ( proxy , {
You can’t perform that action at this time.
0 commit comments