Skip to content
DoS Disclosed report Intermediate CVE-2016-6307

Excessive allocation of memory in tls_get_message_header() (CVE-2016-6307)

A flaw in OpenSSL 1.1.0 causes memory for a TLS message to be allocated before the message length is checked, allowing an attacker to force up to 21Mb of allocation per connection. This could lead to a denial of service through memory exhaustion, though the impact is limited because the connection fails and memory is freed if the application calls SSL_free() promptly.

theyarestone Follow

Originally disclosed on HackerOne

  • Fixed in 36 days
  • Paid in 36 days
  • Disclosed after 37 days

Summary by the program

A TLS message includes 3 bytes for its length in the header for the message. This would allow for messages up to 16Mb in length. Messages of this length are excessive and OpenSSL includes a check to ensure that a peer is sending reasonably sized messages in order to avoid too much memory being consumed to service a connection. A flaw in the logic of version 1.1.0 means that memory for the message is allocated too early, prior to the excessive message length check. Due to way memory is allocated in OpenSSL this could mean an attacker could force up to 21Mb to be allocated to service a connection. This could lead to a Denial of Service through memory exhaustion. However, the excessive message length check still takes place, and this would cause the connection to immediately fail. Assuming that the application calls SSL_free() on the failed conneciton in a timely manner then the 21Mb of allocated memory will then be immediately freed again. Therefore the excessive memory allocation will be transitory in nature. This then means that there is only a security impact if:

  1. The application does not call SSL_free() in a timely manner in the event that the connection fails

or 2) The application is working in a constrained environment where there is very little free memory

or 3) The attacker initiates multiple connection attempts such that there are multiple connections in a state where memory has been allocated for the connection; SSL_free() has not yet been called; and there is insufficient memory to service the multiple requests.

Except in the instance of (1) above any Denial Of Service is likely to be transitory because as soon as the connection fails the memory is subsequently freed again in the SSL_free() call. However there is an increased risk during this period of application crashes due to the lack of memory - which would then mean a more serious Denial of Service.

This issue does not affect DTLS users.

OpenSSL 1.1.0 TLS users should upgrade to 1.1.0a

This issue was reported to OpenSSL on 18th September 2016 by Shi Lei (Gear Team, Qihoo 360 Inc.). The fix was developed by Matt Caswell of the OpenSSL development team.

The report

A TLS message includes 3 bytes for its length in the header for the message. This would allow for messages up to 16Mb in length. Messages of this length are excessive and OpenSSL includes a check to ensure that a peer is sending reasonably sized messages in order to avoid too much memory being consumed to service a connection. A flaw in the logic of version 1.1.0 means that memory for the message is allocated too early, prior to the excessive message length check. Due to way memory is allocated in OpenSSL this could mean an attacker could force up to 21Mb to be allocated to service a connection. This could lead to a Denial of Service through memory exhaustion. However, the excessive message length check still takes place, and this would cause the connection to immediately fail. Assuming that the application calls SSL_free() on the failed conneciton in a timely manner then the 21Mb of allocated memory will then be immediately freed again. Therefore the excessive memory allocation will be transitory in nature. This then means that there is only a security impact if:

  1. The application does not call SSL_free() in a timely manner in the

event that the connection fails or 2) The application is working in a constrained environment where there

is very little free memory or 3) The attacker initiates multiple connection attempts such that there

are multiple connections in a state where memory has been allocated for the connection; SSL_free() has not yet been called; and there is insufficient memory to service the multiple requests.

Except in the instance of (1) above any Denial Of Service is likely to be transitory because as soon as the connection fails the memory is subsequently freed again in the SSL_free() call. However there is an increased risk during this period of application crashes due to the lack of memory - which would then mean a more serious Denial of Service.

This issue does not affect DTLS users.

refer: https://www.openssl.org/news/secadv/20160922.txt

The original report as published on HackerOne, by theyarestone. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

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 code allocates memory for the TLS message before validating the message length, so an oversized length still triggers a large allocation.

Impact

An attacker could cause a denial of service through memory exhaustion, but the impact is limited because the connection fails immediately and memory is freed if SSL_free() is called promptly; only applications that delay SSL_free(), run in constrained environments, or face many simultaneous connections are at risk.

What the attacker needed

OpenSSL 1.1.0 TLS server; Attacker can initiate TLS connections; Application delays SSL_free() or has limited memory

The fix

The issue was fixed in OpenSSL 1.1.0a; users should upgrade.

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.

When two computers talk securely using TLS, each message includes a length field. OpenSSL checks that the length is not too big to avoid using too much memory. In version 1.1.0, the check happens after memory is already reserved, so an attacker can make the program reserve a large amount of memory (up to 21 megabytes) for each connection attempt. If many connections are made or the program does not free memory quickly, the server can run out of memory and crash.

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.

More by theyarestone

View all

7 more disclosed reports, best first.

More from Internet Bug Bounty

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Denial of service

The lesson behind this report.

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.