My god, you only see this type of horrendous API in C don't you.
gets(), on the other hand, that is "horrendous".
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.
You could have come with something simpler in PL/I.
But yes, gets is worse.
If there is no fixed relationship between the two, then that makes sense; but in this case there is a very simple and well-defined relationship between them. But to specify two lengths which must always agree; and if not, then what? You've effectively invented an additional artificial error condition, an additional branch, and burdened all the callers up the chain to do something, which is a treacherous path to complexity and the production of even more bugs.
Or are you just preaching the same mindless idiocy that lead to Microsoft's memcpy_s() (the "s" is for "stupid")?
(Honest questions in this it’s probably been 20 years since I did c)
The only reason for such a design I could think of is that the caller would be able to "detect" the overflow by comparing the returned value against the length of the buffer. But that is of course pointless, as the compiler is free to assume a buffer overflow cannot happen and thus optimize the check away...
This is the appropriate place to put a link to this pair of classics on API design:
"How Do I Make This Hard to Misuse?" https://ozlabs.org/~rusty/index.cgi/tech/2008-03-30.html
"What If I Don't Actually Like My Users?" https://ozlabs.org/~rusty/index.cgi/tech/2008-04-01.html
We’ve known this for well over two decade since heartbleed yet for some reason Linux distros haven’t migrated off of it
And to be fair to OpenSSL, it was one of the first widely used crypto libraries, along with Netscape's NSS. Setting aside the reasonablebess of the initial choices, the rapid uptake meant those choices were difficult if not impossible to completely unwind, particularly the style and typing of parameters and error reporting. Even today debates rage about signed vs unsigned, etc, in C and other languages. (But suffice it to say there are still alot of unforced errors, IMO, such as implicit output buffer sizes.)
EDIT: found the release announcement - June 2015 - https://aws.amazon.com/blogs/security/introducing-s2n-a-new-...
In that world, certainly some projects may be impervious to fixes. We've all seen projects that basically eschew all change, and ignore issue trackers, and are basically dead.
But the ones which still live? Eventually this first wave of LLM derived fixes will get through the old churn. Presumably, code will improve dramatically. If that's so, OpenSSL will become "good code". And the same with old legacy projects which are still hanging around.
Meaning... will legacy simply exist forever? Our two forks above will likely fade away, if openssl's code becomes clean as can be.
LibreSSL had, IIRC, problem known as OpenBSD-itis. Or to put it bluntly, the developers didn't really care about any other platform. Plus I will admit that being the first and loud "we will fix openssl" they got linked with some loud PR that showed less understanding of code they mocked than OpenSSL developer who wrote it, and that's really impressive when you consider some of the mocked code fragments were results of developers never reading foundational documentation for a platform
If you ever try to use libreSSL you rub up against so much friction that most projects would hammer out early.
Well put. This is the crux of the issue.
If only it kept itself to that…
Beyond that, when it comes to exceptionally complex APIs, forward thinking implementation, and revising the 'way things are done'? These are weak points for LLMs. If you don't know how to write OpenSSL(or its replacement), and don't understand all its quirks, and the entire industry surrounding it, you cannot be the human driving the LLM successfully.
There was a great quote at this year's OpenSSL conference that went something like "LLMs if left to their own devices will reinvent sendmail".
if you lok at the commit history of OpenSSL, you can easily notice how a lot of people started contributing once their clanker got up to speed. They are very happy to rip out weird C and replace it with assembler or intrinsics. Rip out lists of characters formatted as a single string and replace them with array syntax, each char quoted.
No need for "AGI", the compiler just needs to have enough value tracking to know that the value saturates (once a bit is set, it never gets unset), and an heuristic to move the comparison inside the loop when it might allow it to do less loop iterations.
(I wrote a Rust crate to do precisely that kind of "constant time memcmp", and the only truly reliable way to do so without help of the compiler, is by using inline assembly as a "black box" to make a few things invisible to the compiler's optimizer. It was inspired by code in the Linux kernel which did the same thing also using inline assembly as a "black box".)
...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.
At the boundary where untrusted input becomes trusted. This is commonly known as the sanitisation/validation layer.
If you mean ceil(inlen * 4/3) + 1 (even if you use exact arithmetic), then you are passing too small a buffer and you will overflow. Which, I think, proves my point.
You should not need to read the manpage of a function you are calling in order to determine whether you have passed a large enough buffer to avoid overflow.
Reading the manpage to get the function to not return an error would be a different story.
If you let untrusted input reach inlen and overflow that computation, you have already failed:
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...
OpenSSL has been around a long time and has a lot of legacy code, but this is in OpenSSL 4.x only -- stuff that was written in the last ~year.
If they don't have the manpower to write new code safely they should just stick to maintaining what they've already written.
If my googling found the PR supposed to fix this, the code before this PR included the check. But that was old code!
Fully agree with your assessment above that line, but damn, this is a strong statement for a library this ubiquitous. You wonder; how could this happen? And yet, as an open source developer myself, I know how little people care about code quality.
All these trillion dollar tech companies have been leaching off open source for free and never contributed back to the projects they rely on.
Then I read articles about billionaires donating millions or even billions to various (sometimes frivolous) charities and I wonder WTF.
The numbers just don't add up. It's like there is an invisible force field preventing people from donating money to open source?
From your HN bio, I guess this is your project: https://socketcluster.io/
From the home page, I see that you are sponsored by two different companies. To me, "in terms of funding, it's crickets for me" isn't an honest statement.
If funding is such a problem for you, why don't you use a non-open source license, e.g., Business Source License? This would allow non-commercial projects to use your software for free, but commercial users need to pay. There are a bunch of big, important open source projects that already changed: HashiCorp, CockroachDB, MariaDB, etc.
[1] https://openssl-corporation.org/blog/2025-02-14-annual-repor...
[2] https://www.openssl-corporation.org/assets/Annual-Report-202...
Yes, that Automattic. Yes, that Google, AWS and Cisco. Yes, that Microsoft. There are one or two entities in this list I don't mind but... damn.
It's time to retire the phrase "open source" and go back to "free software". Not many people know "open source" was originally coined by corporations who didn't want anything to do with freedom.
The problem with "free software" lies exclusively with the English language; other languages don't have the same issue due to having separate words for "freedom" and "zero price".
Also see LibreOffice.
No: first not "many", but very few. And second they are proprietary projects.
Other people express strong opposition to the idea that "open" might just mean the same thing as "available" in the context of open source. None of those people have proposed a more coherent definition that I've seen of what that word means in that specific phrase though.
What you're asking is, should widely used libraries be proprietary software sold for money? And that is indeed an honest question. There's a huge ecosystem of developers out there who say yes, there's nothing special about that idea at all.
For example, on Apple, Google and Microsoft platforms you don't use OpenSSL when writing native apps. You use the vendor's cryptography APIs. The licenses of Windows and macOS force all users large or small to pay for them. On Android, the native crypto provider is Conscrypt:
https://github.com/google/conscrypt/
... which is open source, but you will notice that it doesn't accept outside contributions and is funded by revenue from Android's proprietary components licensing. So that's very close to the model you're suggesting: it's "open source" but in practice large corporations pay Google lots of money for the privilege of shipping it.
Moreover Google fund BoringSSL and other forks of OpenSSL. The issue here isn't funding levels (anymore). The issue is that OpenSSL is written in C, and not very good C at that.
The thing you're allowed to charge for but only a reasonable amount is to provide the sources to software you have previously distributed, for free or otherwise. If I get some binaries from you and then request the sources too, under the GPL, you are forced to provide them, but you can ask for a fee to cover the transfer costs.
Alternatively they can put such large share-back requirements that corporations don't want to use it and would rather pay for an alternate license. SSPL and to a lesser extent AGPL achieve this.
And when Redis changed their license for such reasons, companies and people united to create ValKey or even the Centos/Rocky linux situation.
All yours! Use it to your heart's content.
The API is a fractal of bad design. Not just that, but because of the API refusing to make sensible choices, it forces everyone using it to be an expert in cryptography, with predictable results on those programs that use it.
> And yet, as an open source developer myself, I know how little people care about code quality.
This is a weird statement. I am someone who has worked on closed-source internal enterprise software for my entire career. Universally, the internal source is worse that the numerous open source libraries that we use. If anything, open source has "more eyeballs" than closed source, so the code quality will be better.It all came from a bad place. OpenSSL grew from primitives created by cryptographers. Cryptographers are great, and they make fabulous things. But almost none of the understand software development or care a great deal about the mundane matters of API design.
There is a reason why people did not do a lot of TLS (outside of anything involving monetary transactions) before Firesheep, the NSA leaks were the final nail in the coffin for unencrypted HTTP. On top of that Let's Encrypt and ACME did not exist, so TLS was behind a paywall on top of that.
And then everything proliferated relatively quick even for tech standards. I guess people grabbed onto the next available tooling just like a drowning person would take any piece of driftwood.
Not so fun fact: AFAIK the openssl binary was initially explicitly meant to be only used for testing. That is why its command line is so strange. It was initially meant to expose a couple of low-level primitives, not to implement workflows. One example would be the openssl-ca man page, which explicitly mentions this. People didn't care because unfortunately you could somehow do everything you could ever want with the openssl binary and I guess that is also something how the impression stuck that openssl is the most advanced library.
I'm in shock ! Someone noticed ! Thanks man ! :)
In the meantime in real world IT :>>
line 57: https://github.com/acmesh-official/acme.sh/blob/master/acme....
line 306: "This script requires openssl binary" https://github.com/dehydrated-io/dehydrated/blob/master/dehy...
Pretty recommended scripts :)
And I'm sure there are more and not only for ACME, for example I'm sure I saw few examples in production setup docs from IBM and Redhat... :>
Yes, openssl library is wholesale backdoor, subtype: footgun.
Among the deeply technical and highly credible and detailed articles I've read in my life, it's definitely the spiciest. At the end:
> It is often said that fixing a problem requires smarter minds than those who created that problem. When the problem was architected by a team with strong convictions about the solution‘s correctness, it seems extremely unlikely that the resolution will come from the team that created that problem in the first place. The lack of progress in the latest releases tends to confirm these unfortunate hypotheses. The only path forward seems to be for the team to revert some of the major changes that plague the 3.x versions, but discussions suggest that this is out of the equation for them.
IOW this extremely strong claim does seem to be supported by extremely credible actors.
Well sure, but the world doesn't seem to be able to agree on, or put resources into, a strong contender.
I'm usually for heterogeneity and diversity in the software ecosystem, but for cryptography I'd be happy with a single high-quality "anointed path". Because cryptography.
"Although BoringSSL is an open source project, it is not intended for general use, as OpenSSL is. We don't recommend that third parties depend upon it. Doing so is likely to be frustrating because there are no guarantees of API or ABI stability." (Their README).
> LibreSSL
That does indeed still seem like the most promising avenue. But it is "just" a fork of OpenSSL.
> rustls
... which relies on one of two crates with zero regard for long term support. "Latest release or bust" doesn't cut it for crypto.
Yes. Which is precisely why you need cryptographic libraries that take long term support seriously and don't just fix whatever the latest version is.
> Just recently you needed to block eMudhra intermediate certificates.
Why on earth is your TLS library responsible for your CA certificate database?!
I swear it's de rigueur in C that if an operation requires 5 parameters to insure the operation is error free than the function shall only take 4 parameters.
Rewriting the function with idiot mode disabled
int EVP_EncodeUpdate(EVP_ENCODE_CTX ctx, buffer_t out, const slice_t in);
Or just use bloody C++ that solved that years ago with std::span.
Unfortunately, many C dev prefers whining about "How horribly bloated" C++ is instead of using the part that makes sense.
Providing C compatible APIs is one of them.
However, I do not see any reasons to start a plain C user space project in 2026. Excepted if you are embedded / kernel dev.
Everything advantage you do have in C (portability, compatibility, memory control).... you have them in Modern C++, but better.
Nintendo has been writing their OSes (3DS and Switch 1/Switch 2) fully in C++ (microkernel included), so not even this is an excuse to use C over C++.
Now, rewrite in Ada, given that GNAT supports the same targets as rest of GCC...
On security, both clang and gcc have security flags for this and Boehmgc (or even mimalloc) can be temporally used as a replacement to avoid nasty surprises.
Well, it depends. if in the coming weeks many more Heartbleed-level vulnerabilities would be exposed, {Amazon, Google, OpenAI, Anthropic} can just rewrite it in Rust, formally verified.
There does not exist such implementation as of now as OpenSSL was good enough, AI may expose so many security flaws it would no longer be good enough.
Yep, this is not news. https://en.wikipedia.org/wiki/LibreSSL was forked off OpenSSL now more than ten years ago to address exactly these kind of issues, and more (at the price of occasionally taking some drastic measures)
But somehow we're still here.
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.