LWN: Comments on "A major vulnerability in Sudo" https://lwn.net/Articles/844789/ This is a special feed containing comments posted to the individual LWN article titled "A major vulnerability in Sudo". en-us Wed, 15 Oct 2025 08:16:59 +0000 Wed, 15 Oct 2025 08:16:59 +0000 https://www.rssboard.org/rss-specification lwn@lwn.net A major vulnerability in Sudo https://lwn.net/Articles/847117/ https://lwn.net/Articles/847117/ mina86 <div class="FormattedComment"> Hmm… I stand corrected. (Though creating an array just to iterate over characters feels wasteful).<br> </div> Tue, 23 Feb 2021 10:45:14 +0000 A major vulnerability in Sudo https://lwn.net/Articles/847114/ https://lwn.net/Articles/847114/ anselm <p> What's wrong with <pre> foreach (split //, "abcde") { … } </pre> ? </p> Tue, 23 Feb 2021 10:26:22 +0000 A major vulnerability in Sudo https://lwn.net/Articles/846477/ https://lwn.net/Articles/846477/ immibis <div class="FormattedComment"> How does one elevate privilege in Qubes, and why is it immune to bugs?<br> </div> Wed, 17 Feb 2021 14:58:44 +0000 A major vulnerability in Sudo https://lwn.net/Articles/846433/ https://lwn.net/Articles/846433/ mina86 <div class="FormattedComment"> <font class="QuotedText">&gt; What languages make it hard to iterate through the characters of a string? I can&#x27;t think of a single one.</font><br> <p> Perl. ;)<br> </div> Wed, 17 Feb 2021 12:11:00 +0000 A major vulnerability in Sudo https://lwn.net/Articles/845804/ https://lwn.net/Articles/845804/ nix Via a fifo named /dev/mp3, and this exciting daemon: <pre> #!/usr/bin/zsh FIFO=/dev/mp3 [[ ! -p $FIFO ]] &amp;&amp; { echo "Error: $FIFO does not exist or is not a FIFO." &gt;&amp;2; exit 1; } while true; do mpg123 -b 1024 - &lt; $FIFO &gt;/dev/null 2&gt;/dev/null; done </pre> (This is decades old. If I was doing it these days, I'd probably not pick zsh at random and I'd probably use gst123 so it could play anything, not just mp3s. Obviously this needs a systemwide PulseAudio or something similar: again, this script predates PulseAudio entirely :) ) Thu, 11 Feb 2021 17:43:10 +0000 A major vulnerability in Sudo https://lwn.net/Articles/845651/ https://lwn.net/Articles/845651/ linuxrocks123 <div class="FormattedComment"> How does that work?<br> </div> Thu, 11 Feb 2021 04:47:09 +0000 userv as alternative https://lwn.net/Articles/845346/ https://lwn.net/Articles/845346/ ber <div class="FormattedComment"> Probably<br> <a href="https://packages.debian.org/buster/userv">https://packages.debian.org/buster/userv</a><br> <a href="http://www.chiark.greenend.org.uk/~ian/userv/">http://www.chiark.greenend.org.uk/~ian/userv/</a><br> is, what Werner refers to<br> </div> Mon, 08 Feb 2021 09:23:21 +0000 A major vulnerability in Sudo https://lwn.net/Articles/845337/ https://lwn.net/Articles/845337/ rcampos <div class="FormattedComment"> What is the userv model?<br> </div> Sun, 07 Feb 2021 23:22:42 +0000 A major vulnerability in Sudo https://lwn.net/Articles/845275/ https://lwn.net/Articles/845275/ marcH <div class="FormattedComment"> No, in this particular context &quot;comes for free&quot; (maybe not the best expression here) means: &quot;it&#x27;s memory safe or it does not compile&quot;.<br> <br> It&#x27;s like a static C analyser but built in, not optional and with barely any false positive ever.<br> </div> Sat, 06 Feb 2021 00:45:04 +0000 A major vulnerability in Sudo https://lwn.net/Articles/845265/ https://lwn.net/Articles/845265/ ssmith32 <div class="FormattedComment"> Comes for free just means it&#x27;s more likely to be used, not necessarily it will always be used.<br> <p> But it&#x27;s all about risk management anyways, so might as well try to skew the odds in your favor.<br> </div> Fri, 05 Feb 2021 22:35:55 +0000 A major vulnerability in Sudo https://lwn.net/Articles/845233/ https://lwn.net/Articles/845233/ nix <div class="FormattedComment"> Please. It&#x27;s *cat* that plays mp3s. (Literally true, on my system. I can also play mp3s with lpd.)<br> </div> Fri, 05 Feb 2021 18:50:33 +0000 A major vulnerability in Sudo https://lwn.net/Articles/845123/ https://lwn.net/Articles/845123/ mathstuf <div class="FormattedComment"> A lot of that comes at the expense of overhead in cross-library calls/member lookups. Either you force a function call, have a lookup table of member offsets, or have some weird inline code copying semantics. I believe Rust likely does not want to add such things to the language (at least at this time; it is likely at least in the direction of any likely solution that may appear eventually).<br> </div> Thu, 04 Feb 2021 17:58:47 +0000 A major vulnerability in Sudo https://lwn.net/Articles/845051/ https://lwn.net/Articles/845051/ smoogen <div class="FormattedComment"> Sadly parsing sh is the first thing everyone seems to do with a suid program if it didn&#x27;t before. It is like a moth to a flame.. ooooh I need this thing to do a shell script, it can&#x27;t be that hard.<br> <p> When I was younger, I was naive to believe that most of the core programs could be easily replaced with simpler programs.. and you could just keep to doing that one thing. Then you find that most of the people who espouse the Unix philosophy also think that if you made ooone little change to /bin/rm it would be much better for their usecase.. and 8 billion users later, rm now is setuid, sends email and plays mp3s.<br> </div> Thu, 04 Feb 2021 11:11:31 +0000 A major vulnerability in Sudo https://lwn.net/Articles/845045/ https://lwn.net/Articles/845045/ Jonno <div class="FormattedComment"> <font class="QuotedText">&gt; It seems at the moment the price you pay for memory safety is the inability to have shared libraries (at least with &quot;safe&quot; interfaces).</font><br> <p> Rust does allow you to use the full rust ABI in shared libraries, but the Rust ABI is still unstable between compiler releases. If you want ABI stability you are restricted to the C ABI, which is inherently unsafe. Creating a stable Rust ABI is on the roadmap, but not for anytime soon....<br> </div> Thu, 04 Feb 2021 09:44:41 +0000 A major vulnerability in Sudo https://lwn.net/Articles/845042/ https://lwn.net/Articles/845042/ Cyberax <div class="FormattedComment"> Ask sudo developers. The answer is likely &quot;it was inconvenient at that moment&quot;.<br> </div> Thu, 04 Feb 2021 09:25:37 +0000 A major vulnerability in Sudo https://lwn.net/Articles/845040/ https://lwn.net/Articles/845040/ NYKevin <div class="FormattedComment"> Right, but to do the escaping, you had to make a copy to begin with (because the string gets longer). So why not keep the original? How on Earth does it make sense to un-escape the copy?<br> </div> Thu, 04 Feb 2021 08:32:35 +0000 A major vulnerability in Sudo https://lwn.net/Articles/845035/ https://lwn.net/Articles/845035/ marcH <div class="FormattedComment"> <a href="https://en.wikipedia.org/wiki/Null-terminated_string">https://en.wikipedia.org/wiki/Null-terminated_string</a>: the other billion dollar mistake?<br> <p> <p> <font class="QuotedText">&gt; It’s really not a good strings language. It’s just not.</font><br> <p> The language of manual memory management and corruption.<br> </div> Thu, 04 Feb 2021 06:51:39 +0000 A major vulnerability in Sudo https://lwn.net/Articles/845036/ https://lwn.net/Articles/845036/ Cyberax <div class="FormattedComment"> Nothing at all stops you from making shared libraries with safe interfaces. Swift does that just fine, as an example.<br> </div> Thu, 04 Feb 2021 06:47:27 +0000 A major vulnerability in Sudo https://lwn.net/Articles/845034/ https://lwn.net/Articles/845034/ epa Yes, if you are going to run sh -c "command", where command hasn't been passed as a single argument but somehow as separate args, then you need to do fancy escaping so that the command line is built correctly. The answer is not to offer this functionality at all, it's too error-prone. As others noted, this is only the less used --shell and --login modes. Better to require the user to escalate using a mechanism that's as simple as possible, and then if the user wants to run sh -c that's their decision, once the authentication has been safely done. sudo's own manual page gives an example of this use:<br> <code>$ sudo sh -c "cd /home ; du -s * | sort -rn &gt; USAGE"</code> Thu, 04 Feb 2021 06:39:28 +0000 A major vulnerability in Sudo https://lwn.net/Articles/845019/ https://lwn.net/Articles/845019/ plugwash <div class="FormattedComment"> It seems at the moment the price you pay for memory safety is the inability to have shared libraries (at least with &quot;safe&quot; interfaces). So, in addition to the memory/cache costs of duplicate libraries, if one of the libraries does turn out to have a security flaw you have a much bigger job fixing it.<br> </div> Thu, 04 Feb 2021 02:34:13 +0000 A major vulnerability in Sudo https://lwn.net/Articles/844989/ https://lwn.net/Articles/844989/ marcH <div class="FormattedComment"> <font class="QuotedText">&gt; That makes review of these far easier and more targeted for these kinds of problems. With C and C++, the entire codebase is under such a block </font><br> <p> Exactly, &quot;git grep unsafe&quot; and win.<br> <p> This is once again not a yes/no question, it&#x27;s all about *how much* time is spent in code review and other quality assessments = what every manager say they want but never allocate proper resources for.<br> <p> And to be clear, when I wrote &quot;it comes for free&quot; I meant _memory safety_ comes for (almost) free. Of course switching to a different programming language is everything but free and even practically impossible for some projects.<br> <p> </div> Wed, 03 Feb 2021 22:04:39 +0000 A major vulnerability in Sudo https://lwn.net/Articles/844986/ https://lwn.net/Articles/844986/ Cyberax <div class="FormattedComment"> Unescaping always decreases the string length, so you can keep the previous buffer and just slap a NUL character at the new end.<br> </div> Wed, 03 Feb 2021 21:24:41 +0000 A major vulnerability in Sudo https://lwn.net/Articles/844979/ https://lwn.net/Articles/844979/ NYKevin <div class="FormattedComment"> The part I just realized today: sudo has to make a copy anyway, because backslash escaping modifies the length of the string. So now I *really* don&#x27;t get this bug.<br> </div> Wed, 03 Feb 2021 21:01:35 +0000 A major vulnerability in Sudo https://lwn.net/Articles/844978/ https://lwn.net/Articles/844978/ mathstuf <div class="FormattedComment"> Note that in Rust, many of the &quot;core&quot; crates have comments explaining *why* each and every `unsafe` block is necessary. That makes review of these far easier and more targeted for these kinds of problems. With C and C++, the entire codebase is under such a block and &quot;no one&quot; comments their safety guarantees at that granularity.<br> </div> Wed, 03 Feb 2021 20:12:54 +0000 A major vulnerability in Sudo https://lwn.net/Articles/844971/ https://lwn.net/Articles/844971/ smoogen <div class="FormattedComment"> I would beware of &#x27;it comes for free&#x27;. I have seen that argument used over and over for 30 years.. and inevitably found to be flawed... usually because someplace in execution the program has to go into whatever that language &#x27;unsafe&#x27; mode is. Then all the security bets are off HOWEVER the programmer and reviewers usually just say &#x27;well it was in XYZ language so it can&#x27;t be broken&#x27;. And then we have reliably 4 years after the language has gotten through the hype cycle of all the security problems that no one fuzzed for.<br> </div> Wed, 03 Feb 2021 19:02:21 +0000 A major vulnerability in Sudo https://lwn.net/Articles/844970/ https://lwn.net/Articles/844970/ smoogen <div class="FormattedComment"> I think sudo did that a looong time ago, and it was one of the original &#x27;how to break out of sudo&#x27;. So it had to gain parsing to try and deal with a lot of corner cases where passing things willy nilly to another shell or program caused worse issues. <br> </div> Wed, 03 Feb 2021 18:58:43 +0000 A major vulnerability in Sudo https://lwn.net/Articles/844959/ https://lwn.net/Articles/844959/ dd9jn <div class="FormattedComment"> It is a pity that the simple userv model is so less known. It does all the things right which you could get wrong with privilege elevation. sudo instead tries to be everyone&#x27;s best friend and makes things often too easy.<br> </div> Wed, 03 Feb 2021 16:37:44 +0000 A major vulnerability in Sudo https://lwn.net/Articles/844951/ https://lwn.net/Articles/844951/ epa <div class="FormattedComment"> It may be better to keep tricky code (like escaping things for sh -c) in one place, but a suid-root binary is not the place I&#x27;d pick.<br> </div> Wed, 03 Feb 2021 16:10:23 +0000 A major vulnerability in Sudo https://lwn.net/Articles/844928/ https://lwn.net/Articles/844928/ ibukanov <div class="FormattedComment"> If the log should allow reconstruction of the whole command as-is with all special characters and spaces, sudo could do it when writing the log appending escapes to the log file as necessary. This way the input can be const pointers and in the worst case the code will read pass the allocated buffer, not write.<br> </div> Wed, 03 Feb 2021 16:00:22 +0000 A major vulnerability in Sudo https://lwn.net/Articles/844927/ https://lwn.net/Articles/844927/ ibukanov <div class="FormattedComment"> Typical usage that requires a shell is not to call a shell built-in, but to do a redirections with &lt;, &gt; when the whole command should be passed as single argument. And even if I need to call a built-in with arguments, I can always do it like &#x27;builtin $0 $@&#x27; arg1 arg2 ...<br> <p> What sudo does is way too smart given the danger of bugs in it.<br> </div> Wed, 03 Feb 2021 15:55:21 +0000 A major vulnerability in Sudo https://lwn.net/Articles/844924/ https://lwn.net/Articles/844924/ Paf <div class="FormattedComment"> As a career long C developer...<br> <p> This, a thousand times this. It’s really not a good strings language. It’s just not.<br> </div> Wed, 03 Feb 2021 14:39:45 +0000 A major vulnerability in Sudo https://lwn.net/Articles/844922/ https://lwn.net/Articles/844922/ Jonno <div class="FormattedComment"> <font class="QuotedText">&gt; Why does sudo need any argument escaping at all? Why cannot it pass the arguments to /bin/sh -c directly?</font><br> <p> Because sudo gets the command to run and each of its arguments as separate entries in argv[], but sh -c expects the command and all its arguments as a single entry in its argv[], which it will interpret...<br> </div> Wed, 03 Feb 2021 14:25:11 +0000 A major vulnerability in Sudo https://lwn.net/Articles/844921/ https://lwn.net/Articles/844921/ tzafrir <div class="FormattedComment"> Because it logs the command. And there are some cool tricks you can do with various characters that get into the logs.<br> </div> Wed, 03 Feb 2021 13:52:04 +0000 A major vulnerability in Sudo https://lwn.net/Articles/844919/ https://lwn.net/Articles/844919/ roc <div class="FormattedComment"> What languages make it hard to iterate through the characters of a string? I can&#x27;t think of a single one.<br> <p> C lacks solid string and buffer primitives regardless of how you lampshade it. fmemopen and open_memstream are massive overkill for string manipulation ... they both implement locking by default! C just doesn&#x27;t have an ergonomic way to track bounded string/array slices or growable buffers. All the library solutions are excessively verbose, so developers are constantly tempted to write hand-rolled code with raw pointers and manual buffer size calculations, and they regularly get it wrong with disastrous consequences.<br> </div> Wed, 03 Feb 2021 12:24:33 +0000 A major vulnerability in Sudo https://lwn.net/Articles/844920/ https://lwn.net/Articles/844920/ ibukanov <div class="FormattedComment"> Why does sudo need any argument escaping at all? Why cannot it pass the arguments to /bin/sh -c directly?<br> </div> Wed, 03 Feb 2021 12:17:41 +0000 A major vulnerability in Sudo https://lwn.net/Articles/844918/ https://lwn.net/Articles/844918/ tschoerbi <div class="FormattedComment"> It might be time to replace sudo. Almost always, you just want to be able to grant one group root access for which sudo&#x27;s complexity isn&#x27;t needed.<br> <p> On my systems, I have had permission to sudo restricted for years. I only every need group sudo to be able to execute sudo:<br> <p> dpkg-statoverride --force-statoverride-add --update --add root sudo 4750 /usr/bin/sudo<br> </div> Wed, 03 Feb 2021 12:10:56 +0000 A major vulnerability in Sudo https://lwn.net/Articles/844913/ https://lwn.net/Articles/844913/ Jonno <div class="FormattedComment"> <font class="QuotedText">&gt; Sudo has no business running something fancy like sh -c &quot;command&quot;; it should do the stupidest thing possible, which is to take its literal arguments from the argv array and pass them directly to exec(). Sadly, it may be too late to change.</font><br> <p> That is indeed what sudo does by default. It is only when you pass both &quot;-s&quot; / &quot;--shell&quot; (run a shell) or &quot;-i&quot; / &quot;--login&quot; (run a login shell) as well as specifying a command to execute that sudo starts going haywire, by passing the command to the shell using the &quot;-c&quot; argument of the shell in question.<br> <p> Having sudo execute the specified command through a shell running as the target user is useful for running shell builtins, doing shell redirections, etc; so the alternative to sudo doing the escaping is the caller doing them and then calling `sudo -- /bin/sh -c &quot;...&quot;`. It is _usually_ better to keep tricky stuff like this in one place rather than a hundred, but that presupposes that someone actually checks that it does so correctly...<br> </div> Wed, 03 Feb 2021 11:08:36 +0000 A major vulnerability in Sudo https://lwn.net/Articles/844912/ https://lwn.net/Articles/844912/ epa <div class="FormattedComment"> Personally, as soon as I hear the words &quot;escape it with backslashes&quot; I start to worry. That sort of thing is a cosy nest for bugs, even in a memory-safe language. Sudo has no business running something fancy like sh -c &quot;command&quot;; it should do the stupidest thing possible, which is to take its literal arguments from the argv array and pass them directly to exec(). Sadly, it may be too late to change.<br> </div> Wed, 03 Feb 2021 10:44:24 +0000 A major vulnerability in Sudo https://lwn.net/Articles/844908/ https://lwn.net/Articles/844908/ marcH <div class="FormattedComment"> <font class="QuotedText">&gt; For a bug of this sort to persist for this long in a tool of this nature would seem to indicate that we are not really scrutinizing our code as well as we should be. Or testing and fuzzing enough either.</font><br> <p> &quot;We&quot; generally don&#x27;t find this fun and &quot;we&quot; rarely get paid for any of that either. At least not on the defence side.<br> <p> People who actually care about memory safety are just moving to safe languages - why would they bother about all this tedious and error-prone review and fuzzing work when that part comes &quot;for free&quot; in newer languages? Every minute of work spent on memory safety is a minute not spent on something more productive - including of course other, higher level security issues.<br> <p> </div> Wed, 03 Feb 2021 08:47:45 +0000 A major vulnerability in Sudo https://lwn.net/Articles/844905/ https://lwn.net/Articles/844905/ wahern <div class="FormattedComment"> Also, as has recently been made clear to me today while discussing severity ratings during a security review, unless people *see* things break they don&#x27;t take it seriously. In fact, because convenient, copy+pastable root shell PoCs weren&#x27;t immediately available last week, Tenable rated the CVE *low* severity, which is just patently ridiculous to me. If heap memory corruption in a tool like sudo is proven with a one-liner, it&#x27;s absolutely negligent to harbor any doubts about present exploitation potential, regardless of where one falls on the spectrum of risk averseness. <br> <p> I&#x27;m normally quite cynical when it comes to Linux security--my background assumption is that if someone has shell access on a Linux host, they have root access. But holding that opinion is no excuse for neglecting a diligent and accurate assessment of relative threat potential.<br> <p> </div> Wed, 03 Feb 2021 07:20:35 +0000