upvote
> BTW, OpenSSL seems to be a rather low quality implementation of a very low quality set of APIs.

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.

reply
We have known this since at least heartbleed. The answer was that basically no one funds the project and it had only one developer.

All these trillion dollar tech companies have been leaching off open source for free and never contributed back to the projects they rely on.

reply
Honest question: shall free software licenses be changed to force large corporations to sponsor free software projects adequately?
reply
Many important open source projects have already switched to Business Source License. However, they only switched after they became famous. I have not seen any projects that became famous that started with BSL.
reply
> Many important open source projects have already switched to Business Source License.

No: first not "many", but very few. And second they are proprietary projects.

reply
Some of us have the radical opinion that the definition of open source isn't what a specific organization (with no trademark on the term) dictates, but whether the source is open.

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.

reply
"Open Source" and "Free Software" are both well-established terms with well-documented histories of debate and consensus-forming among huge and healthy communities over a span of decades, and organizations that steward the meanings of those terms. Just because you don't like them doesn't mean you get to pretend you're the first person to try to define the word "open" for software.

https://opensource.org/osd https://www.fsf.org/licensing/

reply
I often hear this criticism and "bait-and-switch" is also mentioned. At the same time, when you have a small project or tool only used by a handful of people the risk of it being hacker or not responding in time is very different to a project which is essential to the whole world. I don't now what a realistic solution would look like though.
reply
Then it wouldn't be free software anymore.
reply
Yes, they should do this. Howvee, they'd stop being considered free software and open source.

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.

reply
A free software license is by definition a license that doesn't place requirements on anyone to pay for it, sponsor it, contribute or otherwise. If a license didn't grant these freedoms, it wouldn't be a free software license.

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.

reply
Minor nitpick, but at least as far as the GNU GPL goes, it explicitly allows you to charge for software distribution when the software came bundled with a tangible item (like the firmware of an IoT device). The distributor can require you to pay them to get it. This was more common in the old days when software mostly came on CD-ROMs and you'd be getting another physical item in the mail, but the provision remains in the GPLv3 under section 6(b)(1) as an option that the distributor can require.
reply
It has to be the reasonable costs of distribution. It can't just be an arbitrary fee.
reply
Not exactly. You can charge whatever you like for the software - but whoever buys it from you is then allowed to give it away for free to anyone else, so this is only a theoretical possibility.

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.

reply
I certainly think so, but we who think this get shouted down because "It's not Open Source(TM)".
reply
Have you ever wondered who's in charge of choosing what counts as Open Source(TM)? Look no farther: https://opensource.org/sponsors

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.

reply
Not many people seem to know that the definition of "open source" they use (the OSD) is actually the definition of "free software" Debian uses (the DFSG) with the serial numbers filed off.

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".

reply
Debian is free to use any inclusion criteria it wants - especially since it still includes software thst doesn't meet the criteria. It shouldn't become the global default definition of "open source" though.
reply
That's why some prefer calling it "libre software."

Also see LibreOffice.

reply
The FSF would say the exact same. So this point is moot, unless you think Richard Stallman is a corporate shill.
reply
This is backwards imo, it is related to people that chose to build these projects. Everyone might have a different decision on it.
reply
Not allo companies loot OS projects with no contributions. M$ has contributes back to many OS projects and Google has dozens of OS projects themselves.

And when Redis changed their license for such reasons, companies and people united to create ValKey or even the Centos/Rocky linux situation.

reply
Redis cloud would cost you arm and leg compared to self hosting. I gives me an idea why big tech was not keen on making business with them
reply
AWS has 90% profit margins and still millions of customers.
reply
big tech can spare a few arms and legs, though
reply
It's insane. I maintain a small open source project with only about 100k downloads per week and so, in terms of funding, it's crickets for me but I assumed famous projects like OpenSSL would get some decent funding.

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?

Crazy to think that the people who once posted a dumb viral 30-second meme video on YouTube probably got more money than the author of a complex, world-famous open source project which has been at the top for decades and which quite literally intermediates every aspect of almost every human's life.

Does not compute.

reply
OpenSSL receives millions of dollars of funding each year. The corporation that runs the foundation reported 5.5M USD funding in 2024[1], and 5.0M USD funding in 2025[2]. These days, OpenSSL is well-funded.

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...

reply
From my understanding the problem was never that OpenSSL had no money, but that all the money it had was tied to services and features that didn't help improve the libraries overall security and in some cases where even outright harmful.
reply
This is really the same for most enterprise software. Customers pay for features , I guess they think the security is implied, but more features at a rapid pace typically ruins long term security.
reply
Historically that was true, but it has improved in the last few years.
reply
I don't believe BSL = commerical issues have to pay. Typically it means that the code can be used internally, but not distributed or resold as a service.
reply
Interesting, three years no new Release necessary of SocketCluster? That must be quite stable, congrats!
reply
AFAIK donation distribution is still unsolved problem. That is there is no single org business can donate $1M to and have it distributed among all the projects business identified it relies on.
reply
I would very much like for my employer, who benefits massively, to donate. However, the people in charge of the money decisions don't know anything about software and don't want to be lectured by me. They have _important business stuff_ to do. Sigh.
reply
Plus it would bring literally no benefit to your company .
reply
I understand why you would say that, nut it's not even true. We've had plenty of bugreports that have had crippling effects. For a minuscule fraction of these, I have been able to provide fixes or workarounds. But mostly, I would have been thrilled to get paid support there!
reply
[flagged]
reply
What's this about?
reply
I'm not the parent poster, but I believe it was a reference to https://en.wikipedia.org/wiki/Omarchy#Funding_and_controvers...
reply
https://boringssl.googlesource.com/boringssl/

All yours! Use it to your heart's content.

reply
If you think about it, giant corporations are making gobbles of money from people who wrote software for free and in their free time. And they still complain when it doesn't work as they expected. Why they didn't fund a better version of OpenSSL?
reply
If you've ever tried using OpenSSL you'll know that it's true.

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 for those programs that use it.

reply
How it happened? A lot of features in OpenSSL was written as part of a PhD and dumped in the repo without any thought about long term maintainability or quality. Now, during the last 5 years or so, people have been trying to straighten it out, but this is a pretty daunting task.
reply
A related problem is that the IETF's RFC production center (that's its actual name) is manufacturing new RFCs far beyond the capability of anyone to keep up, and every half-assed idea anyone ever has or that some vendor pays an IETF consultant to turn into an RFC for them ends up getting bolted onto OpenSSL, which serves as the AB-positive universal recipient that everyone tests their ideas on, typically in a half-finished, barely-tested form of which Heartbleed was the prime example. It's not even a Red Queen problem because no matter how hard you run you're still falling behind each time.
reply
SSL/TLS has always been a wonky and complicated standard built upon other wonky standards like x509 and ASN.1 (for PKI) that nobody would touch unless they are forced to.

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.

reply
> Not so fun fact: AFAIK the openssl binary was initially explicitly meant to be only used for testing.

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.

reply
Many people are using forks that are mostly API compatible. So the ubiquity is not as huge a problem as it used to be.
reply

    > 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.
reply
I don’t know. If you are using all the tools at your disposal like linting, static analysis, dynamic analysis, DAST (if web), fuzzing, SCA, etc and correcting your code for the findings, dispositioning and correcting them can that really be said? Open source doesn’t always
reply
I'd like to point you to: https://www.haproxy.com/blog/state-of-ssl-stacks

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.

reply
Google forked OpenSSL in 2014 (BoringSSL) with a pretty similar rationale, stated more diplomatically.
reply
I just wanted to check what became of the original LibreSSL fork. Google forked it into Boring SSL, that's what happened.
reply
If you use OpenBSD that's what you get in the base system.
reply
I remember a long time ago reading openssl was dumpster file code quality wise. I guess it was just built that way and never improved.
reply
I wanted to see how OpenSSL handles the x64 instructions to accelerate SHA1 hashing and it turns out the assembly code is generated by a perl script.
reply
That's normal, if outdated - you'd use Python in anything written since 2010
reply
That's not automatically bad, in fact it can be better than just inlining the instructions. I won't judge this instance of the pattern, but if faced with (perhaps incomplete at the time) intrinsics, or hand coded inline assembly, vs generating with an external script (or "mini compiler" if you will), it might be less error prone to generate.
reply
Assuming you mean x86, that part was originally written around 30 years ago via this funky setup that did MD5 and SHA-1 from the same code. It's not really any kind of example of current practice.
reply
No, the SHA-NI instructions
reply
> You wonder; how could this happen?

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, or the obnoxious limitations of naively designed processing elements.

Others have cited the documentation for EVP_EncodeBlock(). In the mind of a cryptographer, the text is perfectly clear and trivial, and they likely haven't exposed themselves for many years to anyone that can't read that exactly once and not immediately and correctly visualize the necessary formulae. Nothing wrong here at all. The fact that on real computers, numbers don't just scale to whatever value a computation requires is merely a defect in the design of the machine.

reply
Mathematician: "Um, just ignore that infinity symbol there"
reply
Because you don't roll your own SSL.
reply
> BTW, OpenSSL seems to be a rather low quality implementation of a very low quality set of APIs. Stay away.

We’ve known this for well over two decade since heartbleed yet for some reason Linux distros haven’t migrated off of it

reply
For those too young to remember 2014, Heartbleed led to both BoringSSL and LibreSSL being forked from OpenSSL.
reply
And also led to Amazon's s2n-tls and libcrypto being released around 2015 too as I call.

EDIT: found the release announcement - June 2015 - https://aws.amazon.com/blogs/security/introducing-s2n-a-new-...

reply
AWS-LC[0] itself based on BoringSSL, it makes it feel safer for those behind ALBs (but looks like this CVE may not be TLS related).

[0]: https://github.com/aws/aws-lc

Edit: corrected fork to based on, I don't actually know if it was a fork and a repo just says based on

reply
I wonder. Realistically, Boring and Libre haven't taking off. I measure that by most use and default deploys. But with LLMs, we may be entering a new world.

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.

reply
We used BoringSSL at Cloudflare. I imagine there’s a lot of usage in places you can’t see despite it not seeing more adoption. One place you can see it is all browsers use it since Chromium bundles it everywhere except Apple but Apple’s OSes use it to underpin their Network.framework which underpins WkWebview so all Apple devices use it.
reply
Seriously, at this point BoringSSL is surely more widely deployed than OpenSSL? A billion Apple devices, plus every Chrome installation?
reply
> all browsers use it since Chromium bundles it

Doesn't Firefox use NSS instead?

reply
BoringSSL is somewhat widely used because Google baked it into their projects (and partially by Microsoft, I believe they made a FIPS variant of it and used it in Go?)

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

reply
> LibreSSL had, IIRC, problem known as OpenBSD-itis. Or to put it bluntly, the developers didn't really care about any other platform.

Well put. This is the crux of the issue.

If you ever try to use libreSSL you rub up against so much friction that most projects would hammer out early.

reply
There's LibreSSL portable. It worked better in legacy machines I own, go figure.
reply
TIL it's 2036
reply
To be fair, frustrations with OpenSSL long preceded Heartbleed. Heartbleed was just the final straw for those who forked libressl and BoringSSL.

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.)

reply
Not breaking userspace is more important than security………
reply
The forks of OpenSSL are fairly API compatible with upstream, especially if you're not using new and exotic features. So for many projects you can just link to a better maintained fork and be done.
reply
"not breaking userspace" refers to kernel development. OpenSSL is userspace.
reply
Paraphrasing to "don't make breaking API/ABI changes for projects consuming your API/ABI" doesn't materially change a reasonable point. (And I generally agree with that point, although I confess openssl specifically really strains my view)
reply
And this is why the Linux Desktop will never go mainstream. You should never break apps at all, the OS's API surface goes beyond just the kernel.
reply
The Linux desktop is already mainstream. It has been a first class GUI experience for awhile now. Not to mention the endless papercuts in the proprietary OS's stemming from enshittification (Windows generally) or absurdly poor design (hello Finder).
reply
> OpenSSL is userspace.

If only it kept itself to that…

reply
Yeah, we all know users would rather be reliably hacked than unreliably safe.
reply
Users would rather risk getting hacked than have a computer that doesn't boot or doesn't go on the internet. If they preferred the latter they'd unplug it.
reply
Correct. You can plan around reliable insecurity and stay safe. You cannot ensure safety (or security) of unreliable software.
reply
I just don't get it; this is a task to hand to an LLM, "go rebuild OpenSSL, use Rust (no mistakes)" and have it churn through a greenfield implementation. Then open a PR =). Why hasn't this happened yet? The fact that the LLM will write tests and deal with all the compiler errors probably puts it lightyears ahead.
reply
There’s already a Rust TLS library, rustls, that’s relatively mature (10 years in development, a couple of paid maintainers, robust development and release processes). It’s not a drop-in replacement for OpenSSL, though. There’s a companion project to build an OpenSSL-compatible wrapper API for it, but that’s not as far along. Interestingly, while rustls has a plug-in API that lets you choose your favorite Rust encryption library for the low-level operations (aws-lc-rs, Ring, Graviola, etc), those libraries all tend to contain a lot of assembly … not just for speed, but because it’s easier to avoid side channel timing vulnerabilities in assembly.
reply
Can you explain why it is easier to avoid side-channel timing attacks in assembly?
reply
Compilers like to make code go brrr as much as they can. With crypto you want the code to run at a deterministic speed (execution time), regardless of input. With hand written assembly you can (more easily) make sure you have the same cycle count regardless of what the input is.
reply
I guess it's easier to control the timing of your operations if you write them directly in assembly. Otherwise, the compiler optimizations could change the code in unexpected ways.
reply
At a guess, because it is easier to control timing in assembly than in a higher level language that will compile your source code into whatever shape it feels like
reply
It's still impossible to control actual timing, but easy to ensure control flow isn't data-dependent, which is what you need. Classic example is memcmp. Although you can write the or-then-check-zero memcmp in any high level language and it's very unlikely to compile to data-dependent timing unless your compiler is AGI.
reply
> Although you can write the or-then-check-zero memcmp in any high level language and it's very unlikely to compile to data-dependent timing unless your compiler is AGI.

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".)

reply
The side channels issue is where rust crypto libraries are currently the weakest
reply
LLMs have a bottleneck, human review. And human review is absolutely required at this stage (the future is unknown). A rust built LLM only reviewed SSL library would be a recipe for disaster.

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 is no way for a human to catch all the design mistakes an LLM will make, otherwise.

People seem to get upset, when I say this, for reasons I cannot fathom. However, we need to have a mental model of how we trust LLM output, and the 'new junior' is great for that. Especially considering that every day, is a new day for an LLM, its context window always loses yesterday.

So consider LLMs as an eager, intelligent, incredibly well read junior, just out of college. And on their third day of work.

Zero real world experience. Constant review required.

Would you want that junior to design, build, and write test scripts for a library to underpin the entire internet?

reply
> A rust built LLM only reviewed SSL library would be a recipe for disaster.

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".

reply
Is that Zawinsky's law of LLMs?
reply
you don't get credit for that because it is clear you are not very skillful at what AI-bros value most, namely manipulating other nerds...

if you look 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.

reply
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.
reply
MISRA's not great itself, though. Half of it is obvious and could be summarised as 'don't invoke undefined behaviour' a quarter is rules to get around absolutely terrible ancient compiler problems, and a quarter are arbitrary restrictions that don't really help improve code quality much. For example, the interface of this function wouldn't break any MISRA rules in a way that would force it to be any better.
reply
Even the discussion in the PR about not handling the errors in all call-sites is revealing imo.
reply
What is it revealing? I read it and the assertion seemed like a reasonable middle ground.
reply
Many OpenSSL APIs are terribly designed.
reply
> BTW, OpenSSL seems to be a rather low quality implementation of a very low quality set of APIs. Stay away.

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.

reply
See: Lindy effect
reply
This is really embarrassing because this isn't even ancient code.

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.

reply
This function has been there since the first commit in git history, from 1998.
reply
and now guess who helped writing this code. the chicken are coming home to roost, but people who are happy about their youthful productivity or stock packages will not be able to notice...

the code before this PR included the check. But that was old code!

reply
I've been annoyed by writing code against OpenSSL's APIs before, precisely because it expects me to provide "appropriately sized buffers" without documenting the correct way to compute the correct size very well.
reply
> 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.

reply
> My god, you only see this type of horrendous API in C don't you.

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

reply
gets belongs in category -10
reply
It makes lot of sense when you think what encoding here does. Changes 3 arbitrary bytes to 4 bytes with only some values being possible. Null termination is one issue, but the output is a string such only length of the text itself makes sense.
reply
"No way to prevent this" say users of only language where this regularly happens

https://xeiaso.net/blog/series/no-way-to-prevent-this/

reply
What's "horrendous"? I don't see anything which stands out as being wrong. It specifies exactly the lengths of input and output.

gets(), on the other hand, that is "horrendous".

reply
Even in C, if you have a function that takes an input buffer and output buffer of differing lengths, the right API has the caller pass both lengths.

But yes, gets is worse.

reply
takes an input buffer and output buffer of differing lengths, the right API has the caller pass both lengths.

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")?

reply
The artificial error condition is the whole point and the hoops you have to jump through to be able to reach it as you say are reasons to not use C because it’s hard to enforce invariants like this and easy to ignore them with mostly working code. Mostly working was fine last year, it isn’t anymore.
reply
Turning this into an attack on the language with otherwise nonsense arguments is how I know you're an ideological bully not worth arguing with, just like the ones who called this nothingburger a 9.8.
reply
The thing that jumps out to me is that it returns “the size of the output data minus one” but if I’m passing in a pointer it’s on me to make sure there’s enough memory allocated isn’t it? So the caller must make sure it’s calculated this correctly - in which case why return the size? Taking the size as an argument could be safer as you’d be checking the caller calculated enough space too.

(Honest questions in this it’s probably been 20 years since I did c)

reply
That part of the API seems particularly random indeed, especially when comparing it to other EVP_{En,De}code* functions which use the returned int for success/error.

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...

reply
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.

Horrendous is a strong word, you're right.

reply
One can abstract buffer handling away in C just fine, eliminating all those problems. I don't know why programmers insist on open-coding low-level buffer management.
reply
Yes, of course, this isn’t C, this is just another case of people writing C wrong.
reply
Perhaps we could use another language, where it's not so easy (or possible) to write it wrong?
reply
It is also easy to write it wrong in other languages. The coreutils rewrite had hundreds of issues, cloudflare brought down half of the internet because in the magic language where nothing can go wrong due to the advanced type system someone used an unchecked .unwrap (but this does not count, because this was Rust and not C - so could not possibly be the fault of the language, so only the programmer is to blame), and just recently Microsoft found a couple of memory safety issues in Rust's standard library. And let's better not talk about the supply chain.
reply
The proper way to do it is to factor out the length calc into a utility function that the API provides. Also the calculated buffer length is passed in to the function, and an error is returned if it's too small.
reply
Not even that is usable as excuse, only those that never tried out the systems programming languages that either predated C, or where equally developed during the 1970's outside Bell Labs and UNIX ecosystem.

You could have come with something simpler in PL/I.

reply
You should be comparing with assembly language, not C#.
reply
>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.

https://chromium.googlesource.com/libyuv/libyuv/+/refs/heads...

reply
> BTW, OpenSSL seems to be a rather low quality implementation of a very low quality set of APIs. Stay away.

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.

reply
> There does not exist such implementation as of now as OpenSSL was good enough

A fair amount of such implementation do exist.

reply
[dead]
reply
What's obnoxious is the WG14 standard committee could have at any time in the last 40 years provided a standard slice and buffer type that would go a long way to discourage trash API's like this one.

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);

reply
> What's obnoxious is the WG14 standard committee could have at any time in the last 40 years

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.

reply
There are very few reasons to start a greenfield project in C++ at this point.
reply
There are plenty of reasons to start a greenfield C++ project in 2026.

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.

reply
> embedded

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++.

reply
The world would be better off without yet another newly slopped C/C++ app.
reply
How dare you give your parameters names of multiple characters!
reply
How dare you pass a struct by value to a function. Heresy!
reply
> I can immediately observe that the whole API is bad

I see this is your first time reading OpenSSL code

reply
> BTW, OpenSSL seems to be a rather low quality implementation of a very low quality set of APIs. Stay away.

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.

reply
other commenters mentioned boringssl (used by Google everywhere it applies), LibreSSL (used in BSD), rustls (used in Rust). Go has its own implementation just called crypto/tls.
reply
> boringssl

"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

It relies on one of two crates for cryptographic primitives, both of which have zero regard for long term support. "Latest release or bust" doesn't cut it for crypto.

reply
You do need to keep TLS up to date as the network changes around you. Just recently you needed to block eMudhra intermediate certificates.
reply
> You do need to keep TLS up to date as the network changes around you.

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?!

reply
Because it's a TLS feature? That's what people want from TLS libraries? They say connect, and if it succeeds it's secure?
reply
But the database of trusted CAs is kept and maintained independently of the TLS library, obviously! It's data, not code. And it's agnostic as to which library uses it.

Any comments on my clarification about your misunderstanding of long term support?

reply
One of the ‘rewrite it in rust’ projects that should really cause anyone to be offended IMHO.
reply
The problem with "rewrite this in Rust" is more that Rust has laughable amount of Tier 1 platforms.

Now, rewrite in Ada, given that GNAT supports the same targets as rest of GCC...

reply
Completely agreed but I’ll take any improvement at this point however small
reply
There's gcc-rs too but at a slower pace than mainline/official Rust.

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.

reply
if the input is larger than ~1.5GB.

...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.

reply
I am confused why you make out 32 bit int as being rare. Almost all devices that you'd reasonably connect to the internet at this point have int as 32 bits
reply
> It's base64. 4/3 expansion; round it up and add padding. What's "nontrivial" about that?

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. Maybe your “add padding” part fixes it? In any case, I think that the fact that this confusion is even possible 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.

reply
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.

If you let untrusted input reach inlen and overflow that computation, you have already failed:

https://news.ycombinator.com/item?id=50570319

reply
inlen isn't an untrusted input and it's not this calculation that's overflowing (integer overflow). It's the buffer that oveflows when you allow the operation to proceed based on faulty validation.

The caller shouldn't be responsible for enforcing preconditions of your function. They should just provide the input buffer, output buffer, their sizes and your implementation should verify whether it's safe to proceed.

reply
Are you saying that any code that base64’s a string of attacker-controlled length is a mistake?
reply
I think userbinator thought that you meant that the calculation would overflow, while I think you meant that the calculation, even if not overflowing, would return the wrong value under some conditions and that subsequent code would then overflow the buffer. (As for what I think about the actual issue, I’m too sleepy to even try. Which is probably an indication of something. =) )
reply
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.

reply
The question can be reduce to "who do the length validation".

At the boundary where untrusted input becomes trusted. This is commonly known as the sanitisation/validation layer.

reply