back

by akyuu·2y ago·view on hn ↗
From what I’ve read from some security researchers, glibc is not really focused on security. For example, it contains CPU-specific manually crafted assembly for optimization purposes, and its memory allocator implements exploitation-friendly features such as thread caches. I’m not surprised by this vulnerability, and I suspect there are many similar ones that haven’t been discovered yet.

musl (used by default on Alpine and Chimera Linux) and the BSD libc’s on the other hand are much more minimal and conservative.

5 comments
>musl (used by default on Alpine and Chimera Linux) and the BSD libc’s on the other hand are much more minimal and conservative.

Read: slower and with less comprehensive standards compliance (even if some of those standards are a bit nutty).

I was under the impression that musl does care about standards compliance, hitting problems mostly when people expect non-standardized behavior.
Musl is somewhat the embodiment of malicious compliance to the standard.
musl has a better track record of standards compliance than glibc. Common method for porting to musl is putting non-standard compliant code into an ifdef glibc.
This is, of course, the same musl that refused to implement TCP DNS requests until very recently. And they only did so because the DNS standards people got fed up with people not implementing it, and made it a requirement.
It was made a requirement by RFC 7766 in 2016 https://www.rfc-editor.org/rfc/rfc7766#page-6
That doesn't necessarily contradict "the DNS standards people got fed up with people not implementing it, and made it a requirement."?
It took musl about 6 years to implement the requirement.
And glibc is the one not implementing strlcpy and strlcat until June 2023.
strscpy is the better API anyway
I do not know about standards, but I know the only deployment images I have problems all the time with random weird DNS failures are the musl-based ones. No idea what causes it, but makes me wish to get rid of all musl usage just to have stable deployments.
Counterexample: musl's crypt() does silly things, like treat all unrecognized inputs as DES, even if the salt characters are invalid.
at least it actually supports blowfish
pretty much the only place where it's meaningfully slower is the allocator (which has a massive impact) so in chimera we have a special musl build that uses llvm's scudo instead (same as e.g. android) and is faster as well as more secure than glibc's allocator

the rest is mostly fewer specialized implementations of stuff for different cpus, but that rarely makes a difference in practice (i.e. outside of microbenchmarks)

the overall standards compliance is pretty good in musl

Still there's a difference between not doing the maximum possible to prevent theoretical exploits (like caches thing) and adding an externally controlled feature that crosses into SUID territory and begs to be exploited. It's like the difference between not buying the door made of strongest alloy steel and just leaving the key under the potted plant. The latter makes you say "what were you thinking?"
"musl (used by default on Alpine and Chimera Linux) and the BSD libc's on the other hand are much more minimal and conservative."

Also available on Void Linux.

Scroll through some musl code if you have some spare time, they take code golfing with C strings to a whole new level. What saves them is only that they skip the insane stuff in glibc.
musl's code is hardly pretty, but considering every linux libc's code is cursed and especially glibc's, musl still more or less wins there
Last time i looked, the musl library allocator was also exploitable by similar style 'house of' attacks. Maybe its been fixed now. I dont know if you can make a judgement call that musl is better because it has 'less code' when its still open to exploit mechanisms that glibc fixed many moons ago.
the musl library allocator was also exploitable by similar style 'house of' attacks

What are you basing this on? Can you demonstrate how this works?

Not in a HN news comment, I don't have that level of dedication to this because its definitely non trivial. However you can read about them in use against the glibc allocator are here: https://github.com/DhavalKapil/heap-exploitation/blob/master...

The "house of" attack method are attacks against the allocator, its been a while since I've looked into it, I hope musl have hardened their allocator against this kind of attacks.

The link you have here is 'attacking' by directly changing the meta data in C with pointer offsets and doesn't mention musl anywhere.
I did not say that it did. I'm saying that I believe the same kind of attacks work against the musl allocator, or at least I think they did at that time.

Musl was not being used by the business I worked in, therefore I had no interest in continuing investigation other than trying to get an understanding of how other implementations dealt with it.

I'm sorry for any confusion.

I believe the same kind of attacks work against the musl allocator

Why is this even an attack and why would musl have whatever weakness is claimed here?

Gotcha.