Skip to content

adding bad code#73

Open
snyk-rfrazier wants to merge 2 commits into
mainfrom
bad_code_20250903
Open

adding bad code#73
snyk-rfrazier wants to merge 2 commits into
mainfrom
bad_code_20250903

Conversation

@snyk-rfrazier

Copy link
Copy Markdown
Owner

No description provided.

@snyk-rfrazier

snyk-rfrazier commented Sep 3, 2025

Copy link
Copy Markdown
Owner Author

Snyk checks have failed. 2 issues have been found so far.

Status Scanner Critical High Medium Low Total (2)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues
Code Security 0 1 1 0 2 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

Comment thread routes/index.js
Comment thread routes/index.js
Comment thread routes/index.js
Comment thread routes/index.js
Comment thread routes/index.js
Comment thread routes/index.js
Comment thread routes/index.js
Comment thread routes/index.js

exports.loginHandler = function (req, res, next) {
if (validator.isEmail(req.body.username)) {
User.find({ username: req.body.username, password: req.body.password }, function (err, users) {

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  NoSQL Injection

Unsanitized input from the HTTP request body flows into find, where it is used in an NoSQL query. This may result in an NoSQL Injection vulnerability.

Line 39 | CWE-943 | Priority score 807 | Learn more about this vulnerability
Data flow: 7 steps

Step 1 - 4

if (validator.isEmail(req.body.username)) {

Step 5 - 7

User.find({ username: req.body.username, password: req.body.password }, function (err, users) {

Comment thread routes/index.js
console.log(`User logged in: ${username}`)

if (redirectPage) {
return res.redirect(redirectPage)

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  Open Redirect

Unsanitized input from the HTTP request body flows into redirect, where it is used as input for request redirection. This may result in an Open Redirect vulnerability.

Line 61 | CWE-601 | Priority score 557 | Learn more about this vulnerability
Data flow: 9 steps

Step 1 - 5

const redirectPage = req.body.redirectPage

Step 6 routes/index.js#L44

Step 7 routes/index.js#L54

Step 8 - 9

return res.redirect(redirectPage)

⚡ Fix this issue by replying with the following command: @snyk /fix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants