News for hackers. Stuff that matters.
Re:sudo and su Being Rewritten in Rust for Memory Safety by binjooou on Saturday April 29, 2023 @02:56PM (#35755914)
A 1000 line long dependency file full of random literally whos code doing god knows what does not instill alot of confidence when I want to build and audit security critical programs.
Re:sudo and su Being Rewritten in Rust for Memory Safety by baq on Saturday April 29, 2023 @04:03PM (#35756601)
You don’t need cargo to write software in Rust
Re:sudo and su Being Rewritten in Rust for Memory Safety by Pengtuzi on Saturday April 29, 2023 @04:17PM (#35756733)
You seem to be off by a factor of 100 unless I’m missing something?

[workspace.dependencies] clap = "4.0.32" libc = "0.2.139" thiserror = "1.0.38" glob = "0.3.1" sha2 = "0.10.6" digest = "0.10.6" signal-hook = "0.3.15" log = "0.4.17" syslog = "6.0.1" env_logger = "0.9.3"

Re:sudo and su Being Rewritten in Rust for Memory Safety by akira2501 on Saturday April 29, 2023 @04:40PM (#35756933)
And what dependencies do those dependencies have?
Re:sudo and su Being Rewritten in Rust for Memory Safety by AnIrishDuck on Saturday April 29, 2023 @05:23PM (#35757336)
It transitively expands out to 47 unique packages? Still doesn't seem that crazy to me:

  $ cargo tree -e no-build --prefix none | sort | uniq | grep -v sudo | grep -v '\*'
  aho-corasick v0.7.20
  atty v0.2.14
  bitflags v1.3.2
  block-buffer v0.10.4
  cfg-if v1.0.0
  clap_builder v4.1.14
  clap_derive v4.1.14 (proc-macro)
  clap_lex v0.4.0
  clap v4.1.14
  cpufeatures v0.2.6
  crypto-common v0.1.6
  digest v0.10.6
  env_logger v0.9.3
  error-chain v0.12.4
  generic-array v0.14.7
  glob v0.3.1
  heck v0.4.1
  hostname v0.3.1
  humantime v2.1.0
  io-lifetimes v1.0.9
  is-terminal v0.4.5
  itoa v1.0.6
  libc v0.2.140
  linux-raw-sys v0.1.4
  log v0.4.17
  match_cfg v0.1.0
  memchr v2.5.0
  num_threads v0.1.6
  once_cell v1.17.1
  proc-macro2 v1.0.54
  quote v1.0.26
  regex-syntax v0.6.29
  regex v1.7.3
  rustix v0.36.11
  sha2 v0.10.6
  signal-hook-registry v1.4.1
  signal-hook v0.3.15
  strsim v0.10.0
  syn v2.0.11
  syslog v6.0.1
  termcolor v1.2.0
  thiserror-impl v1.0.40 (proc-macro)
  thiserror v1.0.40
  time-core v0.1.0
  time v0.3.20
  typenum v1.16.0
  unicode-ident v1.0.8
Re:sudo and su Being Rewritten in Rust for Memory Safety by int_19h on Saturday April 29, 2023 @08:10PM (#35758541)
For something like sudo - which is the kind of app where you want to carefully audit the code line by line - this does look pretty bad.
Re:sudo and su Being Rewritten in Rust for Memory Safety by tialaramex on Sunday April 30, 2023 @06:28AM (#35761250)
> the kind of app where you want to carefully audit the code line by line

This should be much less necessary for Safe Rust. The existing C sudo needs libpcre2, and OpenSSL neither of which are small - among other dependencies.

Some of these dependencies do use unsafe Rust in places, and so it's valuable that those places should be inspected carefully (and not only for sudo) - but many do not, humantime for example is entirely safe Rust. Is it possible it has a logic error of some sort? Yes. Is it likely it somehow introduces a security hole? Not really. A C equivalent could easily introduce a critical buffer overflow, use after free or similar but that's not possible in safe Rust.

Re:sudo and su Being Rewritten in Rust for Memory Safety by akira2501 on Sunday April 30, 2023 @01:38PM (#35764777)
sudo doesn't strictly need OpenSSL. That dependency is part of it's log server client implementation, and it's also available for the plugin system.

I had no idea sudo even had the need for plugins.

Which raises the question, maybe there's a need for two different sudo implementations. One that provides the simplest possible implementation of the feature, and another one that provides fancy log server and plugin integrations.

Re:sudo and su Being Rewritten in Rust for Memory Safety by IshKebab on Sunday April 30, 2023 @11:56AM (#35763775)
Are you worried about supply chain attacks? Because those are still extremely rare.

Or are you worried about bugs in dependencies? Because it's not like C sudo doesn't have dependencies.

Would you prefer that they implemented SHA2 themselves rather than using the battle tested crate that everyone else uses?

Re:sudo and su Being Rewritten in Rust for Memory Safety by int_19h on Sunday April 30, 2023 @05:08PM (#35766639)
For something like this, I think I would actually prefer that they copied existing code for hashing. It's simple and stable enough to avoid taking a dependency.
Re:sudo and su Being Rewritten in Rust for Memory Safety by IshKebab on Monday May 01, 2023 @01:10AM (#35769309)
Existing code like the code in the sha2 crate??
Re:sudo and su Being Rewritten in Rust for Memory Safety by int_19h on Monday May 01, 2023 @02:28AM (#35769650)
Sure. Or rather the parts of it that they're actually using.
Re:sudo and su Being Rewritten in Rust for Memory Safety by IshKebab on Monday May 01, 2023 @03:08AM (#35769871)
What would be the point of that?
Re:sudo and su Being Rewritten in Rust for Memory Safety by int_19h on Monday May 01, 2023 @01:53PM (#35776573)
A single bundle of code is easier to audit and easier to package.
Re:sudo and su Being Rewritten in Rust for Memory Safety by IshKebab on Monday May 01, 2023 @05:14PM (#35779268)
It's harder to package if you're using Cargo. Using the sha2 crate is one line. Copying the code into your project is a ton more work.

Ease of auditing is debatable. Using shared popular libraries gives the benefit of lots of people using them.

Plus actual code audits are very rare and of dubious value. They're mostly useful for finding out how well written the code is rather than finding bugs. For that your basically want fuzzing.

Re:sudo and su Being Rewritten in Rust for Memory Safety by jmillikin on Saturday April 29, 2023 @07:24PM (#35758290)
Those are direct dependencies. The full dependency list is in Cargo.lock, which (as binjooou stated) is currently at 1013 lines.

I love Rust as a language, but one of the challenges with many projects currently written in it is that they follow the NPM model of using dozens of tiny dependencies for even trivial functionality. Luckily this seems to be limited to users of crates.io for now, and maybe things will change as the library situation matures.

Re:sudo and su Being Rewritten in Rust for Memory Safety by steveklabnik on Saturday April 29, 2023 @07:31PM (#35758327)
> which (as binjooou stated) is currently at 1013 lines.

That doesn't mean there are a thousand dependencies. Dependencies take far more than one line in a lockfile.

Re:sudo and su Being Rewritten in Rust for Memory Safety by jmillikin on Saturday April 29, 2023 @08:02PM (#35758508)
You may want to re-read their comment. They said "1000 line long dependency file", not 1000 dependencies.
Re:sudo and su Being Rewritten in Rust for Memory Safety by steveklabnik on Saturday April 29, 2023 @08:18PM (#35758589)
Sure. It's worth pointing out this discrepancy even if they didn't mean to imply it, because not everybody knows that this is the case.
Re:sudo and su Being Rewritten in Rust for Memory Safety by tempaccount420 on Sunday April 30, 2023 @12:05PM (#35763858)
That's not what they said.