Skip to content

Commit 7119ab3

Browse files
committed
lodash prototype vuln
1 parent 2a1b6b1 commit 7119ab3

File tree

3 files changed

+38
-0
lines changed

3 files changed

+38
-0
lines changed

package-lock.json

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"dotenv": "^8.2.0",
2222
"express": "^4.17.1",
2323
"faker": "^4.1.0",
24+
"lodash": "^4.17.11",
2425
"mongodb": "^3.5.6",
2526
"mysql": "^2.18.1",
2627
"request": "^2.88.2"

vulnerabilities/dep-lodash.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
const express = require('express');
2+
const router = express.Router()
3+
4+
const lodash = require('lodash');
5+
6+
//if req.body.config == '{"constructor": {"prototype": {"isAdmin": true}}}' it will bypass the authentication
7+
function check(req, res) {
8+
9+
let config = {};
10+
lodash.defaultsDeep(config, JSON.parse(req.body.config));
11+
12+
let user = getCurrentUser();
13+
if(!user){
14+
user = {};
15+
}
16+
17+
if (user.isAdmin && user.isAdmin === true) {
18+
res.send('Welcome Admin')
19+
}else{
20+
res.send('Welcome User')
21+
}
22+
}
23+
24+
//fake function that get current user from session or db
25+
function getCurrentUser(){
26+
return false;
27+
}
28+
29+
30+
router.post('/check-user',check)
31+
32+
module.exports = router

0 commit comments

Comments
 (0)