DEV Community

Cover image for OpenSSL CVE-2026-121481: Base64 Overflow Explained
devTalk
devTalk

Posted on Originally published at dev-talk.com

OpenSSL CVE-2026-121481: Base64 Overflow Explained

Last updated: 21 November 2026. The arithmetic and the "which OpenSSL do I have" checks were run on Ubuntu 24.04 with OpenSSL 3.0.13. Everything about OpenSSL's own rating, fix dates and exploitability comes from secondary reports, because I could not open OpenSSL's advisory for this CVE. SeeHow this was checked.

CVE-2026-121481 is a heap buffer overflow in EVP_EncodeBlock(), OpenSSL's Base64 encoder. The record carries a CVSS 3.1 score of 9.8, which is why headlines call it critical. But the score is reportedly not OpenSSL's own, the trigger needs about 1.6 GB of input in a single call, and no patched release exists yet. This article explains the bug, shows the arithmetic by running it, and sets out what is worth doing before the fix ships.

The short version

  • The bug: EVP_EncodeBlock() takes an int length and returns an int. Base64 output is a third bigger than the input, so an input of about 1.5 GiB or more produces output that no longer fits in an int. The function does not check and can write past the caller's buffer.
  • Affected per the CVE record: OpenSSL 4.0.0 to 4.0.3 and 4.1.0.
  • Fix: 4.0.4 and 4.1.1, reported as scheduled for 1 December 2026. The pull request (#33652) was reported as on hold for discussion as of 20 November.
  • Exploitability: no public exploit, no observed attacks and no CISA KEV listing in the reports I read. The only trigger described so far is openssl s_client with a huge -proxy_pass set by the person running it.
  • Your action: find applications that Base64-encode large, outside-controlled data with OpenSSL; patch on your normal cycle once the release ships.

The arithmetic, by running it

Base64 turns every 3 input bytes into 4 output characters, so the output is 4 * ceil(n / 3) bytes. An int tops out at 2,147,483,647, which makes the largest safe input (INT_MAX / 4) * 3 = 1,610,612,733 bytes. I checked that against the OpenSSL installed here (3.0.13). The program below always gives the encoder an output buffer that is large enough, so nothing is written out of bounds. It only shows what the function reports:

#include <stdio.h>
#include <limits.h>
#include <sys/mman.h>
#include <openssl/evp.h>

static void run(long dlen) {
    size_t outsz = (size_t)4 * ((dlen + 2) / 3) + 1;   /* correct size, computed in size_t */
    unsigned char *in  = mmap(NULL, dlen, PROT_READ, MAP_PRIVATE|MAP_ANONYMOUS|MAP_NORESERVE, -1, 0);
    unsigned char *out = mmap(NULL, outsz, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
    int r = EVP_EncodeBlock(out, in, (int)dlen);
    printf("dlen=%ld true_output_len=%zu returned=%d\n", dlen, outsz - 1, r);
}

int main(void) {
    run(1610612733L);   /* largest input whose output fits in an int */
    run(1610612734L);   /* one byte more */
}
Enter fullscreen mode Exit fullscreen mode
gcc -O1 -o enc enc.c -lcrypto && ./enc
Enter fullscreen mode Exit fullscreen mode

The output on this machine:

dlen=1610612733  true_output_len=2147483644  returned=2147483644
dlen=1610612734  true_output_len=2147483648  returned=-2147483648
Enter fullscreen mode Exit fullscreen mode

One byte past the threshold, the function returns a negative number for a successful encode, because the true length no longer fits. That confirms the arithmetic, and it also shows that the old 3.0 code has the same behavior, although the CVE record lists only 4.0.0 to 4.0.3 and 4.1.0 as affected. I read that as a statement about what the project analyzed and which releases it will fix, not as proof that 3.0 behaves differently; ask your vendor about the branch you run. What I did not do is call the function with an undersized buffer, so I did not reproduce the memory corruption itself. A third-party write-up (on dev.to) reports running the scalar encoder code under AddressSanitizer with a 1 MiB output buffer and a huge length, and seeing a heap-buffer-overflow.

Why 9.8, and why that is disputed

The reports disagree about how serious this is:

Who Rating or position
CVE record (CISA-supplied score, per several reports) CVSS 3.1: 9.8, the score that assumes a remote attacker with no authentication and no user interaction.
OpenSSL Conflicting reports. One says OpenSSL rates it Low because no attacker path is known; another says OpenSSL has not rated it. I could not read the advisory.
Ubuntu Medium priority, with its main openssl packages still to be evaluated, per one report.
The patch author Per a report I could not open, argues that openssl s_client can reach the bug, which disputes OpenSSL's reasoning.
EPSS (as quoted by one site) About 0.14% chance of exploitation in 30 days.

The practical reading: the score describes the worst case for a flaw in a library function that depends entirely on what the calling application feeds it. It does not mean every service using OpenSSL can be taken over. For an attacker to exploit it, an application must (1) call EVP_EncodeBlock() directly or indirectly, (2) with roughly 1.5 GiB or more in one call, (3) of data an attacker influences, and (4) with an output buffer sized from a wrapped int. Few real services do that.

The s_client path

The one described trigger is openssl s_client -proxy_pass, the option that takes the proxy authentication password source. The password would have to be gigabytes long, and on Linux that is hard to supply through the usual routes: in my test, a single command-line argument of 100,000 bytes was accepted and one of 140,000 bytes failed with Argument list too long, which matches the kernel's roughly 128 KiB per-argument limit. A password read from a file is a different route that I did not test. The point is that this needs a local operator doing something unusual, which is why several commentators call the 9.8 exaggerated.

What to do

1. Inventory which OpenSSL you actually run

One host usually has several OpenSSL copies. Here is what mine reported:

openssl version                                  # OpenSSL 3.0.13 30 Jan 2024
node -p "process.versions.openssl"               # 3.5.9
python3 -c "import ssl; print(ssl.OPENSSL_VERSION)"   # OpenSSL 3.5.9 29 Sep 2026
php -r 'echo OPENSSL_VERSION_TEXT, "\n";'        # OpenSSL 3.0.13 30 Jan 2024
ldd "$(command -v curl)" | grep -E "ssl|crypto"  # libssl.so.3, libcrypto.so.3
Enter fullscreen mode Exit fullscreen mode

On this machine the system library was 3.0.13 while Node and Python reported 3.5.9, so they use different copies. That is the reason to check each runtime and each container image instead of the system package alone. One report notes that Ubuntu flags the Node.js package on 22.04 as vulnerable because it bundles its own OpenSSL. None of the versions on my machine is in the 4.0 or 4.1 line that the CVE record lists, and I did not look at Debian or RHEL.

2. Cap the size before you encode

If your code passes data of unknown size to EVP_EncodeBlock(), reject anything above the limit before the call. This is the limit that the proposed OpenSSL fix is reported to enforce:

#include <limits.h>
#include <stddef.h>

#define B64_MAX_INPUT ((INT_MAX / 4) * 3)   /* 1,610,612,733 on a 32-bit int */

if (len > (size_t)B64_MAX_INPUT) {
    return -1;   /* refuse; do not call EVP_EncodeBlock() */
}
Enter fullscreen mode Exit fullscreen mode

A hard application limit far below that, such as a few megabytes for a form field or API payload, is better. Also size the output buffer in size_t (4 * ((len + 2) / 3) + 1), not int. For genuinely large data, encode in chunks, for example with the streaming EVP_EncodeInit, EVP_EncodeUpdate and EVP_EncodeFinal functions, rather than one huge call. I did not test those; check the OpenSSL manual for their limits.

3. Update when the release ships, then restart

The fix is reported as 4.0.4 and 4.1.1 on 1 December. Distribution packages may follow at their own pace and the version numbers will not match upstream's, so check the package changelog for the CVE number as with any backport. After updating, restart the services that load the library and confirm what they use. Applications that bundle OpenSSL (Node.js and similar runtimes, containers) need their own update. One caveat: the proposed fix reportedly turns the overflow into an immediate abort rather than an error return, so after patching, an oversized call crashes the process instead of corrupting memory. A follow-up issue (#33812) discusses returning an error instead.

4. Do not panic-patch to unreleased code

With no released fix and a disputed rating, rushing an unreleased branch into production is a bigger risk than the bug for most teams. Limit inputs, inventory, and wait for the tagged release.

Common mistakes

  • Treating the 9.8 as a statement that all your TLS endpoints are remotely exploitable. The bug is in a Base64 helper, not the TLS handshake.
  • Checking onlyopenssl version. Runtimes and containers carry their own copies.
  • Computing the output size in anint. That is how the bug works.
  • Assuming "not listed" means "not affected". I saw the same integer wrap on 3.0.13, which the CVE record does not list.
  • Confusing this with other OpenSSL issues. It differs from the DTLS memory-disclosure flaw: this one writes outside a buffer, that one reads outside one.

Related Dev Talk articles

Frequently asked questions

Is CVE-2026-121481 exploitable remotely?

Only if an application passes roughly 1.5 GiB or more of attacker-influenced data to EVP_EncodeBlock() in a single call. The CVSS 9.8 assumes the worst case. No exploitation has been reported.

Which OpenSSL versions are affected?

The CVE record lists 4.0.0 through 4.0.3 and 4.1.0. I saw the same integer wrap in 3.0.13, so ask your vendor about older branches.

Is there a patch?

Fixed releases 4.0.4 and 4.1.1 are reported as scheduled for 1 December 2026. As of 20 November the pull request was reported as on hold for discussion.

Does this affect HTTPS or TLS connections?

The reports describe a Base64 helper function, not the TLS handshake, and none says TLS connections are exposed. I did not verify OpenSSL's TLS internals, so I cannot rule out other callers of the function.

What is the safest immediate step?

Enforce a size limit on anything you Base64-encode, and inventory your OpenSSL copies.

update log

  • 21 November 2026: first version.
  • To recheck on each update: OpenSSL's advisory and severity, whether 4.0.4 and 4.1.1 shipped on 1 December, whether the fix aborts or returns an error, affected older branches, and any KEV or exploitation reports.

Sources


Originally published on DEV Talk.

Top comments (0)