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) 功能,则必须将所有动态加载的文件标记为只读。否则,系统会抛出异常。我们建议应用尽可能避免动态加载代码,因为这样做会大大增加应用因代码注入或代码篡改而遭到入侵的风险。
Android 13
每个 Android 版本中都包含数十种用于保护用户的安全增强功能。以下是 Android 13 中提供的一些主要安全增强功能:
- Android 13 添加了对多文档呈现的支持。 通过这个新的 Presentation Session 接口,应用可以执行多文档呈现,而现有 API 无法做到这一点。如需了解详情,请参阅身份凭据
- 在 Android 13 中,当且仅当源自外部应用的 intent 与其声明的 intent 过滤器元素匹配时,这些 intent 才会传送到导出的组件。
- Open Mobile API (OMAPI) 是一种标准 API,用于与设备的安全元件进行通信。在 Android 13 之前,只有应用和框架模块可以访问此接口。通过将其转换为供应商稳定版接口,HAL 模块还能够通过 OMAPI 服务与安全元件进行通信。 如需了解详情,请参阅 OMAPI 供应商稳定版接口。
- 从 Android 13-QPR 开始,共享 UID 被废弃。 使用 Android 13 或更高版本的用户应在其清单中添加 `android:sharedUserMaxSdkVersion="32"` 行。此条目可防止新用户获取共享 UID。如需详细了解 UID,请参阅应用签名。
- Android 13 添加了对密钥库对称加密基元的支持,例如支持 AES(高级加密标准)、HMAC(密钥哈希消息认证码)以及非对称加密算法(包括椭圆曲线加密、RSA2048、RSA4096 和曲线 25519 加密)
- Android 13(API 级别 33)及更高版本支持用于从应用发送非豁免通知的运行时权限。这可让用户控制他们会看到哪些权限通知。
- 针对请求访问所有设备日志的应用,添加了在每次使用时显示提示的功能,以便用户允许或拒绝授予访问权限。
- 推出了 Android 虚拟化框架 (AVF),它使用标准化 API 将不同的 Hypervisor 整合到一个框架下。 它提供安全、私密的执行环境,以便执行通过 Hypervisor 隔离的工作负载。
- 引入了 APK 签名方案 v3.1 所有使用 apksigner 的新密钥轮替都将默认使用 v3.1 签名方案,以便将 Android 13 及更高版本作为轮替目标。
Android 12
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
Android 11
每个 Android 版本中都包含数十项用于保护用户的安全增强功能。如需查看 Android 11 中提供的一些主要安全增强功能的列表,请参阅 Android 版本说明。
Android 10
Every Android release includes dozens of security enhancements to protect users. Android 10 includes several security and privacy enhancements. See the Android 10 release notes for a complete list of changes in Android 10.
Security
BoundsSanitizer
Android 10 deploys BoundsSanitizer (BoundSan) in Bluetooth and codecs. BoundSan uses UBSan's bounds sanitizer. This mitigation is enabled on a per-module level. It helps keep critical components of Android secure and shouldn't be disabled. BoundSan is enabled in the following codecs:
libFLAC
libavcdec
libavcenc
libhevcdec
libmpeg2
libopus
libvpx
libspeexresampler
libvorbisidec
libaac
libxaac
Execute-only memory
By default, executable code sections for AArch64 system binaries are marked execute-only (nonreadable) as a hardening mitigation against just-in-time code reuse attacks. Code that mixes data and code together and code that purposefully inspects these sections (without first remapping the memory segments as readable) no longer functions. Apps with a target SDK of Android 10 (API level 29 or higher) are impacted if the app attempts to read code sections of execute-only memory (XOM) enabled system libraries in memory without first marking the section as readable.
Extended access
Trust agents, the underlying mechanism used by tertiary authentication mechanisms such as Smart Lock, can only extend unlock in Android 10. Trust agents can no longer unlock a locked device and can only keep a device unlocked for a maximum of four hours.
Face authentication
Face authentication allows users to unlock their device simply by looking at the front of their device. Android 10 adds support for a new face authentication stack that can securely process camera frames, preserving security and privacy during face authentication on supported hardware. Android 10 also provides an easy way for security-compliant implementations to enable app integration for transactions such as online banking or other services.
Integer Overflow Sanitization
Android 10 enables Integer Overflow Sanitization (IntSan) in software codecs. Ensure that playback performance is acceptable for any codecs that aren't supported in the device's hardware. IntSan is enabled in the following codecs:
libFLAC
libavcdec
libavcenc
libhevcdec
libmpeg2
libopus
libvpx
libspeexresampler
libvorbisidec
Modular system components
Android 10 modularizes some Android system components and enables them to be updated outside of the normal Android release cycle. Some modules include:
- Android Runtime
- Conscrypt
- DNS Resolver
- DocumentsUI
- ExtServices
- Media
- ModuleMetadata
- Networking
- PermissionController
- Time Zone Data
OEMCrypto
Android 10 uses OEMCrypto API version 15.
Scudo
Scudo is a dynamic user-mode memory allocator designed to be more resilient against heap-related vulnerabilities. It provides the standard C allocation and deallocation primitives, as well as the C++ primitives.
ShadowCallStack
ShadowCallStack
(SCS)
is an LLVM
instrumentation mode that protects against return address overwrites (like
stack buffer overflows) by saving a function's return address to a separately
allocated ShadowCallStack
instance in the function prolog of
nonleaf functions and loading the return address from the
ShadowCallStack
instance in the function epilog.
WPA3 and Wi-Fi Enhanced Open
Android 10 adds support for the Wi-Fi Protected Access 3 (WPA3) and Wi-Fi Enhanced Open security standards to provide better privacy and robustness against known attacks.
Privacy
App access when targeting Android 9 or lower
If your app runs on Android 10 or higher but targets Android 9 (API level 28) or lower, the platform applies the following behavior:
- If your app declares a
<uses-permission>
element for eitherACCESS_FINE_LOCATION
orACCESS_COARSE_LOCATION
, the system automatically adds a<uses-permission>
element forACCESS_BACKGROUND_LOCATION
during installation. - If your app requests either
ACCESS_FINE_LOCATION
orACCESS_COARSE_LOCATION
, the system automatically addsACCESS_BACKGROUND_LOCATION
to the request.
Background activity restrictions
Starting in Android 10, the system places restrictions
on starting activities from the background. This behavior change helps
minimize interruptions for the user and keeps the user more in control of what's
shown on their screen. As long as your app starts activities as a direct result
of user interaction, your app most likely isn't affected by these restrictions.
To learn more about the recommended alternative to starting activities from
the background, see the guide on how to alert
users of time-sensitive events in your app.
Camera metadata
Android 10 changes the breadth of information that the getCameraCharacteristics()
method returns by default. In particular, your app must have the CAMERA
permission in order to access potentially device-specific metadata that is
included in this method's return value.
To learn more about these changes, see the section about camera
fields that require permission.
Clipboard data
Unless your app is the default input method editor (IME) or is the app that currently has focus, your app cannot access clipboard data on Android 10 or higher.
Device location
To support the additional control that users have over an app's access to
location information, Android 10 introduces the ACCESS_BACKGROUND_LOCATION
permission.
Unlike the ACCESS_FINE_LOCATION
and ACCESS_COARSE_LOCATION
permissions, the ACCESS_BACKGROUND_LOCATION
permission only affects
an app's access to location when it runs in the background. An app is considered
to be accessing location in the background unless one of the following
conditions is satisfied:
- An activity belonging to the app is visible.
- The app is running a foreground service that has declared a foreground
service type of
location
.
To declare the foreground service type for a service in your app, set your app'stargetSdkVersion
orcompileSdkVersion
to29
or higher. Learn more about how foreground services can continue user-initiated actions that require access to location.
External storage
By default, apps targeting Android 10 and higher are given scoped access into external storage, or scoped storage. Such apps can see the following types of files within an external storage device without needing to request any storage-related user permissions:
- Files in the app-specific directory, accessed using
getExternalFilesDir()
. - Photos, videos, and audio clips that the app created from the media store.
To learn more about scoped storage, as well as how to share, access, and modify files that are saved on external storage devices, see the guides on how to manage files in external storage and access and modify media files.
MAC address randomization
On devices that run Android 10 or higher, the system transmits randomized MAC
addresses by default.
If your app handles an enterprise use case, the
platform provides APIs for several operations related to MAC addresses:
- Obtain randomized MAC address: Device owner apps and
profile owner apps can retrieve the randomized MAC address assigned to a
specific network by calling
getRandomizedMacAddress()
. - Obtain actual, factory MAC address: Device owner apps can
retrieve a device's actual hardware MAC address by calling
getWifiMacAddress()
. This method is useful for tracking fleets of devices.
Non-resettable device identifiers
Starting in Android 10, apps must have the
READ_PRIVILEGED_PHONE_STATE
privileged permission in order to
access the device's non-resettable identifiers, which include both IMEI and
serial number.
Build
TelephonyManager
If your app doesn't have the permission and you try asking for information about non-resettable identifiers anyway, the platform's response varies based on target SDK version:
- If your app targets Android 10 or higher, a
SecurityException
occurs. - If your app targets Android 9 (API level 28) or lower, the method returns
null
or placeholder data if the app has theREAD_PHONE_STATE
permission. Otherwise, aSecurityException
occurs.
Physical activity recognition
Android 10 introduces the android.permission.ACTIVITY_RECOGNITION
runtime permission for apps that need to detect the user's step count or
classify the user's physical activity, such as walking, biking, or moving in a
vehicle. This is designed to give users visibility of how device sensor data is
used in Settings.
Some libraries within Google Play services, such as the Activity
Recognition API and the Google
Fit API, don't provide results unless the user has granted your app this
permission.
The only built-in
sensors on the device that require you to declare this permission are the step
counter and step
detector sensors.
If your app targets Android 9 (API level 28) or lower, the system
auto-grants the android.permission.ACTIVITY_RECOGNITION
permission
to your app, as needed, if your app satisfies each of the following
conditions:
- The manifest file includes the
com.google.android.gms.permission.ACTIVITY_RECOGNITION
permission. - The manifest file doesn't include the
android.permission.ACTIVITY_RECOGNITION
permission.
If the system-auto grants the
android.permission.ACTIVITY_RECOGNITION
permission, your app
retains the permission after you update your app to target Android 10. However,
the user can revoke this permission at any time in system settings.
/proc/net filesystem restrictions
On devices that run Android 10 or higher, apps cannot access
/proc/net
, which includes information about a device's network
state. Apps that need access to this information, such as VPNs, should use the
NetworkStatsManager
or ConnectivityManager
class.
Permission groups removed from UI
As of Android 10, apps cannot look up how permissions are grouped in the UI.
Removal of contacts affinity
Starting in Android 10, the platform doesn't keep track of contacts affinity
information. As a result, if your app conducts a search on the user's contacts,
the results aren't ordered by frequency of interaction.
The guide about ContactsProvider
contains a notice describing
the specific fields
and methods that are obsolete on all devices starting in Android 10.
Restricted access to screen contents
To protect users' screen contents, Android 10 prevents silent access to the
device's screen contents by changing the scope of the
READ_FRAME_BUFFER
, CAPTURE_VIDEO_OUTPUT
, and
CAPTURE_SECURE_VIDEO_OUTPUT
permissions. As of Android 10, these
permissions are signature-access
only.
Apps that need to access the device's screen contents should use the
MediaProjection
API, which displays a prompt asking the user to provide consent.
USB device serial number
If your app targets Android 10 or higher, your app cannot read the serial
number until the user has granted your app permission to access the USB device
or accessory.
To learn more about working with USB devices, see the guide on how to configure
USB hosts.
Wi-Fi
Apps targeting Android 10 or higher cannot enable or disable Wi-Fi. The
WifiManager.setWifiEnabled()
method always returns false
.
If you need to prompt users to enable and disable Wi-Fi, use a settings
panel.
Restrictions on direct access to configured Wi-Fi networks
To protect user privacy, manual configuration of the list of Wi-Fi networks
is restricted to system apps and device policy
controllers (DPCs). A given DPC can be either the device owner or the
profile owner.
If your app targets Android 10 or higher, and it isn't a system app or a
DPC, then the following methods don't return useful data:
- The
getConfiguredNetworks()
method always returns an empty list. - Each network operation method that returns an integer value—
addNetwork()
andupdateNetwork()
—always returns -1. - Each network operation that returns a boolean value—
removeNetwork()
,reassociate()
,enableNetwork()
,disableNetwork()
,reconnect()
, anddisconnect()
—always returnsfalse
.
Android 9
每个 Android 版本中都包含数十项用于保护用户的安全增强功能。如需 Android 9 中提供的一些主要安全增强功能的列表,请参阅 Android 版本说明。
Android 8
每个 Android 版本中都包含数十种用于保护用户的安全增强功能。以下是 Android 8.0 中提供的一些主要安全增强功能:
- 加密:在工作资料中增加了对撤销密钥 (evict key) 的支持。
- 验证启动:增加了 Android 启动时验证 (AVB)。支持回滚保护(用于引导加载程序)的启动时验证代码库已添加到 AOSP 中。建议提供引导加载程序支持,以便为 HLOS 提供回滚保护。建议将引导加载程序设为只能由用户通过实际操作设备来解锁。
- 锁定屏幕:增加了对使用防篡改硬件验证锁定屏幕凭据的支持。
- KeyStore:搭载 Android 8.0 及更高版本的所有设备都需要进行密钥认证。增加了 ID 认证支持,以改进零触摸注册计划。
- 沙盒:使用 Treble 计划的框架和设备特定组件之间的标准接口更紧密地对许多组件进行沙盒化处理。将 seccomp 过滤应用到了所有不信任的应用,以减少内核的攻击面。WebView 现在运行在一个独立的进程中,对系统其余部分的访问非常有限。
- 内核加固:实现了经过安全强化的 usercopy、PAN 模拟、初始化后变为只读以及 KASLR。
- 用户空间安全强化:为媒体堆栈实现了 CFI。 应用叠加层不能再遮盖系统关键窗口,并且用户可以关闭这些叠加层。
- 操作系统流式更新:在磁盘空间不足的设备上启用了更新。
- 安装未知应用:用户必须授予权限,系统才能从不是第一方应用商店的来源安装应用。
- 隐私权:对于设备上的每个应用和使用设备的每个用户,Android ID (SSAID) 都采用不同的值。对于网络浏览器应用,Widevine 客户端 ID 会针对每个应用软件包名称和网络来源返回不同的值。
net.hostname
现在为空,并且 DHCP 客户端不再发送主机名。android.os.Build.SERIAL
已被替换为Build.SERIAL
API(受到用户控制权限的保护)。改进了某些芯片组中的 MAC 地址随机分配功能。
Android 7
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.
Android 6
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.
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 及更低版本
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.
每个 Android 版本中都包含数十项用于保护用户的安全增强功能。以下是 Android 4.3 中提供的一些安全增强功能:
- 通过 SELinux 得到增强的 Android 沙盒。此版本利用 Linux 内核中的 SELinux 强制访问权限控制系统 (MAC) 增强了 Android 沙盒。SELinux 强化功能(用户和开发者看不到它)可提高现有 Android 安全模型的可靠性,同时与现有应用保持兼容。为了确保持续兼容,此版本允许以宽容模式使用 SELinux。此模式会记录所有政策违规行为,但不会中断应用或影响系统行为。
- 没有 setuid/setgid 程序。针对 Android 系统文件添加了对文件系统功能的支持,并移除了所有 setuid/setgid 程序。 这可以减小 root 攻击面,并降低出现潜在安全漏洞的可能性。
- ADB 身份验证。从 Android 4.2.2 起,开始使用 RSA 密钥对为 ADB 连接进行身份验证。这可以防止攻击者在实际接触到设备的情况下未经授权使用 ADB。
- 限制 Android 应用执行 SetUID 程序。/system 分区现在针对 Zygote 衍生的进程装载了 nosuid,以防止 Android 应用执行 setuid 程序。这可以减小 root 攻击面,并降低出现潜在安全漏洞的可能性。
- 功能绑定。在执行应用之前,Android Zygote 和 ADB 现在会先使用 prctl(PR_CAPBSET_DROP) 舍弃不必要的功能。这可以防止 Android 应用和从 shell 启动的应用获取特权功能。
- AndroidKeyStore 提供程序。Android 现在有一个允许应用创建专用密钥的密钥库提供程序。该程序可以为应用提供一个用于创建或存储私钥的 API,其他应用将无法使用这些私钥。
- KeyChain isBoundKeyAlgorithm。Keychain API 现在提供了一种方法 (isBoundKeyType),可让应用确认系统级密钥是否已绑定到设备的硬件信任根。该方法提供了一个用于创建或存储私钥的位置,即使发生 root 权限被窃取的情况,这些私钥也无法从设备中导出。
- NO_NEW_PRIVS。在执行应用代码之前,Android Zygote 现在会先使用 prctl(PR_SET_NO_NEW_PRIVS) 禁止添加新权限。这可以防止 Android 应用执行可通过 execve 提权的操作。(此功能需要使用 3.5 或更高版本的 Linux 内核)。
- FORTIFY_SOURCE 增强功能。Android x86 和 MIPS 上启用了 FORTIFY_SOURCE,并增强了 strchr()、strrchr()、strlen() 和 umask() 调用。这可以检测潜在的内存损坏漏洞或没有结束符的字符串常量。
- 重定位保护。针对静态关联的可执行文件启用了只读重定位 (relro) 技术,并移除了 Android 代码中的所有文本重定位技术。这可以深度防范潜在的内存损坏漏洞。
- 经过改进的 EntropyMixer。除了定期执行混合操作之外,EntropyMixer 现在还会在关机/重新启动时写入熵。这样一来,便可以保留设备开机时生成的所有熵,而这对于配置之后立即重新启动的设备来说尤其有用。
- 安全修复。Android 4.3 中还包含针对 Android 特有漏洞的修复。有关这些漏洞的信息已提供给“开放手机联盟”(Open Handset Alliance) 成员,并且 Android 开放源代码项目中提供了相应的修复。为了提高安全性,搭载更低版本 Android 的某些设备可能也会包含这些修复。
Android 提供了一个多层安全模型,Android 安全性概述中对该模型进行了介绍。每个 Android 更新版本中都包含数十项用于保护用户的安全增强功能。以下是 Android 4.2 中引入的一些安全增强功能:
- 应用验证 - 用户可以选择启用“验证应用”,并且可以选择在应用安装之前由应用验证程序对其进行筛查。 如果用户尝试安装的应用可能有害,应用验证功能可以提醒用户;如果应用的危害性非常大,应用验证功能可以阻止安装。
- 加强对付费短信的控制 - 如果有应用尝试向使用付费服务的短号码发送短信(可能会产生额外的费用),Android 将会通知用户。用户可以选择是允许还是阻止该应用发送短信。
- 始终开启的 VPN - 可以配置 VPN,以确保在建立 VPN 连接之前应用无法访问网络。这有助于防止应用跨其他网络发送数据。
- 证书锁定 - Android 的核心库现在支持证书锁定。 如果证书未关联到一组应关联的证书,锁定的域将会收到证书验证失败消息。 这有助于保护证书授权机构免遭可能的入侵。
- 改进后的 Android 权限显示方式 - 权限划分到了多个对用户来说更清晰明了的组中。在审核权限时,用户可以点击权限来查看关于相应权限的更多详细信息。
- installd 安全强化 -
installd
守护程序不会以 root 用户身份运行,这样可以缩小 root 提权攻击的潜在攻击面。 - init 脚本安全强化 - init 脚本现在会应用
O_NOFOLLOW
语义来防范与符号链接相关的攻击。 - FORTIFY_SOURCE - Android 现在会实现
FORTIFY_SOURCE
,以供系统库和应用用于防范内存损坏。 - ContentProvider 默认配置 - 默认情况下,对于每个内容提供方,以 API 级别 17 为目标的应用都会将“export”设为“false”,以缩小应用的默认受攻击面。
- 加密 - 修改了 SecureRandom 和 Cipher.RSA 的默认实现,以便使用 OpenSSL。为使用 OpenSSL 1.0.1 的 TLSv1.1 和 TLSv1.2 添加了安全套接字支持
- 安全漏洞修复程序 - 升级了开放源代码库,新增了一些安全漏洞修复程序,其中包括 WebKit、libpng、OpenSSL 和 LibXML。Android 4.2 中还包含针对 Android 特有漏洞的修复程序。有关这些漏洞的信息已提供给“开放手机联盟”(Open Handset Alliance) 成员,并且 Android 开放源代码项目中提供了相应的修复程序。为了提高安全性,部分搭载更低版本 Android 系统的设备可能也会包含这些修复程序。
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(避免内核地址泄露)