SEPAL: Towards a Large-scale Analysis of SEAndroid Policy Customization

Dongsong Yu, Guangliang Yang, Guozhu Meng, Xiaorui Gong, Xiu Zhang, Xiaobo Xiang, Xiaoyu Wang, Yue Jiang, Kai Chen, Wei Zou, Wenke Lee, Wenchang Shi

TL;DR

SEPAL is a large-scale automated analysis tool that uses Natural Language Processing (NLP) and deep learning to identify security-compromising "unregulated rules" in customized Android firmware. By analyzing over 774 firmware images, the researchers discovered that manufacturer-added security policies often break Android's core protections, with the problem surprisingly worsening in newer versions like Android 9.

What Problem Does This Paper Address?

SEAndroid (Security-Enhanced Android) is the "Mandatory Access Control" (MAC) layer that provides the last line of defense in the Android OS. It uses a strict set of rules to ensure that even if a process is compromised, it cannot access sensitive resources (like the camera or kernel drivers) unless explicitly permitted.

While the official Android Open Source Project (AOSP) maintains a solid base policy, device manufacturers (OEMs) like Samsung, Huawei, and Xiaomi must customize these policies to support their specific hardware and features. This customization is a security minefield. Manufacturers often add "unregulated rules"—permissions that are either too broad, unnecessary, or intended only for debugging—which inadvertently open backdoors for attackers. Because there are millions of these rules across thousands of device models, manually vetting them is impossible.

Methods

The authors propose SEPAL (SEAndroid Policy Analyzer), which treats policy analysis as a recommendation system problem. Its workflow consists of three main stages:

  1. Atomic Rule Collection: To handle "fragmentation" (where rules look different across versions), SEPAL decomposes complex manufacturer rules into "atomic rules"—the smallest possible units consisting of one subject, one object, one class, and one permission.
  2. Feature Extraction with NLP: Standard analysis usually ignores the "intent" behind a rule. SEPAL uses NLP (specifically dependency parsing and WordNet) to analyze the comments left by developers in the source code. It extracts "Subject-Verb-Object" triplets (e.g., "Allow apps to send dump information") to understand the semantic context of a rule.
  3. Wide&Deep Learning: SEPAL employs a "Wide&Deep" model—a technique often used in app stores to recommend apps. The "Wide" part (a linear model) memorizes common, safe patterns from the official AOSP policy, while the "Deep" part (a Neural Network) generalizes to find suspicious outliers in manufacturer customizations.

Datasets

The study is one of the largest of its kind, utilizing:

  • 774 stock Android firmware images from 72 different manufacturers.
  • Official AOSP policies from Android 5 through Android 9 to serve as the "ground truth" for safe behavior.
  • A total of 595,236 customized rules, which were expanded into roughly 3.5 million atomic rules for analysis.

Key Insights and Ideas

  • The "Security Regression": One might assume security improves over time. However, SEPAL found that the percentage of unregulated rules actually increased from ~8% in Android 7 to nearly 20% in Android 9.
  • The Project Treble Paradox: Google’s Project Treble was designed to make updates easier by separating vendor code from the system. Ironically, this separation seems to have made it harder for vendors to keep their security policies synchronized with the evolving AOSP standards, leading to more "deprecated" or "misused" attributes.
  • Comments are Gold: By using NLP to parse developer comments, the researchers could identify the purpose of a rule. This allowed them to catch cases where a rule's code looked standard, but its stated intent revealed it was granting excessive privileges to untrusted domains.
  • Common Pitfalls: Most unregulated rules fall into four buckets: misuse of broad attributes (like appdomain), leaving debugging/testing rules in production builds, failing to remove deprecated rules, and granting third-party apps access to sensitive system services.

Key Results

  • High Accuracy: SEPAL achieved 98.5% accuracy in identifying unregulated rules, outperforming the previous state-of-the-art (EASEAndroid) by 15%.
  • Massive Discovery: The tool identified 7,111 unique unregulated rules across the dataset.
  • Real-World Impact: The authors performed "Proof of Concept" attacks based on their findings. They successfully demonstrated exploits that could bypass screen lock passwords and access the camera without permission on retail devices.
  • Vendor Confirmation: After reporting their findings to seven major vendors, four (including ASUS and Huawei) have already confirmed the vulnerabilities and begun patching them.

Limitations and Future Work

  • AOSP Dependency: SEPAL relies on the official AOSP policy as a "gold standard." If the official policy itself contains a flaw or an overly permissive rule, the model will learn that behavior as "safe."
  • New Vendor Types: The model struggles with entirely new, vendor-specific "types" (labels for files or processes) that have no equivalent in the AOSP baseline.
  • Static vs. Dynamic: SEPAL is a static analysis tool. It examines the policy files but does not observe how those policies behave in a live, running system, which might miss certain runtime privilege escalations.

The authors suggest that future work should focus on automated policy patching, helping manufacturers not just find the "mess" in their security rules, but clean it up automatically.

Summary updated

Abstract

Nowadays, SEAndroid has been widely deployed in Android devices to enforce security policies and provide flexible mandatory access control (MAC), for the purpose of narrowing down attack surfaces and restricting risky operations. Generally, the original SEAndroid security policy rules are carefully and strictly written and maintained by the Android community. However, in practice, mobile device manufacturers usually have to customize these policy rules and add their own new rules to satisfy their functionality extensions, which breaks the integrity of SEAndroid and causes serious security issues. Still, up to now, it is a challenging task to identify these security issues due to the large and ever-increasing number of policy rules, as well as the complexity of policy semantics. To investigate the status quo of SEAndroid policy customization, we propose SEPAL, a universal tool to automatically retrieve and examine the customized policy rules. SEPAL applies the NLP technique and employs and trains a wide&deep model to quickly and precisely predict whether one rule is unregulated or not. Our evaluation shows SEPAL is effective, practical and scalable. We verify SEPAL outperforms the state of the art approach (i.e., EASEAndroid) by 15% accuracy rate on average. In our experiments, SEPAL successfully identifies 7,111 unregulated policy rules with a low false positive rate from 595,236 customized rules (extracted from 774 Android firmware images of 72 manufacturers). We further discover the policy customization problem is getting worse in newer Android versions (e.g., around 8% for Android 7 and nearly 20% for Android 9), even though more and more efforts are made. Then, we conduct a deep study and discuss why the unregulated rules are introduced and how they can compromise user devices. Last, we report some unregulated rules to seven vendors and so far four of them confirm our findings.
BibTeX
@inproceedings{yu2021sepal,
  author = {Dongsong Yu and Guangliang Yang and Guozhu Meng and Xiaorui Gong and Xiu Zhang and Xiaobo Xiang and Xiaoyu Wang and Yue Jiang and Kai Chen and Wei Zou and Wenke Lee and Wenchang Shi},
  title = {{SEPAL: Towards a Large-scale Analysis of SEAndroid Policy Customization}},
  booktitle = {The Web Conference},
  year = {2021},
  url = {https://openreview.net/forum?id=OdnWA-UR0yNZ},
}

Loading related content...

Figure