Skip to content

GHSA-26vr-8j45-3r4w BIT-jenkins-2021-28165 CVE-2021-28165

Jetty vulnerable to incorrect handling of invalid large TLS frame, exhausting CPU resources

High Maven
Severity
7.5 / 10
High · CVSS 3.1
Exploit chance (EPSS)
53.86%
Chance of exploitation in the next 30 days. Higher than 99.00% of scored vulnerabilities.
Known exploited
No
Not in CISA's catalog
Weakness
CWE-400 Uncontrolled Resource Consumption
CWE-551 Incorrect Behavior Order: Authorization Before Parsing and Canonicalization
CWE-755 Improper Handling of Exceptional Conditions
Fix
9.4.39
Upgrade org.eclipse.jetty:jetty-server to this version or later

Description

Impact

When using SSL/TLS with Jetty, either with HTTP/1.1, HTTP/2, or WebSocket, the server may receive an invalid large (greater than 17408) TLS frame that is incorrectly handled, causing CPU resources to eventually reach 100% usage.

Workarounds

The problem can be worked around by compiling the following class:

package org.eclipse.jetty.server.ssl.fix6072;

import java.nio.ByteBuffer;
import javax.net.ssl.SSLEngine;
import javax.net.ssl.SSLEngineResult;
import javax.net.ssl.SSLException;
import javax.net.ssl.SSLHandshakeException;

import org.eclipse.jetty.io.EndPoint;
import org.eclipse.jetty.io.ssl.SslConnection;
import org.eclipse.jetty.server.Connector;
import org.eclipse.jetty.server.SslConnectionFactory;
import org.eclipse.jetty.util.BufferUtil;
import org.eclipse.jetty.util.annotation.Name;
import org.eclipse.jetty.util.ssl.SslContextFactory;

public class SpaceCheckingSslConnectionFactory extends SslConnectionFactory
{
    public SpaceCheckingSslConnectionFactory(@Name("sslContextFactory") SslContextFactory factory, @Name("next") String nextProtocol)
    {
        super(factory, nextProtocol);
    }

    @Override
    protected SslConnection newSslConnection(Connector connector, EndPoint endPoint, SSLEngine engine)
    {
        return new SslConnection(connector.getByteBufferPool(), connector.getExecutor(), endPoint, engine, isDirectBuffersForEncryption(), isDirectBuffersForDecryption())
        {
            @Override
            protected SSLEngineResult unwrap(SSLEngine sslEngine, ByteBuffer input, ByteBuffer output) throws SSLException
            {
                SSLEngineResult results = super.unwrap(sslEngine, input, output);

                if ((results.getStatus() == SSLEngineResult.Status.BUFFER_UNDERFLOW ||
                    results.getStatus() == SSLEngineResult.Status.OK && results.bytesConsumed() == 0 && results.bytesProduced() == 0) &&
                    BufferUtil.space(input) == 0)
                {
                    BufferUtil.clear(input);
                    throw new SSLHandshakeException("Encrypted buffer max length exceeded");
                }
                return results;
            }
        };
    }
}

This class can be deployed by:

  • The resulting class file should be put into a jar file (eg sslfix6072.jar)
  • The jar file should be made available to the server. For a normal distribution this can be done by putting the file into ${jetty.base}/lib
  • Copy the file ${jetty.home}/modules/ssl.mod to ${jetty.base}/modules
  • Edit the ${jetty.base}/modules/ssl.mod file to have the following section:
[lib]
lib/sslfix6072.jar
  • Copy the file ${jetty.home}/etc/jetty-https.xml and${jetty.home}/etc/jetty-http2.xml to ${jetty.base}/etc
  • Edit files ${jetty.base}/etc/jetty-https.xml and ${jetty.base}/etc/jetty-http2.xml, changing any reference of org.eclipse.jetty.server.SslConnectionFactory to org.eclipse.jetty.server.ssl.fix6072.SpaceCheckingSslConnectionFactory. For example:
  <Call name="addIfAbsentConnectionFactory">
    <Arg>
      <New class="org.eclipse.jetty.server.ssl.fix6072.SpaceCheckingSslConnectionFactory">
        <Arg name="next">http/1.1</Arg>
        <Arg name="sslContextFactory"><Ref refid="sslContextFactory"/></Arg>
      </New>
    </Arg>
  </Call>
  • Restart Jetty

Affected versions

Maven

PackageVulnerableFixed in
org.eclipse.jetty:jetty-server
>= 7.2.2, < 9.4.39
9.4.39
org.eclipse.jetty:jetty-server
>= 10.0.0, < 10.0.2
10.0.2
org.eclipse.jetty:jetty-server
>= 11.0.0, < 11.0.2
11.0.2

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.

org.eclipse.jetty:jetty-server Maven → 9.4.39

maven
<dependency><groupId>org.eclipse.jetty</groupId><artifactId>jetty-server</artifactId><version>9.4.39</version></dependency>
gradle
implementation("org.eclipse.jetty:jetty-server:9.4.39")

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.

CWE-551: Incorrect Behavior Order: Authorization Before Parsing and Canonicalization

If a web server does not fully parse requested URLs before it examines them for authorization, it may be possible for an attacker to bypass authorization protection.

How to prevent it
  • Architecture and Design: URL Inputs should be decoded and canonicalized to the application's current internal representation before being validated and processed for authorization. Make sure that your application does not decode the same input twice. Such errors could be used to bypass allowlist schemes by introducing dangerous inputs after they have been checked.

CWE-755: Improper Handling of Exceptional Conditions

The product does not handle or incorrectly handles an exceptional condition.

References

Advisories

Packages

Other links

Timeline

  1. Published
  2. Last updated by the source
  3. Latest EPSS score
AdvisorySeverityWhy it's related
GHSA-7p3p-8qv8-m2vh
Eclipse Jetty: HTTP Authority/Host mismatch
Medium Also affects org.eclipse.jetty:jetty-server
GHSA-f4v5-65jj-pcr2
Eclipse Jetty: Cross-Request Leakage for trailers on HTTP/1.1 keep-alive connections
High Also affects org.eclipse.jetty:jetty-server
GHSA-9299-c6m4-mjhc
Eclipse Jetty: DoS attack triggering OutOfMemory with 100-Continue requests
High Also affects org.eclipse.jetty:jetty-server
GHSA-xxh7-fcf3-rj7f
The Eclipse Jetty Server Artifact has a Gzip request memory leak
High Also affects org.eclipse.jetty:jetty-server
GHSA-q4rv-gq96-w7c5
**UNSUPPORTED WHEN ASSIGNED** GzipHandler causes part of request body to be seen as request body of a separate request
High Also affects org.eclipse.jetty:jetty-server
GHSA-g8m5-722r-8whq
Eclipse Jetty's ThreadLimitHandler.getRemote() vulnerable to remote DoS attacks
Medium Also affects org.eclipse.jetty:jetty-server
GHSA-p26g-97m4-6q7c
Eclipse Jetty's cookie parsing of quoted values can exfiltrate values from other cookies
Medium Also affects org.eclipse.jetty:jetty-server
GHSA-qw69-rqj8-6qw8
OutOfMemoryError for large multipart without filename in Eclipse Jetty
Medium Also affects org.eclipse.jetty:jetty-server
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