Vulnerabilities |
11 via 12 paths |
|---|---|
Dependencies |
20 |
Source |
GitHub |
Find, fix and prevent vulnerabilities in your code.
critical severity
- Vulnerable module: json
- Introduced through: simplecov@0.13.0 and codeclimate-test-reporter@1.0.8
Detailed paths
-
Introduced through: rajangdavis/osvc_ruby@rajangdavis/osvc_ruby › simplecov@0.13.0 › json@2.1.0Remediation: Upgrade to simplecov@0.13.0.
-
Introduced through: rajangdavis/osvc_ruby@rajangdavis/osvc_ruby › codeclimate-test-reporter@1.0.8 › simplecov@0.13.0 › json@2.1.0Remediation: Upgrade to codeclimate-test-reporter@1.0.8.
Overview
json is a JSON implementation as a Ruby extension in C.
Affected versions of this package are vulnerable to Denial of Service (DoS). When parsing certain JSON documents, the json gem (including the one bundled with Ruby) can be coerced into creating arbitrary objects in the target system.
This is the same issue as CVE-2013-0269. The previous fix was incomplete, which addressed JSON.parse(user_input), but didn’t address some other styles of JSON
parsing including JSON(user_input) and JSON.parse(user_input, nil).
See CVE-2013-0269 in detail.
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:
AThe 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.DFinally, 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 json to version 2.3.0 or higher.
References
high severity
- Vulnerable module: addressable
- Introduced through: webmock@3.1.1
Detailed paths
-
Introduced through: rajangdavis/osvc_ruby@rajangdavis/osvc_ruby › webmock@3.1.1 › addressable@2.5.2Remediation: Upgrade to webmock@3.1.1.
Overview
addressable is an is an alternative implementation to the URI implementation that is part of Ruby's standard library.
Affected versions of this package are vulnerable to Regular Expression Denial of Service (ReDoS) in the URI template matching due to the use of regular expressions with nested unbounded quantifiers. An attacker can cause excessive resource consumption and application downtime by supplying specially crafted URIs that trigger catastrophic backtracking.
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:
AThe 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.DFinally, 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 addressable to version 2.9.0 or higher.
References
high severity
new
- Vulnerable module: addressable
- Introduced through: webmock@3.1.1
Detailed paths
-
Introduced through: rajangdavis/osvc_ruby@rajangdavis/osvc_ruby › webmock@3.1.1 › addressable@2.5.2Remediation: Upgrade to webmock@3.1.1.
Overview
addressable is an is an alternative implementation to the URI implementation that is part of Ruby's standard library.
Affected versions of this package are vulnerable to Inefficient Algorithmic Complexity via the normalize_path function in Addressable::URI. An attacker can cause quadratic processing and exhaust application resources by supplying a URI with many nested dot segments when the application calls URI#normalize, URI#normalized_path, URI#==, URI#===, or URI#join.
Workarounds
- Limit the length of user-supplied URIs before calling
normalize,==, orjoinon them to reduce the cost of quadratic path normalization. - Reject paths with many dot segments before normalizing them to prevent attacker-supplied paths from triggering expensive normalization.
Remediation
Upgrade addressable to version 2.9.1 or higher.
References
high severity
new
- Vulnerable module: addressable
- Introduced through: webmock@3.1.1
Detailed paths
-
Introduced through: rajangdavis/osvc_ruby@rajangdavis/osvc_ruby › webmock@3.1.1 › addressable@2.5.2Remediation: Upgrade to webmock@3.1.1.
Overview
addressable is an is an alternative implementation to the URI implementation that is part of Ruby's standard library.
Affected versions of this package are vulnerable to Regular Expression Denial of Service (ReDoS) via the Template#match and Template#extract methods in its URI template implementation. An attacker can cause excessive backtracking and uncontrolled CPU consumption by supplying a crafted URI to match or extract against a template expression with multiple exploded variables; on regex engines without effective backtracking memoization, this can deny service to the application.
Notes
- The runtime is a gate: the flaw is exploitable on MRI Ruby before 3.2, JRuby, and TruffleRuby 40.0; on MRI Ruby 3.2 it affects
+and#expressions, while MRI Ruby 3.3 and later are not affected.
Workarounds
- Avoid matching user-supplied input against unpatched templates with more than one exploded variable in the same expression; this prevents crafted URIs from triggering excessive backtracking.
- Apply a short timeout to calls to
Template#matchorTemplate#extractthat process user-supplied data; this limits resource consumption from a ReDoS attempt.
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:
AThe 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.DFinally, 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 addressable to version 2.9.1 or higher.
References
high severity
new
- Vulnerable module: addressable
- Introduced through: webmock@3.1.1
Detailed paths
-
Introduced through: rajangdavis/osvc_ruby@rajangdavis/osvc_ruby › webmock@3.1.1 › addressable@2.5.2Remediation: Upgrade to webmock@3.1.1.
Overview
addressable is an is an alternative implementation to the URI implementation that is part of Ruby's standard library.
Affected versions of this package are vulnerable to Regular Expression Denial of Service (ReDoS) via Template#match and Template#extract in its URI template implementation. An attacker can tie up an application thread and deny service by supplying a crafted URI that fails to match a template with several variables or adjacent expressions, triggering polynomial backtracking; failing matches against + or # expressions with many variables trigger exponential backtracking. This affects Ruby regex engines without match memoization, including MRI before 3.2 and JRuby; the many-variable + and # cases also affect MRI 3.2 and TruffleRuby 40.
Notes
- Runtime gate: MRI Ruby before 3.2 and JRuby are vulnerable to the described forms; on MRI 3.2, only many-variable
+and#expressions are vulnerable. MRI 3.3 and later are unaffected, while TruffleRuby 40.0 is vulnerable to the many-variable+and#form; earlier TruffleRuby versions were not tested. - For many-variable
+and#expressions, the exponential backtracking path requires a failing match: the input must leave the regex unable to match after exploring the possible variable-value splits.
Workarounds
- Avoid passing user-supplied input to
Template#matchorTemplate#extractwith templates that have several variables in one expression or several adjacent expressions; this blocks the vulnerable matching patterns. - Set a short timeout around calls to
Template#matchorTemplate#extractthat process user-supplied data; this limits resource consumption if a crafted URI triggers excessive backtracking.
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:
AThe 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.DFinally, 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 addressable to version 2.9.1 or higher.
References
high severity
new
- Vulnerable module: addressable
- Introduced through: webmock@3.1.1
Detailed paths
-
Introduced through: rajangdavis/osvc_ruby@rajangdavis/osvc_ruby › webmock@3.1.1 › addressable@2.5.2Remediation: Upgrade to webmock@3.1.1.
Overview
addressable is an is an alternative implementation to the URI implementation that is part of Ruby's standard library.
Affected versions of this package are vulnerable to Regular Expression Denial of Service (ReDoS) via exploded-expression matching in Addressable::Template#match and #extract. An attacker can cause uncontrolled resource consumption by supplying a crafted URI that starts with the operator’s leading character for a template using the * modifier with /, ., ;, ?, or &. On MRI Ruby before 3.2 and JRuby, matching takes exponential time and can tie up a thread for minutes.
Notes
- Payload-size limit at the matching step: a malicious URI under 60 bytes is enough to occupy a thread for minutes on an affected Ruby runtime.
Workarounds
- Run the application on MRI Ruby 3.2 or later, if it does not use JRuby, to prevent catastrophic backtracking in the affected template matches.
- On unpatched Addressable versions, avoid matching user-supplied input against templates that use
*with/,.,;,?, or&operators to block the affected attack path. - Wrap calls to
Template#matchorTemplate#extractthat process user-supplied data in a short timeout to limit how long a malicious match can tie up a thread.
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:
AThe 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.DFinally, 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 addressable to version 2.9.1 or higher.
References
high severity
- Vulnerable module: addressable
- Introduced through: webmock@3.1.1
Detailed paths
-
Introduced through: rajangdavis/osvc_ruby@rajangdavis/osvc_ruby › webmock@3.1.1 › addressable@2.5.2Remediation: Upgrade to webmock@3.1.1.
Overview
addressable is an is an alternative implementation to the URI implementation that is part of Ruby's standard library.
Affected versions of this package are vulnerable to Regular Expression Denial of Service (ReDoS) within the URI template implementation. A maliciously crafted template may result in uncontrolled resource consumption.
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:
AThe 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.DFinally, 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 addressable to version 2.8.0 or higher.
References
high severity
- Vulnerable module: rake
- Introduced through: rake@10.5.0
Detailed paths
-
Introduced through: rajangdavis/osvc_ruby@rajangdavis/osvc_ruby › rake@10.5.0Remediation: Upgrade to rake@12.3.3.
Overview
rake is a Make-like program implemented in Ruby.
Affected versions of this package are vulnerable to Arbitrary Code Injection in Rake::FileList when supplying a filename that begins with the pipe character |.
PoC by Katsuhiko Yoshida
% ls -1
Gemfile
Gemfile.lock
poc_rake.rb
vendor
| touch evil.txt
% bundle exec ruby poc_rake.rb
["poc_rake.rb", "Gemfile", "Gemfile.lock", "| touch evil.txt", "vendor"]
poc_rake.rb:6:list.egrep(/something/)
Error while processing 'vendor': Is a directory @ io_fillbuf - fd:7 vendor
% ls -1
Gemfile
Gemfile.lock
evil.txt
poc_rake.rb
vendor
| touch evil.txt
Remediation
Upgrade rake to version 12.3.3 or higher.
References
medium severity
new
- Vulnerable module: addressable
- Introduced through: webmock@3.1.1
Detailed paths
-
Introduced through: rajangdavis/osvc_ruby@rajangdavis/osvc_ruby › webmock@3.1.1 › addressable@2.5.2Remediation: Upgrade to webmock@3.1.1.
Overview
addressable is an is an alternative implementation to the URI implementation that is part of Ruby's standard library.
Affected versions of this package are vulnerable to Interpretation Conflict via the normalize_path function in Addressable::URI. An attacker can bypass a path allowlist by supplying a path such as /../../public/x/../../secret, which Addressable normalizes to /public/x/secret even though an RFC 3986 resolver processes it as /secret. This exposes the outside path when an application checks the normalized path but sends the original URI to a component that resolves dot segments.
Workarounds
- Reject paths containing
..segments, including percent-encoded forms such as%2e%2e, before making access decisions. This blocks traversal attempts from passing the allowlist check. - Use the same Addressable-normalized path for both the access check and the request. This prevents a different URI resolver from interpreting the requested path differently after it passes the check.
Remediation
Upgrade addressable to version 2.9.1 or higher.
References
medium severity
new
- Vulnerable module: addressable
- Introduced through: webmock@3.1.1
Detailed paths
-
Introduced through: rajangdavis/osvc_ruby@rajangdavis/osvc_ruby › webmock@3.1.1 › addressable@2.5.2Remediation: Upgrade to webmock@3.1.1.
Overview
addressable is an is an alternative implementation to the URI implementation that is part of Ruby's standard library.
Affected versions of this package are vulnerable to Improper Validation of Syntactic Correctness of Input via the to_unicode function in the pure-Ruby IDNA implementation. When that implementation is in use, an attacker who controls a domain can send a URI containing an invalid Punycode A-label, such as xn--google-, which to_unicode decodes to google; display_uri then shows a host that differs from the domain the URI actually uses. Users can mistake the displayed host for a trusted one, and applications that compare to_unicode output against trusted names can treat different hosts as the same.
Notes
- The backend is a deployment gate: the flaw affects requests only when Addressable uses its pure-Ruby IDNA implementation; the native implementation used with
libidnand theidn-rubygem is unaffected.
Workarounds
- Install
libidnand theidn-rubygem so Addressable uses the unaffected native IDNA implementation; this prevents invalid A-labels from being misleadingly decoded. - Use
normalized_hostfor host comparisons, and don’t make security decisions usingdisplay_uriorto_unicode; this prevents treating a different host as a trusted one.
Remediation
Upgrade addressable to version 2.9.1 or higher.
References
low severity
new
- Vulnerable module: addressable
- Introduced through: webmock@3.1.1
Detailed paths
-
Introduced through: rajangdavis/osvc_ruby@rajangdavis/osvc_ruby › webmock@3.1.1 › addressable@2.5.2Remediation: Upgrade to webmock@3.1.1.
Overview
addressable is an is an alternative implementation to the URI implementation that is part of Ruby's standard library.
Affected versions of this package are vulnerable to Insufficient Visual Distinction of Homoglyphs Presented to User via the to_unicode function in Addressable::IDNA. An attacker can make a malicious domain appear to be a trusted host by supplying a URI with a Punycode label that decodes to bidirectional controls or invisible characters, when an application displays Addressable::URI#display_uri to users. The misleading appearance affects only the displayed form; URI parsing and the host used for connections are unaffected, though users can be misled into trusting or following the malicious link.
Notes
- The character set depends on the IDNA backend: the pure-Ruby implementation decodes the broader set, while installing both
libidnandidn-rubyselects the native implementation, where libidn rejects most such characters but still allows some added after Unicode 3.2, including bidi isolates U+2066–U+2069.
Workarounds
- Install
libidnand theidn-rubygem so Addressable uses the native IDNA implementation; this reduces exposure to misleading labels, though characters added after Unicode 3.2 may still be accepted. - Check displayed hosts for bidirectional and invisible characters (for example,
/[\p{Cc}\p{Cf}\p{Default_Ignorable_Code_Point}]/) and displaynormalized_hostinstead when any are present; this prevents those characters from misleading users about the host.
Remediation
Upgrade addressable to version 2.9.1 or higher.