Who Needs Root, Anyway? An Android Hardware Story

How getting a joystick to work led me down a rabbit hole involving Android's shared UIDs, process identities, and SELinux policies.
Can a platform-signed system app access hardware devices under Android? And more broadly, what can a system app actually do?
The usual answer is that system apps are privileged, so sure. The real answer is more annoying. A platform-signed app on its own can't open things like /dev/uinput, because the system still drops it into an SELinux domain that has no rules for them. In 2022 I found a way around that with two changes to the manifest. Either one alone fails. Together they put an ordinary-looking APK into the one domain that does have the access, with no root.
This is how I found it, and why it works.
The question
That's the problem statement: how far does a system app's power really go, and can it reach hardware that Android's sandbox keeps away from apps?
I came at it from a concrete case. Several Arcade1Up cabinets run Android on embedded boards, with the controls wired to a proprietary joystick and button encoder that talks over a serial port. Anything you run on the cabinet besides the stock software has no idea what that encoder is. The job is to read the serial data, decode it, and present it to Android as a normal Linux input device so every app sees a controller. On Linux that means uinput.
I'd already documented a fix in A1AndroidControlFix. The README lays out the problem: on these cabinets the system_app domain can reach the serial port but not /dev/uinput. The published fix reflashes the cabinet with a modified policy that adds one allow rule, plus the usual gymnastics to get the system to load the plain-text policy instead of the precompiled one. The README even notes that the shell domain already has uinput access, and that you could run there and split the work across two processes, but you'd lose the serial side.
The rule the published fix adds, straight from the README:
(allow system_app uhid_device (chr_file (ioctl read write getattr lock append map open)))
That worked, but it bothered me. I was convinced it had to be possible another way, because I could already sign apps as system apps, and the system treats those as part of itself. I was determined to prove you could read the joystick data and get the same result without root and without the policy edit.

Everyone said it couldn't be done
Search for "run Android app as shell user" and you get the same answer over and over. The classic is Run Android application as Shell User, asked in November 2013. The author wanted a native binary to read some files under /sys/kernel. It worked from adb and failed from the app. They'd tried android:sharedUserId="android.uid.shell", reported that it "doesn't seem to work," and said they didn't need root, just shell.
The answer says the shell UID is reserved for development and testing, that running an app with shell privileges is circumventing Google's security model, and that you can't do it on a secured commercial device without rooting it. The suggested workaround is an adb-launched service and some IPC.
Other threads circle the same ground: file permissions on Android 6.0, serial ports, platform-signed apps that still can't open input devices, and running adb-style commands from an app.
Those answers are right for what they describe: an ordinary app on a locked-down phone. And the thread about platform-signed apps that still can't open input devices is the one that matters here. Signing as a system app doesn't, by itself, get you hardware access. "What an app can do" isn't one statement. It depends on who signed the app and what identity it ends up running as.
Reading the policy
Android layers several separate things that people mash together. There's the Linux side: a UID, a GID, and supplementary groups. There's SELinux, which gives every process a domain and every object a type, and decides access separately from the file mode. There's the framework, with manifest permissions, runtime grants and Binder checks. And there's the package, which isn't the same thing as the process the system builds for it.
The part that mattered is that an app doesn't choose its own SELinux domain. The system picks it at fork time from a table, using the UID, the signing "seinfo," and the process name. The table is seapp_contexts. What the resulting domain may then do is a different file's job, the actual policy.

So I read the policy. The README had already pointed at the interesting bit: the shell domain is allowed to talk to uinput. The relevant lines in shell.te look like this:
# allow shell input injection
allow shell uhid_device:chr_file rw_file_perms;
If my app could end up in the shell domain, the policy itself would let it create the controller. The only question was how an app becomes shell.
The trick
A platform-signed app on its own isn't enough. It gets its own UID and lands in the platform_app domain, and /dev/uinput stays closed. Getting to the shell domain takes two manifest changes, and neither works without the other. Here are the two attributes, which are the whole trick:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.shellapp"
android:sharedUserId="android.uid.shell">
<application
android:process="com.android.shell">
<!-- activities, services, receivers -->
</application>
</manifest>
The first is android:sharedUserId="android.uid.shell". A platform-signed app can join an existing UID, so this puts the app in UID 2000. On its own, the app then dies at launch. The log, trimmed, says what's going on:
E SELinux : seapp_context_lookup_internal: No match for app with uid 2000, seinfo platform:..., name com.example.shellapp
E SELinux : selinux_android_setcontext: Error setting context for app with uid 2000, seinfo platform:...
F zygote64: JNI FatalError called: ... selinux_android_setcontext(2000, 0, "platform:...", "com.example.shellapp") failed
The zygote aborts. That crash is a plausible reason a lot of people concluded this can't be done. You add the shared UID, the app dies, and a dead end looks like the platform saying no. It didn't say no. It said "I don't have a table row for that."
The second is the process name. The row in seapp_contexts is:
user=shell seinfo=platform domain=shell name=com.android.shell type=shell_data_file
The domain is picked from the pair of UID and process name. So set android:process="com.android.shell", and the lookup finds its row. The android:process docs describe apps with a shared user ID and compatible signing running in one process, and the sharedUserId docs say it was deprecated in API 29, which isn't the same as removed. The name has been pinned in public AOSP since Android 9. The Android 8.0 and 8.1 tags have no name selector at all, so the shared UID alone may have been enough there.
In July 2022 I put it together as ControlFixShell. The manifest declares the shared Linux identity of the system shell package along with the matching process name, and it's signed with the platform key these cabinets trust. The native side reads the serial encoder and creates the virtual controllers through uinput. It ran on real cabinet hardware, on Android 7, 8 and 9 boards, with no root.
The manifest and release APK are dated July 18, 2022, and it targets SDK 29 with a minimum of 23. I'm not posting the original APK or source. The interesting part is two lines of manifest and what the system does with them.
I've since reproduced the mechanism on emulators, removing one ingredient at a time, to show which piece does what. With both, the app runs as UID 2000 in the shell domain, /dev/uinput opens, and the kernel registers a virtual device. With the process name but no shared UID, it gets its own UID in the platform_app domain and uinput is denied. With the shared UID but no process name, the process dies at startup. With neither, it's just a platform-signed app, and uinput is denied. Platform signing on its own isn't enough. The pair is the trick.

Why it works
The trick isn't breaking anything. It's finding the one identity the platform already trusts and getting your app admitted to it. Platform-signed system apps are more powerful than most people assume, and a lot of the restrictions that shape what an Android app can do stop applying when the app's identity changes.
They aren't outside the security model, though. They sit in a more trusted tier of it, and that tier still has walls. In my tests the shell identity could create an input device but still couldn't open the camera or microphone nodes, create a raw socket, or bind a privileged port. The restrictions that bind an ordinary app aren't a universal property of Android. They're a property of the identity the app has.

A lock that only checks the name
Look at how the policy is written. The shell domain is pinned twice: only UID 2000, and only a process named com.android.shell, plus a neverallow that says UID 2000 can't run under any other process name.
The history says what that was for. In October 2017 Nick Kralevich's commit Ensure only com.android.shell can run in the shell domain said: "Don't allow apps to run with uid=shell or selinux domain=shell unless the package is com.android.shell." The comment it added to seapp_contexts is just as plain: "only the package named com.android.shell can run in the shell domain."
The lines it added to seapp_contexts:
# only the package named com.android.shell can run in the shell domain
neverallow domain=shell name=((?!com\.android\.shell).)*
neverallow user=shell name=((?!com\.android\.shell).)*
So the goal was a package gate, and ControlFixShell is, in plain terms, a package other than com.android.shell running in the shell domain. That's exactly what the commit set out to prevent. The policy can't see packages, though. What zygote hands it is the process name, and an app chooses the names of its own processes. My package was com.selinuxpoc, my process was com.android.shell, and the row matched. Think about why you'd pin both. The name check only earns its place if you believe something could run in UID 2000 without being the shell app, and they had exactly that case, as the next paragraph shows. I believe the name check was meant as extra gating on top of the UID, and the design didn't account for an app simply declaring that name for one of its own processes. It isn't spoofing at runtime. The name is declared in the manifest and checked when the process starts, so an app that declares it passes.
It had a rough start, too. Three days after it landed it was reverted, because com.google.android.traceur, a package that had been running in the shell UID, started crashing with No match for app with uid 2000 ... name com.google.android.traceur. That's the same crash anyone gets today by adding the shared UID alone. The change was re-landed in January 2018, and traceur has its own non-shell domain now.
I consider the result a gap in the policy, and in a way a vulnerability, though one that needs a key the platform trusts to use. As a lock on "only the real shell package," the pin holds only if nothing else can get into UID 2000, and the only thing standing between an app and UID 2000 is the signature check on the shared UID (and, since Android 15, an allowlist on top of it). The name was the missing piece, and the app supplies it.
That seam is really the subject of this post. SELinux decides by process identity, Android's permission system decides by package, and a rule written to bridge the two can only check what it can actually see. Understanding where one model stops and the other starts is what let me get an app admitted to an identity it was never supposed to reach.
You might ask why not just update the shell app itself with a better build. It's more fun to introduce your own app, but it's also a worse deal. On Android 15 the real shell package is marked updatableSystem="false", and when I tried installing a platform-signed com.android.shell with a higher version on an emulator, the install was refused: "Installation of this package is not allowed." The Android 14 build I tried let it through. It also broke things. The shell UID takes its permissions from what the packages in it request, and my minimal replacement requested nothing, so adb shell immediately lost the right to dump packages. A replacement has to carry everything the real app did. Adding a second app to the identity gets you the domain and leaves the original alone.
What gets you in is a key
The signature check is the one gate that matters, and it comes down to who holds the key. On a phone whose maker guards it, an app can't do this. Key custody is uneven in the real world, though. "Production device" tells you how the firmware was built, not who can sign for it.
It isn't rare for devices that aren't phones to ship signed with the public AOSP test keys, which means the "secret" is a file in the source tree. I've run into that more than once myself, and I'm not going to name devices. NCC Group has written about release builds signed with publicly known keys, and a paper from JKU reports AOSP test keys in production firmware across devices from different SoC vendors. Real keys have walked out the door too. In late 2022 Google's Android Partner Vulnerability Initiative reported that platform certificates were being used to sign malware, with certificates reportedly tied to Samsung, LG, MediaTek and smaller vendors like Revoview and Szroco. Rapid7's summary is a good short read.
The cabinets are a case in point. The APKs I built for them (ControlFix, ControlFixShell and two serial services) all carry the signing certificate SHA-256 c8a2e9bc...2ab8, which is the fingerprint of the public AOSP platform test certificate. The cabinets accepted them as platform apps. The README says the app lands in system_app because of its platform signature. So on that hardware the platform key was a file in the AOSP tree.
Three things get conflated here. The build variant (user, userdebug, eng), the build tags (release-keys or test-keys), and the key that actually signed the platform are independent. A vendor can ship a user build, run it through the normal release signing tooling, and still use AOSP's public keys, because the tooling doesn't care whether a key is secret. AOSP's own signing script rewrites the tags to release-keys by default, whatever keys you hand it, so I'd treat the build tags as a hint, not a verdict. What matters is the certificate on the platform apps.
Embedded hardware makes "only the manufacturer holds it" hard to defend. There are often several companies between the chip and the brand on the box, and more hands near the firmware means more places for a key to end up. So I don't trust any list of devices where this is or isn't possible. Check the device, not the category.
One more thing about the key itself. Everything above assumes a signature can't be forged without the private key. For the platform certificate these cabinets trust, that's a 2048-bit RSA key, and the public half sits in every APK signed with it. If RSA ever falls to a quantum computer, the gate stops being "who holds the key" and becomes "who can derive it." That isn't today's problem. Gidney's 2025 estimate puts RSA-2048 at under a million noisy qubits and roughly a week of runtime, which is far closer than older numbers but still a machine that doesn't exist, and Google's own write-up on tracking the cost of quantum factoring follows the same trend. It matters for embedded gear because that gear lives for a decade and its platform key is baked into the firmware.
Android is working on the signing side. APK Signature Scheme v3.2 in Android 17 adds a hybrid of a classical key and an ML-DSA key, and Google describes the wider plan in its post-quantum Android write-up. A hybrid scheme only helps devices new enough to check it. Boards on Android 7, 8 and 9 will only ever verify the classical signature, so for them the platform key stays an RSA key for the rest of their life.
The manifest doesn't tell you
Two things I learned along the way matter more than the joystick, and both are about where Android actually enforces things.
First, native code and Java code are policed by different people. A framework call is checked against the app's permissions: the manifest declares them, the system grants them, and the runtime ones come with a prompt. Native code never goes through that. When a native binary opens a device node or a socket, the kernel decides, based on the process's UID, its groups, its capabilities and its SELinux domain. The manifest isn't consulted. That's how the same app can be turned away at one door and waved through another, and why the native side of my diagnostic could open /dev/uinput with nothing Settings would ever show.
Second, a shared UID shares grants. The test app's own manifest asked for almost nothing, and the Settings screen for it agrees: its Permissions entry lists a single item, Notifications. But the app shares a UID with the real shell package, and the grants are tracked for the shared UID, not for each package. When the app asked the framework about sensitive permissions it never declared, the answer was granted. Nothing was requested, nothing prompted, and nothing shows up on screen.

That's the Android-side lesson. Install screens, Settings and most app audits read the package's own manifest. For an app in a shared UID, the manifest tells you what the app asked for, not what it can do. If you're auditing an embedded image, the question to ask is which UID the app runs as and who else is in it.
More than a joystick
The joystick is the boring use of this identity. The network side is worth a note, because it shows how native code sees the world.
What counts for native code is the Linux identity the process carries: its UID, its groups, its capabilities and its SELinux domain. The shell identity includes the inet group, so a native binary running under it can open network sockets even though the app's manifest declares nothing. My diagnostic declared no permissions at all and could still open TCP sockets. A platform-signed control with the same empty manifest and no shared UID couldn't, and failed with "operation not permitted." The shell identity could also read /proc/net/tcp, which the control couldn't, and ordinary apps have been blocked from that since Android 10 (the Android 10 privacy changes page lists the /proc/net restriction).
It has limits. A raw ICMP socket and binding a privileged port on loopback both failed, because those need Linux capabilities that the shell identity doesn't carry. So what you get is outbound network access that never shows up in the app's declared permissions, plus a look at network state that ordinary apps don't get.
On hardware you control, that's mundane. On a device whose key has leaked, it's one more thing an app signed with that key gets for free.
Where Android is going
Android has noticed this area. Starting in Android 15, a platform-signed app that isn't part of the system image has to be explicitly allowlisted before it can join a platform-signed shared UID. The documentation is short and worth reading, and the implementation was authored in February 2024 and landed on the release branch in March. The same check shows up in the Android 14 QPR3 source. System apps are exempt, and non-system ones need an entry or the install fails. Android 15 also marks the real shell package as non-updatable, which closes the "just replace it" route too.

It's worth being precise about what that covers. The check is skipped on debuggable builds, which is what the current emulator images are, so the reproduction above runs straight through it. I haven't tested a production build. The allowlist also only governs non-system apps joining at install time. It does nothing about someone who can ship a platform-signed system app or modify the system image, which is exactly what a cabinet reflash is. It closes the sideload route on patched builds. The key is still the boundary.
Zoom out and the commit trail shows Google working on this seam for years. The 2017 pin tried to keep the shell domain for the real shell package. In June 2022 a change tried to reject data apps that shared a privileged app's UID and signature and requested privileged permissions, and it was reverted a couple of months later. In December 2023 another change tried to block platform-signed non-system apps from joining platform UIDs outright. It was reverted in February, and a few days after that the allowlist version landed, which is the one that stuck. The name pin and the allowlist are two different answers to the same question: who gets to be in a trusted UID.

When I first worked this out in 2022, I talked it over with Google engineers, off the record. The allowlist landed about a year and a half later. It's possible that conversation played some part, and I can't prove it either way, so I'm not claiming it. It just belongs in the story.
Why write it up
Because at the time it was thought not to be possible, and I'd proven that it was, using a trick and a lot of reading SELinux policy. If you're somewhere similar, with hardware you own, a platform key you can sign with (yours, or the public AOSP one the device happens to ship with), and a peripheral Android's normal app sandbox won't let you near, the answer to "do I have to root this" may be no. It was for me, on real cabinet hardware.
System apps are more powerful than they look. What you need is the right identity, and knowing how Android assigns one is more useful than assuming the limits on ordinary apps apply to everyone.
If you build or audit embedded Android, a few checks are cheap. Look at what the firmware is actually signed with. Compare the certificate on platform apps like the shell package against the public AOSP platform test certificate from AOSP's build/target/product/security:
apksigner verify --print-certs Shell.apk
# the public AOSP platform test certificate to compare against
SHA-256: c8a2e9bccf597c2fb6dc66bee293fc13f2fc47ec77bc6b2b0d52c11f51192ab8
Don't trust the build tags alone, since a build signed with the public keys can still say release-keys. Look for platform-signed apps that aren't part of the system image. On newer builds, confirm the shared UID allowlist is actually in place and not just present in the source tree.
It started as a stubborn point about a cabinet, a serial encoder and a stick that wouldn't talk to the OS, and I wanted to prove it could be done without root. I ended up reading the Android security model's source and finding out the rules are a lot more interesting than the folklore.

Comments