--
--
Chromium OS Developers mailing list: chromiu...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-os-dev?hl=en
---
You received this message because you are subscribed to the Google Groups "Chromium OS dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-os-dev+unsubscribe@chromium.org.
| ||
yes, breaking shell script execution out of ~/Downloads/ is expected and what we want. we've seen exploits use this vector specifically. on non-test images, execution of code in /tmp will also break. both are mounted noexec.with chroots on removable media, i don't think the shell part is new. if you're attempting to chroot & execute code in there (like a shell or any other program), if it was mounted noexec, those would fail.
the bug referenced inadvertent execution that came up during code review in comment #0, and referenced `sh xxx.sh` in comment #1. it also came up again in a recent bug chain (crbug.com/766253).
we could make the behavior dependent upon "am i in verified mode", but we don't usually throw dev-mode users under the bus. it will also mean we can't verify any of this behavior in the CQ/release trybots because all the DUTs are running in dev mode. so any breakage won't show up until we actually ship the release to users.
On Mon, Nov 6, 2017 at 2:28 PM, Mike Frysinger <vap...@chromium.org> wrote:yes, breaking shell script execution out of ~/Downloads/ is expected and what we want. we've seen exploits use this vector specifically. on non-test images, execution of code in /tmp will also break. both are mounted noexec.with chroots on removable media, i don't think the shell part is new. if you're attempting to chroot & execute code in there (like a shell or any other program), if it was mounted noexec, those would fail.Please look carefully at the commands I typed. For removable media, enter-chroot is run via "sh /media/removable/.../enter-chroot", which works today regardless of noexec and will be broken by this change. The only direct-exec stuff in crouton is /usr/local/bin/*-chroot.
the bug referenced inadvertent execution that came up during code review in comment #0, and referenced `sh xxx.sh` in comment #1. it also came up again in a recent bug chain (crbug.com/766253).The bug referenced the inadvertent execution via "source" or ., but only mentioned explicit execs of "sh" as another way to bypass noexec, and not in a reference to actual exploits.
I do not have access to 766253, so perhaps that proves without a doubt "sh /a/b/c" is dangerous. From what I *can* see, we have a clear and fairly common misuse of source (or . ) for pulling in stateful configuration that needs protection in depth against. Explicitly calling "sh" to execute a shell script is highlighted as another way of executing scripts, but it is not (in the bugs I have access to) shown to be an exploitable error in the scripts on our roofts, and I have a hard time seeing it being used in such a way.
Since I doubt everyone on this list will get access to 766253, could you please explain the usage style of explicitly calling sh that is dangerous?
On Mon, Nov 6, 2017 at 5:48 PM, David Schneider <dnsc...@chromium.org> wrote:On Mon, Nov 6, 2017 at 2:28 PM, Mike Frysinger <vap...@chromium.org> wrote:yes, breaking shell script execution out of ~/Downloads/ is expected and what we want. we've seen exploits use this vector specifically. on non-test images, execution of code in /tmp will also break. both are mounted noexec.with chroots on removable media, i don't think the shell part is new. if you're attempting to chroot & execute code in there (like a shell or any other program), if it was mounted noexec, those would fail.Please look carefully at the commands I typed. For removable media, enter-chroot is run via "sh /media/removable/.../enter-chroot", which works today regardless of noexec and will be broken by this change. The only direct-exec stuff in crouton is /usr/local/bin/*-chroot.i'm aware of what you typed -- that doesn't change my response which itself included qualifications.if you're implying that the unpacked chroot lives on the removable media, then as i said, the shell part is irrelevant -- you already need to have that device mounted "exec". if it wasn't, then the ELF files living in that chroot fail to run today.
if the chroot isn't in the removable media, then what's the point of putting scripts like "enter-chroot" in there if it's going to turn around and `chroot` into paths in /usr/local ?the bug referenced inadvertent execution that came up during code review in comment #0, and referenced `sh xxx.sh` in comment #1. it also came up again in a recent bug chain (crbug.com/766253).The bug referenced the inadvertent execution via "source" or ., but only mentioned explicit execs of "sh" as another way to bypass noexec, and not in a reference to actual exploits.you're ignoring comment #1 which i referenced already. if you search for "geohot pwnium bug" you'll find open exploit chains that involved running `sh xxx.sh`.
I do not have access to 766253, so perhaps that proves without a doubt "sh /a/b/c" is dangerous. From what I *can* see, we have a clear and fairly common misuse of source (or . ) for pulling in stateful configuration that needs protection in depth against. Explicitly calling "sh" to execute a shell script is highlighted as another way of executing scripts, but it is not (in the bugs I have access to) shown to be an exploitable error in the scripts on our roofts, and I have a hard time seeing it being used in such a way.flip it around: there is no valid use case for running `sh foo.sh` when foo.sh lives on a noexec point. since we have multiple examples of exploit writers using this, and we can safely kill it off, we might as well. crouton abusing that function is not critical to crouton continuing to work (ignoring intermediate migration pain).
as i mentioned in the original post, we know this doesn't fix all possible methods for running shell code, and exploit writers will move on to other methods. our plan is to keep chipping away and remove features that are not necessary so that at some point we can close this off entirely. that's the standard security dance: attackers find a method, defenders close it off, and attackers move on to the next. we don't look at the system and say "well you could do this other thing that's almost as easy, so let's not bother fixing that bug until we can make everything bullet proof".
On Mon, Nov 6, 2017 at 3:14 PM, Mike Frysinger <vap...@chromium.org> wrote:On Mon, Nov 6, 2017 at 5:48 PM, David Schneider <dnsc...@chromium.org> wrote:On Mon, Nov 6, 2017 at 2:28 PM, Mike Frysinger <vap...@chromium.org> wrote:yes, breaking shell script execution out of ~/Downloads/ is expected and what we want. we've seen exploits use this vector specifically. on non-test images, execution of code in /tmp will also break. both are mounted noexec.with chroots on removable media, i don't think the shell part is new. if you're attempting to chroot & execute code in there (like a shell or any other program), if it was mounted noexec, those would fail.Please look carefully at the commands I typed. For removable media, enter-chroot is run via "sh /media/removable/.../enter-chroot", which works today regardless of noexec and will be broken by this change. The only direct-exec stuff in crouton is /usr/local/bin/*-chroot.i'm aware of what you typed -- that doesn't change my response which itself included qualifications.if you're implying that the unpacked chroot lives on the removable media, then as i said, the shell part is irrelevant -- you already need to have that device mounted "exec". if it wasn't, then the ELF files living in that chroot fail to run today.enter-chroot sh-runs mount-chroot, which will create an exec-able bind mount (or ecryptfs mount if the chroot is encrypted) in a shadow tree in /var.Summarized:1. User runs "sudo sh /mount/removable/.../bin/enter-chroot" [canonical, and broken]2. which itself runs "sh /mount/removable/.../bin/mount-chroot" [broken, but can be worked around in an update]3. which bind-mounts (with exec) or encryptfs-mounts (also with exec) to a shadow tree in /var4. after which everything that is +x'd in the chroot is executable. [not broken]
if the chroot isn't in the removable media, then what's the point of putting scripts like "enter-chroot" in there if it's going to turn around and `chroot` into paths in /usr/local ?the bug referenced inadvertent execution that came up during code review in comment #0, and referenced `sh xxx.sh` in comment #1. it also came up again in a recent bug chain (crbug.com/766253).The bug referenced the inadvertent execution via "source" or ., but only mentioned explicit execs of "sh" as another way to bypass noexec, and not in a reference to actual exploits.you're ignoring comment #1 which i referenced already. if you search for "geohot pwnium bug" you'll find open exploit chains that involved running `sh xxx.sh`.It also involves running tar, and base64, and a few other commands before ultimately executing the extracted shell script via sh. I'm not going to pretend I can fully understand the code, but is it actually an integral part of the exploit, or just a convenience that can easily be done without? [you comment on this below; continuing there...]
I do not have access to 766253, so perhaps that proves without a doubt "sh /a/b/c" is dangerous. From what I *can* see, we have a clear and fairly common misuse of source (or . ) for pulling in stateful configuration that needs protection in depth against. Explicitly calling "sh" to execute a shell script is highlighted as another way of executing scripts, but it is not (in the bugs I have access to) shown to be an exploitable error in the scripts on our roofts, and I have a hard time seeing it being used in such a way.flip it around: there is no valid use case for running `sh foo.sh` when foo.sh lives on a noexec point. since we have multiple examples of exploit writers using this, and we can safely kill it off, we might as well. crouton abusing that function is not critical to crouton continuing to work (ignoring intermediate migration pain).That is an argument for removing a lot of the conveniences we provide for users of dev mode.
Yes, the instructions on all of the abandoned (but popular) blog posts for crouton will probably change from:1. Click link to download crouton2. sudo sh ~/Downloads/croutonto:1. Click link to download crouton2. sudo install crouton /usr/local/bin/3. sudo crouton
which isn't terrible. And if you're ignoring the intermediate migration pain, then yes, we can keep hacking around things so crouton works. Unfortunately, many popular blog posts are *still* telling people to VT switch into chroots, so the odds of ever getting past the migration pain are slim to nil.as i mentioned in the original post, we know this doesn't fix all possible methods for running shell code, and exploit writers will move on to other methods. our plan is to keep chipping away and remove features that are not necessary so that at some point we can close this off entirely. that's the standard security dance: attackers find a method, defenders close it off, and attackers move on to the next. we don't look at the system and say "well you could do this other thing that's almost as easy, so let's not bother fixing that bug until we can make everything bullet proof".Sure, but there's a difference between an exploitable hole and something that just provides short-hand convenience once access has already been gained.source /to/noexec is an exploitable hole.As far as I can tell from the geohot exploit, sh /to/noexec is a short-hand used after the system is already wide open.
--
cros-payloads.conf will break, so we'll have to adjust that. that is only part of a test image right ? it could copy the scripts to a dir in /tmp first and execute it from there (since on test images, /tmp will be exec).
in factory_install.sh, looks like all of its scripts run via `mktemp -d` which should create a dir in /tmp. is this run as part of a test image ? or is this in a factory install shim ? for test image, /tmp is exec. for initramfs projects, iirc, /tmp is just a dir on / which is a tmpfs already mounted as exec.
2017-11-07 22:38 GMT+08:00 Mike Frysinger <vap...@chromium.org>:cros-payloads.conf will break, so we'll have to adjust that. that is only part of a test image right ? it could copy the scripts to a dir in /tmp first and execute it from there (since on test images, /tmp will be exec).We were trying to prevent an extra copy because the payloads there may be pretty huge, for example an compressed rootfs.Will it help if we do "mount -o exec,remount /mnt/stateful_partition" in cros_payloads.conf?
in factory_install.sh, looks like all of its scripts run via `mktemp -d` which should create a dir in /tmp. is this run as part of a test image ? or is this in a factory install shim ? for test image, /tmp is exec. for initramfs projects, iirc, /tmp is just a dir on / which is a tmpfs already mounted as exec.That is executed in factory_shim - initramfs after switch_root.switch_root will invoke /sbin/init, which may do the mounting of /tmp again with noexec I think?