The malicious "rustdecimal" crate
The malicious "rustdecimal" crate
Posted May 11, 2022 19:41 UTC (Wed) by epa (subscriber, #39769)Parent article: The malicious "rustdecimal" crate
That’s not to claim that Haskell is some promised land of strictly typed and fine-grained permissions: as far as I know you will tend to just label everything as ‘IO’ and it’s not common to declare that a library function may perform disk access but not network access, or whatever. But let’s dream for a moment.
What if you wrote a library as pure code with no side effects, enforced by the type system, and then when importing a crate you require this stricter type? Then adding the malicious code would require a type change and no longer build.
I’d like to apply a higher review standard to libraries that are permitted to do I/O. If I want to decompress some gzip data from one buffer in memory to another buffer, I am not that paranoid about using third party code to do it, if the language can guarantee memory safety (as Rust does) and that no side effects or I/O can be performed by the library code. (Even better if you can guarantee that it cannot read the state of the outside world, so its behaviour must only depend on the input buffer and arguments explicitly passed.) Of course there would be libraries that need full access to the environment, but I would pick those more carefully, just as code inside ‘unsafe’ blocks needs extra scrutiny.
(I am not claiming that there could not still be exploits from a malicious decompression routine, any more than ‘safe’ or managed code does not need reviewing. I just mean the risk is higher if full I/O is allowed.)
So when picking the libraries included in your build, you would see the ‘purity’ of each one — which could include an ultra-strict level where not even memory allocation is allowed. The more freedom the library code has, the more carefully you must review it. And if a newer version wants more abilities, then like configuring permissions for apps on your phone, that must be an explicit step.
The LWN site is currently under high scraper load, so comment display has been suppressed for anonymous users. If you are a human, you may read the comments by clicking the button below:
Note: you can avoid this step in the future by logging into your LWN account.
