Sensitive permissions use proper permission API
Why it matters
Accessing device hardware through undocumented native paths instead of the platform's official permission API means the app bypasses the OS-level permission gate entirely. OWASP Mobile Top 10 A01 (Improper Credential Usage) includes improper access to device hardware as a credential misuse vector. CWE-272 (Least Privilege Violation) is directly triggered when an app reads from a sensor without first verifying it has been granted access. Beyond correctness, bypassing react-native-permissions or expo-permissions means your code will behave unpredictably when users revoke permissions mid-session, because the native module has no revocation-aware wrapper — the call will silently fail or crash instead of returning a denied status.
Severity rationale
High because bypassing the standard permission API means the app can silently access hardware after a user revokes permission mid-session, with no graceful fallback — a direct OWASP A01 and CWE-272 violation.
Remediation
Replace direct native module calls with react-native-permissions (bare React Native) or expo-permissions / expo-location (Expo). Always distinguish between LOCATION_WHEN_IN_USE and LOCATION_ALWAYS.
import { request, PERMISSIONS, RESULTS } from 'react-native-permissions'
import { Platform } from 'react-native'
async function requestLocationPermission(): Promise<boolean> {
const permission =
Platform.OS === 'ios'
? PERMISSIONS.IOS.LOCATION_WHEN_IN_USE
: PERMISSIONS.ANDROID.ACCESS_FINE_LOCATION
const result = await request(permission)
return result === RESULTS.GRANTED
}
For Expo, use the typed exports from expo-location, expo-camera, or expo-contacts — they wrap the same Keychain/Keystore-aware permission APIs and handle revocation correctly.
DetectionPro
The detection method for this pattern is part of AuditBuffet Pro.
The full method (what to look for, pass and fail conditions, and how results get reported) ships inside the Mobile Permissions & Privacy Audit. The pattern definition, severity rationale, and remediation remain openly licensed under CC-BY-4.0.
External references
- cwe · CWE-272 — Least Privilege Violation
- owasp:2021 · A01 — Broken Access Control
- external · react-native-permissions — react-native-permissions: Cross-platform permissions API
Taxons
History
- 2026-04-18·v1.0.0·Initial import from mobile-permissions-privacy·automated