Android Nougat 中的文件系统更改
File system changes in Android Nougat
自从 Android N 开发者预览版首次发布以来,我在尝试列出根目录或其他系统目录时遇到 "permission denied" 错误。这些目录的权限似乎没有改变(据我所知)。
问题:
Android N 中的哪些更改导致这些权限被拒绝错误?
如何复制:
在 ADB shell、运行 中执行以下命令:
run-as com.debuggable.packagename
ls /
这会导致 Android N 出现权限被拒绝的错误。
为什么列出系统目录:
我在 Android N 上发现了几个文件管理器的这种行为。他们无法再列出根目录或其他系统文件。这也限制了 运行ning ps
在 shell 中的输出。这些更改还导致此 library 停止在 Android N.
上工作
这是为 security and privacy reasons 完成的。来自错误报告:
In the case of the root (/) and /sys filesystems, a directory listing is not possible.
来自Google的官方回答:
The behavior you're describing is working as intended. Android provides strict sandboxes that applications must run in. These sandboxes protect application data from other applications, including application metadata such as process state.
/sys and /proc are well known for leaking side channel information about processes, information which can be used to infer state about the processes. For instance, it's been documented for years that /proc access can be used to monitor for app launching, enabling phishing attacks.
有两组更改减少了对 /proc 的访问。
procfs 文件系统现在挂载了 hidepid=2,消除了其他用户对 /proc/PID 目录的访问。此更改在 CopperheadOS 中实现,然后基于它被上游采用。有一个例外组,但它没有作为权限公开。它仅用于对基础系统中的某些进程进行例外处理。它可以作为 'dangerous' 权限公开,这是我预期 Google 最终会做的,但他们认为用户不会理解它的含义。
https://android-review.googlesource.com/#/c/181345/
SELinux 政策也变得更加严格。对于应用程序,根本没有对 /proc 的基线访问权限,尽管这仅适用于 /proc/PID 目录以外的文件。仍然可以访问一些标签不属于一般 proc 策略的文件,但大部分都消失了。这是渐进的,并且有许多相关的提交。大佬之一:
https://android-review.googlesource.com/#/c/105337/
这不仅删除了许多明显的信息,而且还关闭了一些更明显的安全漏洞,这些漏洞涉及允许记录键盘输入的侧通道:
- https://www.lightbluetouchpaper.org/2016/07/29/yet-another-android-side-channel/
- https://staff.ie.cuhk.edu.hk/~khzhang/my-papers/2016-oakland-interrupt.pdf
随着时间的推移,SELinux 政策总体上也变得更加严格。您可以在 platform/system/sepolicy repository. Note that it was at platform/external/sepolicy 中看到其余的很长一段时间,但它最近被移动了。
自从 Android N 开发者预览版首次发布以来,我在尝试列出根目录或其他系统目录时遇到 "permission denied" 错误。这些目录的权限似乎没有改变(据我所知)。
问题:
Android N 中的哪些更改导致这些权限被拒绝错误?
如何复制:
在 ADB shell、运行 中执行以下命令:
run-as com.debuggable.packagename
ls /
这会导致 Android N 出现权限被拒绝的错误。
为什么列出系统目录:
我在 Android N 上发现了几个文件管理器的这种行为。他们无法再列出根目录或其他系统文件。这也限制了 运行ning ps
在 shell 中的输出。这些更改还导致此 library 停止在 Android N.
这是为 security and privacy reasons 完成的。来自错误报告:
In the case of the root (/) and /sys filesystems, a directory listing is not possible.
来自Google的官方回答:
The behavior you're describing is working as intended. Android provides strict sandboxes that applications must run in. These sandboxes protect application data from other applications, including application metadata such as process state.
/sys and /proc are well known for leaking side channel information about processes, information which can be used to infer state about the processes. For instance, it's been documented for years that /proc access can be used to monitor for app launching, enabling phishing attacks.
有两组更改减少了对 /proc 的访问。
procfs 文件系统现在挂载了 hidepid=2,消除了其他用户对 /proc/PID 目录的访问。此更改在 CopperheadOS 中实现,然后基于它被上游采用。有一个例外组,但它没有作为权限公开。它仅用于对基础系统中的某些进程进行例外处理。它可以作为 'dangerous' 权限公开,这是我预期 Google 最终会做的,但他们认为用户不会理解它的含义。
https://android-review.googlesource.com/#/c/181345/
SELinux 政策也变得更加严格。对于应用程序,根本没有对 /proc 的基线访问权限,尽管这仅适用于 /proc/PID 目录以外的文件。仍然可以访问一些标签不属于一般 proc 策略的文件,但大部分都消失了。这是渐进的,并且有许多相关的提交。大佬之一:
https://android-review.googlesource.com/#/c/105337/
这不仅删除了许多明显的信息,而且还关闭了一些更明显的安全漏洞,这些漏洞涉及允许记录键盘输入的侧通道:
- https://www.lightbluetouchpaper.org/2016/07/29/yet-another-android-side-channel/
- https://staff.ie.cuhk.edu.hk/~khzhang/my-papers/2016-oakland-interrupt.pdf
随着时间的推移,SELinux 政策总体上也变得更加严格。您可以在 platform/system/sepolicy repository. Note that it was at platform/external/sepolicy 中看到其余的很长一段时间,但它最近被移动了。