News for hackers. Stuff that matters.
Re:Why Bloat Is Still Software's Biggest Vulnerability by jurschreuder on Friday February 09, 2024 @04:29PM (#39320760)
This is what I keep saying about Rust.

Maybe you have 70% fewer vulnerabilities per line of code than C++ if really 70% of (old) C++ vulnerabilities are memory related.

But if you then pull in hundreds of packages in Rust and have 10x as many lines of code...

30% of 100k lines is more in total than 100% of 10k lines of code.

Re:Why Bloat Is Still Software's Biggest Vulnerability by estebank on Friday February 09, 2024 @04:46PM (#39320906)
Counting crates and comparing that with number of C++ libraries is making an obtological error. In Rust, a single team usually splits their project in multiple crates. Something like QT would be hundreds of crates on its own if it were written in Rust, but the amount of code and level of risk taken would be exactly the same.
Re:Why Bloat Is Still Software's Biggest Vulnerability by kstrauser on Friday February 09, 2024 @06:04PM (#39321595)
> an obtological error

I don't know if that was a deliberate portmanteau of obtuse+ontological, or if it was a happy typo, but I'm stealing it.

Re:Why Bloat Is Still Software's Biggest Vulnerability by estebank on Friday February 09, 2024 @06:54PM (#39321967)
It was typo ^_^'
Re:Why Bloat Is Still Software's Biggest Vulnerability by arccy on Friday February 09, 2024 @07:01PM (#39322028)
teams might split their own stuff into crates, but rust has still managed to adopt to npm culture of pulling in lots of small dependencies for trivial things, opening them up to different sorts of supply chain attacks.
Re:Why Bloat Is Still Software's Biggest Vulnerability by steveklabnik on Friday February 09, 2024 @05:17PM (#39321165)
https://wiki.alopex.li/LetsBeRealAboutDependencies is an interesting exploration of these dynamics.
Re:Why Bloat Is Still Software's Biggest Vulnerability by jsheard on Friday February 09, 2024 @05:07PM (#39321085)
Plus many crates have zero unsafe code, so they're not much of a liability at least in terms of the common memory safety problems. The nice thing about unsafe code having to be declared is you can get an idea of a crates attack surface at a glance just by grepping for it - if only evaluating C/C++ libraries were so easy.
Re:Why Bloat Is Still Software's Biggest Vulnerability by PhilipRoman on Friday February 09, 2024 @05:16PM (#39321161)
>you can get an idea of a crates attack surface at a glance just by grepping for it

please don't... I understand your point but there are hundreds of vulnerabilities introduced every day in memory-safe languages that have nothing to do with rust's concept of "unsafe".

Re:Why Bloat Is Still Software's Biggest Vulnerability by PH95VuimJjqBqy on Friday February 09, 2024 @05:16PM (#39321163)
no, absolutely not, and I have no idea where this misapprehension came from.

the root cause of a problem in unsafe could can absolutely be from safe code because the safe code can set state in a way that causes problems.

One can easily see this if you consider safe code that sets an index and then calls into unsafe code but the index is out of range. The root cause is absolutely in the safe code.

Re:Why Bloat Is Still Software's Biggest Vulnerability by ptx on Friday February 09, 2024 @06:12PM (#39321661)
Isn't that the idea that unsafe code can do unsafe things internally while exposing a safe interface? So in your example the bug would be in the unsafe code, which shouldn't have allowed the unsafety to leak into the safe code.
Re:Why Bloat Is Still Software's Biggest Vulnerability by BobbyTables2 on Friday February 09, 2024 @06:58PM (#39322003)
Yes, but by that same logic, safe programs can also be written C.

However, I do believe Rust gets a whole lot of things right.

I sincerely hope that unnecessary use of unsafe code is avoided.

Re:Why Bloat Is Still Software's Biggest Vulnerability by jsheard on Friday February 09, 2024 @05:38PM (#39321353)
There has to be unsafe code for that to happen though, if you consume a crate which doesn't touch unsafe at all then it's only going to happen if you write the sloppy unsafe code which makes assumptions that don't actually hold. If you blindly pass indices from code you didn't write and haven't audited into Slice::get_unchecked() then that's on you, if you're not willing to do your due diligence then stick to the bounds checked version. That's what it's there for.
Re:Why Bloat Is Still Software's Biggest Vulnerability by PH95VuimJjqBqy on Saturday February 10, 2024 @12:27AM (#39323848)
unsafe code should be sitting in a module protected by safe code. Which implies safe code can be the root cause of unsafety.

People have got to stop believing that safe code in rust is automatically not the root cause of problems. It's a misapprehension.

Re:Why Bloat Is Still Software's Biggest Vulnerability by arccy on Friday February 09, 2024 @06:58PM (#39322002)
you don't need unsafe to sneak in a cryptominer
Re:Why Bloat Is Still Software's Biggest Vulnerability by jsheard on Friday February 09, 2024 @07:14PM (#39322108)
Hence why I said it gives you an idea of exposure to memory safety issues, not that grep unsafe is a substitute for a full audit. Besides, time not spent having to pore over every line of code looking for subtle memory safety bugs is time you can spend looking for bundled cryptominers instead.
Re:Why Bloat Is Still Software's Biggest Vulnerability by robertlagrant on Saturday February 10, 2024 @07:14PM (#39331519)
> you can get an idea of a crates attack surface at a glance just by grepping for it

I hope that the code that streams your data out to an endpoint isn't memory safe, so you easily find it!

Re:Why Bloat Is Still Software's Biggest Vulnerability by cperciva on Friday February 09, 2024 @10:06PM (#39323176)
> the amount of code and level of risk taken would be exactly the same.

The amount of code might be the same, but that doesn't guarantee that the level of risk is the same. A lot of bugs are introduced at interfaces -- the provider of an API makes a subtle change without realizing how it affects some of the API consumers -- and that's inherently more likely to occur if the two sides of the API are developed separately.

In the FreeBSD world we've found that it's incredibly useful to develop the kernel and libc and system binaries together; all sorts of problems Linux trips over simply never happen in FreeBSD.

Re:Why Bloat Is Still Software's Biggest Vulnerability by estebank on Friday February 09, 2024 @11:49PM (#39323680)
A really common thing in the Rust ecosystem is to write APIs that are impossible or at least hard to misuse. That cultural aspect plus the ownership system does help reduce those kind of problems. I've seen crates where there are "mistakes" in the API, lending a mutable borrow instead of returning an owned value, for example, that make them less useful than they could be otherwise, but I've seen fewer cases of bug prone APIs.
Re:Why Bloat Is Still Software's Biggest Vulnerability by josephg on Friday February 09, 2024 @10:37PM (#39323338)
This risk is much worse in C or C++ than rust because of the borrow checker. I’ve certainly seen some crimes against performance at the boundary between libraries, but I don’t think I’ve seen any subtle interface bugs.
Re:Why Bloat Is Still Software's Biggest Vulnerability by tcoff91 on Friday February 09, 2024 @04:38PM (#39320834)
memory related vulnerabilities tend to be the worst kind though, like RCEs and stuff. Remote code execution is so much worse than many other types of vulnerabilities like DOS. How many RCEs have there been in rust programs compared with C++? I bet C++ has far more than 70% more RCE frequency than rust.
Re:Why Bloat Is Still Software's Biggest Vulnerability by bsdpufferfish on Friday February 09, 2024 @04:43PM (#39320880)
Only for software directly connected to the internet. Unix process separation is a thing too.
Re:Why Bloat Is Still Software's Biggest Vulnerability by lionkor on Saturday February 10, 2024 @04:38AM (#39324871)
the worst kind? probably not. The worst kind is the vulerability that is a logic error, which no language catches for you, which can leave unskilled attackers accidentally breavhing your whole system. RCE takes effort usually, exploiting a logic error not so much.

For example, rust happily lets you access a database before checking that the user's auth token is valid - absolutely nothing prevents you from that.

Re:Why Bloat Is Still Software's Biggest Vulnerability by Ygg2 on Friday February 09, 2024 @05:41PM (#39321387)
> But if you then pull in hundreds of packages in Rust and have 10x as many lines of code...

No one is forcing you to use the libraries. Just write your own software stack yourself.

But big problem is vulnerablilities. Is it better to fix hundred libs by fixing a bug in one shared lib or is it better to fix hundred libs one by one?

Re:Why Bloat Is Still Software's Biggest Vulnerability by whstl on Saturday February 10, 2024 @04:13AM (#39324747)
False dichotomy.

What is actually better is to have code that is properly auditable for end-users, or even to not introduce the risk for those vulnerabilities in the first place.

Things like Heartbleed and Log4Shell were serious vulnerabilities that were useful only for a minority of people, and were hidden inside bloated code. The same thing is happening now with package supply chain.

Re:Why Bloat Is Still Software's Biggest Vulnerability by Ygg2 on Saturday February 10, 2024 @08:25AM (#39325963)
It's not a false dichotomy. You either put your vulnerabilities in a few baskets, or you spread (and multiply) them in many more baskets. Neither is intrinsically better.

Why multiply? If everyone rolls their own libs, you can expect different library makers to repeat similar mistakes (stuff like not sanitizing input, forgetting to cap anything that generates output from outside sources, etc.).

> Heartbleed and Log4Shell were serious vulnerabilities that were useful only for a minority of people

Minority of people need SSL and logging?!? Most applications need logging, and most of today's applications need the Internet to function. Could have they been omitted when possible? Perhaps, but you're not making a persuasive argument.

Re:Why Bloat Is Still Software's Biggest Vulnerability by whstl on Saturday February 10, 2024 @08:48AM (#39326102)
I never said people should roll their own. I said code should be auditable for end users. Hundreds (or thousands) of packages isn’t auditable.

I didn’t make a suggestion, but micro-packages aren’t silver bullets.

Deep transitive dependencies are problematic for their lack of visibility, and often a signal of bloat.

> Minority of people need SSL and logging?!

Heartbleed and Log4Shell weren’t caused by the core SSL or logging code of those libraries, they were caused by code in niche features (heartbeat extension and SAMBA) that should have been plugins (or at least deactivatable by flags). that would massively decrease their impact.

Both Heartbleed and Log4Shell were caused by feature bloat and lack of auditability.

Re:Why Bloat Is Still Software's Biggest Vulnerability by Ygg2 on Saturday February 10, 2024 @03:26PM (#39329869)
> I said code should be auditable for end users. Hundreds (or thousands) of packages isn’t auditable.

And what is your idea to fix this?

> Deep transitive dependencies are problematic and...

Gonna stop you right here. Deep transitive dependencies are nothing more than huh, other library find this functionality useful, let's pull it into a library.

By not having deep dependencies, you are in no uncertain terms claiming everyone should write their own. Or God forbid copying code into your own project.

Imagine we write a set of perfect auditable libraries. Fuzzed, written to spec, proven correct & fast in theory and practice.

Guess what? Everyone and their mother will use it leading to deep transitive dependencies.

The complexity of consumer hardware and software requires that even trivial libraries carry with them lots and lots of dependencies.

Alternative is basically Ludditism.

Re:Why Bloat Is Still Software's Biggest Vulnerability by yukkuri on Sunday February 11, 2024 @12:00AM (#39332770)
Yes, even the original link admits their "simple is better" solution is only better in limited use cases.

"Our software will be so much better quality if it won't do the things you're paying me to make it do" is a non-starter in the real world.

Re:Why Bloat Is Still Software's Biggest Vulnerability by whstl on Sunday February 11, 2024 @07:12AM (#39334490)
You two are talking with a straw man.

Nobody ever said anything of the sort.

Re:Why Bloat Is Still Software's Biggest Vulnerability by whstl on Sunday February 11, 2024 @07:07AM (#39334462)
Fuzzed, proven correct libraries clearly aren't the problem here.

But this is really far away from the bulk of Rust or NPM libraries, and it's very naive to pretend that the situation isn't like that.

I already mentioned two examples of things that could have been separate from the main libraries (or at least require flags or separate compilation) and caused global problems: heartbeat extensions from OpenSSL and LDAP/JDNI from Log4J.

EDIT: I can mention two other examples that I already talked about in this thread: I often come across simple GraphQL-API-consuming apps or libraries that have dependencies on large frontend libraries, while a simple fetch would suffice. The library is needed for introspection, or for building autocomplete clients, but for pure consumption this is unnecessary. Another example are libraries from authors that are splitting code only to bump their NPM or Cargo metrics, like is-odd, or the ora package that has 15 dependencies and a lot are covered by stdlib.

Re:Why Bloat Is Still Software's Biggest Vulnerability by Ygg2 on Sunday February 11, 2024 @06:17PM (#39339803)
> Fuzzed, proven correct libraries clearly aren't the problem here.

They aren't. I'm steelmanning your position. "What if there exists a set of well audited libraries". And "what if we have package managers everyone uses". The logical answer is that everyone reuses them, leading to deeply nested transitive dependencies. Hence a contradiction. Deeply nested libraries aren't a problem.

> caused global problems: heartbeat extensions from OpenSSL and LDAP/JDNI from Log4J.

Already covered that. How do you disambiguate what is a crucial feature and what is overhead? On surface it seems simple, but constraints, call for features and backwards compatibility guarantees makes that something that only seems obvious in hindsight.

Re:Why Bloat Is Still Software's Biggest Vulnerability by Ygg2 on Monday February 12, 2024 @01:48AM (#39342207)
Here are my underlying assumptions:

- Some set of libraries are fully audited.

- Some libraries can't be fully specced and audited because their specs are in flux (e.g. games, GUIs, webapps)

- Those libraries/apps will limit their maintenance burden by using audited ones

- Package managers are useful.

As long as the set of audited libraries is large or tends to grow large, or the audited libraries build upon each other, or the non-audited libraries depend on many other libraries, the "deeply nested" (I don't think it's deeply nested as much as many dependencies) hierarchy will be replicated.

Re:Why Bloat Is Still Software's Biggest Vulnerability by whstl on Tuesday February 13, 2024 @08:09AM (#39357251)
I'm fine with people using single-function libraries if they're audited. The problem is that those are the ones who historically are not cared at all :/
Re:Why Bloat Is Still Software's Biggest Vulnerability by whstl on Tuesday February 13, 2024 @08:07AM (#39357238)
> They aren't. I'm steelmanning your position.

Sure, but nevertheless: if this were a reality, sure, it would be perfectly fine! But we don't live in the fantasy world so we have problems.

This is why people don't complain about this kind of code being moved to standard libraries: stdlibs they are often heavily audited (with exceptions),

So maybe that's a suggestion: moving SOME things (NOT ALL) that are traditionally in stdlibs in other languages to the stdlib of your own language.

Or perhaps force yourself to only use heavily audited libraries (parent commenter mentioned NewtonSoft.JSON, this is a good one that is an industry standard).

> How do you disambiguate what is a crucial feature and what is overhead

To keep using the same two examples: if you don't need something for 99% of regular use cases, then it can definitely be optional.

I'm not advocating removing features or not making it, like another person said. I'm just advocating building software a bit differently.

Instead of having 100 features and a lot of dependencies in one root package, have instead 1 base package (with fewer features and fewer dependencies) + N plugin packages (with the remaining features and dependencies).

This way you can reduce the blast radius of problematic dependencies without removing features.

Re:Why Bloat Is Still Software's Biggest Vulnerability by yukkuri on Saturday February 10, 2024 @11:57PM (#39332756)
Once upon a time I had to track down a catastrophic performance failure (process that should have taken a few minutes couldn't finish in the THREE DAYS allotted to it as a maximum runtime) that turned out to be because it was using a hand-rolled "simple" JSON parser instead of just pulling in Newtonsoft.
Re:Why Bloat Is Still Software's Biggest Vulnerability by IshKebab on Saturday February 10, 2024 @08:40AM (#39326059)
Do you have any evidence that Rust programs actually run 10x as much code as C++ programs? That seems very unlikely. Most translations from C++ to Rust or vice versa that I've seen are within like 30% of each other.

The fact that Rust makes it easy to pull in a large number of small dependencies instead of a few enormous dependencies is irrelevant. You aren't using any more code.

For example are you counting Rusts `regex` crate as a dependency? Well that's just in the standard library for C++.

Does Boost count as a single dependency in C++? Because that would be like 30 separate crates in Rust.

Re:Why Bloat Is Still Software's Biggest Vulnerability by jurschreuder on Monday February 12, 2024 @02:27PM (#39349162)
Just to pick out some examples, rust-analyzer is 28M against clangd which is only 291K; ripgrep is 4.7M against GNU grep which is only 211K (binaries have already been strip-ed in both cases).