安全增强功能

Android 一直在不断改进其安全功能和产品/服务。您可以在左侧导航栏中查看各个版本的增强功能列表。

Android 14

每个 Android 版本中都包含数十种安全增强功能,以保护用户。以下是 Android 14 中提供的一些主要安全增强功能:

  • Android 10 中引入的硬件辅助 AddressSanitizer (HWASan) 是一款类似于 AddressSanitizer 的内存错误检测工具。Android 14 对 HWASan 进行了重大改进。如需了解它如何帮助防止 bug 进入 Android 版本,请访问 HWAddressSanitizer
  • 在 Android 14 中,从与第三方共享位置数据的应用开始,系统运行时权限对话框现在包含一个可点击的部分,用于突出显示应用的数据分享做法,包括诸如以下信息:应用为什么可能会决定与第三方分享数据。
  • Android 12 引入了在调制解调器级别停用 2G 支持的选项,以保护用户免受 2G 的过时安全模型固有的安全风险的影响。认识到停用 2G 对企业客户的重要性后,Android 14 在 Android Enterprise 中启用了此安全功能,以便 IT 管理员能够限制受管设备降级到 2G 连接
  • 开始支持拒绝未加密的移动网络连接,确保电路交换语音和短信流量始终会加密,并可防范被动无线拦截。详细了解 Android 的移动网络连接强化计划
  • 新增了对多个 IMEI 的支持
  • 从 Android 14 开始,AES-HCTR2 是采用加速加密指令的设备的首选文件名加密模式。
  • 移动网络连接
  • 在 Android 安全中心添加了相关文档
  • 如果您的应用以 Android 14 为目标平台并使用动态代码加载 (DCL) 功能,则必须将所有动态加载的文件标记为只读。否则,系统会抛出异常。我们建议应用尽可能避免动态加载代码,因为这样做会大大增加应用因代码注入或代码篡改而遭到入侵的风险。

请查看完整的 AOSP 版本说明以及 Android 开发者功能和变更列表

Android 13

Every Android release includes dozens of security enhancements to protect users. Here are some of the major security enhancements available in Android 13:

  • Android 13 adds multi-document presentation support. This new Presentation Session interface enables an app to do a multi-document presentation, something which isn't possible with the existing API. For further information, refer to Identity Credential
  • In Android 13, intents originating from external apps are delivered to an exported component if and only if the intents match their declared intent-filter elements.
  • Open Mobile API (OMAPI) is a standard API used to communicate with a device's Secure Element. Before Android 13, only apps and framework modules had access to this interface. By converting it to a vendor stable interface, HAL modules are also capable of communicating with the secure elements through the OMAPI service. For more information, see OMAPI Vendor Stable Interface.
  • As of Android 13-QPR, shared UIDs are deprecated. Users of Android 13 or higher should put the line `android:sharedUserMaxSdkVersion="32"` in their manifest. This entry prevents new users from getting a shared UID. For further information on UIDs, see App signing.
  • Android 13 added support Keystore symmetric cryptographic primitives such as AES (Advanced Encryption Standard), HMAC (Keyed-Hash Message Authentication Code), and asymmetric cryptographic algorithms (including Elliptic Curve, RSA2048, RSA4096, and Curve 25519)
  • Android 13 (API level 33) and higher supports a runtime permission for sending non-exempt notifications from an app. This gives users control over which permission notifications they see.
  • Added per-use prompt for apps requesting access to all device logs, giving users the ability to allow or deny access.
  • introduced the Android Virtualization Framework (AVF), which brings together different hypervisors under one framework with standardized APIs. It provides secure and private execution environments for executing workloads isolated by hypervisor.
  • Introduced APK signature scheme v3.1 All new key rotations that use apksigner use the v3.1 signature scheme by default to target rotation for Android 13 and higher.

Check out our full AOSP release notes and the Android Developer features and changes list.

Android 12

每个 Android 版本中都包含数十种用于保护用户的安全增强功能。以下是 Android 12 中提供的一些主要安全增强功能:

  • Android 12 引入了 BiometricManager.Strings API,它为使用 BiometricPrompt 进行身份验证的应用提供本地化的字符串。这些字符串旨在感知设备,并更明确地指定可以使用哪种/哪些身份验证类型。Android 12 还支持屏下指纹传感器
  • 添加了对屏下指纹传感器的支持
  • 引入了 Fingerprint Android 接口定义语言 (AIDL)
  • 支持新的 Face AIDL
  • 引入了 Rust 作为平台开发语言
  • 添加了可供用户仅授权应用访问其大致位置信息的选项
  • 当应用使用摄像头或麦克风时,现在状态栏上会显示隐私指示标志
  • Android 的 Private Compute Core (PCC)
  • 添加了用于停用 2G 支持的选项

Android 11

每个 Android 版本中都包含数十项用于保护用户的安全增强功能。如需查看 Android 11 中提供的一些主要安全增强功能的列表,请参阅 Android 版本说明

Android 10

每个 Android 版本中都包含数十项用于保护用户的安全增强功能。Android 10 包含多项安全和隐私增强功能。如需查看 Android 10 中变化的完整列表,请参阅 Android 10 版本说明

安全

BoundsSanitizer

Android 10 在蓝牙和编解码器中部署了 BoundsSanitizer (BoundSan)。BoundSan 使用 UBSan 的边界排错程序。该缓解功能在各个模块级别启用,有助于确保 Android 关键组件的安全性,因此不应停用。以下编解码器启用了 BoundSan:

  • libFLAC
  • libavcdec
  • libavcenc
  • libhevcdec
  • libmpeg2
  • libopus
  • libvpx
  • libspeexresampler
  • libvorbisidec
  • libaac
  • libxaac

只执行内存

默认情况下,AArch64 系统二进制文件的可执行代码部分会被标记为只执行(不可读取),作为应对即时代码重用攻击的安全强化缓解方法。将数据和代码混合在一起的代码以及有目的地检查这些部分的代码(无需首先将内存段重新映射为可读)将不再起作用。如果目标 SDK 为 Android 10(API 级别 29 或更高)的应用尝试读取内存中已启用只执行内存 (XOM) 的系统库的代码部分,而未首先将该部分标记为可读,则此类应用将会受到影响。

延长设备解锁时间

可信代理是 Smart Lock 等三重身份验证机制使用的底层机制,只能在 Android 10 中延长解锁时间。可信代理无法再解锁已锁定的设备,并且最多只能将设备解锁状态维持四个小时。

人脸识别身份验证

借助人脸识别身份验证功能,用户只需将面孔对准设备正面即可将其解锁。Android 10 添加了对一种全新人脸识别身份验证堆栈的支持,该堆栈可安全处理相机帧,从而在支持的硬件上进行人脸识别身份验证时保障安全和隐私。Android 10 还提供了一种快捷的方式来集成符合安全标准的实现方案,让人们能通过集成应用来处理一些事务(如网上银行或其他服务)。

整数溢出排错功能

Android 10 在软件编解码器中启用了整数溢出排错功能 (IntSan)。确保播放性能对于设备硬件中不支持的任何编解码器而言都在接受范围内。 以下编解码器启用了 IntSan:

  • libFLAC
  • libavcdec
  • libavcenc
  • libhevcdec
  • libmpeg2
  • libopus
  • libvpx
  • libspeexresampler
  • libvorbisidec

模块化系统组件

Android 10 采用模块化方式处理一些 Android 系统组件,使其能够在 Android 的常规发布周期外的时间进行更新。下面列举了几种模块:

OEMCrypto

Android 10 使用 OEMCrypto API 版本 15。

Scudo

Scudo 是一个动态的用户模式内存分配器,旨在提高遇到堆相关漏洞时的复原能力。它提供了标准 C 分配和取消分配基元,以及 C++ 基元。

ShadowCallStack

ShadowCallStack (SCS) 是一种 LLVM 插桩模式,可将函数的返回地址保存到非叶函数的函数 prolog 中单独分配的 ShadowCallStack 实例,并从函数 epilog 中的 ShadowCallStack 实例加载返回地址,从而防止返回地址覆盖(比如堆栈缓冲区溢出)。

WPA3 和 Wi-Fi Enhanced Open

Android 10 添加了对 Wi-Fi Protected Access 3 (WPA3) 和 Wi-Fi Enhanced Open 安全标准的支持,可更好地保护隐私,更稳健地防御已知攻击。

隐私权

以 Android 9 或更低版本为目标平台时的应用访问权限

如果您的应用在 Android 10 或更高版本上运行,但其目标平台是 Android 9(API 级别 28)或更低版本,则 Android 平台具有以下行为:

  • 如果您的应用为 ACCESS_FINE_LOCATIONACCESS_COARSE_LOCATION 声明了 <uses-permission> 元素,则系统会在安装期间自动为 ACCESS_BACKGROUND_LOCATION 添加 <uses-permission> 元素。
  • 如果您的应用请求了 ACCESS_FINE_LOCATIONACCESS_COARSE_LOCATION,系统会自动将 ACCESS_BACKGROUND_LOCATION 添加到请求中。

后台 Activity 限制

从 Android 10 开始,系统会增加针对从后台启动 Activity 的限制。此项行为变更有助于最大限度地减少对用户造成的干扰,并且可以让用户更好地控制其屏幕上显示的内容。只要您的应用启动 activity 是因用户互动直接引发的,该应用就极有可能不会受到这些限制的影响。
如需详细了解从后台启动 activity 的建议替代方法,请参阅有关如何在应用中提醒用户注意有时效性的事件的指南。

相机元数据

Android 10 更改了 getCameraCharacteristics() 方法默认返回的信息的广度。具体而言,您的应用必须具有 CAMERA 权限才能访问此方法的返回值中可能包含的设备特定元数据。
如需详细了解这些变更,请参阅关于需要权限的相机字段的部分。

剪贴板数据

对于 Android 10 或更高版本,除非您的应用是默认输入法 (IME) 或是目前聚焦的应用,否则它无法访问剪贴板中的数据。

设备位置信息

为了让用户更好地控制应用对位置信息的访问权限,Android 10 引入了 ACCESS_BACKGROUND_LOCATION 权限。
不同于 ACCESS_FINE_LOCATIONACCESS_COARSE_LOCATION 权限,ACCESS_BACKGROUND_LOCATION 权限仅会影响应用在后台运行时对位置信息的访问权限。除非符合以下条件之一,否则应用将被视为在后台访问位置信息:

外部存储设备

默认情况下,以 Android 10 及更高版本为目标平台的应用在访问外部存储设备中的文件时存在范围限制,即分区存储。此类应用可以查看外部存储设备内以下类型的文件,无需请求任何与存储相关的用户权限:

  • 特定于应用的目录中的文件(使用 getExternalFilesDir() 访问)。
  • 应用创建的照片、视频和音频片段(通过媒体库访问)。

如需详细了解分区存储以及如何共享、访问和修改在外部存储设备上保存的文件,请参阅有关如何管理外部存储设备中的文件以及如何访问和修改媒体文件的指南。

随机分配 MAC 地址

默认情况下,在搭载 Android 10 或更高版本的设备上,系统会传输随机分配的 MAC 地址。
如果您的应用处理企业使用场景,Android 平台会提供 API,用于执行与 MAC 地址相关的几个操作。

  • 获取随机分配的 MAC 地址:设备所有者应用和资料所有者应用可以通过调用 getRandomizedMacAddress() 检索分配给特定网络的随机分配 MAC 地址。
  • 获取实际的出厂 MAC 地址:设备所有者应用可以通过调用 getWifiMacAddress() 检索设备的实际硬件 MAC 地址。此方法对于跟踪设备队列非常有用。

不可重置的设备标识符

从 Android 10 开始,应用必须具有 READ_PRIVILEGED_PHONE_STATE 特许权限才能访问设备的不可重置标识符(包括 IMEI 和序列号)。

如果您的应用没有该权限,但您仍尝试查询不可重置标识符的相关信息,则 Android 平台的响应会因目标 SDK 版本而异:

  • 如果应用以 Android 10 或更高版本为目标平台,则会发生 SecurityException
  • 如果应用以 Android 9(API 级别 28)或更低版本为目标平台,则相应方法会返回 null 或占位符数据(如果应用具有 READ_PHONE_STATE 权限)。否则,会发生 SecurityException

身体活动识别

Android 10 针对需要检测用户步数或对用户的身体活动(例如步行、骑车或坐车)进行分类的应用引入了 android.permission.ACTIVITY_RECOGNITION 运行时权限。此项权限旨在让用户了解设备传感器数据在“设置”中的使用方式。
除非用户已向您的应用授予此权限,否则 Google Play 服务中的一些库(例如 Activity Recognition APIGoogle Fit API)不会提供结果。
设备上要求您声明此权限的内置传感器只有计步器步测器传感器。
如果您的应用以 Android 9(API 级别 28)或更低版本为目标平台,只要您的应用满足以下各项条件,系统会根据需要自动向您的应用授予 android.permission.ACTIVITY_RECOGNITION 权限:

  • 清单文件包含 com.google.android.gms.permission.ACTIVITY_RECOGNITION 权限。
  • 清单文件包含 android.permission.ACTIVITY_RECOGNITION 权限。

如果系统自动授予 android.permission.ACTIVITY_RECOGNITION 权限,当您将应用更新为以 Android 10 为目标平台后,您的应用会保留此权限。但是,用户可以随时在系统设置中撤消此权限。

/proc/net 文件系统限制

在搭载 Android 10 或更高版本的设备上,应用无法访问 /proc/net,包括与设备的网络状态相关的信息。需要访问此信息的应用(如 VPN)应使用 NetworkStatsManagerConnectivityManager 类。

从界面中移除了权限组

从 Android 10 开始,应用无法在界面中查询权限的分组方式

移除了联系人关系密切程度

从 Android 10 开始,平台不再记录联系人的关系密切程度信息。因此,如果您的应用对用户的联系人进行搜索,系统将不会按互动频率对搜索结果排序。
有关 ContactsProvider 的指南包含一项说明特定字段和方法已废弃的声明(从 Android 10 开始,这些字段和方法在所有设备上已作废)。

限制对屏幕内容的访问

为了保护用户的屏幕内容,Android 10 更改了 READ_FRAME_BUFFERCAPTURE_VIDEO_OUTPUTCAPTURE_SECURE_VIDEO_OUTPUT 权限的作用域,从而禁止以静默方式访问设备的屏幕内容。从 Android 10 开始,这些权限只能通过签名访问
需要访问设备屏幕内容的应用应使用 MediaProjection API,此 API 会显示要求用户同意访问的提示。

USB 设备序列号

如果您的应用以 Android 10 或更高版本为目标平台,则该应用只能在用户授予其访问 USB 设备或配件的权限后才能读取序列号。
如需详细了解如何使用 USB 设备,请参阅有关如何配置 USB 主机的指南。

Wi-Fi

以 Android 10 或更高版本为目标平台的应用无法启用或停用 Wi-Fi。WifiManager.setWifiEnabled() 方法始终返回 false
如果您需要提示用户启用或停用 Wi-Fi,请使用设置面板

对直接访问已配置的 Wi-Fi 网络实施了限制

为了保护用户隐私,只有系统应用和设备政策控制者 (DPC) 支持手动配置 Wi-Fi 网络列表。给定 DPC 可以是设备所有者,也可以是资料所有者。
如果应用以 Android 10 或更高版本为目标平台,并且应用不是系统应用或 DPC,则下列方法不会返回有用数据:

Android 9

每个 Android 版本中都包含数十项用于保护用户的安全增强功能。如需 Android 9 中提供的一些主要安全增强功能的列表,请参阅 Android 版本说明

Android 8

Every Android release includes dozens of security enhancements to protect users. Here are some of the major security enhancements available in Android 8.0:

  • Encryption. Added support to evict key in work profile.
  • Verified Boot. Added Android Verified Boot (AVB). Verified Boot codebase supporting rollback protection for use in boot loaders added to AOSP. Recommend bootloader support for rollback protection for the HLOS. Recommend boot loaders can only be unlocked by user physically interacting with the device.
  • Lock screen. Added support for using tamper-resistant hardware to verify lock screen credential.
  • KeyStore. Required key attestation for all devices that ship with Android 8.0+. Added ID attestation support to improve Zero Touch Enrollment.
  • Sandboxing. More tightly sandboxed many components using Project Treble's standard interface between framework and device-specific components. Applied seccomp filtering to all untrusted apps to reduce the kernel's attack surface. WebView is now run in an isolated process with very limited access to the rest of the system.
  • Kernel hardening. Implemented hardened usercopy, PAN emulation, read-only after init, and KASLR.
  • Userspace hardening. Implemented CFI for the media stack. App overlays can no longer cover system-critical windows and users have a way to dismiss them.
  • Streaming OS update. Enabled updates on devices that are are low on disk space.
  • Install unknown apps. Users must grant permission to install apps from a source that isn't a first-party app store.
  • Privacy. Android ID (SSAID) has a different value for each app and each user on the device. For web browser apps, Widevine Client ID returns a different value for each app package name and web origin. net.hostname is now empty and the dhcp client no longer sends a hostname. android.os.Build.SERIAL has been replaced with the Build.SERIAL API which is protected behind a user-controlled permission. Improved MAC address randomization in some chipsets.

Android 7

每个 Android 版本中都包含数十项用于保护用户的安全增强功能。以下是 Android 7.0 中提供的一些主要安全增强功能:

  • 文件级加密:在文件级进行加密,而不是将整个存储区域作为单个单元进行加密。这种加密方式可以更好地隔离和保护设备上的不同用户和资料(例如个人资料和工作资料)。
  • 直接启动:通过文件级加密实现,允许特定应用(例如,闹钟和无障碍功能)在设备已开机但未解锁的情况下运行。
  • 验证启动:现在,验证启动会被严格强制执行,从而使遭到入侵的设备无法启动;验证启动支持纠错功能,有助于更可靠地防范非恶意数据损坏。
  • SELinux。更新后的 SELinux 配置和更高的 Seccomp 覆盖率有助于进一步锁定应用沙盒并减小受攻击面。
  • 库加载顺序随机化和改进的 ASLR。 增大随机性降低了某些代码重用攻击的有效性。
  • 内核加固:通过将内核内存的各个分区标记为只读,限制内核对用户空间地址的访问,并进一步减小现有的受攻击面,为更高版本的内核添加额外的内存保护。
  • APK 签名方案 v2:引入了一种全文件签名方案,该方案有助于加快验证速度并增强完整性保证。
  • 可信 CA 存储区。为了使应用更容易控制对其安全网络流量的访问,对于 API 级别为 24 及以上的应用,由用户安装的证书颁发机构以及通过 Device Admin API 安装的证书颁发机构在默认情况下不再受信任。此外,所有新的 Android 设备必须搭载相同的可信 CA 存储区。
  • 网络安全配置。通过声明式配置文件来配置网络安全设置和传输层安全协议 (TLS)。

Android 6

每个 Android 版本中都包含数十种用于保护用户的安全增强功能。以下是 Android 6.0 中提供的一些主要安全增强功能:

  • 运行时权限:应用在运行时请求权限,而不是在安装时被授予权限。用户可以为 M 及更低版本的 Android 应用启用和停用权限。
  • 验证启动:在执行系统软件之前,先对其进行一系列加密检查,以确保手机从引导加载程序到操作系统均处于正常状况。
  • 硬件隔离安全措施:新的硬件抽象层 (HAL),Fingerprint API、锁定屏幕、设备加密功能和客户端证书可以利用它来保护密钥免遭内核入侵和/或现场攻击。
  • 指纹:现在,只需触摸一下,即可解锁设备。开发者还可以借助新的 API 来使用指纹锁定和解锁加密密钥。
  • 加装 SD 卡:可将移动媒体设备加装到设备上,以便扩展可用存储空间来存放本地应用数据、照片、视频等内容,但仍受块级加密保护。
  • 明文流量:开发者可以使用新的 StrictMode 来确保其应用不会使用明文。
  • 系统加固:通过由 SELinux 强制执行的政策对系统进行加固。这可以实现更好的用户隔离和 IOCTL 过滤、降低可从设备/系统之外访问的服务面临的威胁、进一步强化 SELinux 域,以及高度限制对 /proc 的访问。
  • USB 访问控制:必须由用户确认是否允许通过 USB 访问手机上的文件、存储空间或其他功能。现在,默认设置是“仅充电”,如果要访问存储空间,必须获得用户的明确许可。

Android 5

5.0

每个 Android 版本中都包含数十种用于保护用户的安全增强功能。以下是 Android 5.0 中提供的一些主要安全增强功能:

  • 默认加密。在以开箱即用的方式搭载 L 的设备上,会默认启用全盘加密功能,以便更好地保护丢失设备或被盗设备上的数据。对于更新到 L 的设备,可以在设置 > 安全性部分进行加密。
  • 经过改进的全盘加密功能。使用 scrypt 保护用户密码免遭暴力破解攻击;在可能的情况下,该密钥会绑定到硬件密钥库,以防范来自设备外的攻击。和以往一样,Android 屏幕锁定密钥和设备加密密钥不会被发送到设备以外,也不会提供给任何应用。
  • 通过 SELinux 得到增强的 Android 沙盒。对于所有域,Android 现在都要求 SELinux 处于强制模式。SELinux 是 Linux 内核中的强制访问控制 (MAC) 系统,用于增强现有的自主访问控制 (DAC) 安全模型。这个新的安全层为防范潜在的安全漏洞提供了额外的保护屏障。
  • Smart Lock。Android 现在包含一些 Trustlet,它们可以提供更灵活的设备解锁方式。例如,Trustlet 可让设备在靠近其他可信设备(通过 NFC、蓝牙)时或用户拥有可信面孔时自动解锁。
  • 面向手机和平板电脑的多用户功能、受限个人资料和访客模式。Android 现在为手机提供了多用户功能,并包含一个访客模式。利用访客模式,您可以让访客轻松地临时使用您的设备,而不向他们授予对您的数据和应用的访问权限。
  • 不使用 OTA 的 WebView 更新方式。现在可以独立于框架对 WebView 进行更新,而且无需采用系统 OTA 方式。这有助于更快速地应对 WebView 中的潜在安全问题。
  • 经过更新的 HTTPS 和 TLS/SSL 加密功能。现在启用了 TLSv1.2 和 TLSv1.1,首选是正向加密,启用了 AES-GCM,停用了弱加密套件(MD5、3DES 和导出密码套件)。如需了解详情,请访问 https://developer.android.com/reference/javax/net/ssl/SSLSocket.html
  • 移除了非 PIE 链接器支持。Android 现在要求所有动态链接的可执行文件都要支持 PIE(位置无关可执行文件)。这有助于增强 Android 的地址空间布局随机化 (ASLR) 实现。
  • FORTIFY_SOURCE 改进。以下 libc 函数现在实现了 FORTIFY_SOURCE 保护功能:stpcpy()stpncpy()read()recvfrom()FD_CLR()FD_SET()FD_ISSET()。这有助于防范涉及这些函数的内存损坏漏洞。
  • 安全修复程序。Android 5.0 中还包含针对 Android 特有漏洞的修复程序。有关这些漏洞的信息已提供给“开放手机联盟”(Open Handset Alliance) 成员,并且 Android 开放源代码项目中提供了相应的修复程序。为了提高安全性,部分搭载更低版本 Android 系统的设备可能也会包含这些修复程序。

Android 4 及更低版本

每个 Android 版本中都包含数十项用于保护用户的安全增强功能。以下是 Android 4.4 中提供的一些安全增强功能:

  • 通过 SELinux 得到增强的 Android 沙盒。 Android 现在以强制模式使用 SELinux。SELinux 是 Linux 内核中的强制访问控制 (MAC) 系统,用于增强基于自主访问控制 (DAC) 的现有安全模型。 这为防范潜在的安全漏洞提供了额外的保护屏障。
  • 按用户应用 VPN。 在多用户设备上,现在按用户应用 VPN。 这样一来,用户就可以通过一个 VPN 路由所有网络流量,而不会影响使用同一设备的其他用户。
  • AndroidKeyStore 中的 ECDSA 提供程序支持。 Android 现在有一个允许使用 ECDSA 和 DSA 算法的密钥库提供程序。
  • 设备监测警告。 如果有任何可能允许监测加密网络流量的证书添加到设备证书库中,Android 都会向用户发出警告。
  • FORTIFY_SOURCE。 Android 现在支持 FORTIFY_SOURCE 第 2 级,并且所有代码在编译时都会受到这些保护。FORTIFY_SOURCE 已得到增强,能够与 Clang 配合使用。
  • 证书锁定。 Android 4.4 能够检测安全的 SSL/TLS 通信中是否使用了欺诈性 Google 证书,并且能够阻止这种行为。
  • 安全修复程序。 Android 4.4 中还包含针对 Android 特有漏洞的修复程序。 有关这些漏洞的信息已提供给“开放手机联盟”(Open Handset Alliance) 成员,并且 Android 开源项目中提供了相应的修复程序。为了提高安全性,搭载更低版本 Android 的某些设备可能也会包含这些修复程序。

Every Android release includes dozens of security enhancements to protect users. The following are some of the security enhancements available in Android 4.3:

  • Android sandbox reinforced with SELinux. This release strengthens the Android sandbox using the SELinux mandatory access control system (MAC) in the Linux kernel. SELinux reinforcement is invisible to users and developers, and adds robustness to the existing Android security model while maintaining compatibility with existing apps. To ensure continued compatibility this release allows the use of SELinux in a permissive mode. This mode logs any policy violations, but will not break apps or affect system behavior.
  • No setuid or setgid programs. Added support for filesystem capabilities to Android system files and removed all setuid or setgid programs. This reduces root attack surface and the likelihood of potential security vulnerabilities.
  • ADB authentication. Starting in Android 4.2.2, connections to ADB are authenticated with an RSA keypair. This prevents unauthorized use of ADB where the attacker has physical access to a device.
  • Restrict Setuid from Android Apps. The /system partition is now mounted nosuid for zygote-spawned processes, preventing Android apps from executing setuid programs. This reduces root attack surface and the likelihood of potential security vulnerabilities.
  • Capability bounding. Android zygote and ADB now use prctl(PR_CAPBSET_DROP) to drop unnecessary capabilities prior to executing apps. This prevents Android apps and apps launched from the shell from acquiring privileged capabilities.
  • AndroidKeyStore Provider. Android now has a keystore provider that allows apps to create exclusive use keys. This provides apps with an API to create or store private keys that cannot be used by other apps.
  • KeyChain isBoundKeyAlgorithm. Keychain API now provides a method (isBoundKeyType) that allows apps to confirm that system-wide keys are bound to a hardware root of trust for the device. This provides a place to create or store private keys that can't be exported off the device, even in the event of a root compromise.
  • NO_NEW_PRIVS. Android zygote now uses prctl(PR_SET_NO_NEW_PRIVS) to block addition of new privileges prior to execution app code. This prevents Android apps from performing operations that can elevate privileges through execve. (This requires Linux kernel version 3.5 or greater).
  • FORTIFY_SOURCE enhancements. Enabled FORTIFY_SOURCE on Android x86 and MIPS and fortified strchr(), strrchr(), strlen(), and umask() calls. This can detect potential memory corruption vulnerabilities or unterminated string constants.
  • Relocation protections. Enabled read only relocations (relro) for statically linked executables and removed all text relocations in Android code. This provides defense in depth against potential memory corruption vulnerabilities.
  • Improved EntropyMixer. EntropyMixer now writes entropy at shutdown or reboot, in addition to periodic mixing. This allows retention of all entropy generated while devices are powered on, and is especially useful for devices that are rebooted immediately after provisioning.
  • Security fixes. Android 4.3 also includes fixes for Android-specific vulnerabilities. Information about these vulnerabilities has been provided to Open Handset Alliance members and fixes are available in Android Open Source Project. To improve security, some devices with earlier versions of Android may also include these fixes.

Android provides a multi-layered security model described in the Android Security Overview. Each update to Android includes dozens of security enhancements to protect users. The following are some of the security enhancements introduced in Android 4.2:

  • App verification: Users can choose to enable Verify Apps and have apps screened by an app verifier, prior to installation. App verification can alert the user if they try to install an app that might be harmful; if an app is especially bad, it can block installation.
  • More control of premium SMS: Android provides a notification if an app attempts to send SMS to a short code that uses premium services that might cause additional charges. The user can choose whether to allow the app to send the message or block it.
  • Always-on VPN: VPN can be configured so that apps won't have access to the network until a VPN connection is established. This prevents apps from sending data across other networks.
  • Certificate pinning: The Android core libraries now support certificate pinning. Pinned domains receive a certificate validation failure if the certificate doesn't chain to a set of expected certificates. This protects against possible compromise of certificate authorities.
  • Improved display of Android permissions: Permissions are organized into groups that are more easily understood by users. During review of the permissions, the user can click on the permission to see more detailed information about the permission.
  • installd hardening: The installd daemon does not run as the root user, reducing potential attack surface for root privilege escalation.
  • init script hardening: init scripts now apply O_NOFOLLOW semantics to prevent symlink related attacks.
  • FORTIFY_SOURCE: Android now implements FORTIFY_SOURCE. This is used by system libraries and apps to prevent memory corruption.
  • ContentProvider default configuration: Apps that target API level 17 have export set to false by default for each Content Provider, reducing default attack surface for apps.
  • Cryptography: Modified the default implementations of SecureRandom and Cipher.RSA to use OpenSSL. Added SSL Socket support for TLSv1.1 and TLSv1.2 using OpenSSL 1.0.1
  • Security fixes: Upgraded open source libraries with security fixes include WebKit, libpng, OpenSSL, and LibXML. Android 4.2 also includes fixes for Android-specific vulnerabilities. Information about these vulnerabilities has been provided to Open Handset Alliance members and fixes are available in Android Open Source Project. To improve security, some devices with earlier versions of Android may also include these fixes.

Android 提供了一个多层安全模型,Android 安全性概述中对该模型进行了介绍。每个 Android 更新版本中都包含数十种用于保护用户的安全增强功能。以下是 Android 1.5 至 4.1 版中引入的一些安全增强功能:

Android 1.5
  • ProPolice:旨在防止堆栈缓冲区溢出 (-fstack-protector)
  • safe_iop:旨在减少整数溢出
  • OpenBSD dlmalloc 的扩展程序:旨在防范 double free() 漏洞和连续块攻击。连续块攻击是利用堆损坏的常见攻击方式。
  • OpenBSD calloc:旨在防止在内存分配期间发生整数溢出
Android 2.3
  • 格式化字符串漏洞防护功能 (-Wformat-security -Werror=format-security)
  • 基于硬件的 No eXecute (NX):旨在防止在堆栈和堆上执行代码
  • Linux mmap_min_addr:旨在降低空指针解引用提权风险(在 Android 4.1 中得到了进一步增强)
Android 4.0
地址空间布局随机化 (ASLR):旨在随机排列内存中的关键位置
Android 4.1
  • PIE(位置无关可执行文件)支持
  • 只读重定位/立即绑定 (-Wl,-z,relro -Wl,-z,now)
  • 启用了 dmesg_restrict(避免内核地址泄露)
  • 启用了 kptr_restrict(避免内核地址泄露)