Skip to content

Add bad code#81

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

Add bad code#81
snyk-rfrazier wants to merge 2 commits into
mainfrom
add_bc

Conversation

@snyk-rfrazier

Copy link
Copy Markdown
Owner

No description provided.

@snyk-rfrazier

snyk-rfrazier commented Jan 14, 2026

Copy link
Copy Markdown
Owner Author

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

Status Scan Engine 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)


Commands
  • ⚡ To see AI-powered Snyk Agent Fix suggestions, reply with: @snyk /fix. You'll need to refresh the page 🔄

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