Skip to content

Commit 597599e

Browse files
committed
fix(error-response-plugin): percentage-encode path < and > to limit XSS
1 parent e7ae009 commit 597599e

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/plugins/default/error-response-plugin.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,12 @@ export const errorResponsePlugin: Plugin = (proxyServer, options) => {
2525
res.writeHead(statusCode);
2626
}
2727

28+
const encodedPath = req.url
29+
.replace(/</g, '%3C')
30+
.replace(/>/g, '%3E');
31+
2832
const host = req.headers && req.headers.host;
29-
res.end(`Error occurred while trying to proxy: ${host}${req.url}`);
33+
res.end(`Error occurred while trying to proxy: ${host}${encodedPath}`);
3034
} else if (isSocketLike(res)) {
3135
res.destroy();
3236
}

0 commit comments

Comments
 (0)