Skip to content
Open
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
3 changes: 2 additions & 1 deletion src/node/routes/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ export const register = async (
// TODO: This does *NOT* work if you have a base path since to specify the
// protocol we need to specify the whole path.
if (args.cert && !(req.connection as tls.TLSSocket).encrypted) {
return res.redirect(`https://${req.headers.host}${req.originalUrl}`)
const host = String(req.headers.host || "").replace(/[^\w.\-:[\]]/g, "")
return res.redirect(`https://${host}${req.originalUrl}`)
}
next()
})
Expand Down
2 changes: 1 addition & 1 deletion src/node/routes/pathProxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const getProxyTarget = (
const base = (req as any).base || ""
// Cast since we only have one port param.
const port = parseInt(req.params.port as string, 10)
if (isNaN(port)) {
if (isNaN(port) || port < 1024 || port > 65535) {
throw new HttpError("Invalid port", HttpCode.BadRequest)
}
return `http://0.0.0.0:${port}${opts?.proxyBasePath || ""}/${req.originalUrl.slice(base.length)}`
Expand Down