Find, fix and prevent vulnerabilities in your code.
high severity
- Vulnerable module: rack
- Introduced through: rack-test@2.0.2 and sinatra@3.0.6
Detailed paths
-
Introduced through: borja/herocalf@borja/herocalf#844ec4ae68f237ca8f655fb538b1c20c1778c923 › rack-test@2.0.2 › rack@2.2.7Remediation: Upgrade to rack-test@2.0.2.
-
Introduced through: borja/herocalf@borja/herocalf#844ec4ae68f237ca8f655fb538b1c20c1778c923 › sinatra@3.0.6 › rack@2.2.7Remediation: Upgrade to sinatra@3.0.6.
-
Introduced through: borja/herocalf@borja/herocalf#844ec4ae68f237ca8f655fb538b1c20c1778c923 › sinatra@3.0.6 › rack-protection@3.0.6 › rack@2.2.7Remediation: Upgrade to sinatra@3.0.6.
Overview
rack is a minimal, modular and adaptable interface for developing web applications in Ruby. By wrapping HTTP requests and responses in the simplest way possible, it unifies and distills the API for web servers, web frameworks, and software in between (the so-called middleware) into a single method call.
Affected versions of this package are vulnerable to Relative Path Traversal in the can_serve()
function in Rack::Static
that enables local file inclusion. An attacker who knows the exact path to any file in the root:
file directory can access it by supplying a path traversing pathname.
Remediation
Upgrade rack
to version 2.2.13, 3.0.14, 3.1.12 or higher.
References
high severity
- Vulnerable module: rack
- Introduced through: rack-test@2.0.2 and sinatra@3.0.6
Detailed paths
-
Introduced through: borja/herocalf@borja/herocalf#844ec4ae68f237ca8f655fb538b1c20c1778c923 › rack-test@2.0.2 › rack@2.2.7Remediation: Upgrade to rack-test@2.0.2.
-
Introduced through: borja/herocalf@borja/herocalf#844ec4ae68f237ca8f655fb538b1c20c1778c923 › sinatra@3.0.6 › rack@2.2.7Remediation: Upgrade to sinatra@3.0.6.
-
Introduced through: borja/herocalf@borja/herocalf#844ec4ae68f237ca8f655fb538b1c20c1778c923 › sinatra@3.0.6 › rack-protection@3.0.6 › rack@2.2.7Remediation: Upgrade to sinatra@3.0.6.
Overview
rack is a minimal, modular and adaptable interface for developing web applications in Ruby. By wrapping HTTP requests and responses in the simplest way possible, it unifies and distills the API for web servers, web frameworks, and software in between (the so-called middleware) into a single method call.
Affected versions of this package are vulnerable to Denial of Service (DoS) in handling of the Range
request header. Carefully crafted Range
headers can cause a server to respond with an unexpectedly large response. This issue is present when the Rack::File
middleware or the Rack::Utils.byte_ranges
methods are used (which includes applications built with Rails).
Details
Denial of Service (DoS) describes a family of attacks, all aimed at making a system inaccessible to its intended and legitimate users.
Unlike other vulnerabilities, DoS attacks usually do not aim at breaching security. Rather, they are focused on making websites and services unavailable to genuine users resulting in downtime.
One popular Denial of Service vulnerability is DDoS (a Distributed Denial of Service), an attack that attempts to clog network pipes to the system by generating a large volume of traffic from many machines.
When it comes to open source libraries, DoS vulnerabilities allow attackers to trigger such a crash or crippling of the service by using a flaw either in the application code or from the use of open source libraries.
Two common types of DoS vulnerabilities:
High CPU/Memory Consumption- An attacker sending crafted requests that could cause the system to take a disproportionate amount of time to process. For example, commons-fileupload:commons-fileupload.
Crash - An attacker sending crafted requests that could cause the system to crash. For Example, npm
ws
package
Remediation
Upgrade rack
to version 2.2.8.1, 3.0.9.1 or higher.
References
high severity
- Vulnerable module: rack
- Introduced through: rack-test@2.0.2 and sinatra@3.0.6
Detailed paths
-
Introduced through: borja/herocalf@borja/herocalf#844ec4ae68f237ca8f655fb538b1c20c1778c923 › rack-test@2.0.2 › rack@2.2.7Remediation: Upgrade to rack-test@2.0.2.
-
Introduced through: borja/herocalf@borja/herocalf#844ec4ae68f237ca8f655fb538b1c20c1778c923 › sinatra@3.0.6 › rack@2.2.7Remediation: Upgrade to sinatra@3.0.6.
-
Introduced through: borja/herocalf@borja/herocalf#844ec4ae68f237ca8f655fb538b1c20c1778c923 › sinatra@3.0.6 › rack-protection@3.0.6 › rack@2.2.7Remediation: Upgrade to sinatra@3.0.6.
Overview
rack is a minimal, modular and adaptable interface for developing web applications in Ruby. By wrapping HTTP requests and responses in the simplest way possible, it unifies and distills the API for web servers, web frameworks, and software in between (the so-called middleware) into a single method call.
Affected versions of this package are vulnerable to Improper Output Neutralization for Logs through the Rack::CommonLogger
process. An attacker can manipulate log entries by crafting input that includes newline characters to insert fraudulent entries or obscure real activity.
Remediation
Upgrade rack
to version 2.2.11, 3.0.12, 3.1.10 or higher.
References
medium severity
- Vulnerable module: rack
- Introduced through: rack-test@2.0.2 and sinatra@3.0.6
Detailed paths
-
Introduced through: borja/herocalf@borja/herocalf#844ec4ae68f237ca8f655fb538b1c20c1778c923 › rack-test@2.0.2 › rack@2.2.7Remediation: Upgrade to rack-test@2.0.2.
-
Introduced through: borja/herocalf@borja/herocalf#844ec4ae68f237ca8f655fb538b1c20c1778c923 › sinatra@3.0.6 › rack@2.2.7Remediation: Upgrade to sinatra@3.0.6.
-
Introduced through: borja/herocalf@borja/herocalf#844ec4ae68f237ca8f655fb538b1c20c1778c923 › sinatra@3.0.6 › rack-protection@3.0.6 › rack@2.2.7Remediation: Upgrade to sinatra@3.0.6.
Overview
rack is a minimal, modular and adaptable interface for developing web applications in Ruby. By wrapping HTTP requests and responses in the simplest way possible, it unifies and distills the API for web servers, web frameworks, and software in between (the so-called middleware) into a single method call.
Affected versions of this package are vulnerable to Improper Output Neutralization for Logs in the Rack::Sendfile
middleware which logs values from the X-Sendfile-Type
header. An attacker can inject messages into logs by including escape sequences such as newline characters in sent headers.
Remediation
Upgrade rack
to version 2.2.12, 3.0.13, 3.1.11 or higher.
References
medium severity
- Vulnerable module: rack
- Introduced through: rack-test@2.0.2 and sinatra@3.0.6
Detailed paths
-
Introduced through: borja/herocalf@borja/herocalf#844ec4ae68f237ca8f655fb538b1c20c1778c923 › rack-test@2.0.2 › rack@2.2.7Remediation: Upgrade to rack-test@2.0.2.
-
Introduced through: borja/herocalf@borja/herocalf#844ec4ae68f237ca8f655fb538b1c20c1778c923 › sinatra@3.0.6 › rack@2.2.7Remediation: Upgrade to sinatra@4.0.0.
-
Introduced through: borja/herocalf@borja/herocalf#844ec4ae68f237ca8f655fb538b1c20c1778c923 › sinatra@3.0.6 › rack-protection@3.0.6 › rack@2.2.7Remediation: Upgrade to sinatra@3.0.6.
Overview
rack is a minimal, modular and adaptable interface for developing web applications in Ruby. By wrapping HTTP requests and responses in the simplest way possible, it unifies and distills the API for web servers, web frameworks, and software in between (the so-called middleware) into a single method call.
Affected versions of this package are vulnerable to Web Cache Poisoning by using a vector called parameter cloaking. When the attacker can separate query parameters using a semicolon (;), they can cause a difference in the interpretation of the request between the proxy (running with default configuration) and the server. This can result in malicious requests being cached as completely safe ones, as the proxy would usually not see the semicolon as a separator, and therefore would not include it in a cache key of an unkeyed parameter.
PoC
GET /?q=legitimate&utm_content=1;q=malicious HTTP/1.1
Host: somesite.com
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.83 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,imag e/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9 Accept-Encoding: gzip, deflate
Accept-Language: en-US,en;q=0.9 Connection: close
The server sees 3 parameters here: q
, utm_content
and then q
again. On the other hand, the proxy considers this full string: 1;q=malicious
as the value of utm_content
, which is why the cache key would only contain somesite.com/?q=legitimate
.
Remediation
Upgrade rack
to version 3.0.0.beta1 or higher.
References
medium severity
- Vulnerable module: rack
- Introduced through: rack-test@2.0.2 and sinatra@3.0.6
Detailed paths
-
Introduced through: borja/herocalf@borja/herocalf#844ec4ae68f237ca8f655fb538b1c20c1778c923 › rack-test@2.0.2 › rack@2.2.7Remediation: Upgrade to rack-test@2.0.2.
-
Introduced through: borja/herocalf@borja/herocalf#844ec4ae68f237ca8f655fb538b1c20c1778c923 › sinatra@3.0.6 › rack@2.2.7Remediation: Upgrade to sinatra@3.0.6.
-
Introduced through: borja/herocalf@borja/herocalf#844ec4ae68f237ca8f655fb538b1c20c1778c923 › sinatra@3.0.6 › rack-protection@3.0.6 › rack@2.2.7Remediation: Upgrade to sinatra@3.0.6.
Overview
rack is a minimal, modular and adaptable interface for developing web applications in Ruby. By wrapping HTTP requests and responses in the simplest way possible, it unifies and distills the API for web servers, web frameworks, and software in between (the so-called middleware) into a single method call.
Affected versions of this package are vulnerable to Regular Expression Denial of Service (ReDoS) in the build_nested_query()
function, used when parsing Accept
and Forwarded
headers. This can cause parsing performance to slow down.
Details
Denial of Service (DoS) describes a family of attacks, all aimed at making a system inaccessible to its original and legitimate users. There are many types of DoS attacks, ranging from trying to clog the network pipes to the system by generating a large volume of traffic from many machines (a Distributed Denial of Service - DDoS - attack) to sending crafted requests that cause a system to crash or take a disproportional amount of time to process.
The Regular expression Denial of Service (ReDoS) is a type of Denial of Service attack. Regular expressions are incredibly powerful, but they aren't very intuitive and can ultimately end up making it easy for attackers to take your site down.
Let’s take the following regular expression as an example:
regex = /A(B|C+)+D/
This regular expression accomplishes the following:
A
The string must start with the letter 'A'(B|C+)+
The string must then follow the letter A with either the letter 'B' or some number of occurrences of the letter 'C' (the+
matches one or more times). The+
at the end of this section states that we can look for one or more matches of this section.D
Finally, we ensure this section of the string ends with a 'D'
The expression would match inputs such as ABBD
, ABCCCCD
, ABCBCCCD
and ACCCCCD
It most cases, it doesn't take very long for a regex engine to find a match:
$ time node -e '/A(B|C+)+D/.test("ACCCCCCCCCCCCCCCCCCCCCCCCCCCCD")'
0.04s user 0.01s system 95% cpu 0.052 total
$ time node -e '/A(B|C+)+D/.test("ACCCCCCCCCCCCCCCCCCCCCCCCCCCCX")'
1.79s user 0.02s system 99% cpu 1.812 total
The entire process of testing it against a 30 characters long string takes around ~52ms. But when given an invalid string, it takes nearly two seconds to complete the test, over ten times as long as it took to test a valid string. The dramatic difference is due to the way regular expressions get evaluated.
Most Regex engines will work very similarly (with minor differences). The engine will match the first possible way to accept the current character and proceed to the next one. If it then fails to match the next one, it will backtrack and see if there was another way to digest the previous character. If it goes too far down the rabbit hole only to find out the string doesn’t match in the end, and if many characters have multiple valid regex paths, the number of backtracking steps can become very large, resulting in what is known as catastrophic backtracking.
Let's look at how our expression runs into this problem, using a shorter string: "ACCCX". While it seems fairly straightforward, there are still four different ways that the engine could match those three C's:
- CCC
- CC+C
- C+CC
- C+C+C.
The engine has to try each of those combinations to see if any of them potentially match against the expression. When you combine that with the other steps the engine must take, we can use RegEx 101 debugger to see the engine has to take a total of 38 steps before it can determine the string doesn't match.
From there, the number of steps the engine must use to validate a string just continues to grow.
String | Number of C's | Number of steps |
---|---|---|
ACCCX | 3 | 38 |
ACCCCX | 4 | 71 |
ACCCCCX | 5 | 136 |
ACCCCCCCCCCCCCCX | 14 | 65,553 |
By the time the string includes 14 C's, the engine has to take over 65,000 steps just to see if the string is valid. These extreme situations can cause them to work very slowly (exponentially related to input size, as shown above), allowing an attacker to exploit this and can cause the service to excessively consume CPU, resulting in a Denial of Service.
Remediation
Upgrade rack
to version 2.0.9.4, 2.1.4.4, 2.2.8.1, 3.0.9.1 or higher.
References
medium severity
- Vulnerable module: rack
- Introduced through: rack-test@2.0.2 and sinatra@3.0.6
Detailed paths
-
Introduced through: borja/herocalf@borja/herocalf#844ec4ae68f237ca8f655fb538b1c20c1778c923 › rack-test@2.0.2 › rack@2.2.7Remediation: Upgrade to rack-test@2.0.2.
-
Introduced through: borja/herocalf@borja/herocalf#844ec4ae68f237ca8f655fb538b1c20c1778c923 › sinatra@3.0.6 › rack@2.2.7Remediation: Upgrade to sinatra@3.0.6.
-
Introduced through: borja/herocalf@borja/herocalf#844ec4ae68f237ca8f655fb538b1c20c1778c923 › sinatra@3.0.6 › rack-protection@3.0.6 › rack@2.2.7Remediation: Upgrade to sinatra@3.0.6.
Overview
rack is a minimal, modular and adaptable interface for developing web applications in Ruby. By wrapping HTTP requests and responses in the simplest way possible, it unifies and distills the API for web servers, web frameworks, and software in between (the so-called middleware) into a single method call.
Affected versions of this package are vulnerable to Regular Expression Denial of Service (ReDoS) when parsing Content-Type data in media_type.rb
, causing a slow-down in parsing performance. Code using any of the following may be vulnerable: request.media_type
, request.media_type_params
, Rack::MediaType.type(content_type)
Details
Denial of Service (DoS) describes a family of attacks, all aimed at making a system inaccessible to its original and legitimate users. There are many types of DoS attacks, ranging from trying to clog the network pipes to the system by generating a large volume of traffic from many machines (a Distributed Denial of Service - DDoS - attack) to sending crafted requests that cause a system to crash or take a disproportional amount of time to process.
The Regular expression Denial of Service (ReDoS) is a type of Denial of Service attack. Regular expressions are incredibly powerful, but they aren't very intuitive and can ultimately end up making it easy for attackers to take your site down.
Let’s take the following regular expression as an example:
regex = /A(B|C+)+D/
This regular expression accomplishes the following:
A
The string must start with the letter 'A'(B|C+)+
The string must then follow the letter A with either the letter 'B' or some number of occurrences of the letter 'C' (the+
matches one or more times). The+
at the end of this section states that we can look for one or more matches of this section.D
Finally, we ensure this section of the string ends with a 'D'
The expression would match inputs such as ABBD
, ABCCCCD
, ABCBCCCD
and ACCCCCD
It most cases, it doesn't take very long for a regex engine to find a match:
$ time node -e '/A(B|C+)+D/.test("ACCCCCCCCCCCCCCCCCCCCCCCCCCCCD")'
0.04s user 0.01s system 95% cpu 0.052 total
$ time node -e '/A(B|C+)+D/.test("ACCCCCCCCCCCCCCCCCCCCCCCCCCCCX")'
1.79s user 0.02s system 99% cpu 1.812 total
The entire process of testing it against a 30 characters long string takes around ~52ms. But when given an invalid string, it takes nearly two seconds to complete the test, over ten times as long as it took to test a valid string. The dramatic difference is due to the way regular expressions get evaluated.
Most Regex engines will work very similarly (with minor differences). The engine will match the first possible way to accept the current character and proceed to the next one. If it then fails to match the next one, it will backtrack and see if there was another way to digest the previous character. If it goes too far down the rabbit hole only to find out the string doesn’t match in the end, and if many characters have multiple valid regex paths, the number of backtracking steps can become very large, resulting in what is known as catastrophic backtracking.
Let's look at how our expression runs into this problem, using a shorter string: "ACCCX". While it seems fairly straightforward, there are still four different ways that the engine could match those three C's:
- CCC
- CC+C
- C+CC
- C+C+C.
The engine has to try each of those combinations to see if any of them potentially match against the expression. When you combine that with the other steps the engine must take, we can use RegEx 101 debugger to see the engine has to take a total of 38 steps before it can determine the string doesn't match.
From there, the number of steps the engine must use to validate a string just continues to grow.
String | Number of C's | Number of steps |
---|---|---|
ACCCX | 3 | 38 |
ACCCCX | 4 | 71 |
ACCCCCX | 5 | 136 |
ACCCCCCCCCCCCCCX | 14 | 65,553 |
By the time the string includes 14 C's, the engine has to take over 65,000 steps just to see if the string is valid. These extreme situations can cause them to work very slowly (exponentially related to input size, as shown above), allowing an attacker to exploit this and can cause the service to excessively consume CPU, resulting in a Denial of Service.
Remediation
Upgrade rack
to version 2.2.8.1, 3.0.9.1 or higher.
References
medium severity
- Vulnerable module: sinatra
- Introduced through: sinatra@3.0.6
Detailed paths
-
Introduced through: borja/herocalf@borja/herocalf#844ec4ae68f237ca8f655fb538b1c20c1778c923 › sinatra@3.0.6Remediation: Upgrade to sinatra@4.1.0.
Overview
Affected versions of this package are vulnerable to Reliance on Untrusted Inputs in a Security Decision via the X-Forwarded-Host (XFH)
header. When making a request to a method with redirect applied, it is possible to trigger an Open Redirect Attack by inserting an arbitrary address into this header. If used for caching purposes, such as with servers like Nginx, or as a reverse proxy, without handling the X-Forwarded-Host
header, attackers can potentially exploit Cache Poisoning or Routing-based SSRF.
Remediation
Upgrade sinatra
to version 4.1.0 or higher.
References
medium severity
- Vulnerable module: webrick
- Introduced through: webrick@1.8.1
Detailed paths
-
Introduced through: borja/herocalf@borja/herocalf#844ec4ae68f237ca8f655fb538b1c20c1778c923 › webrick@1.8.1Remediation: Upgrade to webrick@1.8.2.
Overview
webrick is a HTTP server toolkit that can be configured as an HTTPS server, a proxy server, and a virtual-host server.
Affected versions of this package are vulnerable to HTTP Request Smuggling when httprequest.rb
processes a request with both Content-Length
and Transfer-Encoding
headers. An attacker can send a GET /admin
inside a POST /user
to trick the server into treating the second one as a legitimate request, exposing unintended data.
Note: The package maintainers instruct users not to use this package in production and that it is no longer part of the Ruby language although it was in the past.
PoC
POST /user HTTP/1.1
Host: 127.0.0.1:8000
Content-Length: 50
Transfer-Encoding: chunked
0
GET /admin HTTP/1.1
Host: 127.0.0.1:8000
Remediation
Upgrade webrick
to version 1.8.2 or higher.