Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions routes/login.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { challenges, users } from '../data/datacache'
import { BasketModel } from '../models/basket'
import * as security from '../lib/insecurity'
import { UserModel } from '../models/user'
import * as models from '../models/index'
import { type User } from '../data/types'
import * as utils from '../lib/utils'

Expand All @@ -31,7 +30,7 @@ export function login () {

return (req: Request, res: Response, next: NextFunction) => {
verifyPreLoginChallenges(req) // vuln-code-snippet hide-line
models.sequelize.query(`SELECT * FROM Users WHERE email = '${req.body.email || ''}' AND password = '${security.hash(req.body.password || '')}' AND deletedAt IS NULL`, { model: UserModel, plain: true }) // vuln-code-snippet vuln-line loginAdminChallenge loginBenderChallenge loginJimChallenge
UserModel.findOne({ where: { email: req.body.email || '', password: security.hash(req.body.password || '') } })
.then((authenticatedUser) => { // vuln-code-snippet neutral-line loginAdminChallenge loginBenderChallenge loginJimChallenge
const user = utils.queryResultToJson(authenticatedUser)
if (user.data?.id && user.data.totpSecret !== '') {
Expand Down
2 changes: 1 addition & 1 deletion routes/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export function searchProducts () {
return (req: Request, res: Response, next: NextFunction) => {
let criteria: any = req.query.q === 'undefined' ? '' : req.query.q ?? ''
criteria = (criteria.length <= 200) ? criteria : criteria.substring(0, 200)
models.sequelize.query(`SELECT * FROM Products WHERE ((name LIKE '%${criteria}%' OR description LIKE '%${criteria}%') AND deletedAt IS NULL) ORDER BY name`) // vuln-code-snippet vuln-line unionSqlInjectionChallenge dbSchemaChallenge
models.sequelize.query('SELECT * FROM Products WHERE ((name LIKE :criteria OR description LIKE :criteria) AND deletedAt IS NULL) ORDER BY name', { replacements: { criteria: `%${criteria}%` } }) // vuln-code-snippet vuln-line unionSqlInjectionChallenge dbSchemaChallenge
.then(([products]: any) => {
const dataString = JSON.stringify(products)
if (challengeUtils.notSolved(challenges.unionSqlInjectionChallenge)) { // vuln-code-snippet hide-start
Expand Down
15 changes: 1 addition & 14 deletions routes/userProfile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,20 +51,7 @@ export function getUserProfile () {

let username = user.username

if (username?.match(/#{(.*)}/) !== null && utils.isChallengeEnabled(challenges.usernameXssChallenge)) {
req.app.locals.abused_ssti_bug = true
const code = username?.substring(2, username.length - 1)
try {
if (!code) {
throw new Error('Username is null')
}
username = eval(code) // eslint-disable-line no-eval
} catch (err) {
username = '\\' + username
}
} else {
username = '\\' + username
}
username = '\\' + username

const themeKey = config.get<string>('application.theme') as keyof typeof themes
const theme = themes[themeKey] || themes['bluegrey-lightgreen']
Expand Down