this post was submitted on 10 Apr 2024
114 points (87.0% liked)
Technology
57997 readers
2851 users here now
This is a most excellent place for technology news and articles.
Our Rules
- Follow the lemmy.world rules.
- Only tech related content.
- Be excellent to each another!
- Mod approved content bots can post up to 10 articles per day.
- Threads asking for personal tech support may be deleted.
- Politics threads may be removed.
- No memes allowed as posts, OK to post as comments.
- Only approved bots from the list below, to ask if your bot can be added please contact us.
- Check for duplicates before posting, duplicates may be removed
Approved Bots
founded 1 year ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
"not so safe now are you Rust" ~C, probably
It's not Rust, the language or even Windows.
It's if you write a program that allows the end user to call a command prompt and don't carefully sanitize the input, bad things could happen.
I mean, maybe Windows could do something different but if you wrote JavaScript that takes text input from a webpage and pass it to "sudo bash ##commands", you're going to have a bad time.
It's complete click bait because Rust has a reputation for security.
It's definitely not Rust's fault, but it's kinda Windows' one and cmd.exe escape logic... It's really difficult to write logic that will correctly escape any argument given to it, cmd.exe really is a pain to deal with :/
I get that in situations where they can't safely escape a parameter they'll just stop with an error, which sound as sane as one could go with this!
Is cmd.exe even a thing in Windows? I know it exists and you can run it but I thought I read that the default is Power Shell now. (Just Googled, yeah Powershell replaced cmd.exe by default in 2022.)
https://learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-createprocessa
Because a batch file (.bat or .cmd) is basically a set of cmd.exe instructions I guess that's why you can't get away from it.
And as if making sense of this
CreateProcessA
system call wasn't funny enough, you also need to figure out how to safely prepare thatlpCommandLine
for it following all of cmd.exe's weird escaping rules... lolDo you have to run a batch file? Why not a Powershell script since that's the default?
If you can avoid running batch files altogether then great, amazing. But there are projects out there using Rust that still depend on running those and that's the focus of the issue... But yeah I cannot wait until the day I won't hear about cmd.exe again.