Comments by "Mikko Rantalainen" (@MikkoRantalainen) on "Low Level" channel.

  1. 112
  2. 8
  3. 8
  4. 5
  5. 5
  6. 5
  7. 5
  8. 4
  9. 3
  10. 3
  11. 2
  12. 2
  13. 2
  14. 2
  15. 2
  16. 1
  17. 1
  18. 1
  19. 1
  20. 1
  21. 1
  22. 1
  23. 1
  24. 1
  25. 1
  26. 1
  27. I would argue that this is actually a security vulnerability in Windows .bat execution instead of vulnerability in Rust. Unlike in POSIX shells where the command line is parsed and executed by the shell and arg() correctly encodes the arguments, Windows .bat execution takes the correctly encoded user input as a single parameter and then internally make another interpretation of the arguments! The reason windows binaries do this is because their command line is too stupid to do any processing so all processing must be re-implemented by every program you run. And as usual, you MUST encode all untrusted user input in a way that's appropriate for the context and for this case, you need double encoding: encode once for .bat argument syntax and another time for the Rust Command syntax where the arg() is the correct solution. This is similar to having to encode a piece of user input as JavaScript string and add another encoding step to encode the JavaScript as part of HTML input. Failing to do either of the two required steps results in injection attack. Current Rust doesn't have a "bugfix" for this vulnerability. Instead they fixed the documentation to explain this to Windows developers that may not be aware of this Windows behavior: "On Windows use caution with untrusted inputs. Most applications use the standard convention for decoding arguments passed to them. These are safe to use with arg. However some applications, such as cmd.exe and .bat files, use a non-standard way of decoding arguments and are therefore vulnerable to malicious input. In the case of cmd.exe this is especially important because a malicious argument can potentially run arbitrary shell commands." On Windows, there are no generic safe way to encode command line arguments as data. The correct encoding depends on the command you execute. And as a result, arg() cannot be modified to have generic safe encoding for all commands.
    1
  28. 1
  29. 1
  30. 1
  31. 1
  32. 1
  33. 1
  34. 1
  35. 1
  36. 1
  37. 1
  38. 1
  39. 1
  40. 1
  41. 1
  42. 1
  43. 1
  44. 1
  45. 1
  46. 1