Skip to content

Commit caec9f2

Browse files
committed
redirects, template injection
1 parent ed51b0e commit caec9f2

File tree

8 files changed

+45
-2
lines changed

8 files changed

+45
-2
lines changed

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,13 @@
11
# crazy-vulnerable-nodejs-application
22
CVNA
3+
4+
5+
[ ] Command Injection
6+
[ ] Loop Bound Injection
7+
[ ] NoSQLI
8+
[ ] Unsafe Redirects
9+
[ ] ReDoS
10+
[ ] SQLI
11+
[ ] SSRF
12+
[ ] XSS
13+
[ ] XXE

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const bodyParser = require('body-parser');
44
const app = express()
55
const port = 3000
66

7-
7+
app.set('view engine', 'ejs'); //for template injection
88
app.use(bodyParser.json());
99

1010
app.get('/', (req, res) => res.send('Hello World!'))

views/index.ejs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<!-- partials/header.ejs -->
2+
3+
Application home

views/partials/header.ejs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<% if (user_name) { %>
2+
<h2>Hello <%- user_name %></h2>
3+
<% } %>

vulnerabilities/exec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const { exec, spawn } = require('child_process');
55

66

77
router.post('/ping', (req,res) => {
8-
exec(`${req.body.url}`, (error, stdout, stderr) => {
8+
exec(`${req.body.url}`, (error) => {
99
if (error) {
1010
return res.send('error');
1111
}

vulnerabilities/redirect.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
2+
const express = require('express');
3+
const router = express.Router()
4+
5+
router.get('/login',function(req, res){
6+
let followPath = req.query.path;
7+
if(req.session.isAuthenticated()){
8+
res.redirect('http://example.com/'+followPath); //false positive
9+
}else{
10+
res.redirect('/');
11+
}
12+
});
13+
14+
router.get('/goto',function(req, res){
15+
let url = encodeURI(req.query.url); //vulnerability
16+
res.redirect(url);
17+
});
18+
19+
20+
module.exports = router

vulnerabilities/template-injection.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
WIP

vulnerabilities/xss.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,9 @@ router.get('/greeting', (req, res) => {
66
res.send('<h1> Hello :'+ name +"</h1>")
77
})
88

9+
router.get('/greet-template', (req,res) => {
10+
name = req.query.name
11+
res.render('index', { user_name: name});
12+
})
13+
914
module.exports = router

0 commit comments

Comments
 (0)