Skip to content

GHSA-q28m-8xjw-8vr5 CVE-2021-29509

Puma's Keepalive Connections Causing Denial Of Service

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

Description

This vulnerability is related to CVE-2019-16770.

Impact

The fix for CVE-2019-16770 was incomplete. The original fix only protected existing connections that had already been accepted from having their requests starved by greedy persistent-connections saturating all threads in the same process. However, new connections may still be starved by greedy persistent-connections saturating all threads in all processes in the cluster.

A puma server which received more concurrent keep-alive connections than the server had threads in its threadpool would service only a subset of connections, denying service to the unserved connections.

Patches

This problem has been fixed in puma 4.3.8 and 5.3.1.

Workarounds

Setting queue_requests false also fixes the issue. This is not advised when using puma without a reverse proxy, such as nginx or apache, because you will open yourself to slow client attacks (e.g. slowloris).

The fix is very small. A git patch is available here for those using unsupported versions of Puma.

For more information

If you have any questions or comments about this advisory:

Acknowledgements

Thank you to @MSP-Greg, @wjordan and @evanphx for their review on this issue.

Thank you to @ioquatix for providing a modified fork of wrk which made debugging this issue much easier.

Affected versions

RubyGems

PackageVulnerableFixed in
puma
< 4.3.8
4.3.8
puma
>= 5.0.0, < 5.3.1
5.3.1

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.

puma RubyGems → 4.3.8

bundler
bundle update puma # Gemfile: gem "puma", ">= 4.3.8"

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-2vqw-3mp8-cgmx
Puma PROXY Protocol v1 Accepts Repeated Protocol Headers on Persistent Connections
High Also affects puma
GHSA-qpgp-93vx-g8v8
Puma PROXY Protocol v1 Parser Allows Remote Memory Exhaustion
High Also affects puma
GHSA-9hf4-67fc-4vf4
Puma's header normalization allows for client to clobber proxy set headers
Medium Also affects puma
GHSA-c2f4-cvqm-65w2
Puma HTTP Request/Response Smuggling vulnerability
High Also affects puma
GHSA-68xg-gqqm-vgj8
Puma HTTP Request/Response Smuggling vulnerability
Critical Also affects puma
GHSA-h99w-9q5r-gjq9
Puma vulnerable to HTTP Request Smuggling
Critical Also affects puma
GHSA-rmj8-8hhh-gv5h
Puma used with Rails may lead to Information Exposure
High Also affects puma
GHSA-48w2-rm65-62xx
Puma with proxy which forwards LF characters as line endings could allow HTTP request smuggling
Low Also affects puma
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