Termux on Google Play (Android / Bionic / linker64)
A Bionic-native Linux userspace runs under a current target SDK by never asking the kernel to execute a file from the app's writable data directory.
| Field | Value |
|---|---|
| Language | Java app; C LD_PRELOAD shim; shell/Make package recipes; Go and C patches |
| License | App GPL-3.0 (terminal libraries Apache-2.0); termux-exec Apache-2.0; packages under their own terms |
| Repository | termux-apps, termux-exec, termux-packages, termux-tools |
| Documentation | Organization README; termux-exec README |
| Category | Shared kernel; exec redirection through the system dynamic linker |
| Prerequisites | Bionic-linked packages; libc-mediated exec; APK-bundled loaders for anything else |
| Custom app fit | The exec contract transfers to any app; the package universe is Bionic, not aarch64-linux Nix |
| First / latest | First Play release June 7, 2024; inspected app googleplay.2026.10.09 (versionCode 142) |
Overview
What it solves
Upstream Termux kept targetSdkVersion at Android 9 so that downloaded packages stayed executable, which locked it out of Google Play. The organization README states the trade it reversed: “Android 10 disallowed executing downloaded files directly. The Termux app avoided that by using a targetSdkVersion of Android 9 … Termux was not able to be updated on Google Play starting in 2020”. The Play build is a separate code base that targets the current API level, drops sharedUserId, and requests fewer permissions.
Design philosophy
The restriction is an SELinux rule about execve(2), not about executable memory. AOSP's app_neverallows.te forbids execute_no_trans on app_data_file for every untrusted app except the legacy target-SDK domains, calling it “a W^X violation (loading executable code from a writable home directory)”. untrusted_app_all.te keeps two neighboring permissions for every app: mapping app data executable (allow untrusted_app_all app_data_file:file { r_file_perms execute }, the dlopen path) and executing the system linker (allow untrusted_app_all system_linker_exec:file execute_no_trans, added because “Chrome Crashpad uses the the dynamic linker to load native executables from an APK”). termux-exec's README names the escape those two permissions combine into: “instead of executing an ELF file directly, executes /system/bin/linker64 /path/to/elf … the kernel sees only /system/bin/linker64 being executed.” Everything else in the fork — the app launcher, the Go and PRoot patches, the /proc/self/exe emulation, the removed packages — exists to keep that one substitution invisible to programs, or to route around the cases it cannot cover.
How it works
The two executable locations
An app targeting API 29 or later may execve system files and the APK's extracted native libraries, which app.te grants as apk_data_file:file { … x_file_perms }; Android 10's behavior notes say apps “should load only the binary code that's embedded within an app's APK file” (execute permission). The Play app uses both locations deliberately:
- The data directory holds packages;
linker64runs them.TermuxShellUtilsstarts every session by executing/system/bin/linker64with the real ELF as its first argument whenever the target lies under/data/data/com.termux/files, and setsLD_PRELOAD=$PREFIX/lib/libtermux-exec.sofor every child. - The native-library directory holds what
linker64cannot run. The app build downloads PRoot's static loader intosrc/main/jniLibs/<abi>/libproot-loader.soand setsjniLibs.useLegacyPackaging = true, so the package manager extracts it to an executable location.TermuxInstaller.setupAppLibSymlinklinks$FILES/applibtonativeLibraryDir, giving package recipes a stable path to it.
The bootstrap itself does not come from the network at first run. The build embeds the ~24 MB per-ABI bootstrap-<arch>.zip into libtermux-bootstrap.so with an .incbin (assembly), and the installer extracts it into a staging prefix, applies SYMLINKS.txt, marks bin/, libexec and the APT helpers 0700, then renames the prefix into place. The entry-name canonicalization carries the comment “Silence google play scanning flagging about this”, linking Google's zip-path-traversal advisory (installer).
The exec rewrite
execve in termux-exec runs in every process that inherits LD_PRELOAD:
- Rewrite
/bin/xand/usr/bin/x(and shebang interpreters) to$PREFIX/bin/x, then normalize the path without resolving symlinks —$PREFIX/bin/lsmust stayls, not becomecoreutils. - Read the first 255 bytes. An ELF proceeds; a
#!line yields the interpreter and at most one argument; anything else returnsENOEXEC. - If the real path lies under the data directory (or is
/system/bin/sh), issueexecve("/system/bin/linker64", [argv0, target, (interp-arg, script,) args…])and addTERMUX_EXEC__PROC_SELF_EXE=<target>to the environment. Otherwise stripLD_PRELOAD,LD_LIBRARY_PATHand that variable, and execute directly. - If the file cannot even be opened, clean the environment and pass the call through, which keeps KernelSU's virtual
/system/bin/suworking (termux-apps#10).
The dynamic linker accepts this because Bionic made it directly executable in a 2018 commit first shipped in Android 10. That commit also states the cost the rest of the fork pays: “The linker adjusts the argc/argv passed to main() … but doesn't adjust the auxv vector or files like /proc/self/{exe,cmdline,auxv,stat}. Those files will report that the kernel loaded the linker as an executable.” The linker then maps the target and its libraries with mmap(PROT_EXEC), which the policy above still allows for app data files. exec-variants.c reimplements execv, execvp, execvpe, execl* and fexecve on top of the hooked execve because, as its header says, “For some reason these are only necessary starting with Android 14 - before that intercepting execve() is enough.” system(3) and popen(3) were fixed separately in termux-exec 1.4.
Run the route model to see the rewrite and its limits on synthetic headers (output identical on any host):
dub docs/research/android-dev-env/termux-play-store/examples/exec-route.dIt prints, for example, execve: /system/bin/linker64 ls /data/data/com.termux/files/usr/bin/ls -l for a package binary and linker64 cannot link glibc: needs PRoot's APK loader … for a Nix store executable.
Repairing what the rewrite breaks
For every process started through the rewrite, the kernel records linker64 as the executable. The fork repairs the visible consequences one mechanism at a time:
| Breakage | Repair | Evidence |
|---|---|---|
readlink("/proc/self/exe") → linker64 | termux-exec hooks readlink(3) and realpath(3) to answer from TERMUX_EXEC__PROC_SELF_EXE; /proc/<pid>/exe is answered by reading that process's /proc/<pid>/environ | termux-readlink.c, termux-realpath.c |
Programs that read /proc/self/exe with raw syscalls or bypass libc | Per-package patches: LLVM's getMainExecutable, procps, pulseaudio, vtm, kitty, android-tools, zellij, lua-language-server | LLVM patch; org README changelog |
Go's os/exec issues raw execve | The Go toolchain is patched: os.StartProcess reads the header itself and prepends linker64 for ELFs and shebangs; os.Executable returns argv instead of /proc/self/exe | exec_posix.go patch, executable_procfs.go patch |
Non-cgo Go binaries see linker64's argv | runtime.goargs drops the extra leading argument when cgo is disabled, because Bionic's argument adjustment is only visible to code that goes through its libc | runtime1.go patch |
| Go downloads an unpatched toolchain | The build fails unless the pinned Go equals the latest release, because “a newer go version in go.mod lead[s] to a prebuilt toolchain (which lacks the Termux patches)” | termux_setup_golang.sh diff |
| PRoot extracts and executes its loader | The loader is built as libproot-loader-<arch>.so, shipped in the APK, and the path is hard-coded to $FILES/applib/libproot-loader.so | proot/build.sh, enter.c patch |
memfd executable mappings | libffi is built with ac_cv_func_memfd_create=no | commit a4d1756c13 |
su must not inherit the shim | termux-tools' su wrapper unsets LD_PRELOAD and opts out of termux-exec | su.in |
What the fork removed instead
Some packages left the repository instead, for mixed reasons. Against the last merged upstream revision, 24 packages/ and 7 x11-packages/ directories are gone (a few only renamed, such as pipes.sh → pipes-sh and openjdk-17 → openjdk-21/-25), among them zig (“Remove zig for now as it does not work with android-10 termux-exec”, commit 95e4f10b3e), the whole glibc-repo (“Remove glibc support for simplicity”, commit a356aadb31), valgrind and pypy/pypy3 (“for now”, no reason given), and cabal-install, lfortran and qt5-qtwebengine, which did not build. Only the first two are stated consequences of the exec model. Packages build at API level 30 instead of upstream's 24, for the three ABIs aarch64, arm and x86_64 — i686 was dropped. Packages are served from the separate termux.net repository with a dedicated signing key, so F-Droid and Play prefixes never share binaries (bootstrap generator diff, repo.json). The maintainer's standard answer is that it “uses a package repository with modifications to be able to run under the updated targetSdk that Google Play requires, which so far has no mirrors” (termux-issues#46); termux-tools' mirror selection was removed accordingly.
Analysis
Deployment and permissions
Device experiments on an Android 14 phone reproduce the mechanism below in a target-36 build of the Sparkles terminal: direct execution from app data fails, the linker64 route and dlopen work, and a static ELF runs only from the APK. A patched nix-on-droid bootstrap then works end to end with PRoot and its loader in the APK.
The inspected app declares minSdkVersion=30 and targetSdkVersion=37 (gradle.properties), one level above Play's floor: since August 31, 2026, “New apps and app updates must target Android 16 (API level 36) or higher” (target API policy). Under seapp_contexts that target places it in the plain untrusted_app domain, where nix-on-droid's target 28 places it in untrusted_app_27. It needed no root, no exemption and no kernel change: the workaround uses only operations the platform still grants to every app.
The technical gate and the policy gate are different. Play's Device and Network Abuse policy says an app “may not download executable code (such as dex, JAR, .so files) from a source other than Google Play”, exempting only code that “runs in a virtual machine or an interpreter”. Termux's own maintainers do not claim the linker64 route satisfies it. The termux.dev grant post (November 2024) calls system_linker_exec a “hack” that “will likely get patched by Android as it is a security risk and cannot be relied on as a long term solution and is also not compliant with Google PlayStore policies”, and recommends the APK native-library route as “The solution that is approved by Android”; agnostic-apollo's documentation repeats that it “is not compliant with Google PlayStore Policies”. Fredrik Fornwall, who maintains the Play build, framed it in the upstream review as “a temporary workaround … not a perfect solution, but I think it's the best one”. The app has nonetheless passed review continuously since June 2024. What Termux overcame is the target-SDK exec ban; no public source records an exemption from the download clause, so the app's presence shows only that review has not applied it so far.
Upstream's announcement of the release was explicit: the Play build “is functionally equivalent to v0.108”, lacks the RUN_COMMAND intent, and its exec route “violates PlayStore policies, so the PlayStore release may be taken down in future” (termux-app discussion #4000).
The permission and component surface was reshaped for review, not only for the SDK bump. The organization README records that sharedUserId “is deprecated and did not pass the Google Play review” and that “the initial Google Play review did not approve the usage of multiple permissions.” Review then removed Termux:Boot from the store “due to not providing significant functionality”, and after “An initial appeal was overturned” it was folded into the app (termux-apps#47). The response was consolidation: Termux:Boot and Termux:Widget became components of the main APK in October 2024, and roughly twenty Termux:API commands — clipboard, notifications, SAF, camera info, microphone, speech — are now implemented in the app itself, so no second APK needs the old shared UID. Termux:API, Termux:Tasker and Termux:Float remain unavailable on Play. The manifest declares a specialUse foreground service with a written justification (a user serving pages to a browser while Termux is backgrounded); Play reviews that subtype and asks for “a link to a video demonstrating each foreground service feature” (declaration requirements). It also declares MANAGE_EXTERNAL_STORAGE, although terminals are not among the policy's listed uses. Review first rejected it — “Your app's usage of the permission must fall within permitted uses” — and accepted a resubmission that cited IDE apps already holding it (termux-apps#18); termux-setup-storage requests it since version 0.128. Supporting 16 KB pages, added in 2025.10.05, is required of Play updates targeting API 35+ from February 1, 2027 (page-size guide).
Nix compatibility and services
The workaround is Bionic-specific. linker64 links against Bionic's libc.so; it cannot run an aarch64-linux glibc executable, whose PT_INTERP names a glibc ld-linux-aarch64.so.1 that the kernel will not execute from app data either. The fork removed upstream's optional glibc repository rather than solve that. For nix-on-droid the usable precedent is the PRoot path: PRoot rewrites every tracee execve into an execve of its loader, the loader maps the target and its interpreter with mmap, and the Play build makes that legal by shipping the loader as an APK native library. PRoot's get_loader_path already honors PROOT_LOADER even in its bundled build, so the existing nix-on-droid proot-static needs no loader patch — only a location the kernel will execute, for itself and for the loader.
Terminal and no-DEX integration
The entire mechanism is native: an LD_PRELOAD library, an argument vector and a path convention. Nothing depends on Java except the launcher, whose decision is a dozen lines (setupShellCommandArguments). A NativeActivity app can make the same decision before execve in its PTY child. The Play app's own adaptations that do need managed code — notification permission prompts, SAF, MANAGE_EXTERNAL_STORAGE, foreground-service promotion — are lifecycle and permission matters, not execution ones.
Files, networking and DNS
Shared storage is reached through MANAGE_EXTERNAL_STORAGE and symlinks under ~/storage, the same layout as the F-Droid build; it is not executable in either. Networking is unchanged by the workaround. Targeting API 37 has a networking cost of its own: “Android 17 blocks local network access (ping, ssh, etc. to LAN devices) by default for apps targeting SDK 37+”, so the app requests ACCESS_LOCAL_NETWORK since July 2026 (commit f8809967).
Performance and isolation
Exec through linker64 adds the header read, a realpath and one getenv per exec; the loaded program then runs natively. There is no tracer, unlike PRoot. The workaround weakens nothing the kernel enforces: it is exactly what the policy permits, which is also why it offers no isolation beyond the app UID. The LD_PRELOAD contract is fragile rather than slow: a program that clears its environment, or a static helper that execs, silently loses the rewrite.
Lifecycle and maintenance
The route rests on two allow rules Google keeps for compatibility, and the policy shows it watching them. app_data_file execute carries an auditallow, so every such mapping is logged, and the newer storage-area type is already denied execute with the comment “execute cannot be blocked on all of app_data_file without causing backwards compatibility issues (see b/237289679)” (app_neverallows.te). Each target bump also moves the app into a domain with fewer compatibility grants: at Android 17, untrusted_app_34 (targets 34–36) still allows ashmem ioctls on memfd files, while the target-37 untrusted_app does not — a constraint on libandroid-shmem, whose own targetSdk fix the README dates January 13, 2026, before the bump to 37. A future target domain without app_data_file execute would break linker64 and PRoot alike; only executables shipped inside the APK would survive. Android 17 moved one step in that direction for target 37: “All native files loaded using System.load() must be marked as read-only” (Android 17 behavior changes). The rule as documented covers System.load, not the system linker's own mappings, and the app has shipped at target 37 since googleplay.2026.06.21; agnostic-apollo nonetheless expects “The system linker hack would likely break though unless apt is patched” to install files read-only (termux-app#2155).
Process lifetime is unchanged by the Play build. Android 12's phantom-process limit (32 by default) still kills a session's whole process group, surfacing as [Process completed (signal 9)] (termux-app#2366); Android 14 added “Disable child process restrictions” to Developer options, which resets when Developer options are switched off.
The cost is permanent divergence. termux-packages carries 1,285 changed files against its upstream merge base, and termux-apps is a rewrite rather than a patch series. Upstream merges are manual and periodic (the inspected main last merged upstream on June 21, 2026). Each Go release must be re-patched before the toolchain ships, and every newly packaged program that inspects its own executable is a potential regression. The org README still calls the split “a temporary one as things stabilises”.
Extent of the workaround
The status column comes from upstream sources and reports; the last column records what the device experiments observed.
The issue tracker (1,122 issues up to #1653 on October 16, 2026, 361 open; 446 were closed on January 11, 2026 alone) records where the table below comes from. The maintainer's diagnosis recurs in it: “Termux on Google Play is not allowed to execute …/usr/bin/tmux directly, instead it executes /apex/com.android.runtime/bin/linker64 …” (termux-issues#149), and the standing rule is that “you need to keep the LD_PRELOAD environment variable around while spawning sub processes” (termux-issues#24). Relative interpreter paths once failed with linker64's “error: expected absolute path” (#76, closed). Breakpoints that never trigger under gdb (#744) and Go binaries from outside Termux's toolchain receiving their own path as argv[1] (termux-exec#9) remain open.
| Workload | Status on the Play build | Local device evidence |
|---|---|---|
Packages from termux.net | Works: Bionic-dynamic ELFs and shebang scripts through linker64 | E2 observes the ELF route only; packages/scripts untested |
| User-compiled C/C++/Rust with Termux's clang | Works: the outputs are Bionic-dynamic and exec through libc | E1/E2 observe a cross-compiled Bionic D ELF, not these toolchains |
Go programs built with Termux's golang | Works through the patched os/exec and runtime; Go toolchains fetched by GOTOOLCHAIN lack the patches | Still source-inspected / upstream-reported |
| Static executables (Zig/musl, static Go) | Fails under termux-exec: linker64 does not load them; an unmerged September 2025 branch would hand ET_EXEC files to a termux-elf-loader not yet packaged | E4 observes linker rejection of a static Bionic ELF and execution of its identical APK-native copy; other toolchains untested |
Raw-execve programs outside libc | Fails unless patched or run under PRoot | Still source-inspected; E1 uses libc execve, not a raw-syscall payload |
| glibc executables (glibc repo, Nix store) | Not provided; possible only under PRoot with the APK loader | E5 observes glibc hello; E6 observes the experimental signed-cache/compiler/Git/local-build workflow and restart |
| PRoot distributions | Works since app 0.126 with the APK-shipped loader | E6 completes a patched nix-on-droid bootstrap; not evidence for every distribution or firmware |
Programs that inspect /proc/self/exe | Works when hooked or patched; unpatched raw readers see linker64 | E2 observes unhooked identity; E9 observes the Play preload's path correction |
Debugging with gdb | Open: breakpoints reported not to stop (#744) | E9 locally reproduces a missed main breakpoint in Play Termux/GDB 16.3-3 |
| Plugins and add-ons | Boot and Widget merged; about twenty API commands built in; Termux:API, Tasker, Float absent | Source-inspected / upstream-reported; not locally tested |
Strengths
- Current target SDK, Play distribution and no root, using only operations every app retains.
- Exec indirection is native and small; the kernel-visible change is one path substitution.
- The APK-native-library route generalizes to anything known at build time: loaders, launchers and helpers can ship inside the APK.
Weaknesses
- Correctness depends on
LD_PRELOADreaching every process and every program going through libc. - Static, glibc and raw-syscall executables need per-package patches, PRoot or removal.
- A permanent fork of the package repository, toolchains and app, with a separate binary repository.
- Tolerated rather than sanctioned: the maintainers themselves call the route non-compliant with Play's executable-code policy and expect Android to close it.
Key design decisions and trade-offs
| Decision | Rationale | Trade-off |
|---|---|---|
execve the system linker, not the file | The kernel checks only the exec'd file's label | /proc/self/exe, argv and static ELFs need emulation or fail |
LD_PRELOAD interposition | Covers every libc-mediated exec without rebuilding apps | Lost when environments are cleared; blind to raw syscalls |
Ship loaders as lib*.so in the APK | Native-library files remain executable | Loader updates require an app release |
| Embed the bootstrap in a native library | No first-run download; extraction is a local transaction | ~24 MB per ABI in the APK |
| Merge plugins into one APK | No sharedUserId; fewer permissions per review | Larger app; several plugins still missing |
Separate termux.net repository | Different API level, prefix assumptions and patches | No binary sharing with F-Droid; duplicate maintenance |
Sources
- Organization README (status, rationale, release history) and issue tracker.
termux-execsource, README,execvariants,readlinkandrealpathhooks.- App launcher, installer, build, manifest.
- Go patches, PRoot loader packaging, bootstrap generator.
- Bionic direct linker execution; PRoot loader lookup.
- SELinux policy at
android17-release:app_neverallows.te,untrusted_app_all.te,app.te,seapp_contexts. - Play policy: target API, executable code, all-files access, foreground services; 16 KB pages.
- Maintainer statements: termux.dev, upstream announcement, agnostic-apollo,
termux-exec-package#24; review events intermux-apps#47and#18. - Source ledger; exec-route model.