News for hackers. Stuff that matters.
Re:Nghttp3 1.0.0 – HTTP/3 library written in C by codewiz on Saturday October 21, 2023 @08:25PM (#37971765)
How about using a memory-safe HTTP/3 implementation which is also callable from C or any other language? https://github.com/cloudflare/quiche
Re:Nghttp3 1.0.0 – HTTP/3 library written in C by codewiz on Saturday October 21, 2023 @08:27PM (#37971779)
Re:Nghttp3 1.0.0 – HTTP/3 library written in C by mgaunard on Saturday October 21, 2023 @09:42PM (#37972123)
ha, the Rust fanboys and their "memory-safe"...

Just say it's a Rust implementation instead of going about it about like this.

Re:Nghttp3 1.0.0 – HTTP/3 library written in C by adgjlsfhk1 on Saturday October 21, 2023 @11:07PM (#37972479)
Most languages are memory safe. Literally every language with a GC is. C and C++ are pretty much the only 2 languages that are not memory safe by default.
Re:Nghttp3 1.0.0 – HTTP/3 library written in C by tczMUFlmoNk on Sunday October 22, 2023 @12:03AM (#37972729)
Go is famously not memory safe. Not only can you trivially create data races, if you data race on an interface fat pointer then you can corrupt its vtable (entirely in "safe" code; no `unsafe.Pointer`).

It is of course better at memory safety than C and C++, but these issues do come up in real deployments.

Re:Nghttp3 1.0.0 – HTTP/3 library written in C by zakkor1 on Sunday October 22, 2023 @04:52AM (#37973866)
Good thing Go has a race detector!
Re:Nghttp3 1.0.0 – HTTP/3 library written in C by mgaunard on Sunday October 22, 2023 @06:13AM (#37974151)
and C++ doesn't?
Re:Nghttp3 1.0.0 – HTTP/3 library written in C by dontlaugh on Sunday October 22, 2023 @05:31AM (#37973996)
Data races aren’t memory unsafe. The vtable thing is, but at least that’s accidental.
Re:Nghttp3 1.0.0 – HTTP/3 library written in C by mseepgood on Sunday October 22, 2023 @05:35AM (#37974011)
Data races have nothing to do with memory safety. Please do not conflate these two. Java, C#, Go, etc. can all have data races, but they are all memory safe languages.
Re:Nghttp3 1.0.0 – HTTP/3 library written in C by anonymoushn on Sunday October 22, 2023 @07:21AM (#37974422)
Golang permits safe code to use a data race to cause type confusion and violate memory safety though.
Re:Nghttp3 1.0.0 – HTTP/3 library written in C by Thaxll on Sunday October 22, 2023 @08:41AM (#37974855)
Go is memory safe, data races are inherent to all languages beside Rust? As for interface fat pointer it's a none issue in real life code.

https://research.swtch.com/gorace

Re:Nghttp3 1.0.0 – HTTP/3 library written in C by astrobe_ on Sunday October 22, 2023 @10:00AM (#37975457)
"Only 2" is very short-sighted, there's also Assembler, Pascal, Ada, Objective-C...

One general comment: it's kind of funny to see a C library being bashed right away at V1.0. As far as I can tell, nghtpp2 isn't even a CVE nest to begin with [1]. Some people must be desperate for "easy" targets.

[1] https://www.cvedetails.com/vendor/15772/Nghttp2.html

Re:Nghttp3 1.0.0 – HTTP/3 library written in C by 3c6bYDXLMj on Sunday October 22, 2023 @06:21AM (#37974183)
I’ve never written a line of Rust in my life. Though as a user of computers I have an interest in software being secure, especially an HTTP client which I may at some point be subject to. I’ve been a developer for a long enough time, worked with enough developers, and written enough C (not much), to have formed the strong belief that: C’s typical use is not memory-safe due to completely understandable human error, these footguns do not justify its use in most greenfield contexts, and any developer that denies the existence of these footguns has bought into a delusion that I can’t even begin to understand.

I don’t care if it’s Rust or something else. The fact that this completely legitimate and long-proven drawback of C is always met with “Rust fanboy!” comments speaks volumes, and not about ‘Rust people’. It’s incredibly disappointing that this is where we’re at with these sorts of discussions. Comments that essentially amount to “fake news!” and reject any premise of a shared reality.

Re:Nghttp3 1.0.0 – HTTP/3 library written in C by zik on Saturday October 21, 2023 @09:47PM (#37972138)
quiche may be great - I haven't tried it - but it definitely isn't memory safe. It uses unsafe constructs liberally.
Re:Nghttp3 1.0.0 – HTTP/3 library written in C by josephg on Saturday October 21, 2023 @10:30PM (#37972330)
What does “liberally” mean here? Because without even looking at the code, I bet less than 5% of the code in quiche is unsafe. It’s probably about 2% or something. And remember, unsafe rust is still borrow checked and often run through Miri as well - which is crazy strict. Miri rejects a lot of correct programs.

There is no comparison with C, where trivial programs exhibit UB and memory unsafety all the time, and the standard library is covered in foot guns.

I really dislike the puritan wing of the rust community who see the unsafe keyword as some sort of blight to be excised. Unsafe is a necessary and important part of the language. It is needed for lots of reasons - like how you can’t make high performance container types in purely safe rust. Or to interact with code written in other languages.

Unsafe is not a devils mark. It’s a good and useful tool. Get over it.

Re:Nghttp3 1.0.0 – HTTP/3 library written in C by nine_k on Saturday October 21, 2023 @10:50PM (#37972416)
It often suffices to find one remotely triggerable unsafe memory write in a huge executable to achieve RCE.

Memory safe would be 0% unsafe.

Re:Nghttp3 1.0.0 – HTTP/3 library written in C by minitech on Saturday October 21, 2023 @11:43PM (#37972647)
“n% unsafe” here refers to `unsafe` blocks that can’t be automatically guaranteed safe by the Rust compiler, not to actual concrete instances of memory unsafety.
Re:Nghttp3 1.0.0 – HTTP/3 library written in C by josephg on Sunday October 22, 2023 @10:45AM (#37975807)
Right. And even if you only work in “safe rust”, a massive part of the software stack you rely on still isn’t formally verified like that. LLVM and rustc aren’t formally verified - and they likely have bugs. The kernel is all “unsafe” code. And the rust standard library is full of unsafe code. And so on. Moving heaven and earth to excise the last 2% of unsafe code in random rust libraries just doesn’t make engineering sense. Especially when doing so comes with a significant performance cost.

If reliability is what you’re after, that time is almost certainly better spent adding more tests, fuzz testing and validating your code with Miri and friends.

Re:Nghttp3 1.0.0 – HTTP/3 library written in C by mcronce on Saturday October 21, 2023 @10:10PM (#37972244)
That doesn't mean it's not memory safe - it means that those constructs need to be thoroughly scrutinized for memory safety, which is significantly better than the entire codebase needing to be thoroughly scrutinized for memory safety
Re:Nghttp3 1.0.0 – HTTP/3 library written in C by zik on Wednesday October 25, 2023 @05:45PM (#38018815)
By that reasoning C is also memory safe.
Re:Nghttp3 1.0.0 – HTTP/3 library written in C by mcronce on Friday October 27, 2023 @02:56PM (#38042455)
No? Your entire C codebase needs to be thoroughly scruitinized, whereas in Rust, you can build a small portion with unsafe code, thoroughly audit that, and build a sound abstraction on top.
Re:Nghttp3 1.0.0 – HTTP/3 library written in C by rapsey on Sunday October 22, 2023 @12:27AM (#37972816)
Examples, tests and interfacing with C are almost all the instances of unsafe.
Re:Nghttp3 1.0.0 – HTTP/3 library written in C by zamalek on Sunday October 22, 2023 @03:53AM (#37973621)
I assumed the FFI would be the unsafe bit, you can't interact with an unsafe language from a safe context - the mere act of dereferencing a pointer that originates from unsafeland is fraught with UB.
Re:Nghttp3 1.0.0 – HTTP/3 library written in C by nonameiguess on Sunday October 22, 2023 @07:04AM (#37974363)
Why does discussion always have to devolve into this? This isn't an advertisement asking brand-new greenfield projects to base their work on C libraries. This work is done because it's an update to nghttp2 to add support for HTTP/3. The reason you would use it is because you're already using nghttp2 and want to know about the added features. The list of tooling using nghttp2 is pretty extensive, including at bare minimum the Apache web server and curl, which collectively likely initiate at least a plurality of the Internet's HTTP traffic because of their age and ubiquity.

Why are these tools written in C? Because they're old. nghttp2 was released in 2009, before Go was released and before Rust was even a twinkle in its eventual creators' eyes. Adding comments like this any time a feature announcement to a C library is made comes across like you're saying nobody should ever update tools that are already in use. Should Linux just stop doing work until the kernel is rewritten from the ground up in Rust? Should all longstanding software take a five-year pause to do total from-scratch rewrites? Can you see why that is impractical? If you can, then you can see why libraries like nghttp2 exist and continue to add features.

Re:Nghttp3 1.0.0 – HTTP/3 library written in C by codewiz on Tuesday October 24, 2023 @02:15AM (#37995339)
The title of this post puts emphasis on "written in C", making me wonder when this would ever be a desirable feature, given that more secure implementations are available, and can be integrated into old C projects just as easily.

No need to rewrite everything from the ground up: https://github.com/cloudflare/quiche#curl

Re:Nghttp3 1.0.0 – HTTP/3 library written in C by torstenvl on Tuesday October 24, 2023 @08:07PM (#38007495)
Just stop. It is not a requirement for you to wage holy wars against languages you dislike. In fact, as a form of "ideological battle," it's against the Guidelines.