Android 一直在不断改进其安全功能和产品/服务。您可以在左侧导航栏中查看各个版本的增强功能列表。
Every Android release includes dozens of security enhancements to protect users. Here are some of the major security enhancements available in Android 14:
- Hardware-assisted AddressSanitizer (HWASan), introduced in Android 10, is a memory error detection tool similar to AddressSanitizer. Android 14 brings significant improvements to HWASan. Learn how it helps prevent bugs from making it into Android releases, HWAddressSanitizer
- In Android 14, starting with apps that share location data with third-parties, the system runtime permission dialog now includes a clickable section that highlights the app's data-sharing practices, including information such as why an app may decide to share data with third parties.
- Android 12 introduced an option to disable 2G support at the modem level, which protects users from the inherent security risk from 2G's obsolete security model. Recognizing how critical disabling 2G could be for enterprise customers, Android 14 enables this security feature in Android Enterprise, introducing support for IT admins to restrict the ability of a managed device to downgrade to 2G connectivity.
- Added support to reject null-ciphered cellular connections, ensuring that circuit-switched voice and SMS traffic is always encrypted and protected from passive over-the-air interception. Learn more about Android's program to harden cellular connectivity.
- Added support for multiple IMEIs
- Since Android 14, AES-HCTR2 is the preferred mode of filenames encryption for devices with accelerated cryptography instructions.
- Cellular connectivity
- Documentation added for Android Safety Center
- If your app targets Android 14 and uses Dynamic Code Loading (DCL), all dynamically-loaded files must be marked as read-only. Otherwise, the system throws an exception. We recommend that apps avoid dynamically loading code whenever possible, as doing so greatly increases the risk that an app can be compromised by code injection or code tampering.
Check out our full AOSP release notes and the Android Developer features and changes list.
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.
Every Android release includes dozens of security enhancements to protect users. Here are some of the major security enhancements available in Android 12:
- Android 12 introduces the BiometricManager.Strings API, which provides localized strings for apps that use BiometricPrompt for authentication. These strings are intended to be device-aware and provide more specificity about which authentication types might be used. Android 12 also includes support for under-display fingerprint sensors
- Support added for under-display fingerprint sensors
- Introduction of the Fingerprint Android Interface Definition Language (AIDL)
- Support for new Face AIDL
- Introduction of Rust as a language for platform development
- The option for users to grant access only to their approximate location added
- Added Privacy indicators on the status bar when an app is using the camera or microphone
- Android's Private Compute Core (PCC)
- Added an option to disable 2G support
Every Android release includes dozens of security enhancements to protect users. For a list of some of the major security enhancements available in Android 11, see the Android Release Notes.
每个 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 的常规发布周期外的时间进行更新。下面列举了几种模块:
- Android 运行时
- Conscrypt
- DNS 解析器
- DocumentsUI
- ExtServices
- 媒体
- ModuleMetadata
- 网络
- PermissionController
- 时区数据
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_LOCATION
或ACCESS_COARSE_LOCATION
声明了<uses-permission>
元素,则系统会在安装期间自动为ACCESS_BACKGROUND_LOCATION
添加<uses-permission>
元素。 - 如果您的应用请求了
ACCESS_FINE_LOCATION
或ACCESS_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_LOCATION
和 ACCESS_COARSE_LOCATION
权限,ACCESS_BACKGROUND_LOCATION
权限仅会影响应用在后台运行时对位置信息的访问权限。除非符合以下条件之一,否则应用将被视为在后台访问位置信息:
- 属于该应用的 Activity 可见。
- 该应用运行的某个前台服务已声明前台服务类型为
location
。
如需将应用中的某个服务声明为前台服务类型,请将应用的targetSdkVersion
或compileSdkVersion
设置为29
或更高版本。详细了解前台服务如何继续执行用户发起的需要访问位置信息的操作。
外部存储空间
默认情况下,以 Android 10 及更高版本为目标平台的应用在访问外部存储设备中的文件时存在范围限制,即分区存储。此类应用可以查看外部存储设备内以下类型的文件,无需请求任何与存储相关的用户权限:
- 特定于应用的目录中的文件(使用
getExternalFilesDir()
访问)。 - 应用创建的照片、视频和音频片段(通过媒体库访问)。
如需详细了解分区存储以及如何共享、访问和修改在外部存储设备上保存的文件,请参阅有关如何管理外部存储设备中的文件以及如何访问和修改媒体文件的指南。
随机分配 MAC 地址
默认情况下,在搭载 Android 10 或更高版本的设备上,系统会传输随机分配的 MAC 地址。
如果您的应用处理企业使用场景,Android 平台会提供 API,用于执行与 MAC 地址相关的几个操作。
- 获取随机分配的 MAC 地址:设备所有者应用和资料所有者应用可以通过调用
getRandomizedMacAddress()
检索分配给特定网络的随机分配 MAC 地址。 - 获取实际的出厂 MAC 地址:设备所有者应用可以通过调用
getWifiMacAddress()
检索设备的实际硬件 MAC 地址。此方法对于跟踪设备队列非常有用。
不可重置的设备标识符
从 Android 10 开始,应用必须具有 READ_PRIVILEGED_PHONE_STATE
特许权限才能访问设备的不可重置标识符(包括 IMEI 和序列号)。
Build
TelephonyManager
如果您的应用没有该权限,但您仍尝试查询不可重置标识符的相关信息,则 Android 平台的响应会因目标 SDK 版本而异:
- 如果应用以 Android 10 或更高版本为目标平台,则会发生
SecurityException
。 - 如果应用以 Android 9(API 级别 28)或更低版本为目标平台,则相应方法会返回
null
或占位符数据(如果应用具有READ_PHONE_STATE
权限)。否则,会发生SecurityException
。
身体活动识别
Android 10 针对需要检测用户步数或对用户的身体活动(例如步行、骑车或坐车)进行分类的应用引入了 android.permission.ACTIVITY_RECOGNITION
运行时权限。此项权限旨在让用户了解设备传感器数据在“设置”中的使用方式。
除非用户已向您的应用授予此权限,否则 Google Play 服务中的一些库(例如 Activity Recognition API 和 Google 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)应使用 NetworkStatsManager
或 ConnectivityManager
类。
从界面中移除了权限组
从 Android 10 开始,应用无法在界面中查询权限的分组方式。
移除了联系人关系密切程度
从 Android 10 开始,平台不再记录联系人的关系密切程度信息。因此,如果您的应用对用户的联系人进行搜索,系统将不会按互动频率对搜索结果排序。
有关 ContactsProvider
的指南包含一项说明特定字段和方法已废弃的声明(从 Android 10 开始,这些字段和方法在所有设备上已作废)。
限制对屏幕内容的访问
为了保护用户的屏幕内容,Android 10 更改了 READ_FRAME_BUFFER
、CAPTURE_VIDEO_OUTPUT
和 CAPTURE_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,则下列方法不会返回有用数据:
getConfiguredNetworks()
方法始终返回空列表。- 每个返回整数值的网络操作方法(
addNetwork()
和updateNetwork()
)始终返回 -1。 - 每个返回布尔值的网络操作(
removeNetwork()
、reassociate()
、enableNetwork()
、disableNetwork()
、reconnect()
和disconnect()
)始终返回false
。
Every Android release includes dozens of security enhancements to protect users. For a list of some of the major security enhancements available in Android 9, see the Android Release Notes.
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 theBuild.SERIAL
API which is protected behind a user-controlled permission. Improved MAC address randomization in some chipsets.
Every Android release includes dozens of security enhancements to protect users. Here are some of the major security enhancements available in Android 7.0:
- File-based encryption. Encrypting at the file level, instead of encrypting the entire storage area as a single unit, better isolates and protects individual users and profiles (such as personal and work) on a device.
- Direct Boot. Enabled by file-based encryption, Direct Boot allows certain apps such as alarm clock and accessibility features to run when device is powered on but not unlocked.
- Verified Boot. Verified Boot is now strictly enforced to prevent compromised devices from booting; it supports error correction to improve reliability against non-malicious data corruption.
- SELinux. Updated SELinux configuration and increased seccomp coverage further locks down the Application Sandbox and reduces attack surface.
- Library load-order randomization and improved ASLR. Increased randomness makes some code-reuse attacks less reliable.
- Kernel hardening. Added additional memory protection for newer kernels by marking portions of kernel memory as read-only, restricting kernel access to userspace addresses and further reducing the existing attack surface.
- APK signature scheme v2. Introduced a whole-file signature scheme that improves verification speed and strengthens integrity guarantees.
- Trusted CA store. To make it easier for apps to control access to their secure network traffic, user-installed certificate authorities and those installed through Device Admin APIs are no longer trusted by default for apps targeting API Level 24+. Additionally, all new Android devices must ship with the same trusted CA store.
- Network Security Config. Configure network security and TLS through a declarative configuration file.
Every Android release includes dozens of security enhancements to protect users. Here are some of the major security enhancements available in Android 6.0:
- Runtime Permissions. Apps request permissions at runtime instead of being granted at App install time. Users can toggle permissions on and off for both M and pre-M apps.
- Verified Boot. A set of cryptographic checks of system software are conducted prior to execution to ensure the phone is healthy from the bootloader all the way up to the operating system.
- Hardware-Isolated Security. New Hardware Abstraction Layer (HAL) used by Fingerprint API, Lockscreen, Device Encryption, and Client Certificates to protect keys against kernel compromise and/or local physical attacks
- Fingerprints. Devices can now be unlocked with just a touch. Developers can also take advantage of new APIs to use fingerprints to lock and unlock encryption keys.
- SD Card Adoption. Removable media can be adopted to a device and expand available storage for app local data, photos, videos, etc., but still be protected by block-level encryption.
- Clear Text Traffic. Developers can use a new StrictMode to make sure their app doesn't use cleartext.
- System Hardening. Hardening of the system via policies enforced by SELinux. This offers better isolation between users, IOCTL filtering, reduce threat of exposed services, further tightening of SELinux domains, and extremely limited /proc access.
- USB Access Control: Users must confirm to allow USB access to files, storage, or other functionality on the phone. Default is now charge only with access to storage requiring explicit approval from the user.
5.0
Every Android release includes dozens of security enhancements to protect users. Here are some of the major security enhancements available in Android 5.0:
- Encrypted by default. On devices that ship with L out-of-the-box, full disk encryption is enabled by default to improve protection of data on lost or stolen devices. Devices that update to L can be encrypted in Settings > Security .
- Improved full disk encryption. The user password is
protected against brute-force attacks using
scrypt
and, where available, the key is bound to the hardware keystore to prevent off-device attacks. As always, the Android screen lock secret and the device encryption key are not sent off the device or exposed to any application. - Android sandbox reinforced with SELinux . Android now requires SELinux in enforcing mode for all domains. SELinux is a mandatory access control (MAC) system in the Linux kernel used to augment the existing discretionary access control (DAC) security model. This new layer provides additional protection against potential security vulnerabilities.
- Smart Lock. Android now includes trustlets that provide more flexibility for unlocking devices. For example, trustlets can allow devices to be unlocked automatically when close to another trusted device (through NFC, Bluetooth) or being used by someone with a trusted face.
- Multi user, restricted profile, and guest modes for phones and tablets. Android now provides for multiple users on phones and includes a guest mode that can be used to provide easy temporary access to your device without granting access to your data and apps.
- Updates to WebView without OTA. WebView can now be updated independent of the framework and without a system OTA. This allows for faster response to potential security issues in WebView.
- Updated cryptography for HTTPS and TLS/SSL. TLSv1.2 and TLSv1.1 is now enabled, Forward Secrecy is now preferred, AES-GCM is now enabled, and weak cipher suites (MD5, 3DES, and export cipher suites) are now disabled. See https://developer.android.com/reference/javax/net/ssl/SSLSocket.html for more details.
- non-PIE linker support removed. Android now requires all dynamically linked executables to support PIE (position-independent executables). This enhances Android's address space layout randomization (ASLR) implementation.
- FORTIFY_SOURCE improvements. The following libc
functions now implement FORTIFY_SOURCE protections:
stpcpy()
,stpncpy()
,read()
,recvfrom()
,FD_CLR()
,FD_SET()
, andFD_ISSET()
. This provides protection against memory-corruption vulnerabilities involving those functions. - Security Fixes. Android 5.0 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.
Every Android release includes dozens of security enhancements to protect users. The following are some of the security enhancements available in Android 4.4:
- Android sandbox reinforced with SELinux. Android now uses SELinux in enforcing mode. SELinux is a mandatory access control (MAC) system in the Linux kernel used to augment the existing discretionary access control (DAC) based security model. This provides additional protection against potential security vulnerabilities.
- Per User VPN. On multi-user devices, VPNs are now applied per user. This can allow a user to route all network traffic through a VPN without affecting other users on the device.
- ECDSA Provider support in AndroidKeyStore. Android now has a keystore provider that allows use of ECDSA and DSA algorithms.
- Device Monitoring Warnings. Android provides users with a warning if any certificate has been added to the device certificate store that could allow monitoring of encrypted network traffic.
- FORTIFY_SOURCE. Android now supports FORTIFY_SOURCE level 2, and all code is compiled with these protections. FORTIFY_SOURCE has been enhanced to work with clang.
- Certificate Pinning. Android 4.4 detects and prevents the use of fraudulent Google certificates used in secure SSL/TLS communications.
- Security Fixes. Android 4.4 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.
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
orsetgid
programs. Added support for filesystem capabilities to Android system files and removed allsetuid
orsetgid
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 executingsetuid
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 usesprctl(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. EnabledFORTIFY_SOURCE
on Android x86 and MIPS and fortifiedstrchr()
,strrchr()
,strlen()
, andumask()
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 implementsFORTIFY_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 tofalse
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(避免内核地址泄露)