Skip to content

GHSA-7wjx-3g7j-8584 CVE-2021-22904

Possible DoS Vulnerability in Action Controller Token Authentication

High RubyGems
Severity
7.5 / 10
High · CVSS 3.1
Exploit chance (EPSS)
4.87%
Chance of exploitation in the next 30 days. Higher than 92.05% of scored vulnerabilities.
Known exploited
No
Not in CISA's catalog
Weakness
CWE-400 Uncontrolled Resource Consumption
Fix
6.0.3.7
Upgrade actionpack to this version or later

Description

There is a possible DoS vulnerability in the Token Authentication logic in Action Controller.

Versions Affected: >= 4.0.0 Not affected: < 4.0.0 Fixed Versions: 6.1.3.2, 6.0.3.7, 5.2.4.6, 5.2.6

Impact

Impacted code uses authenticate_or_request_with_http_token or authenticate_with_http_token for request authentication. Impacted code will look something like this:

class PostsController < ApplicationController
  before_action :authenticate

  private

  def authenticate
    authenticate_or_request_with_http_token do |token, options|
      # ...
    end
  end
end

All users running an affected release should either upgrade or use one of the workarounds immediately.

Releases

The fixed releases are available at the normal locations.

Workarounds

The following monkey patch placed in an initializer can be used to work around the issue:

module ActionController::HttpAuthentication::Token
  AUTHN_PAIR_DELIMITERS = /(?:,|;|\t)/
end

Patches

To aid users who aren't able to upgrade immediately we have provided patches for the two supported release series. They are in git-am format and consist of a single changeset.

  • 5-2-http-authentication-dos.patch - Patch for 5.2 series
  • 6-0-http-authentication-dos.patch - Patch for 6.0 series
  • 6-1-http-authentication-dos.patch - Patch for 6.1 series

Please note that only the 6.1.Z, 6.0.Z, and 5.2.Z series are supported at present. Users of earlier unsupported releases are advised to upgrade as soon as possible as we cannot guarantee the continued availability of security fixes for unsupported releases.

Credits

Thank you to https://hackerone.com/wonda_tea_coffee for reporting this issue!

Affected versions

RubyGems

PackageVulnerableFixed in
actionpack
>= 6.0.0, < 6.0.3.7
6.0.3.7
actionpack
>= 6.1.0, < 6.1.3.2
6.1.3.2
actionpack
>= 5.2.5, < 5.2.6
5.2.6
actionpack
>= 4.0.0, < 5.2.4.6
5.2.4.6

How to fix

Move to the fixed version or later with your package manager, update the lockfile, and run your tests. If the package only arrives through another dependency, upgrade that dependency first. If none of its releases pulls a fixed version yet, force the version with your package manager's override.

actionpack RubyGems → 6.0.3.7

bundler
bundle update actionpack # Gemfile: gem "actionpack", ">= 6.0.3.7"

Severity breakdown

CVSS 3.1 7.5

CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H

Attack vector
Network
Attack complexity
Low
Privileges required
None
User interaction
None
Scope
Unchanged
Confidentiality
None
Integrity
None
Availability
High

Weakness

CWE-400: Uncontrolled Resource Consumption

The product does not properly control the allocation and maintenance of a limited resource.

How to prevent it
  • Architecture and Design: Design throttling mechanisms into the system architecture. The best protection is to limit the amount of resources that an unauthorized user can cause to be expended. A strong authentication and access control model will help prevent such attacks from occurring in the first place. The login application should be protected against DoS attacks as much as possible. Limiting the database access, perhaps by caching result sets, can help minimize the resources expended. To further limit the potential for a DoS attack, consider tracking the rate of requests received from users and blocking requests that exceed a defined rate threshold.
  • Architecture and Design: Mitigation of resource exhaustion attacks requires that the target system either: recognizes the attack and denies that user further access for a given amount of time, or uniformly throttles all requests in order to make it more difficult to consume resources more quickly than they can again be freed. The first of these solutions is an issue in itself though, since it may allow attackers to prevent the use of the system by a particular valid user. If the attacker impersonates the valid user, they may be able to prevent the user from accessing the server in question. The second solution is simply difficult to effectively institute -- and even when properly done, it does not provide a full solution. It simply makes the attack require more resources on the part of the attacker.
  • Architecture and Design: Ensure that protocols have specific limits of scale placed on them.
  • Implementation: Ensure that all failures in resource allocation place the system into a safe posture.

References

Timeline

  1. Published
  2. Last updated by the source
  3. Latest EPSS score
AdvisorySeverityWhy it's related
GHSA-6x85-j5j2-27jx
actionpack Path Traversal vulnerability
High Known exploited Also affects actionpack
GHSA-xrr4-p6fq-hjg7
Directory traversal vulnerability in Action View in Ruby on Rails
High Known exploited Also affects actionpack
GHSA-pgm4-439c-5jp6
Rails has a possible XSS vulnerability in its Action Pack debug exceptions
Medium Also affects actionpack
GHSA-vfm5-rmrh-j26v
Possible Content Security Policy bypass in Action Dispatch
Low Also affects actionpack
GHSA-vfg9-r3fq-jvx4
Possible ReDoS vulnerability in HTTP Token authentication in Action Controller
Medium Also affects actionpack
GHSA-x76w-6vjr-8xgj
Possible ReDoS vulnerability in query parameter filtering in Action Dispatch
Medium Also affects actionpack
GHSA-fwhr-88qx-h9g7
Missing security headers in Action Pack on non-HTML responses
Critical Also affects actionpack
GHSA-9822-6m93-xqf4
Rails has possible XSS Vulnerability in Action Controller
Medium Also affects actionpack
Is this in your code?

MergeHarbor checks every repository's dependencies against this database, ranks what matters by exploitability and reachability, routes it to the owning team and opens the fix pull request.

Check your repos with MergeHarbor