Skip to content

Commit 4557bca

Browse files
author
spencer
committed
add mocha tests
1 parent a51b2f9 commit 4557bca

File tree

7 files changed

+926
-34
lines changed

7 files changed

+926
-34
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
/.idea
12
/node_modules

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ and then run the following command in another terminal
1717
```
1818
curl --path-as-is 'http://127.0.0.1:8001/api/'
1919
```
20-
You can see the the code execution vulnerability are executed mutliple times.
20+
You can see the code execution vulnerability are executed mutliple times.
2121

2222

2323
## Vulnerability 2 Exploit

index.js

Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,6 @@
11
'use strict';
22

3-
const http = require('http'),
4-
algoserv = require('algo-httpserv'),
5-
fs = require('fs'),
6-
yaml = require('js-yaml'),
7-
yamlTo = require('to'),
8-
yamlConf = require('node-yaml-config');// the vunlerable library is include to check whether we have false postives
9-
10-
11-
///----------The following are the driver---------------------///
12-
13-
// call vulnerable method js-yaml.load directly
14-
// js-yaml.load is vulnerable to code execution in yaml file
15-
const data = yaml.load(fs.readFileSync('./data/yaml-exploit.yml', 'utf-8'));
16-
console.log(data);
17-
18-
// transitive vulnerable method,
19-
// the to lib uses js-yaml.load which is vulnerable
20-
const data2 = yamlTo.load('./data/yaml-exploit.yml');
21-
console.log(data2);
22-
23-
// pass the vulnerable method as a callback
24-
const server = http.createServer(algoserv.serve);
25-
26-
// pass an callback which calls vulnerable method
27-
algoserv.on('/api/', (request, response, url) => {
28-
response.writeHead(200, {'Content-Type': 'application/json'});
29-
const data3 = yaml.load(fs.readFileSync('./data/yaml-exploit.yml', 'utf-8'));
30-
console.log(data3);
31-
response.write(JSON.stringify(data3));
32-
response.end();
33-
});
34-
3+
const server = require('./server');
354
server.listen(8001);
365

376

0 commit comments

Comments
 (0)