On a very very quick read, the bug is that EVP_EncodeBlock malfunctions if the input is larger than ~1.5GB. EVP_EncodeBlock is a function that encodes base64.
As a seasoned C programmer, I can immediately observe that the whole API is bad: the caller is expected to calculate the buffer length in their own, using a nontrivial formula, and the caller does not pass in the output buffer length, so the implementation cannot validate it. But apparently OpenSSL 4 also implemented it wrong and wrote (possibly far) past the end of the buffer.
You should probably assume that, if you are running anything that can be convinced to use this API to encode a very long blob as base64, then you are in trouble. I don’t know why a modern server would do this.
BTW, OpenSSL seems to be a rather low quality implementation of a very low quality set of APIs. Stay away.
edit: Fixed my size threshold, hopefully. I was thinking of unsigned ints, but this is a signed int. I have not looked at the code, just the description.
I like to declare that industry coding standards such as MISRA exist precisely because code bases like OpenSSL (specifically) exist, as it's such a good example of breaking every sensible rule in the standards.
...on a system where ints are 32 bits. The bottom line is that this doesn't appear to be easily exploitable and IMHO it should be the callers of EVP_EncodeBlock which need to be inspected to determine the actual risk.
using a nontrivial formula
It's base64. 4/3 expansion; round it up and add padding. What's "nontrivial" about that?
and the caller does not pass in the output buffer length, so the implementation cannot validate it
Not necessary, because the caller is responsible for allocation.
The question can be reduce to "who do the length validation".
In my case, if i write a public-facing API, i never trust the caller will do the correct thing, thus the caller must provide all the critical parameters, and i must validate all of them.
> EVP_EncodeBlock() encodes a full block of input data in f and of length dlen and stores it in t. For every 3 bytes of input provided 4 bytes of output data will be produced. If dlen is not divisible by 3 then the block is encoded as a final block of data and the output is padded such that it is always divisible by 4. Additionally a NUL terminator character will be added. For example if 16 bytes of input data is provided then 24 bytes of encoded data is created plus 1 byte for a NUL terminator (i.e. 25 bytes in total). The length of the data generated without the NUL terminator is returned from the function.
My god, you only see this type of horrendous API in C don't you.
Perhaps I'm just used to having programmed in C# professionally for a little bit, but these sorts of APIs where you have to do a calculation to determine the destination buffer size make me feel like a caveman. A minuscule typo and you get a CVE like this.
I know, I know, C is low level and high performance, but surely in the year of our lord 2026, we could have come out with something simpler.
>As a seasoned C programmer, I can immediately observe that the whole API is bad: the caller is expected to calculate the buffer length in their own, using a nontrivial formula, and the caller does not pass in the output buffer length, so the implementation cannot validate it. But apparently OpenSSL 4 also implemented it wrong and wrote (possibly far) past the end of the buffer.
Many such cases.
I expect we'll see some fun libyuv bugs soon in applications which decode media. The APIs are begging for misuse.
I think CVSS 9.8 is exaggerated. This is not remotely anywhere near as serious as Heartbleed. It's an internal function which will fail if its input is far too long, but exploitability rests on how untrusted input can reach it; the key word being "untrusted". E.g. if you operate a base64 encoding service on the Internet that just reads all the data into memory at once and calls EVP_EncodeBlock(), that's exploitable. If you have a protocol that involves a block of data with a 16-bit length field which is passed to EVP_EncodeBlock(), that's 100% safe.
For those wondering about TLS: speaking as someone who has written a TLS implementation, AFAIK neither base64 encoding nor decoding occurs in the protocol itself, and the longest length field is 24 bits (Hello stream). Certificate processing involves ASN.1 which does support arbitrarily-long integers, but that's a big hint to check that they're within a sensical range.
(I'm a broken record on this so I'll keep it brief). The problem here is that the CVSS score is in the headline, as if it meant anything. But CVSS doesn't mean anything. It's a Ouija board; VR people jack it up to get attention, vendors nerf it to chill their customers out.
Someone should design something better, and less malleable.
It feels to me the only way to beat LLMs finding vulnerabilities is to have LLMs (or LLMs paired with other AI methods) constantly monitor your infrastructure, traffic, database, etc. to ensure that nothing out of the ordinary is happening
I think so too; I think apart from pushing vulnerability research forward (which is important on its own merits just for computer science reasons), the major engineering challenge of this moment is figuring out how to make platforms resilient without rewriting everything; that could be better live-patching, it could be some weird monitoring thing, it could be automatic segregation and workload isolation.
It's not "just keep up with the patches". That's going to be a losing strat.
So, uh, like, any word on what the "9.8" actually means? Is this "an obscure feature nobody has on could with a bit of luck and a cosmic ray strike allow arbitrary code execution if you're one of the few people using it" or is this "if you have a socket with OpenSSL exposed to the internet you're already compromised" or what?
So this might be very similar to Java4shell, though will need to be verified.
This is another base64 encoder where it takes a blob and coverts it to base64. I'm assuming an attacker control bit of data could be passed to the function which then overflows. Not sure if it can attempt to control a valid address or not, but unlocked AI likely could pretty quick.
I see the OpenBSD guys are all over the PR (deservedly) shitting all over the proposed fixes so I assume LibreSSL may be impacted? Or are they just providing free advice and color commentary?
I'm not really involved in OpenSSL, aside from a few tiny changes and commenting on a few things that affected GNU coreutils. However, I have seen Bob, whom I assume you are referring to based on the profile picture, participate in many discussions. I wouldn't infer too much from it.
>>I am really worried about the negative return value being added. Existing third party callers might not be ready to handle this correctly (i.e. if they cast the return to size_t without checking). Could we instead return 0? (In all the added error returns in this PR.)
https://docs.openssl.org/1.0.2/man3/EVP_EncodeInit/
As a seasoned C programmer, I can immediately observe that the whole API is bad: the caller is expected to calculate the buffer length in their own, using a nontrivial formula, and the caller does not pass in the output buffer length, so the implementation cannot validate it. But apparently OpenSSL 4 also implemented it wrong and wrote (possibly far) past the end of the buffer.
You should probably assume that, if you are running anything that can be convinced to use this API to encode a very long blob as base64, then you are in trouble. I don’t know why a modern server would do this.
BTW, OpenSSL seems to be a rather low quality implementation of a very low quality set of APIs. Stay away.
edit: Fixed my size threshold, hopefully. I was thinking of unsigned ints, but this is a signed int. I have not looked at the code, just the description.
We’ve known this for well over two decade since heartbleed yet for some reason Linux distros haven’t migrated off of it
...on a system where ints are 32 bits. The bottom line is that this doesn't appear to be easily exploitable and IMHO it should be the callers of EVP_EncodeBlock which need to be inspected to determine the actual risk.
using a nontrivial formula
It's base64. 4/3 expansion; round it up and add padding. What's "nontrivial" about that?
and the caller does not pass in the output buffer length, so the implementation cannot validate it
Not necessary, because the caller is responsible for allocation.
In my case, if i write a public-facing API, i never trust the caller will do the correct thing, thus the caller must provide all the critical parameters, and i must validate all of them.
My god, you only see this type of horrendous API in C don't you.
https://xeiaso.net/blog/series/no-way-to-prevent-this/
gets(), on the other hand, that is "horrendous".
But yes, gets is worse.
I know, I know, C is low level and high performance, but surely in the year of our lord 2026, we could have come out with something simpler.
Horrendous is a strong word, you're right.
Many such cases.
I expect we'll see some fun libyuv bugs soon in applications which decode media. The APIs are begging for misuse.
https://chromium.googlesource.com/libyuv/libyuv/+/refs/heads...
For those wondering about TLS: speaking as someone who has written a TLS implementation, AFAIK neither base64 encoding nor decoding occurs in the protocol itself, and the longest length field is 24 bits (Hello stream). Certificate processing involves ASN.1 which does support arbitrarily-long integers, but that's a big hint to check that they're within a sensical range.
Someone should design something better, and less malleable.
And yea, I'd really like a day where I'm not writing an email to customers about what they do and don't need to update regarding our software.
It's not "just keep up with the patches". That's going to be a losing strat.
I feel like in the post heartbleed era, a lot of people are not including new features of upstream openssl as much as they used to.
Fortunately it doesn't look like I need to patch anything at work though.
This is another base64 encoder where it takes a blob and coverts it to base64. I'm assuming an attacker control bit of data could be passed to the function which then overflows. Not sure if it can attempt to control a valid address or not, but unlocked AI likely could pretty quick.
Sometimes the fix can be worse than the bug. Like patching a hole in the wall.
Rust fixes it.