LWN: Comments on "Local root vulnerability in snap-confine" https://lwn.net/Articles/885195/ This is a special feed containing comments posted to the individual LWN article titled "Local root vulnerability in snap-confine". en-us Mon, 22 Sep 2025 20:14:45 +0000 Mon, 22 Sep 2025 20:14:45 +0000 https://www.rssboard.org/rss-specification lwn@lwn.net Local root vulnerability in snap-confine https://lwn.net/Articles/885956/ https://lwn.net/Articles/885956/ Wol <div class="FormattedComment"> What you need is something that OPTIONALLY enforces all this stuff. Like David Wheeler&#x27;s comments on filenames for example - a *create*time flag for a filesystem that says &quot;enforce these safety rules&quot;.<br> <p> Sure, all hell could then break loose, as old apps assume they can write garbage, etc etc, but it gives *developers* the opportunity to have a flag day and clean up their own stuff. Then they recommend that users enable this flag, which can&#x27;t be enabled on existing systems to avoid breaking them, and all this goodness is enforced going forwards.<br> <p> Then you reverse the default state of the flag so all of a sudden, people with old apps have to ask for the old behaviour ... But the breakage is minimised by making it easy for those in the know to be early adopters and test their own systems. You only need something like SUSE&#x27;s Open Build System flipping their default setting, as developer&#x27;s build systems start breaking and a distro could then rapidly switch their own default knowing all the apps they&#x27;ve built are compliant ...<br> <p> Cheers,<br> Wol<br> </div> Thu, 24 Feb 2022 11:07:31 +0000 Local root vulnerability in snap-confine https://lwn.net/Articles/885737/ https://lwn.net/Articles/885737/ mathstuf <div class="FormattedComment"> Heh. The C string library functions routinely shows as &quot;hot&quot; when I benchmark certain programs because there&#x27;s no way to use a view reliably (C++ helps out here, but if it were C…there wouldn&#x27;t even be the ability to factor out that `strlen` from `if/else` trees at least using static strings). To use a substring, you have to allocate and copy it to new memory just to put a NUL at the end and that adds up over time. So I don&#x27;t think performance is really the thing keeping C back from a new string library because it&#x27;s frankly just not that great for string manipulation-heavy tasks to begin with IME.<br> <p> As for convenience, sure it&#x27;s handy to be able to pass a &quot;string&quot; around in a register because it&#x27;s &quot;just&quot; the size of a pointer, but weighing that against the inconvenience of having to debug mishandling of these APIs, they are by *far* in the red in my book. I mean, we have how many flavors of &quot;append a string&quot;? `strcat`, `strncat`, and `strlcat`? Toss `snprintf` in there too if you want to be fancy. And there&#x27;s not even *consensus* on this set. Reviewing code dense with use of the C string library requires notes because I need to track where lengths are coming from, are the right APIs being used, and &quot;oh, that&#x27;s just a poorly coded `strdup`&quot; recognitions. I don&#x27;t find it useful.<br> <p> So given that it scores (IMO) a 2/5 on performance (sure, registers get you something I guess), 1/5 in (overall) convenience, and 0/5 on security because the APIs just don&#x27;t help out half the time, why, specifically, would roc&#x27;s &quot;attitude&quot; not be warranted?<br> </div> Tue, 22 Feb 2022 02:29:34 +0000 Local root vulnerability in snap-confine https://lwn.net/Articles/885733/ https://lwn.net/Articles/885733/ Smon <div class="FormattedComment"> @smcv: Thank you very much for your detailed insight. It was really interesting to me!<br> </div> Mon, 21 Feb 2022 23:32:37 +0000 Local root vulnerability in snap-confine https://lwn.net/Articles/885698/ https://lwn.net/Articles/885698/ Cyberax <div class="FormattedComment"> <font class="QuotedText">&gt; David Wheeler&#x27;s proposal would ban every ~1/(26+26+10+4) = 1/66-th video downloaded by youtube-dl. It is too late to ban anything.</font><br> <p> Just add automatic escaping for such names.<br> </div> Mon, 21 Feb 2022 18:04:24 +0000 Local root vulnerability in snap-confine https://lwn.net/Articles/885690/ https://lwn.net/Articles/885690/ adobriyan <div class="FormattedComment"> David Wheeler&#x27;s proposal would ban every ~1/(26+26+10+4) = 1/66-th video downloaded by youtube-dl. It is too late to ban anything.<br> <p> GNU ls(1) started to quote filenames with spaces at some point, it was huge step in right direction because copy paste suddenly started working &quot;out of the box&quot;. More features lke this are necessary.<br> </div> Mon, 21 Feb 2022 17:33:08 +0000 Local root vulnerability in snap-confine https://lwn.net/Articles/885687/ https://lwn.net/Articles/885687/ nybble41 <div class="FormattedComment"> <font class="QuotedText">&gt; What is actually wanted is system calls, that return unambigous, well defined data..</font><br> <p> We have the system calls (open, read, write). What is missing is the &quot;unambiguous, well-defined data&quot;. Given an appropriate serialization format there is nothing wrong with communicating the data through /proc. I see no need to restrict access to languages with support for making special-purpose system calls.<br> </div> Mon, 21 Feb 2022 16:37:51 +0000 Local root vulnerability in snap-confine https://lwn.net/Articles/885681/ https://lwn.net/Articles/885681/ rgmoore <p>I think your comment gets very nicely at the root of our problems. We will never get security right as long as it is given lower priority than convenience and performance. Mon, 21 Feb 2022 15:20:12 +0000 Local root vulnerability in snap-confine https://lwn.net/Articles/885664/ https://lwn.net/Articles/885664/ zdzichu Everything except NULL and / is allowed in filenames. But it doesn't mean it's a good idea to use it. Please take time to read the essay, it is eye-opening. <br></br> And you do not need a website. Just <code>touch -- --foot-shooter</code> (or <code>touch -- -rf\ .</code> if you like). Mon, 21 Feb 2022 14:15:03 +0000 Local root vulnerability in snap-confine https://lwn.net/Articles/885627/ https://lwn.net/Articles/885627/ adobriyan <div class="FormattedComment"> <font class="QuotedText">&gt; Even &quot;-&quot; character should not be allowed as the first character of a filename.</font><br> <p> &#x27;-&#x27; is allowed in URLs. Any site issuing randomised names (like: YT) to user submitted content will create a file starting with minus easily.<br> </div> Mon, 21 Feb 2022 13:37:24 +0000 Local root vulnerability in snap-confine https://lwn.net/Articles/885618/ https://lwn.net/Articles/885618/ zdzichu <div class="FormattedComment"> Even &quot;-&quot; character should not be allowed as the first character of a filename. There are many gotchas with various characters. David A. Wheeler summarized them neatly in <a href="https://dwheeler.com/essays/fixing-unix-linux-filenames.html">https://dwheeler.com/essays/fixing-unix-linux-filenames.html</a> .<br> </div> Mon, 21 Feb 2022 12:43:27 +0000 "owning" a symlink? https://lwn.net/Articles/885612/ https://lwn.net/Articles/885612/ kronat <div class="FormattedComment"> <font class="QuotedText">&gt; The legitimate uses of symlinks are mostly static [...]</font><br> Based on the above, isn&#x27;t it possible to &quot;block&quot; any modification to the symlink until the application(s) that &quot;locked&quot; the symlink by opening it for reading is (are) done (doing a close on it)?<br> </div> Mon, 21 Feb 2022 10:14:14 +0000 Local root vulnerability in snap-confine https://lwn.net/Articles/885606/ https://lwn.net/Articles/885606/ epa <div class="FormattedComment"> I meant mount points should be restricted to alphanumeric and -_. characters. For filenames in general I agree that humans expect to use ().<br> <p> On some platforms space is not a legal character in filenames but you can use non-breaking space, which isn’t treated specially by the shell. I’m not sure whether that is better or worse. <br> </div> Mon, 21 Feb 2022 07:01:55 +0000 Local root vulnerability in snap-confine https://lwn.net/Articles/885585/ https://lwn.net/Articles/885585/ judas_iscariote <div class="FormattedComment"> <font class="QuotedText">&gt; proper serialization formats when communicating complex data structures to between kernel and userland, instead of this stringly typed complex to parse hodgepodge that &gt; is &quot;mountinfo&quot;.</font><br> <p> What is actually wanted is system calls, that return unambigous, well defined data.. same on all archictectures or kernel config options.. no new proc files to parse or to write to...<br> </div> Sun, 20 Feb 2022 23:42:57 +0000 Local root vulnerability in snap-confine https://lwn.net/Articles/885553/ https://lwn.net/Articles/885553/ epa <div class="FormattedComment"> I meant the names of mount points, not file names in general.<br> </div> Sun, 20 Feb 2022 16:59:03 +0000 Local root vulnerability in snap-confine https://lwn.net/Articles/885531/ https://lwn.net/Articles/885531/ smcv <div class="FormattedComment"> Another reason why Snap needs root, but Flatpak usually does not, is that Snap uses an LSM (AppArmor) as part of its sandboxing but Flatpak does not.<br> <p> As with the different scopes I described in my previous comment, this is a trade-off, and neither is trivially better than the other.<br> <p> The fact that Snap uses AppArmor means it can rely on the LSM mechanism in the kernel, which is quite powerful, particularly if you are willing to patch the kernel (I believe Ubuntu&#x27;s kernel patches to add SO_PEERSEC support to AppArmor still haven&#x27;t gone upstream). If the kernel gives you information about a peer&#x27;s LSM labels, then you can trust that information to be correct and securely obtained; and if a process is restricted by LSM policies, the kernel will forbid anything that those policies forbid, without needing to rely on other mechanisms like userns and seccomp as heavily as Flatpak does.<br> <p> On the other hand, you need CAP_MAC_ADMIN (i.e. root) to manipulate AppArmor profiles, and if running on a distribution like Fedora that uses a different &quot;big&quot; LSM, or a distribution that doesn&#x27;t compile any of the &quot;big&quot; LSMs into its kernel at all, then you&#x27;re not going to be able to benefit from AppArmor at all.<br> <p> Flatpak has gone for the approach that makes it work equally well on &quot;most&quot; distros, and give it an equal level of sandboxing on &quot;most&quot; distros even if installed as non-root. Snap has gone for the approach that is maximally powerful on e.g. Ubuntu, at the cost of working less well on non-Ubuntu and requiring root.<br> </div> Sun, 20 Feb 2022 13:11:19 +0000 Local root vulnerability in snap-confine https://lwn.net/Articles/885530/ https://lwn.net/Articles/885530/ smcv <div class="FormattedComment"> The flatpak-system-helper is part of the distribution/installation layer of Flatpak rather than part of the sandboxing layer: it&#x27;s the part that lets semi-privileged (but non-root-equivalent) users install an app or runtime system-wide, into /var/lib/flatpak. It&#x27;s only about getting files into the right directories, and gets invoked when you install or upgrade an app, not when you run it.<br> <p> The sandboxing layer of Flatpak *usually* (on modern distros) runs with the privileges of its caller, and can&#x27;t do anything its caller couldn&#x27;t already do on their own.<br> <p> The exception to that is when the distro doesn&#x27;t allow unprivileged users to create new user namespaces, for example Debian 10 and RHEL 7, in which case the bubblewrap executable (typically /usr/bin/bwrap or /usr/libexec/flatpak-bwrap) needs to be setuid root. I don&#x27;t think it&#x27;s coincidence that two out of four CVEs reported against bubblewrap have only been applicable when it&#x27;s setuid root, and those two were the really serious ones. Setuid is dangerous and it&#x27;s good to avoid it whenever possible (see also the recent pkexec vulnerability).<br> <p> (CVE-2016-8659 and CVE-2020-5291 were root privilege escalation when setuid root, but were not applicable when not setuid root; CVE-2017-5226 wasn&#x27;t really a vulnerability in bubblewrap at all, but more like a vulnerability in Flatpak and other bubblewrap users; CVE-2019-12439 only applied in unusual system configurations, and as far as I&#x27;m aware it was only a denial-of-service.)<br> </div> Sun, 20 Feb 2022 12:54:33 +0000 Local root vulnerability in snap-confine https://lwn.net/Articles/885527/ https://lwn.net/Articles/885527/ smcv <div class="FormattedComment"> Flatpak is designed for a narrower use-case than Snap, so it&#x27;s willing to accept more restrictions on what it can do, and doesn&#x27;t need to be as &quot;powerful&quot; as Snap. On one hand, this makes Snap useful in situations where Flatpak isn&#x27;t; on the other hand, this means Flatpak developers can focus on the situations that it supports, and ignore the situations it doesn&#x27;t.<br> <p> In particular, when Flatpak developers encounter something that would be hard to implement securely, we are often able to declare it to be out-of-scope and not implement it at all, resulting in fewer attack vectors.<br> <p> Flatpak is designed to sandbox &quot;apps&quot;, with a meaning that is not 100% well-defined, but &quot;programs that behave like an Android/iOS app&quot; or &quot;GUI programs with a .desktop file&quot; are reasonable approximations. Snap is designed to sandbox &quot;apps&quot;, but also non-&quot;app&quot; things like system services: you can install lxd as a Snap, but it would not be possible to install lxd as a Flatpak app.<br> <p> I personally think that&#x27;s a strength of Flatpak rather than a weakness, but it would be reasonable for Snap users/developers to disagree on that: neither approach is trivially better than the other.<br> </div> Sun, 20 Feb 2022 12:38:34 +0000 Local root vulnerability in snap-confine https://lwn.net/Articles/885515/ https://lwn.net/Articles/885515/ foom <div class="FormattedComment"> Eh? No use for spaces and parentheses? Both of those are incredibly useful in filenames for humans! Characters like newlines or tabs, sure -- those have no place in filenames. And you could arguably exclude double quotes as well, but a filename like &quot;Aaron&#x27;s Report: Cats (2010)&quot; is completely reasonable.<br> <p> If there&#x27;s blame to be had, it&#x27;d be for the Unix shell language which treats strings in a variable unsafely by default!<br> </div> Sun, 20 Feb 2022 03:03:55 +0000 Local root vulnerability in snap-confine https://lwn.net/Articles/885511/ https://lwn.net/Articles/885511/ jra <div class="FormattedComment"> If I can get this mount flag to be easily used I will certainly add it to the recommended settings for a Samba server.<br> <p> I&#x27;m sick of symlink insanity.<br> <p> </div> Sat, 19 Feb 2022 23:21:20 +0000 Local root vulnerability in snap-confine https://lwn.net/Articles/885493/ https://lwn.net/Articles/885493/ spigot Amusingly, the Acknowledgments section of <a href="https://www.qualys.com/2022/02/17/cve-2021-44731/oh-snap-more-lemmings.txt">the write-up</a> has this dedication: </p> <blockquote>This advisory is dedicated to 8lgm -- followers of symbolic links, overflowers of stack buffers, and dereferencers of NULL pointers: [...]</blockquote> Sat, 19 Feb 2022 18:02:57 +0000 Local root vulnerability in snap-confine https://lwn.net/Articles/885451/ https://lwn.net/Articles/885451/ intgr <div class="FormattedComment"> <font class="QuotedText">&gt; whoever came up with the mountinfo format, but that may be a little unfair as I&#x27;m sure it has simply evolved rather than being designed</font><br> <p> I don&#x27;t really blame whoever came up with it, but I blame kernel developers for not offering better alternatives for new use cases and migrating old kludges over.<br> <p> Kernel developers should decide on a new unambiguous and extensible serialization format for complex nested data structures. In 1990s these lessons hadn&#x27;t really been learned yet, but in 2022 we have protobuf, Avro, Arrow, ASN.1, JSON and plenty more. I&#x27;m sure we can find at least one that suits the kernel use case.<br> <p> <font class="QuotedText">&gt; blame whoever decided that ( ) and space should be legal characters in a mount point path name</font><br> <p> This wouldn&#x27;t even help that much. Restricting characters in path names would solve this particular issue for paths, but there are still plenty of other strings with arbitrary content that may end up being communicated to user space. So would you propose blocking a set of characters in *all* kernel inputs?<br> <p> I feel like a broken record at this point, but again: if you&#x27;re having trouble transmitting certain characters in your serialization format, it&#x27;s the serialization format that sucks.<br> <p> </div> Sat, 19 Feb 2022 10:26:26 +0000 Local root vulnerability in snap-confine https://lwn.net/Articles/885448/ https://lwn.net/Articles/885448/ adobriyan <div class="FormattedComment"> The technical bug is that (deleted) is appended, not prepended so it is impossible to disambiguate just by looking at the output.<br> </div> Sat, 19 Feb 2022 09:40:38 +0000 Local root vulnerability in snap-confine https://lwn.net/Articles/885442/ https://lwn.net/Articles/885442/ roc <div class="FormattedComment"> <font class="QuotedText">&gt; Please use (create) a proper C library of high-level string manipulation functions, no shortcuts!</font><br> <p> The problem is that C doesn&#x27;t provide enough language features to make a library string type as convenient and performant to use as char*. (Language features such as destructors.) Therefore C programmers will be disinclined to use it. It&#x27;s not an accident that after all these years no such library is in broad use.<br> </div> Sat, 19 Feb 2022 08:55:12 +0000 Local root vulnerability in snap-confine https://lwn.net/Articles/885431/ https://lwn.net/Articles/885431/ intelfx <div class="FormattedComment"> <font class="QuotedText">&gt; &quot;This application is only known to be secure when used on a filesystem mounted with the MNT_NOSYMFOLLOW option. Use on filesystems allowing symlinks can lead to race conditions and security vulnerabilities.&quot;</font><br> <p> I wouldn&#x27;t use such software.<br> </div> Sat, 19 Feb 2022 06:23:17 +0000 Local root vulnerability in snap-confine https://lwn.net/Articles/885407/ https://lwn.net/Articles/885407/ walters <div class="FormattedComment"> I only glanced at <a href="https://github.com/snapcore/snapd/tree/61b66aaa1beb861f308ea7dd75c2f0c042bf29a3/cmd/snap-confine">https://github.com/snapcore/snapd/tree/61b66aaa1beb861f30...</a> and there&#x27;s a lot going on there, but...I think the flatpak equivalent of part of this is <a href="https://github.com/flatpak/flatpak/blob/main/system-helper/flatpak-system-helper.c">https://github.com/flatpak/flatpak/blob/main/system-helpe...</a> which runs as a DBus service, not a suid binary.<br> <p> <p> <p> <p> </div> Fri, 18 Feb 2022 21:57:43 +0000 Local root vulnerability in snap-confine https://lwn.net/Articles/885399/ https://lwn.net/Articles/885399/ ms-tg <div class="FormattedComment"> <font class="QuotedText">&gt; It&#x27;s &quot;sacred&quot; because getting any traction for moving away from such permissiveness means an unknown amount of work for an unknown number of people who don&#x27;t even know you&#x27;re planning to impose that work on them.</font><br> <p> I wonder if there are steps that, over some years, could help make the unknown number of people visible? For example, what if Linux, either in the file systems or more likely in distro-level utilities, simply detected filenames that violated certain rules, and let the user know that these existed and might need to be renamed to follow a proposed RFC naming convention in the future if it becomes accepted?<br> <p> Perhaps users could opt-in to also reporting counts back to a central server?<br> <p> I&#x27;m even picturing a nice web page, the way big security vulnerabilities have these days? Maybe &#x27;linux-filenames-rfc.io&#x27;? Which could include the latest text of the proposal, links to Github where changes can be proposed, mailing lists where it is discussed, etc?<br> <p> Using these sorts of community consensus approaches, might it be possible to get more of a defined sense of how often how big a real-world impact would be felt by any proposed reduction in Linux filename permissiveness?<br> </div> Fri, 18 Feb 2022 21:11:09 +0000 Local root vulnerability in snap-confine https://lwn.net/Articles/885395/ https://lwn.net/Articles/885395/ Smon <div class="FormattedComment"> I enjoyed reading the report. Thank you!<br> <br> Flatpaks bwrap is able to run as non root and use user-namespacing. So this cannot happen there.<br> Why does snap need a suid binary?<br> </div> Fri, 18 Feb 2022 21:06:07 +0000 Local root vulnerability in snap-confine https://lwn.net/Articles/885392/ https://lwn.net/Articles/885392/ developer122 <div class="FormattedComment"> A surprisingly elegant solution, imo.<br> </div> Fri, 18 Feb 2022 20:50:18 +0000 Local root vulnerability in snap-confine https://lwn.net/Articles/885390/ https://lwn.net/Articles/885390/ developer122 <div class="FormattedComment"> Side question: would it have done anything if it was originally required that the user have permissions for the destination if they wished to create a simlink? Is this feasible? (invalid symlinks might be a tricky edgecase, especially if they&#x27;re not invalidated when their target is removed)<br> </div> Fri, 18 Feb 2022 20:41:50 +0000 Local root vulnerability in snap-confine https://lwn.net/Articles/885370/ https://lwn.net/Articles/885370/ mpr22 <div class="FormattedComment"> It&#x27;s &quot;sacred&quot; because getting any traction for moving away from such permissiveness means an unknown amount of work for an unknown number of people who don&#x27;t even know you&#x27;re planning to impose that work on them.<br> </div> Fri, 18 Feb 2022 18:33:08 +0000 Local root vulnerability in snap-confine https://lwn.net/Articles/885363/ https://lwn.net/Articles/885363/ jra <div class="FormattedComment"> One of the things I&#x27;d like to see is wide knowledge and availability of MNT_NOSYMFOLLOW use, and making it available as a normal mount flag.<br> <p> Then applications can state:<br> <p> &quot;This application is only known to be secure when used on a filesystem mounted with the MNT_NOSYMFOLLOW option. Use on filesystems allowing symlinks can lead to race conditions and security vulnerabilities.&quot;<br> <p> Let admins know how to protect themselves from this misfeature.<br> <p> </div> Fri, 18 Feb 2022 18:21:09 +0000 Local root vulnerability in snap-confine https://lwn.net/Articles/885365/ https://lwn.net/Articles/885365/ nix <div class="FormattedComment"> <font class="QuotedText">&gt; This would be fail-safe for older code</font><br> <p> What? It would cause new failures for older code, i.e. it would introduce countless DoS vectors, only a microscopic proportion of which correspond to actual attacks, but all of which would annoy users (where &quot;annoy users&quot; spans the entire spectrum from &quot;slightly annoying&quot; through &quot;bug we can&#x27;t track down that goes away on restarting&quot; through to &quot;oops now the system is unbootable because of an unexpected and undiagnosed EREFRESH while installing something boot-critical&quot;).<br> <p> Hell no.<br> </div> Fri, 18 Feb 2022 17:43:23 +0000 Local root vulnerability in snap-confine https://lwn.net/Articles/885354/ https://lwn.net/Articles/885354/ epa <div class="FormattedComment"> I think you can also blame whoever decided that ( ) and space should be legal characters in a mount point path name. It serves no purpose to allow them. But this is a cultural hot button issue, since the original Unix decision to allow any byte except / and NUL in a filename has become somehow sacred. (I&#x27;m not even talking about filenames in general, just the name of mount points!)<br> <p> You can also blame whoever came up with the mountinfo format, but that may be a little unfair as I&#x27;m sure it has simply evolved rather than being designed. With hindsight, if you are pasting together strings in a formatted text output you should think in advance of what to do if one of the formatting characters (like, I don&#x27;t know, newline) appears in a string. But again, there&#x27;s no cultural consensus on what to do, and any scheme you invented would probably be parsed wrongly by lots of userland code, since it&#x27;s an uncommon case.<br> </div> Fri, 18 Feb 2022 16:20:48 +0000 Local root vulnerability in snap-confine https://lwn.net/Articles/885274/ https://lwn.net/Articles/885274/ intgr <div class="FormattedComment"> <font class="QuotedText">&gt; <a href="https://www.qualys.com/2022/02/17/cve-2021-44731/oh-snap-more-lemmings.txt">https://www.qualys.com/2022/02/17/cve-2021-44731/oh-snap-...</a></font><br> <p> Thanks for the link, this report is pure gold and worth reading in full.<br> <p> Truly, props to snap-confine developers for implementing mitigations to make exploitation so complicated.<br> <p> As for the other vulnerabilities they found......... *sigh*<br> <p> <font class="QuotedText">&gt; CVE-2021-3995: Unauthorized unmount in util-linux&#x27;s libmount</font><br> <p> <font class="QuotedText">&gt; only the first &quot;sz&quot; characters of the</font><br> <font class="QuotedText">&gt; current user&#x27;s uid are compared to the filesystem&#x27;s &quot;user_id&quot; option (sz</font><br> <font class="QuotedText">&gt; is user_id&#x27;s length). This second vulnerability allows an unprivileged</font><br> <font class="QuotedText">&gt; user to unmount the FUSE filesystems that belong to certain other users;</font><br> <font class="QuotedText">&gt; for example, if our own uid is 1000, then we can unmount the FUSE</font><br> <font class="QuotedText">&gt; filesystems of the users whose uid is 100, 10, or 1</font><br> <p> This is hilarious and sad at the same time. It would be obvious to blame the C language. But I think it&#x27;s time to start putting blame on developers as well, when instead of using proper primitives like &quot;compare string A and B and tell me if they&#x27;re equal&quot;, they insist on using low-level primitives with pointer arithmetic and buffer manipulation. This is the same mindset that led to the recent &quot;pkexec&quot; vulnerability.<br> <p> This way of parsing and handling strings should be unacceptable in a culture that values security. Please use (create) a proper C library of high-level string manipulation functions, no shortcuts!<br> <p> <font class="QuotedText">&gt; CVE-2021-3996: Unauthorized unmount in util-linux&#x27;s libmount</font><br> <p> <font class="QuotedText">&gt; when parsing /proc/self/mountinfo, the libmount blindly</font><br> <font class="QuotedText">&gt; removes any &quot; (deleted)&quot; suffix from the mountpoint pathnames</font><br> <p> <font class="QuotedText">&gt; For example, on Fedora, /tmp is a tmpfs, so we can mount a basic FUSE</font><br> <font class="QuotedText">&gt; filesystem named &quot;/tmp/ (deleted)&quot; (with FUSE&#x27;s &quot;hello world&quot; program,</font><br> <font class="QuotedText">&gt; ./hello) and unmount /tmp itself (a denial of service)</font><br> <p> Hilarious. This, again, is a culture problem. We should be migrating to proper serialization formats when communicating complex data structures to between kernel and userland, instead of this stringly typed complex to parse hodgepodge that is &quot;mountinfo&quot;.<br> <p> The &quot;deleted&quot; flag should be a boolean or flags field, not part of the path name string.<br> <p> <font class="QuotedText">&gt; CVE-2021-3997: Uncontrolled recursion in systemd&#x27;s systemd-tmpfiles</font><br> <p> <font class="QuotedText">&gt; if we create thousands</font><br> <font class="QuotedText">&gt; of nested directories in /tmp, then &quot;systemd-tmpfiles --remove&quot; (when</font><br> <font class="QuotedText">&gt; executed as root at boot time) will call its rm_rf_children() function</font><br> <font class="QuotedText">&gt; recursively (on each nested directory) and will exhaust its stack and crash</font><br> <p> <font class="QuotedText">&gt; - for example, on Ubuntu 21.04, systemd-tmpfiles fails to create the</font><br> <font class="QuotedText">&gt; directory /run/lock/subsys; but because /run/lock is world-writable,</font><br> <font class="QuotedText">&gt; attackers can create their own /run/lock/subsys; and because various</font><br> <font class="QuotedText">&gt; legacy packages and daemons write into /run/lock/subsys as root, the</font><br> <font class="QuotedText">&gt; attackers may create arbitrary files via symlinks in /run/lock/subsys.</font><br> <p> Mind=blown. One would expect the crash of a startup service to &quot;fail safe&quot; and possibly disable part of the system. But the auditors managed to turn it into a privilege escalation vulnerability.<br> <p> Not sure where to put the blame, I could see myself making this mistake just as well.<br> <p> </div> Fri, 18 Feb 2022 15:35:58 +0000 Local root vulnerability in snap-confine https://lwn.net/Articles/885275/ https://lwn.net/Articles/885275/ Wol <div class="FormattedComment"> Yup. Don&#x27;t snapshot your symlinks per process, but make it so the first access caches it - REMEMBERING THE INODE - and any further attempts to access the symlink get the same inode until the cache is actively flushed.<br> <p> Cheers,<br> Wol<br> </div> Fri, 18 Feb 2022 14:57:57 +0000 Local root vulnerability in snap-confine https://lwn.net/Articles/885266/ https://lwn.net/Articles/885266/ epa <div class="FormattedComment"> One of the vulnerabilities, CVE-2021-44731, is a symlink attack.<br> </div> Fri, 18 Feb 2022 12:49:16 +0000 Local root vulnerability in snap-confine https://lwn.net/Articles/885265/ https://lwn.net/Articles/885265/ epa <div class="FormattedComment"> Maybe if a symbolic link has appeared or changed since you last called refresh(), then path lookup operations traversing that link would fail with EREFRESH. This would be fail-safe for older code, and newer code might be able to handle it sanely (it certainly sounds easier than meticulously rewriting all your code with the &#x27;at&#x27; system calls). At worst, you just have to restart your daemon. Again, symlinks don&#x27;t change often in practice so this doesn&#x27;t seem too high a price.<br> <p> It would have to be based on real world time, not just whatever mtime is in the file system. A fully snapshottable filesystem would be impossible to graft on to current POSIX semantics, but if we&#x27;re just making a sticking plaster for race conditions with symlinks, some kind of per-process view of the world seems possible. You&#x27;re not trying to snapshot exactly what symlinks existed at a point of time, but only to note whether one has changed in any way, and if so fail when it&#x27;s used.<br> </div> Fri, 18 Feb 2022 12:46:45 +0000 Local root vulnerability in snap-confine https://lwn.net/Articles/885261/ https://lwn.net/Articles/885261/ mathstuf <div class="FormattedComment"> That is a lot of state that needs to be tracked. It also raises the question of &quot;how do I debug this path (name) not resolving in this daemon&quot; with fun &quot;oh, it hasn&#x27;t updated its symlink view&quot; kinds of answers.<br> <p> Other questions that come to mind:<br> <p> - Should symlinks in mounts that show up after the process starts count?<br> - How would this work with something like AndrewFS where finding all symlinks sounds like an absolute nightmare?<br> - Can this be namespaced (i.e., &quot;update symlink perms under `/etc/systemd/system`&quot; for systemd)?<br> - Now the kernel is subject to symlink races that hide themselves in process-specific state that you can&#x27;t see without a way to debug?<br> - If it is just `mtime`-based or whatever, that is trivially attacker-controlled too, so that doesn&#x27;t sound like it&#x27;s saving anything there.<br> <p> Sure, global mutable state is terrible in practice and a fun source of bugs for everyone, but that&#x27;s what a filesystem *is*, so I don&#x27;t see how snapshotting it makes it any better without a way to launch a process that is pinned to &quot;the symlink view of PID X&quot; for a way to have some sanity in multi-process systems or debugging scenarios.<br> </div> Fri, 18 Feb 2022 11:51:00 +0000 Local root vulnerability in snap-confine https://lwn.net/Articles/885262/ https://lwn.net/Articles/885262/ auerswal <div class="FormattedComment"> <font class="QuotedText">&gt; Oh look, *ANOTHER* symlink vulnerability.</font><br> <p> Please read the report, there are no symlink vulnerabilities mentioned at all.<br> </div> Fri, 18 Feb 2022 11:48:36 +0000 Local root vulnerability in snap-confine https://lwn.net/Articles/885244/ https://lwn.net/Articles/885244/ epa Would it be fair to say that most of these security holes are not caused by symlinks alone, but by <i>race conditions with symlinks</i>? <p> The legitimate uses of symlinks are mostly static -- a shared library linked to a different name, an old user who no longer exists. They don't change much. Can we somehow restrict the times at which symbolic links can be created or changed? Perhaps a process should only be able to see the symlinks that existed when that process started, unless it calls a refresh_symlinks() system call. That would avoid path traversal race conditions while still letting us have the uses of symlinks we've come to depend on. Fri, 18 Feb 2022 08:59:02 +0000