Server-side ReDoS via user-controlled regex in OIDC Access Policy
The OIDC Access Policy compiled user-supplied regular expressions with Ruby's Regexp engine and matched them against JWT claim values without any timeout or complexity check. A crafted pattern with catastrophic backtracking could tie up a Puma worker thread, and a few concurrent requests could exhaust the small thread pool and cause a denial of service.
- Fixed in 17 days
- Disclosed after 48 days
The OIDC Access Policy implementation evaluates user-supplied regular expressions against JWT claim values using Ruby’s Regexp engine without any timeout or complexity validation.
The vulnerable code path is:
Regexp.new(value).match?(claim_value)
Where:
valueis fully user-controlled (defined when creating an OIDC API Key Role using thestring_matchesoperator)claim_valueis derived from JWT claims and can be influenced via GitHub Actions metadata (e.g. branch names)
A malicious regular expression with catastrophic backtracking characteristics can be supplied, causing the server to spend an excessive amount of CPU time evaluating a single request.
Example pattern: ^(a+)+$
Example input: refs/heads/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa!
This causes Ruby’s regex engine to enter exponential backtracking during evaluation.
Impact
A single crafted request can block a Puma worker thread for an extended period of time due to catastrophic regex backtracking.
Since RubyGems.org runs with a very small thread pool, a small number of concurrent requests can exhaust all available workers, resulting in partial or full denial of service.
This can disrupt gem publishing operations and CI/CD pipelines that rely on RubyGems.org availability.
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 the user-controlled regex was compiled and evaluated with Ruby's Regexp engine without a timeout or any check on pattern complexity.
Impact
A small number of concurrent crafted requests could exhaust the small Puma thread pool, causing partial or full denial of service and disrupting gem publishing and CI/CD pipelines.
What the attacker needed
Ability to create an OIDC API Key Role; control over a JWT claim value; a few concurrent requests
How it was found
- Create an OIDC API Key Role using the string_matches operator with a pattern that backtracks catastrophically.
- Trigger evaluation of the policy against a JWT claim value shaped to cause exponential backtracking.
- Send a small number of concurrent requests to exhaust the worker pool.
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, and some patterns can take an enormous amount of time on certain inputs. Here the site let users supply their own pattern and ran it against values from a login token, so a deliberately slow pattern could keep the server busy. Enough of these requests at once can make the site stop responding to other people.
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.