Dev.to Security 🔐 Cybersecurity 👁 0 📖 6 min read

OpenSSL's Base64 Function Has a 9.8. The Score Is the Least Interesting Part

OpenSSL's Base64 Function Has a 9.8. The Score Is the Least Interesting Part Last week, OpenSSL got a 9.8. Not in TLS. Not in the handshake, not in certificate parsing, not in anything with "crypto" in the name that wo

OpenSSL's Base64 Function Has a 9.8. The Score Is the Least Interesting Part

Last week, OpenSSL got a 9.8. Not in TLS. Not in the handshake, not in certificate parsing, not in anything with "crypto" in the name that would make a headline writer's job easy. In base64.

The function is EVP_EncodeBlock(). It takes bytes in and writes base64 out. It is the kind of function you call a hundred times a day without thinking about it, because it does the most boring job in cryptography: turning binary into printable text. On November 18, OpenSSL published CVE-2026-121481 against it, a heap buffer overflow, and CISA's scoring put it at 9.8 out of 10. Critical. The Hacker News thread ran to 300 comments. Security feeds lit up overnight.

Then OpenSSL itself rated the severity Low.

Both of those things are true, and the gap between them is the actual story.

What actually broke

Here is the function:

int EVP_EncodeBlock(unsigned char *t, const unsigned char *f, int n)

It reads n bytes from f, writes base64 into t, adds a NUL terminator, and returns the number of encoded bytes. Every three input bytes become four output bytes. The caller allocates t, and the documentation tells the caller how big it needs to be: 4 * ((len + 2) / 3) + 1.

The problem is the int. The length parameter is a signed 32-bit integer, and so is the arithmetic that sizes the output. Feed it an input length close to INT_MAX, around 2.15 gigabytes, and the size calculation wraps around. The real output for that input is about 2.86 GB. The wrapped calculation says about 1.43 GB. The function writes the full 2.86 GB into a buffer sized for 1.43 GB, and you have a heap buffer overflow.

That is the whole bug. No exotic memory corruption technique, no chain of three vulnerabilities. Just integer arithmetic in a function that has been doing this job since the SSLeay days, before most of us were writing code.

Why the 9.8 and the Low are both honest

CVSS scores the worst case. It asks: if an attacker could reach this, with no authentication and no user interaction, how bad would it be? The answer is a heap overflow in one of the most widely deployed libraries on earth, so the number is 9.8. That is what the number is for. It is a ceiling.

OpenSSL asked a different question: can an attacker actually reach it? And the answer, after they went looking, was that they could not find a path. Their own TLS, QUIC, and CMS implementations never encode a buffer anywhere near that size in a single call. The command line tools cannot practically be made to do it either. The one confirmed trigger runs through the proxy password helper in openssl s_client, which is not exactly a service you expose to the internet. To reach the bug at all, an application has to accept an attacker-controlled length and hand it to the encoder without checking it first, and it has to already be holding a two-gigabyte buffer to do so.

So CISA is right that the worst case is critical, and OpenSSL is right that the realistic case is low. The EPSS score, which estimates the probability of actual exploitation, sits at 0.14 percent. There is no known exploitation, no public proof of concept, and it is not on CISA's Known Exploited Vulnerabilities list.

This is the part that gets lost when a CVE number trends. A score is not a forecast. It is a measurement of the ceiling, and the ceiling of a function that every program on the planet links against is always going to be high. Reading an advisory means reading past the score to the trigger conditions, and the trigger conditions here say: you need a single two-gigabyte input, in one call, from an attacker, into a function almost nobody calls that way.

The part worth paying attention to

The interesting thing is not the overflow. It is the API.

Look at that signature again. The function receives a destination pointer and no size for it. It cannot check whether the buffer is big enough, because nobody told it. The caller is expected to do the arithmetic, and the arithmetic is the thing that overflows. The function trusts the caller completely, and the caller trusts the documentation's formula completely, and neither side has any way to catch the other being wrong.

This is a design from the 1990s, and it survived because base64 encoding is boring. Nobody audits the boring functions. The streaming version of the same API, EVP_EncodeUpdate(), got input guards at some point. The one-shot version never did, because who would bother attacking base64?

That is the lesson I keep coming back to in my own work. I build a messenger, and base64 is everywhere in it: keys, tokens, message payloads, anything that has to survive being text. I did not write those encoders myself, and neither did you. We all stand on a stack of small utility functions that were written decades ago, reviewed less than the code around them, and called with the assumption that they cannot fail because they are too simple to fail.

The fix that won approval in OpenSSL's pull request #33652 is an assertion, not a redesign. The function will refuse inputs it cannot safely encode instead of wrapping around silently. That is the right call, and it is also a small admission: the API cannot be fixed without breaking every caller, so the best you can do is make it fail loudly.

If you write code that calls into a crypto library, the takeaway is not "base64 is dangerous." It is that the boundary between your code and the library is where the assumptions live, and assumptions are what break. Bound your inputs before they cross that boundary. Do not hand a library a length you did not check yourself, just because the library never complained before. And when you review your own code, spend some time on the boring parts. The handshake code gets reviewed. The base64 call does not.

What to do about it

The affected versions are OpenSSL 4.0.0 through 4.0.3, and 4.1.0. The 3.x line is outside the affected range. Fixes land in 4.0.4 and 4.1.1, expected on December 1, alongside fixes from the November 10 and 17 advisories.

Until then, the practical steps are short:

  • Check what you actually run. openssl version tells you the system one, but the copies that matter are often the ones you forgot about: containers, vendored builds, runtimes that embed their own OpenSSL. Node.js is the classic blind spot here, and Ubuntu's tracker already flags its nodejs package on 22.04 LTS as vulnerable.
  • If you call EVP_EncodeBlock() on data you did not produce, cap the input size before the call. A few megabytes is a generous limit for a single base64 encode. Nothing legitimate needs two gigabytes in one shot.
  • When 4.0.4 or 4.1.1 ships, upgrade and rescan. A version number in a changelog is not proof that your distribution's package has the fix yet.

This is not Heartbleed. Nobody's keys leaked, nobody's traffic was decrypted, and most systems were never in reach of the bug at all. But it is a good reminder of something easy to forget: the most dangerous code in your dependency tree is usually the function you stopped thinking about years ago. Base64 does not feel like an attack surface. Last week, for one specific input size, it was one.

Sources: OpenSSL advisory for CVE-2026-121481 (published November 18, 2026); OpenSSL fix PR #33652; CISA ADP CVSS 3.1 scoring; Ubuntu security tracker.

📰 Read the original article on Dev.to Security

Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.