I have an Express Request Handler that takes a request, which includes user form input (email
), makes a request to another one of my (trusted) endpoints (via newFunctionWithRequest
), and then returns data from that new response (newResponse
).
export const Handler = async (req: Request, res: Response, next: NextFunction) => {
const { newResponse } = await newFunctionWithRequest(req)
res.send(newResponse.data) // Snyk identifies this line as the problem
}
Snyk
has identified an XSS vulnerability
:
Unsanitized input from the HTTP request body flows into send, where it is used to render an HTML page returned to the user. This may result in a `Cross-Site Scripting attack (XSS)`
How can I fix this vulnerability?