New issue
Advanced search Search tips

Issue 867356 link

Starred by 2 users

Issue metadata

Status: Fixed
Owner:
Closed: Aug 26
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Chrome
Pri: 2
Type: Bug-Security



Sign in to add a comment

Security: Chrome OS: filesystem restrictions bypass using crosvm sshfs

Project Member Reported by jannh@google.com, Jul 25

Issue description

Tested on Version 69.0.3473.0 (Official Build) dev (64-bit)

A local user with the ability to use crosvm can get access to the whole filesystem with chronos privileges as follows:

1. Open a shell in the VM by starting "Terminal".
2. In the VM, run "mkdir -p rootdir/home/x".
3. On the host, open "Files", navigate to "Linux Files", go into "rootdir/home/x".
4. In the VM, run "mv rootdir rootdir_; ln -s / rootdir".
5. On the host, click on "home" in the directory hierarchy on the left side of the screen.
6. You now have read+write access to everything in /home (as long as chronos has access).
 
Cc: -mnissler@chromium.org mortonm@chromium.org benchan@chromium.org
Components: Platform>Apps>FileManager
Labels: Security_Impact-Stable Security_Severity-Low Pri-2
Owner: satorux@chromium.org
Thanks for the report.

While access to arbitrary chronos-owned files is certainly not intentional, it doesn't cross a security boundary. We still tried to fix these cases in the past, since this is a useful mechanism to access otherwise inaccessible state on disk when constructing exploit chains. See  issue 677817  for a recent similar example.

I think the immediate action here should be to make File Manager be more careful when handling paths such that it doesn't traverse symlinks accidentally.

Assigning to satorux@ to route to the file manager folks.

As a more fundamental measure, we should investigate what we can do to lock down dangerous file system features on user-supplied file systems. I've filed issue 867807 to track that.
Project Member

Comment 2 by sheriffbot@chromium.org, Jul 26

Status: Assigned (was: Unconfirmed)
Cc: slangley@chromium.org
Owner: joelhockey@chromium.org
mnissler@, Files app is now led by slangley@. IIRC, Linux Files support was done by joelhockey@
Cc: dats@chromium.org
I'll look at this early next week with the aim to disallow traversing symlinks.
Owner: dats@chromium.org
dats@, I think that this is fixed if sshfs uses follow_symlinks option.  It looks like you might have already meant to include that option at https://chromium.googlesource.com/chromiumos/platform2/+/master/cros-disks/sshfs_helper.cc#37
@joelhockey: I don't think that's going to work. Here's what sshfs actually looks like: https://github.com/libfuse/sshfs/blob/master/sshfs.c

Look at sshfs_getattr():

```
static int sshfs_getattr(const char *path, struct stat *stbuf,
			 struct fuse_file_info *fi)
{
	int err;
	struct buffer buf;
	struct buffer outbuf;
	struct sshfs_file *sf = NULL;

	if (fi != NULL && !sshfs.fstat_workaround) {
		sf = get_sshfs_file(fi);
		if (!sshfs_file_is_conn(sf))
			return -EIO;
	}
	

	buf_init(&buf, 0);
	if(sf == NULL) {
		buf_add_path(&buf, path);
		err = sftp_request(sshfs.follow_symlinks ? SSH_FXP_STAT : SSH_FXP_LSTAT,
				   &buf, SSH_FXP_ATTRS, &outbuf);
	}
	else {
		buf_add_buf(&buf, &sf->handle);
		err = sftp_request(SSH_FXP_FSTAT, &buf, SSH_FXP_ATTRS, &outbuf);
	}		
	if (!err) {
		err = buf_get_attrs(&outbuf, stbuf, NULL);
#ifdef __APPLE__
		stbuf->st_blksize = 0;
#endif
		buf_free(&outbuf);
	}
	buf_free(&buf);
	return err;
}
```

As far as I can tell, the follow_symlinks option only influences what commands are sent to sftp-server, not how the data coming back is interpreted; therefore, a malicious guest should still be able to present symlinks to you, even if you can't see them when the guest is playing nice.
Cc: joelhockey@chromium.org
Owner: joelhockey@chromium.org
Adding follow_symlinks did fix this particular issue and I think is worth setting since it is likely what users would expect for how FilesApp handles symlinks in the container.

But I agree that it is still worth guarding FilesApp to not traverse symlinks.  I've created https://chromium-review.googlesource.com/c/chromiumos/platform2/+/1152344 for follow_symlinks, and I'll look at FilesApp more.


As Jann mentions, setting follow_symlinks will only mitigate if the sshfs implementation does indeed reject symlinks received from the remote in case follow_symlinks is set. However, the sshfs implementation allows the remote side to set any file type it likes (buf_get_attrs), so follow_symlinks makes symlinks disappear with well-behaved servers, but doesn't fix the security issue.

At the very least, you'd have to patch sshfs to never report symlinks to FUSE if follow_symlinks is set. And this is still suboptimal in the light that an attacker who manages to exploit the sshfs process from a malicious ssh server,  can still inject symlinks into FUSE.

Thus, a robust fix would be to either have the kernel block symlink traversal or prevent symlinks from causing harm by isolating sshfs in a mount namespace that doesn't contain anything sensitive. Issue 867807 is meant to track these improvements.
Cc: smbar...@chromium.org dgreid@chromium.org
Project Member

Comment 12 by bugdroid1@chromium.org, Aug 1

The following revision refers to this bug:
  https://chromium.googlesource.com/chromiumos/platform2/+/1a00fefd737bcfca71e5a19a00da6fb1fd8eb9fc

commit 1a00fefd737bcfca71e5a19a00da6fb1fd8eb9fc
Author: Joel Hockey <joelhockey@chromium.org>
Date: Wed Aug 01 03:35:35 2018

cros-disks: Include follow_symlinks option for sshfs

Any symlinks in the container must be followed as
paths in the container rather than interpreted as
paths in the host.

BUG= chromium:867356 
TEST=Manually verified this fixes bug, updated unittest.

Change-Id: Id7aeae6f449573443f9029bce5d7163b726b84d1
Reviewed-on: https://chromium-review.googlesource.com/1152344
Commit-Ready: Joel Hockey <joelhockey@chromium.org>
Tested-by: Joel Hockey <joelhockey@chromium.org>
Reviewed-by: Mattias Nissler <mnissler@chromium.org>
Reviewed-by: Ben Chan <benchan@chromium.org>
Reviewed-by: Mike Frysinger <vapier@chromium.org>

[modify] https://crrev.com/1a00fefd737bcfca71e5a19a00da6fb1fd8eb9fc/cros-disks/sshfs_helper.cc
[modify] https://crrev.com/1a00fefd737bcfca71e5a19a00da6fb1fd8eb9fc/cros-disks/sshfs_helper_unittest.cc

Cc: weifangsun@chromium.org
Quick check - Should this fix be merged to M69? Would like to reflect the proper milestone target for tracking. Thanks!
Labels: M-69
yes, lets get this in to 69. Thanks!
Labels: Merge-Request-69
Project Member

Comment 17 by sheriffbot@chromium.org, Aug 8

Labels: -Merge-Request-69 Merge-Review-69 Hotlist-Merge-Review
This bug requires manual review: M69 has already been promoted to the beta branch, so this requires manual review
Please contact the milestone owner if you have questions.
Owners: amineer@(Android), kariahda@(iOS), cindyb@(ChromeOS), govind@(Desktop)

For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
Project Member

Comment 18 by sheriffbot@chromium.org, Aug 9

Status: Fixed (was: Assigned)
Please mark security bugs as fixed as soon as the fix lands, and before requesting merges. This update is based on the merge- labels applied to this issue. Please reopen if this update was incorrect.

For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
Labels: -Merge-Review-69 Merge-Approved-69
Merge approved, M69.
Project Member

Comment 20 by bugdroid1@chromium.org, Aug 9

Labels: merge-merged-release-R69-10895.B
The following revision refers to this bug:
  https://chromium.googlesource.com/chromiumos/platform2/+/8b494b4248db30002f4a3877cb7b818bf4b8a0de

commit 8b494b4248db30002f4a3877cb7b818bf4b8a0de
Author: Joel Hockey <joelhockey@chromium.org>
Date: Thu Aug 09 21:53:23 2018

cros-disks: Include follow_symlinks option for sshfs

Any symlinks in the container must be followed as
paths in the container rather than interpreted as
paths in the host.

BUG= chromium:867356 
TEST=Manually verified this fixes bug, updated unittest.

Change-Id: Id7aeae6f449573443f9029bce5d7163b726b84d1
Reviewed-on: https://chromium-review.googlesource.com/1152344
Commit-Ready: Joel Hockey <joelhockey@chromium.org>
Tested-by: Joel Hockey <joelhockey@chromium.org>
Reviewed-by: Mattias Nissler <mnissler@chromium.org>
Reviewed-by: Ben Chan <benchan@chromium.org>
Reviewed-by: Mike Frysinger <vapier@chromium.org>
(cherry picked from commit 1a00fefd737bcfca71e5a19a00da6fb1fd8eb9fc)
Reviewed-on: https://chromium-review.googlesource.com/1170062
Commit-Queue: Joel Hockey <joelhockey@chromium.org>

[modify] https://crrev.com/8b494b4248db30002f4a3877cb7b818bf4b8a0de/cros-disks/sshfs_helper.cc
[modify] https://crrev.com/8b494b4248db30002f4a3877cb7b818bf4b8a0de/cros-disks/sshfs_helper_unittest.cc

Project Member

Comment 21 by sheriffbot@chromium.org, Aug 10

Labels: -Restrict-View-SecurityTeam Restrict-View-SecurityNotify
Project Member

Comment 22 by sheriffbot@chromium.org, Aug 13

Cc: cindyb@chromium.org
This issue has been approved for a merge. Please merge the fix to any appropriate branches as soon as possible!

If all merges have been completed, please remove any remaining Merge-Approved labels from this issue.

Thanks for your time! To disable nags, add the Disable-Nags label.

For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
Labels: -Merge-Approved-69
Status: Assigned (was: Fixed)
Should this be marked fixed?
Status: Fixed (was: Assigned)
Closed as fixed.

As per #c10, my understanding is that other required fixes are being tracked in separate bugs.

mnissler@, others,
Reopen if you feel like this bug still needs to track further changes in FilesApp code, or perhaps reassign if work is required elsewhere.
Project Member

Comment 27 by sheriffbot@chromium.org, Dec 3

Labels: -Restrict-View-SecurityNotify allpublic
This bug has been closed for more than 14 weeks. Removing security view restrictions.

For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot

Sign in to add a comment