Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
"why-is-node-running": "^3.2.2"
},
"dependencies": {
"@fastify/reply-from": "^12.4.0",
"@fastify/reply-from": "^12.5.0",
"fast-querystring": "^1.1.2",
"fastify-plugin": "^5.1.0",
"ws": "^8.18.3"
Expand Down
21 changes: 21 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -846,6 +846,27 @@ async function run () {
t.assert.strictEqual(body, `this is "variable-api" endpoint with id 123 and query params ${queryParams}`)
})

test('check against traversal attempts', async t => {
const server = Fastify()
server.register(proxy, {
upstream: `http://localhost:${origin.server.address().port}/bar/`,
preHandler (_, reply) {
reply.from('/foo/%2E%2E/bar')
}
})

await server.listen({ port: 0 })
t.after(() => server.close())

{
const response = await fetch(`http://localhost:${server.server.address().port}/%2e%2e`)
t.assert.strictEqual(response.status, 400)
const text = await response.json()
t.assert.strictEqual(text.error, 'Bad Request')
t.assert.strictEqual(text.message, 'source/request contain invalid characters')
}
})

test('manual from call via fromParameters', async t => {
const server = Fastify()
server.register(proxy, {
Expand Down
Loading