Skip to content
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

Hardening suggestions for juice-shop / pixeebot/drip-2024-07-31-codeql-javascript/llm-nosql-code-injection #7

Open
wants to merge 1 commit into
base: pixeebot/drip-2024-07-31-codeql-javascript/llm-nosql-code-injection
Choose a base branch
from
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
2 changes: 1 addition & 1 deletion routes/showProductReviews.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ module.exports = function productReviews () {

// Measure how long the query takes, to check if there was a nosql dos attack
const t0 = new Date().getTime()
db.reviews.find({ $expr: { $eq: ['$product', id] } }).then((reviews: Review[]) => {
db.reviews.find({ product: id }).then((reviews: Review[]) => {
const t1 = new Date().getTime()
challengeUtils.solveIf(challenges.noSqlCommandChallenge, () => { return (t1 - t0) > 2000 })
const user = security.authenticatedUsers.from(req)
Expand Down
2 changes: 1 addition & 1 deletion routes/trackOrder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ module.exports = function trackOrder () {
const id = utils.disableOnContainerEnv() ? String(req.params.id).replace(/[^\w-]+/g, '') : req.params.id

challengeUtils.solveIf(challenges.reflectedXssChallenge, () => { return utils.contains(id, '<iframe src="javascript:alert(`xss`)">') })
db.orders.find({ $expr: { $eq: ['$orderId', id] } }).then((order: any) => {
db.orders.find({ orderId: id }).then((order: any) => {
const result = utils.queryResultToJson(order)
challengeUtils.solveIf(challenges.noSqlOrdersChallenge, () => { return result.data.length > 1 })
if (result.data[0] === undefined) {
Expand Down
Loading