Nov 17, 2026·11 min read·1 visit
termux-sync versions prior to 1.2.4 are vulnerable to path traversal (CVE-2026-86046) during archive restoration. By manipulating manifest.json source paths or embedding traversal sequences inside tar archives, an attacker can achieve arbitrary file write and subsequent code execution when a user restores an untrusted backup. Users must upgrade to version 1.2.4.
A path traversal vulnerability (CWE-22) in termux-sync prior to version 1.2.4 allows an attacker to overwrite arbitrary files within the Termux environment during the backup restoration process. The flaw stems from the application trusting attacker-controlled extraction paths defined in the backup's manifest.json file, failing to validate archive members against directory traversal sequences during tar extraction, and using unsanitized backup names when constructing temporary directories. If a user restores a malicious backup archive from local storage, shared folders, GitHub, or Google Drive, an attacker can overwrite sensitive configuration files such as shell startup scripts or local binaries, resulting in arbitrary code execution under the privileges of the Termux user.
termux-sync is an open-source, Python-based command-line utility developed to back up and restore Termux environments, configurations, and package states across Android devices. The tool operates by packaging designated directories and configuration files into compressed tar archives alongside a metadata file named manifest.json. Users can export these backups to or import them from local disk storage, shared device directories, remote GitHub repositories, or Google Drive.
In versions prior to 1.2.4, the restoration mechanism implemented in termux-sync contains multiple path traversal weaknesses classified under CWE-22 (Improper Limitation of a Pathname to a Restricted Directory). When executing the termux-sync restore command, the utility parses the untrusted manifest.json file contained within the backup archive and extracts the accompanying .tar member archives without validating destination boundaries or sanitizing file paths.
The primary attack surface is exposed when a user imports and restores a backup archive originating from an external or untrusted source, such as a shared community dotfiles repository on GitHub or a public cloud storage link. Because the restoration routine implicitly trusts both the structural metadata in manifest.json and the member headers within the .tar archives, an attacker can direct file extraction to arbitrary locations on the filesystem.
While the process runs within the Android application sandbox assigned to Termux, successful exploitation grants the attacker arbitrary file write capabilities across any directory writable by the Termux user. By overwriting shell initialization files (such as ~/.bashrc or ~/.zshrc) or replacing executable binaries in $PREFIX/bin, an attacker can transition from arbitrary file overwrite to persistent code execution upon the next shell invocation.
The vulnerability in termux-sync prior to version 1.2.4 is the result of three distinct but compounding input validation failures across the cmd_restore() and extract_archive() functions. Each flaw independently allows an archive to escape its intended extraction directory.
The first flaw resides in how cmd_restore() determines the target extraction directory for each sub-archive listed in manifest.json. As the function iterates through the dictionary returned by manifest.get("files", {}).items(), it reads the source property directly from the untrusted JSON object and assigns Path(info.get("source", str(TERMUX_FILES))).parent as the destination root (src_dir). Furthermore, the application fails to verify whether the dictionary key corresponds to a legitimate, predefined backup category in BACKUP_ITEMS. Consequently, an attacker can define arbitrary keys in manifest.json and set the source attribute to any path on the filesystem, instructing termux-sync to extract the payload archive directly into the parent directory of that path.
The second flaw occurs inside extract_archive(), which handles the unpacking of tar archives using Python's standard tarfile module. The function iterates over tf.getmembers() and passes each TarInfo object directly to tf.extract(member, dest_path) without verifying that the resolved target path remains within dest_path. In Python versions prior to 3.12, or when the PEP 706 filter="data" parameter is omitted, tarfile.extract() honors absolute paths, relative .. traversal sequences, and symbolic or hard links pointing outside the extraction root. An attacker can embed member names such as ../../../../home/.bashrc or include symlinks pointing to sensitive directories followed by regular files writing through those links.
The third flaw involves the construction of the temporary working directory at the start of cmd_restore(). The application constructs the temporary path using string interpolation: Path(os.environ.get("TMPDIR", ...)) / f"restore_{backup_name}". Because backup_name is not sanitized to strip path separators or parent directory references (..), supplying a crafted backup_name allows directory creation and initial archive unpacking to traverse outside the designated temporary directory structure.
Comparing the vulnerable implementation in termux-sync 1.2.3 against the patch introduced in commit 9c8637b280ee3e126885def5ff5b326c289ee7cf (v1.2.4) illustrates the exact mechanics of the flaw and the defense-in-depth measures applied to resolve it.
<= 1.2.3)In versions up to 1.2.3, cmd_restore() and extract_archive() operated without path normalization, boundary verification, or manifest key whitelisting:
# Vulnerable temporary directory creation in cmd_restore()
tmp_dir = Path(os.environ.get("TMPDIR", "/data/data/com.termux/files/usr/tmp")) / f"restore_{backup_name}"
tmp_dir.mkdir(parents=True, exist_ok=True)
# Vulnerable manifest processing in cmd_restore()
for key, info in manifest.get("files", {}).items():
archive = tmp_dir / info["archive"]
# BUG 1: Directly trusts the 'source' path from untrusted manifest.json
src_dir = Path(info.get("source", str(TERMUX_FILES))).parent
try:
extract_archive(archive, src_dir, info["archive"], progress)
# Vulnerable extraction routine in extract_archive()
with tarfile.open(archive_path, "r:*") as tf:
for member in tf.getmembers():
try:
# BUG 2: No traversal check, symlink validation, or PEP 706 filter
tf.extract(member, dest_path, set_attrs=True)
except Exception:
try:
member.uid = os.getuid()
member.gid = os.getgid()
tf.extract(member, dest_path, set_attrs=False)1.2.4)Commit 9c8637b280ee3e126885def5ff5b326c289ee7cf modifies both src/termux_sync/__init__.py and termux-sync.py to enforce strict input validation across four layers.
First, backup_name is sanitized using os.path.basename() after normalizing backslashes, and explicitly rejected if it resolves to ., .., or contains path separators:
# FIX 1: Sanitize backup_name before constructing tmp_dir
safe_backup_name = os.path.basename(str(backup_name).replace("\\", "/")).strip()
if not safe_backup_name or safe_backup_name in (".", "..") or "/" in safe_backup_name:
console.print(f" [red]✗ Invalid backup name: {backup_name!r}[/red]")
return
backup_name = safe_backup_nameSecond, cmd_restore() eliminates reliance on the source field inside manifest.json. Instead, it builds an allowed_roots dictionary mapped exclusively from the hardcoded BACKUP_ITEMS configuration. If a manifest key does not exist in allowed_roots, extraction for that entry is aborted:
# FIX 2: Derive destination roots strictly from internal BACKUP_ITEMS whitelist
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().parent
for key, info in manifest.get("files", {}).items():
archive = tmp_dir / info["archive"]
src_dir = allowed_roots.get(key)
if src_dir is None:
console.print(f" [red]✗ Refusing unknown/untrusted restore target for {key!r}[/red]")
log("WARNING", f"Refused restore for unknown manifest key: {key!r}")
continueThird, the patch introduces _safe_extract_member() to validate every TarInfo entry prior to extraction, alongside enabling Python's data_filter (PEP 706) when supported by the runtime:
# FIX 3: Comprehensive member validation before extraction
def _safe_extract_member(member: tarfile.TarInfo, dest_path: Path):
dest_root = dest_path.resolve()
member_name = member.name
# Reject absolute paths
if member_name.startswith("/") or member_name.startswith("\\"):
raise ValueError(f"Unsafe absolute path in archive: {member_name!r}")
# Reject explicit parent traversal segments
if any(part == ".." for part in Path(member_name).parts):
raise ValueError(f"Path traversal attempt in archive: {member_name!r}")
# Verify canonicalized target path resides within canonicalized dest_root
target = (dest_path / member_name).resolve()
try:
target.relative_to(dest_root)
except ValueError:
raise ValueError(f"Archive member escapes destination: {member_name!r} -> {target}")
# Validate symbolic and hard link targets stay within dest_root
if member.issym() or member.islnk():
link_target = member.linkname
if os.path.isabs(link_target):
raise ValueError(f"Unsafe absolute link target in archive: {member_name!r} -> {link_target!r}")
resolved_link = (target.parent / link_target).resolve()
try:
resolved_link.relative_to(dest_root)
except ValueError:
raise ValueError(f"Archive link escapes destination: {member_name!r} -> {link_target!r}")
# Block special device nodes and FIFOs
if member.ischr() or member.isblk() or member.isfifo():
raise ValueError(f"Refusing device/fifo entry in archive: {member_name!r}")The remediation in v1.2.4 addresses the identified attack vectors by combining static target whitelisting, pre-extraction path canonicalization (Path.resolve() paired with relative_to()), link target boundary verification, and Python 3.12+ filter="data" enforcement. One subtle consideration in sequential tar extraction is symlink race or two-stage symlink traversal (where member A creates a valid internal symlink subdir/link -> . or similar, and member B traverses through it). However, because _safe_extract_member calls .resolve() on dest_path / member_name dynamically as each member is processed in sequence, any previously extracted symlink on disk is resolved by the operating system during the target = (dest_path / member_name).resolve() check, preventing two-stage symlink escapes outside dest_root.
Exploiting CVE-2026-86046 requires convincing a victim user to restore a crafted backup archive using termux-sync restore. Because termux-sync is specifically designed to synchronize environments across devices via GitHub repositories, Google Drive, or local files, distributing a weaponized backup archive disguised as a pre-configured Termux theme or development environment is a realistic delivery mechanism.
An attacker can achieve arbitrary file overwrite through two distinct techniques within the archive structure:
source Path ManipulationThe attacker constructs a backup package containing a manifest.json file that specifies a target file inside the Termux home or binary directory as the source attribute. Because cmd_restore() uses Path(info.get("source")).parent as the extraction directory (src_dir), setting source to /data/data/com.termux/files/home/.bashrc causes src_dir to evaluate to /data/data/com.termux/files/home.
{
"timestamp": "2026-07-28T12:00:00",
"files": {
"custom_stage": {
"archive": "payload.tar.gz",
"source": "/data/data/com.termux/files/home/.bashrc"
}
}
}The attacker then packs a normal file named .bashrc (with no traversal characters required in the tar member header) inside payload.tar.gz. When extract_archive() unpacks payload.tar.gz into src_dir, it directly overwrites /data/data/com.termux/files/home/.bashrc.
Alternatively, the attacker leaves manifest.json pointing to a standard backup key and constructs payload.tar.gz using Python's tarfile module to insert relative traversal sequences (../../) or absolute paths directly into the TarInfo.name header:
import io
import tarfile
payload_content = b"#!/data/data/com.termux/files/usr/bin/sh\nid > /data/data/com.termux/files/home/pwned.txt\n"
with tarfile.open("payload.tar.gz", "w:gz") as tf:
info = tarfile.TarInfo(name="../../../../data/data/com.termux/files/home/.bashrc")
info.size = len(payload_content)
info.mode = 0o755
tf.addfile(info, io.BytesIO(payload_content))termux-sync restore.termux-sync unpacks the outer container into $TMPDIR/restore_<backup_name> and reads manifest.json..bashrc in the user's home directory (or a binary in /data/data/com.termux/files/usr/bin/) is overwritten with attacker-controlled shell commands.The severity of CVE-2026-86046 is rated as High with a CVSS v3.1 base score of 7.1 (CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:N/I:H/A:H). The Attack Vector is Local (AV:L) and User Interaction is Required (UI:R) because exploitation depends on the user manually initiating the restoration of a malicious or tampered backup archive. Once triggered, Attack Complexity is Low (AC:L) and requires no additional privileges (PR:N).
The direct technical impact is High Integrity (I:H) and High Availability (A:H) within the scope of the Termux user context (S:U). An attacker can overwrite any file writable by the Termux UNIX user (u0_a* on Android). Overwriting critical shared libraries in $PREFIX/lib, package database metadata in $PREFIX/var/lib/dpkg, or core binaries in $PREFIX/bin can corrupt the environment and render the Termux installation inoperable.
Although the CVSS vector records Confidentiality Impact as None (C:N) because the archive extraction step itself only writes files and does not directly exfiltrate data, the practical secondary impact includes complete compromise of confidentiality. By overwriting shell startup scripts (~/.bashrc, ~/.profile, ~/.zshrc) or SSH configurations (~/.ssh/config, ~/.ssh/authorized_keys), an attacker achieves arbitrary code execution on subsequent shell startup. From that execution context, the attacker can read SSH private keys, cloud provider credentials, API tokens stored in environment variables, and any shared Android storage (~/storage/shared) mounted into Termux.
> [!NOTE] > As of the latest threat intelligence assessment, CVE-2026-86046 has an EPSS score of 0.00266 (18.70th percentile), indicating a low probability of widespread opportunistic exploitation. It is not listed in the CISA Known Exploited Vulnerabilities (KEV) catalog, and no public weaponized exploits have been observed in the wild.
To remediate CVE-2026-86046, users must update termux-sync to version 1.2.4 or later, which incorporates commit 9c8637b280ee3e126885def5ff5b326c289ee7cf.
termux-syncIf installed via pip, upgrade the package directly within the Termux environment:
pip install --upgrade "termux-sync>=1.2.4"If running termux-sync directly from a cloned Git repository, pull the latest release tag and verify the commit hash:
git fetch --all --tags
git checkout v1.2.4In environments where upgrading immediately is not feasible, apply the following operational controls:
termux-sync restore on backup archives downloaded from untrusted third-party sources, public GitHub dotfiles repositories, or unverified cloud storage links.manifest.json and list the member paths of all internal .tar archives to verify the absence of .. segments, leading slashes, or unexpected symlink targets:
# Inspect manifest.json for unexpected keys or modified 'source' paths
cat manifest.json
# List tar members and check for '../', leading '/', or '->' link targets
tar -tvf archive_member.tar.gz | grep -E '(^/|\.\./|->)'Users who have previously restored untrusted backups using termux-sync < 1.2.4 should audit their Termux installation for indicators of compromise. Specifically, inspect ~/.bashrc, ~/.bash_profile, ~/.zshrc, ~/.profile, and ~/.ssh/authorized_keys for unauthorized modifications, and verify the integrity of installed packages in $PREFIX/bin.
CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:N/I:H/A:H| Product | Affected Versions | Fixed Version |
|---|---|---|
termux-sync djunekz | < 1.2.4 | 1.2.4 |
| Attribute | Detail |
|---|---|
| Vulnerability ID | CVE-2026-86046 / GHSA-259w-wmqg-fp76 |
| Weakness Class | CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal') |
| CVSS v3.1 Score | 7.1 High (CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:N/I:H/A:H) |
| EPSS Score | 0.27% (18.70th Percentile) |
| Affected Versions | termux-sync < 1.2.4 |
| Patched Version | termux-sync 1.2.4 |
| Primary Impact | Arbitrary File Write leading to Local Code Execution via Shell Startup Modification |
| CISA KEV Status | Not Listed |
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.
SpamScope mail-parser versions 3.8.0 prior to 4.6.0 contain a path traversal vulnerability (CWE-22) within the write_attachments() and write_sample() functions. The library passes untrusted attachment filenames directly into os.path.join() without stripping directory components, validating path containment, or verifying symbolic links. An attacker can send a crafted email containing relative path traversal sequences or absolute filesystem paths in the Content-Disposition header to write or overwrite arbitrary files accessible to the parsing process.
A Regular Expression Denial of Service (ReDoS) vulnerability exists in SpamScope mail-parser versions 4.2.0 prior to 4.6.1. Two separate regular expressions evaluated during standard email header parsing exhibit quadratic to cubic backtracking complexity when processing headers padded with whitespace or angle brackets. An unauthenticated remote attacker can exploit this flaw by sending a small, RFC-compliant email message, causing parsing worker threads or processes to stall at 100% CPU utilization for extended periods.
CVE-2026-129297 is an origin validation vulnerability (CWE-345) in the Python library mail-parser prior to version 4.6.2. The MailParser.get_server_ipaddress() method fails to properly isolate MTA-recorded client IP addresses from sender-controlled text within email Received headers. Due to naive substring delimiter matching, appearance-based regular expression scanning, and fail-open header traversal, remote attackers can spoof their originating IP address to bypass email security controls, blocklists, and anti-spam attribution.
CVE-2026-129299 (GHSA-24mq-4vc6-2prf) is a parsing and serialization flaw in SpamScope mail-parser prior to version 4.6.2. The library uses reflective Python attribute resolution (getattr) over untrusted email header names and applies caller convenience transformations (such as underscore-to-hyphen folding and _json/_raw suffix stripping) directly to wire headers. An unauthenticated remote attacker can send crafted emails that trigger uncaught TypeError exceptions during JSON serialization or cause security-relevant headers and body content to be silently dropped without setting defect indicators.
CVE-2026-129236 is a command-line argument injection vulnerability (CWE-88) in Kubeshark, an eBPF-based network observability tool for Kubernetes. Located within the Model Context Protocol (MCP) server implementation in cmd/mcpRunner.go, the flaw occurs when handling the start_kubeshark tool request. When the MCP server runs with the --allow-destructive flag, the callStartKubeshark function appends the caller-supplied pod_regex parameter directly to the kubeshark tap argument slice without an end-of-options (--) delimiter. Because Kubeshark uses the Cobra and pflag libraries for command-line parsing, any pod_regex value prefixed with a hyphen is interpreted as a CLI flag rather than a positional regular expression. An attacker capable of influencing MCP tool arguments, such as through indirect prompt injection against a connected Large Language Model (LLM) agent, can inject the --set flag to override Helm chart values like tap.docker.registry. Because Kubeshark deploys its worker DaemonSet with privileged security contexts and host networking enabled, redirecting the container image registry allows arbitrary code execution as root across all Kubernetes cluster nodes.
Kubeshark versions 53.1.0 prior to 53.4.0 contain an arbitrary file write and path traversal vulnerability (CWE-22) alongside an argument injection vulnerability (CWE-88) in the Model Context Protocol (MCP) server implementation (cmd/mcpRunner.go). The download_file tool fails to validate caller-supplied path and dest arguments, allowing an attacker who influences an AI agent driving kubeshark mcp to write Kubeshark Hub API responses to arbitrary locations writable by the local user. Additionally, the start_kubeshark tool appends the pod_regex argument without flag delimiters, allowing argument injection into the kubeshark tap subcommand.