Android SELinux Internals Part III - Kernel-Level SELinux By... - #2879
Open
carlospolop wants to merge 1 commit into
Open
carlospolop wants to merge 1 commit into
carlospolop wants to merge 1 commit into
Conversation
Collaborator
Author
🔗 Additional ContextOriginal Blog Post: https://8ksec.io/android-selinux-internals-part-iii Content Categories: Based on the analysis, this content was categorized under "Mobile Pentesting > Android Applications Pentesting > Android Kernel Exploitation and SELinux Bypasses, with a cross-link from Binary Exploitation > Linux kernel exploitation". Repository Maintenance:
Review Notes:
Bot Version: HackTricks News Bot v1.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤖 Automated Content Update
This PR was automatically generated by the HackTricks News Bot based on a technical blog post.
📝 Source Information
🎯 Content Summary
Scope and threat model
Android SELinux Internals Part III assumes that an attacker has already obtained an arbitrary kernel read/write primitive, for example through a use-after-free, out-of-bounds write, or another kernel memory-corruption bug. Kernel read/write alone does not change the process UID, credentials, or SELinux domain, so SELinux remains the main obstacle to turning the primitive into full device compromise. The post explains six kernel-level SELinux byp...
🔧 Technical Details
Global SELinux-state corruption: An attacker who already has arbitrary kernel write can locate the legacy
selinux_enforcinginteger or the newerselinux_state.enforcingfield through/proc/kallsyms, a separate kernel information leak, build-specific offsets, or KASLR-slide calculation. Writing zero changes the entire device to permissive mode while AVC denials continue to be logged.Domain-scoped permissive mode: Read the process context from
/proc/self/attr/current, resolve the corresponding SELinux type ID through the policy database or SETools, locateselinux_state->policy->policydb->permissive_map, and set the type's ebitmap bit usingebitmap_set_bit(&pdb->permissive_map, target_type_id, 1). This makes only processes in the selected domain permissive.AVC cache poisoning: Locate the AVC hash table, calculate
avc_h...🤖 Agent ActionsPlan:
Repository mapping is complete. Next I’m checking the Android landing page, the Linux-kernel exploitation index and representative kernel/SELinux pages to avoid duplicating existing material and to match local style.
The existing corpus covers Android kernel primitives and GPU/SMMU takeovers, but not post–kernel-R/W SELinux data-target selection. I’m now verifying the article against the credited primary research and upstream kernel structures before drafting one dedicated binary-exploitation page.
Source verification shows the primary research supports six post-R/W targets, while the Black Hat work supports page-level cross-cache grooming and permission-map corruption—not the article’s more specific claim that an AVC-node spray itself was demonstrated. I’ll preserve that distinction and omit unverified pKVM/GKI generalizations.
I’m implementing the verified material as a single canonical kernel-exploitation page, then adding discovery links from Android pentesting, the GPU/SMMU page, and the book summary. The page will explicitly correct the article’s permission-map simplification: zeroed mappings only become permissive when
allow_unknownis enabled, and stale AVC denials may still need invalidation/patching.The implementation is in place. I’m now doing a technical review of constants and version caveats, checking every internal path/reference, then running repository-level formatting/build validation.
One remaining check is the kernel-side constant name/value for
allow_unknown; I’m verifying it against upstream source so the pseudocode does not accidentally use a userspace-only libsepol symbol.Technical review is complete: the permission-map pseudocode now writes the kernel’s boolean
allow_unknownfield rather than a libsepol-style constant. Final validation will check source availability, code fences, reference numbering, internal links, and the clean diff.Implemented the HackTricks update.
Changes
src/binary-exploitation/linux-kernel-exploitation/android-kernel-selinux-bypass.mdnum_permsalone does not grant access;allow_unknownand preserved permission slots are required.SUMMARY.mdValidation
git diff --checkpasses.mdbookwas unavailable in the environment, so a full build could not be run.This PR was automatically created by the HackTricks Feed Bot. Please review the changes carefully before merging.