-
Notifications
You must be signed in to change notification settings - Fork 0
add new endpoint function #15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
⛔ Snyk checks have failed. 3 issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
|
|
||
| // res.send(html); | ||
| // }); | ||
| res.send(html); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cross-site Scripting (XSS)
Unsanitized input from an HTTP parameter 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).
Line 27 | CWE-79 | Priority score 850 | Learn more about this vulnerability
Data flow: 14 steps
Step 1 - 7
nodejs-goof/routes/xss-vulnerable.js
Line 23 in f2f3e4e
| const userInput = req.query.input || 'No input provided'; |
Step 8 routes/xss-vulnerable.js#L25
Step 9 routes/xss-vulnerable.js#L30
Step 10 routes/xss-vulnerable.js#L39
Step 11 routes/xss-vulnerable.js#L31
Step 12 routes/xss-vulnerable.js#L25
Step 13 - 14
nodejs-goof/routes/xss-vulnerable.js
Line 27 in f2f3e4e
| res.send(html); |
Commands
- ⚡ To see AI-powered Snyk Agent Fix suggestions, reply with:
@snyk /fix. You'll need to refresh the page 🔄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@snyk /fix
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
⚡ Snyk Agent Fix suggestion 1 of 5
The original code snippet had a security vulnerability where user input for userInput was sent directly to the end-user without sanitization, potentially allowing for Cross-Site Scripting (XSS) attacks. The amended code changes the response Content-Type to text/plain, ensuring that the output is treated as plain text and not interpreted as HTML or JavaScript by the client. This simple change mitigates the risk of XSS by displaying user input as literal text rather than executable code. The processUserInput function is presumably where input sanitization would occur to prevent secure data from being displayed as hotlinked text, but this snippet doesn't include that logic. generated by AI
Code changes
--- routes/xss-vulnerable.js
+++ routes/xss-vulnerable.js
@@ -24,7 +24,7 @@
const html = processUserInput(userInput, res);
- res.send(html);
+ res.contentType('text/plain').send(html);
});
function processUserInput(userInput, res) {
Content generated by AI, expires on 2025-12-13 07:09:28 UTC. Refresh the page after running Snyk commands.
Commands
-
⏩ To see another AI-powered fix suggestion - reply with
@snyk /fix -
✅ To apply this fix and create a commit - reply with
@snyk /apply 1
No description provided.