Uncovering Android Sensor Types, Permissions, and Hidden Security Vulnerabilities

This article explains the variety of sensors built into modern Android smartphones, how developers access them via the SensorManager API, the required permissions, and analyzes several memory, logic, and side‑channel vulnerabilities that expose user privacy and system integrity.

OPPO Amber Lab
OPPO Amber Lab
OPPO Amber Lab
Uncovering Android Sensor Types, Permissions, and Hidden Security Vulnerabilities

1.1 Android Sensor Types

Modern smartphones embed numerous hardware sensors such as accelerometers, gravity sensors, light sensors, proximity sensors, gyroscopes, barometers, temperature, humidity, magnetic field, and more. Sensors enable apps to detect user motion, device orientation, ambient light, distance to the user, and environmental conditions, improving user experience and enabling richer applications.

Hardware sensors directly measure physical properties, while software (virtual) sensors combine data from multiple hardware sources to provide higher‑level information like linear acceleration or gravity.

1.2 Android Sensor Architecture and Usage

Apps obtain a SensorManager instance, retrieve a Sensor object (e.g., accelerometer), and register a SensorEventListener to receive callbacks when sensor values or accuracy change. The framework also offers a sampling‑rate control interface for high‑frequency data collection.

Typical usage steps:

Get SensorManager object.

Obtain the desired Sensor (e.g., accelerometer).

Create and register a custom SensorEventListener.

Unregister the listener when no longer needed.

Android sensor architecture diagram
Android sensor architecture diagram

2.1 Memory‑type Vulnerabilities

CVE‑2021‑0318 is a use‑after‑free (UAF) bug in SensorEventConnection.cpp. The SensorEventConnection allocates a cache buffer ( mEventCache) on the heap. After the connection is destroyed, the buffer is freed, but later code still reads and writes the freed memory, creating a heap corruption that can be exploited for privilege escalation.

SensorService::createSensorEventConnection() implementation
SensorService::createSensorEventConnection() implementation
mEventCache initialization
mEventCache initialization
SensorEventConnection::destroy() implementation
SensorEventConnection::destroy() implementation
appendEventsToCacheLocked() use‑after‑free
appendEventsToCacheLocked() use‑after‑free

2.2 Logic‑type Vulnerabilities

CVE‑2023‑21034 bypasses permission checks for ACTIVITY_RECOGNITION and HIGH_SAMPLING_RATE_SENSORS. The flaw resides in isRateCappedBasedOnPermission() and canAccessSensor(), which rely on the app’s target SDK version. A stale cache ( sPackageTargetVersion) can retain an old, lower SDK version after an app upgrade, allowing the app to evade new permission requirements.

isRateCappedBasedOnPermission() implementation
isRateCappedBasedOnPermission() implementation
canAccessSensor() implementation
canAccessSensor() implementation
getTargetSDKVersion() implementation
getTargetSDKVersion() implementation
sPackageTargetVersion cache structure
sPackageTargetVersion cache structure

2.3 Side‑channel Attacks

Researchers have demonstrated that the built‑in accelerometer can capture acoustic vibrations from the speaker, enabling speech eavesdropping. By collecting high‑frequency accelerometer data and applying deep‑learning models, attackers can reconstruct spoken words, especially when the sensor’s sampling rate exceeds 200 Hz. Android 12 limits sensor sampling rates to mitigate this risk, but the threat remains for apps that obtain the HIGH_SAMPLING_RATE_SENSORS permission.

Accelerometer data collection scenario
Accelerometer data collection scenario
Voice reconstruction from accelerometer data
Voice reconstruction from accelerometer data

Conclusion

The article provides an overview of common Android sensor types, their usage, related permissions, and analyzes several representative security vulnerabilities, including memory‑type, logic‑type, and side‑channel attacks. While Google continues to strengthen sensor security, the growing variety of sensors and their easy accessibility ensure they remain a focal point for both security researchers and malicious actors.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

AndroidSecurityPermissionsSensorsside-channelvulnerabilities
OPPO Amber Lab
Written by

OPPO Amber Lab

Centered on user data security and privacy, we conduct research and open our tech capabilities to developers, building an information‑security fortress for partners and users and safeguarding OPPO device security.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.