Vulnerabilities in pkg:pypi/termux-sync

PACKAGE
Advisory Identifier: GHSA-x9x8-xcv7-5x5g
Advisory Summary

CVE-2026-141553 is a MODERATE (CVSS 5.5) restore extracts archive members outside vulnerability (CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')) affecting termux-sync libraries in the PyPI ecosystem. The issue involves restore extracts archive members outside the backed-up directory because the extraction jail is the parent of each backup root. Remediation is available by upgrading affected packages to version 1.3.8.

2 Known Advisory Record(s)
Package Vulnerability Intelligence

pkg:pypi/termux-sync

2 Known Advisory Record(s)

Vulnerability advisories affecting package pkg:pypi/termux-sync. Select an advisory below to view technical details or fixes.

Advisory ID CVE / NVD Severity Summary
GHSA-x9x8-xcv7-5x5g CVE-2026-141553 MODERATE termux-sync: Restore extracts archive members outside the backed-up directory because the extraction jail is the parent of each backup root
GHSA-259w-wmqg-fp76 CVE-2026-86046 HIGH termux-sync: Arbitrary file write during restore via attacker-controlled manifest source path

CVE-2026-141553 at a Glance

CVE Identifier CVE-2026-141553
GHSA Identifier GHSA-x9x8-xcv7-5x5g
Severity MODERATE
CVSS v3.1 Base Score 5.5
CWE Classification CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')
Affected Product termux-sync
Package Ecosystem PyPI
Published Date
Last Updated

Security Impact

CVSS: 5.5

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:N/I:H/A:N).

Attack Vector Local (AV:L)
Attack Complexity Low (AC:L)
Privileges Required None (PR:N)
User Interaction Required (UI:R)
Scope Unchanged (S:U)
Confidentiality None (C:N)
Integrity High (I:H)
Availability None (A:N)

How to Fix CVE-2026-141553

To remediate this vulnerability, upgrade all affected termux-sync dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

termux-sync fixed: 1.3.8
pip install termux-sync>=1.3.8
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

pip show termux-sync

How to Check if You Are Affected

To determine whether your Python environment is affected by CVE-2026-141553, inspect your installed packages using pip:

pip show termux-sync

Analyze the terminal output to locate any version of termux-sync in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 1.3.8), your application is affected.

Note: The pip show termux-sync command checks currently installed packages in your active Python environment.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal'), where the product 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 product 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. In termux-sync, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

## Summary `termux-sync restore` extracts each archive into the parent of the directory that archive is supposed to hold. The containment check then compares members against that wider directory, so an archive declared as `usr_etc` or `usr_lib` can write anywhere under `$PREFIX`, including `$PREFIX/bin`. This is a residual gap in the fix for GHSA-259w-wmqg-fp76 / CVE-2026-86046. The guards that advisory added all work. What survives is the choice of destination they are checked against. ## Affected versions Tested on: - Package version: `termux-sync` 1.3.6 installed from PyPI (`termux_sync-1.3.6-py3-none-any.whl`) - Repository commit: `054e6d88acf16c7d9b025846bcc2652b2975c68a` on main - Python: 3.12.16, where `tarfile.data_filter` is available - Dependencies: `rich==15.0.0`, `markdown-it-py==4.3.0`, `mdurl==0.1.2`, `Pygments==2.21.0` - OS: Debian in a container, non-root, no network during the restore Only 1.3.6 was tested. The primitive looks present in earlier releases, but unchecked. Releases before `9c8637b` are already covered by CVE-2026-86046. Main and the release differ only inside `cmd_daemon`. Lines 1 to 700, which hold all the archive and extraction code, are identical, so main has the same behaviour. `termux-sync.py` is a byte-identical copy of `src/termux_sync/__init__.py`, so the line numbers below apply to both. ## Impact An attacker who controls the content of a backup that a victim restores can write files anywhere under `$PREFIX`, overwriting existing ones. Replacing an executable such as `$PREFIX/bin/sh` gives code execution as the Termux user the next time anything invokes it, and it leaves dpkg's record of `$PREFIX` disagreeing with what is on disk. Attacker requirements: - Write access to the backup the victim restores. Nothing on the victim's device. This is the same position GHSA-259w-wmqg-fp76 described: "a victim who restores a malicious backup (local, shared, or from a compromised GitHub/Google Drive storage backend)". A backup shared between people moving to a new device is the use the README describes, and `SECURITY.md:41` already contemplates a GitHub storage repo being public. - The victim runs `termux-sync restore` and answers `y` at the prompt (`__init__.py:1599`). - No authentication, no root, and no non-default configuration. `$PREFIX` is writable by the Termux user by design, which is how `pkg install` works, so no privilege escalation is involved. The restore preview (`__init__.py:1587-1596`) shows the backup name, date, package count and archive count. It does not list member paths, so a victim who inspects it cannot see `bin/sh` in a config archive. ## Root cause `cmd_restore` builds the destination for each manifest key by taking the parent of the backup root (`src/termux_sync/__init__.py:1611-1614`): ```python 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 ``` With `BACKUP_ITEMS` at `:69-74` and `TERMUX_HOME` = `$PREFIX`, `TERMUX_FILES` = `$HOME` (`:66-67`): | manifest key | backup root | resulting jail | what that jail holds | |---|---|---|---| | `home` | `$HOME` | `…/files` | all of `$PREFIX` | | `usr_etc` | `$PREFIX/etc` | `$PREFIX` | `bin/`, `lib/`, `libexec/`, `etc/` | | `usr_lib` | `$PREFIX/lib` | `$PREFIX` | same | The extraction then passes that jail to `extract_archive` at `:1631`, and `_safe_extract_member` (`:555-582`) checks members against it: ```python target = (dest_path / member_name).resolve() try: target.relative_to(dest_root) ``` That check is written correctly. Both sides are resolved, `..` and absolute members are rejected, link targets are checked, device and FIFO entries are refused, and `extract` runs with `filter="data"` at `:601` and `:609`. A member named `bin/sh` in a `usr_etc` archive simply is inside `$PREFIX`, so it passes and gets written. The comment three lines above `:1614` describes the invariant the code is meant to hold: ```python # Build the set of destinations this app is actually willing to restore into. # Manifest-supplied "source" values are attacker-controlled backup content # and must never be trusted as an extraction root — only used to double # check they agree with the known-safe root for that item key. ``` The known-safe root for `usr_etc` is `$PREFIX/etc`. The code uses `$PREFIX`. A backup the project's own code produces can never contain such a member. `create_archive` always adds one tree under `arcname=source_path.name` (`:545`, `:547`), so a real `usr_etc` archive holds only `etc/...`. Nothing checks that a member's first component matches the arcname the writer would have used. `$PREFIX/bin` is not part of the documented restore surface. `FAQ.md:80` lists the four components as the package list, the home directory, `$PREFIX/etc` and `$PREFIX/lib`, and `README.md:49` and `:272-276` say the same. ## Reproduction The PoC is local and non-destructive. It builds a fake Termux layout under a temp directory, points `HOME`, `PREFIX` and `TMPDIR` at it, and writes nothing outside it. Both roots come from those environment variables at `:66-67`, which is how the code behaves on a device. The malicious backup has two archives. `usr_etc.tar.gz`, whose declared surface is `$PREFIX/etc`, contains `etc/motd` (legitimate), `bin/MARKER_from_usr_etc`, `bin/sh` at mode 0755 containing `echo ATTACKER_CODE_RUNS`, and two controls, `../escape_dotdot.txt` and `/abs_escape.txt`. `home.tar.gz`, declared surface `$HOME`, contains `home/.bashrc` (legitimate) and `usr/bin/MARKER_from_home`. Manifest checksums are correct so no checksum prompt fires, and the package list is empty so no `pkg` call happens. Install: ```bash python -m venv /tmp/venv && /tmp/venv/bin/pip install termux-sync==1.3.6 ``` Run the restore through the real entry point: ```bash python -I poc.py /path/to/termux-sync-wrapper ``` Actual result: ```text 1.3.6 /work/venv/lib/python3.12/site-packages/termux_sync/__init__.py Step 2/4 Verifying checksums… ✓ usr_etc.tar.gz 832a54b0130e… ✓ home.tar.gz c2942b552bc8… ⚠ This will overwrite existing files. Proceed with restore? [y/n]: Step 3/4 Extracting archives… usr_etc.tar.gz ✓ home.tar.gz ✓ ✓ Restore completed successfully! === RESULT === ESCAPE $PREFIX/bin/MARKER_from_usr_etc exists=True ESCAPE $PREFIX/bin/MARKER_from_home exists=True expected $PREFIX/etc/motd exists=True expected $HOME/.bashrc exists=True control files/escape_dotdot.txt exists=False control run/escape_dotdot.txt exists=False control /abs_escape.txt exists=False $PREFIX/bin/sh contents after restore: #!/bin/sh echo ATTACKER_CODE_RUNS log tail: [WARNING] Skipped unsafe archive member during restore: Path traversal attempt in archive: '../escape_dotdot.txt' [WARNING] Skipped unsafe archive member during restore: Unsafe absolute path in archive: '/abs_escape.txt' [INFO] Extracted usr_etc.tar.gz → /work/poc/run/files/usr [INFO] Extracted home.tar.gz → /work/poc/run/files [INFO] Restore completed from: termux_backup_evil ``` The two control members were rejected and logged, which is the project's existing guards working. The two escapes are members that never leave the wider jail, so nothing rejects them. The log lines also show the separate destinations, `…/files/usr` for the config archive and `…/files` for the home archive, so each escape is independently attributable. The mode survives `filter="data"` and the replaced file runs: ```text -rw-r--r-- 1 1000 1000 7 MARKER_from_home -rw-r--r-- 1 1000 1000 7 MARKER_from_usr_etc -rwxr-xr-x 1 1000 1000 34 sh --- ATTACKER_CODE_RUNS ``` Expected safe behaviour: a `usr_etc` archive can write only under `$PREFIX/etc`, and `$PREFIX/bin/sh` is untouched. ## The narrow claim The `home` variant is the weaker one. A `home` archive legitimately overwrites `$HOME/.bashrc`, which already gives code execution at the next login shell, so the escape adds less there. The claim to keep is the `usr_etc` and `usr_lib` one. An attacker can ship a manifest that declares only `usr_etc`, with no `home` archive and nothing touching `$HOME`, and still take `$PREFIX/bin`. The victim consented to restoring configuration. One related detail: `usr_lib` is in `BACKUP_ITEMS`, but `cmd_backup` only ever produces `home` and `usr_etc` archives (`:1394-1397`). A manifest containing a `usr_lib` key is therefore always forged, and it is accepted anyway. ## Suggested fix Jail each item to its own root instead of the parent, and drop the leading component when extracting. Alternatively keep extracting into the parent and require each member to start with the arcname that key would really produce, which is the smaller change and leaves the archive format alone: ```python expected = Path(item_root).name + "/" # "etc/", "lib/", "home/" if member.name != expected.rstrip("/") and not member.name.startswith(expected): raise ValueError(...) ``` `_safe_extract_member` needs no change. A regression test fits next to `test_extract_rejects_hardlink_escaping_destination` in `tests/test_audit_fixes.py:200`: a `usr_etc` archive containing `bin/sh` must leave `$PREFIX/bin/sh` alone. ## One thing that couldn't be tested `install_packages` (`:441-464`, called from `cmd_restore:1641`) passes manifest-supplied package names into `["pkg", "install", "-y", pkg]`. A name starting with `-` would reach apt as an option rather than a package, and some apt options run commands. This could not be reproduced without Termux's `pkg` wrapper and a writable dpkg, so this is not claimed and not part of this report. A `--` separator before the package name would close it cheaply. ## Scope of what was verified Everything above ran against the published 1.3.6 wheel, including the containment decision and the overwrite. The one simulated part is the filesystem layout: `$HOME` and `$PREFIX` point at container directories rather than a real Android install, and this wasn't run on a device. The rest of the package appears clean. All ten `subprocess` call sites use argument lists with no `shell=True`. There is no `pickle`, `yaml.load`, `eval`, `exec` or `os.system` outside tests. Config is written 0o600 and re-chmodded (`:153-161`), `export-config` redacts the token (`:2319-2323`), and untrusted strings reaching the console go through `rich.markup.escape`. `tsctl` and `install.sh` extract a single member matched by name and clean up with a trap. The CI workflows take no untrusted PR content into a `run:` block. ## Disclosure AI tooling was used while investigating and drafting this. Every measurement above comes from a run the reporter executed and checked, on the published package rather than a checkout, and the one simulated element is labelled where it appears. *Fix*: Fixed in 1.3.7. Restore now requires every archive member to start with the folder name the backup would have produced (`etc`, `lib`, `home`), and package names from the manifest are validated and passed to `pkg install` after `--`. Users should upgrade and only restore backups they created themselves.

CVE-2026-141553 Affected termux-sync Versions

1 component(s)
Fixed Versions:
1.3.8
Product / Package Ecosystem Affected Versions Fixed Version
termux-sync
PyPI
< 1.3.8
1.3.8

References

Frequently Asked Questions

What is CVE-2026-141553?
CVE-2026-141553 is a security vulnerability in termux-sync involving Restore extracts archive members outside the backed-up directory because the extraction jail is the parent of each backup root under CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal').
Which termux-sync versions are affected?
Affected versions include releases prior to 1.3.8 across affected packages: termux-sync.
What version fixes CVE-2026-141553?
Upgrading to 1.3.8 (or the latest patched release for your respective branch) resolves the vulnerability.
Is termux-sync affected?
Yes, termux-sync is affected in releases prior to 1.3.8. Upgrade your dependency to 1.3.8 or later.
What is the CVSS score of CVE-2026-141553?
CVE-2026-141553 has a CVSS v3.1 base score of 5.5 (MODERATE) with vector string CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:N/I:H/A:N.
What CWE is associated with CVE-2026-141553?
CVE-2026-141553 is classified under CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal') (The product 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 product 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.).
How can I check PyPI dependencies for CVE-2026-141553?
Run the dependency tree command: 'pip show termux-sync'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-x9x8-xcv7-5x5g",
  "modified" : "2026-12-03T02:36:05Z",
  "published" : "2026-12-03T02:36:05Z",
  "aliases" : [ "CVE-2026-141553" ],
  "summary" : "termux-sync: Restore extracts archive members outside the backed-up directory because the extraction jail is the parent of each backup root",
  "details" : "## Summary\n\n`termux-sync restore` extracts each archive into the parent of the directory that archive is supposed to hold. The containment check then compares members against that wider directory, so an archive declared as `usr_etc` or `usr_lib` can write anywhere under `$PREFIX`, including `$PREFIX/bin`.\n\nThis is a residual gap in the fix for GHSA-259w-wmqg-fp76 / CVE-2026-86046. The guards that advisory added all work. What survives is the choice of destination they are checked against.\n\n## Affected versions\n\nTested on:\n\n- Package version: `termux-sync` 1.3.6 installed from PyPI (`termux_sync-1.3.6-py3-none-any.whl`)\n- Repository commit: `054e6d88acf16c7d9b025846bcc2652b2975c68a` on main\n- Python: 3.12.16, where `tarfile.data_filter` is available\n- Dependencies: `rich==15.0.0`, `markdown-it-py==4.3.0`, `mdurl==0.1.2`, `Pygments==2.21.0`\n- OS: Debian in a container, non-root, no network during the restore\n\nOnly 1.3.6 was tested. The primitive looks present in earlier releases, but unchecked. Releases before `9c8637b` are already covered by CVE-2026-86046.\n\nMain and the release differ only inside `cmd_daemon`. Lines 1 to 700, which hold all the archive and extraction code, are identical, so main has the same behaviour. `termux-sync.py` is a byte-identical copy of `src/termux_sync/__init__.py`, so the line numbers below apply to both.\n\n## Impact\n\nAn attacker who controls the content of a backup that a victim restores can write files anywhere under `$PREFIX`, overwriting existing ones. Replacing an executable such as `$PREFIX/bin/sh` gives code execution as the Termux user the next time anything invokes it, and it leaves dpkg's record of `$PREFIX` disagreeing with what is on disk.\n\nAttacker requirements:\n\n- Write access to the backup the victim restores. Nothing on the victim's device. This is the same position GHSA-259w-wmqg-fp76 described: \"a victim who restores a malicious backup (local, shared, or from a compromised GitHub/Google Drive storage backend)\". A backup shared between people moving to a new device is the use the README describes, and `SECURITY.md:41` already contemplates a GitHub storage repo being public.\n- The victim runs `termux-sync restore` and answers `y` at the prompt (`__init__.py:1599`).\n- No authentication, no root, and no non-default configuration. `$PREFIX` is writable by the Termux user by design, which is how `pkg install` works, so no privilege escalation is involved.\n\nThe restore preview (`__init__.py:1587-1596`) shows the backup name, date, package count and archive count. It does not list member paths, so a victim who inspects it cannot see `bin/sh` in a config archive.\n\n## Root cause\n\n`cmd_restore` builds the destination for each manifest key by taking the parent of the backup root (`src/termux_sync/__init__.py:1611-1614`):\n\n```python\n        allowed_roots = {}\n        for item_key, _label, item_root in BACKUP_ITEMS:\n            if item_root is not None:\n                allowed_roots[item_key] = Path(item_root).resolve().parent\n```\n\nWith `BACKUP_ITEMS` at `:69-74` and `TERMUX_HOME` = `$PREFIX`, `TERMUX_FILES` = `$HOME` (`:66-67`):\n\n| manifest key | backup root | resulting jail | what that jail holds |\n|---|---|---|---|\n| `home` | `$HOME` | `…/files` | all of `$PREFIX` |\n| `usr_etc` | `$PREFIX/etc` | `$PREFIX` | `bin/`, `lib/`, `libexec/`, `etc/` |\n| `usr_lib` | `$PREFIX/lib` | `$PREFIX` | same |\n\nThe extraction then passes that jail to `extract_archive` at `:1631`, and `_safe_extract_member` (`:555-582`) checks members against it:\n\n```python\n    target = (dest_path / member_name).resolve()\n    try:\n        target.relative_to(dest_root)\n```\n\nThat check is written correctly. Both sides are resolved, `..` and absolute members are rejected, link targets are checked, device and FIFO entries are refused, and `extract` runs with `filter=\"data\"` at `:601` and `:609`. A member named `bin/sh` in a `usr_etc` archive simply is inside `$PREFIX`, so it passes and gets written.\n\nThe comment three lines above `:1614` describes the invariant the code is meant to hold:\n\n```python\n        # Build the set of destinations this app is actually willing to restore into.\n        # Manifest-supplied \"source\" values are attacker-controlled backup content\n        # and must never be trusted as an extraction root — only used to double\n        # check they agree with the known-safe root for that item key.\n```\n\nThe known-safe root for `usr_etc` is `$PREFIX/etc`. The code uses `$PREFIX`.\n\nA backup the project's own code produces can never contain such a member. `create_archive` always adds one tree under `arcname=source_path.name` (`:545`, `:547`), so a real `usr_etc` archive holds only `etc/...`. Nothing checks that a member's first component matches the arcname the writer would have used.\n\n`$PREFIX/bin` is not part of the documented restore surface. `FAQ.md:80` lists the four components as the package list, the home directory, `$PREFIX/etc` and `$PREFIX/lib`, and `README.md:49` and `:272-276` say the same.\n\n## Reproduction\n\nThe PoC is local and non-destructive. It builds a fake Termux layout under a temp directory, points `HOME`, `PREFIX` and `TMPDIR` at it, and writes nothing outside it. Both roots come from those environment variables at `:66-67`, which is how the code behaves on a device.\n\nThe malicious backup has two archives. `usr_etc.tar.gz`, whose declared surface is `$PREFIX/etc`, contains `etc/motd` (legitimate), `bin/MARKER_from_usr_etc`, `bin/sh` at mode 0755 containing `echo ATTACKER_CODE_RUNS`, and two controls, `../escape_dotdot.txt` and `/abs_escape.txt`. `home.tar.gz`, declared surface `$HOME`, contains `home/.bashrc` (legitimate) and `usr/bin/MARKER_from_home`. Manifest checksums are correct so no checksum prompt fires, and the package list is empty so no `pkg` call happens.\n\nInstall:\n\n```bash\npython -m venv /tmp/venv && /tmp/venv/bin/pip install termux-sync==1.3.6\n```\n\nRun the restore through the real entry point:\n\n```bash\npython -I poc.py /path/to/termux-sync-wrapper\n```\n\nActual result:\n\n```text\n1.3.6 /work/venv/lib/python3.12/site-packages/termux_sync/__init__.py\n\n  Step 2/4  Verifying checksums…\n  ✓ usr_etc.tar.gz  832a54b0130e…\n  ✓ home.tar.gz  c2942b552bc8…\n  ⚠ This will overwrite existing files.\n  Proceed with restore? [y/n]:\n  Step 3/4  Extracting archives…\n  usr_etc.tar.gz ✓\n  home.tar.gz ✓\n  ✓ Restore completed successfully!\n\n=== RESULT ===\n  ESCAPE  $PREFIX/bin/MARKER_from_usr_etc      exists=True\n  ESCAPE  $PREFIX/bin/MARKER_from_home         exists=True\n  expected $PREFIX/etc/motd                    exists=True\n  expected $HOME/.bashrc                       exists=True\n  control files/escape_dotdot.txt              exists=False\n  control run/escape_dotdot.txt                exists=False\n  control /abs_escape.txt                      exists=False\n\n$PREFIX/bin/sh contents after restore:\n  #!/bin/sh\n  echo ATTACKER_CODE_RUNS\n\nlog tail:\n  [WARNING] Skipped unsafe archive member during restore: Path traversal attempt in archive: '../escape_dotdot.txt'\n  [WARNING] Skipped unsafe archive member during restore: Unsafe absolute path in archive: '/abs_escape.txt'\n  [INFO] Extracted usr_etc.tar.gz → /work/poc/run/files/usr\n  [INFO] Extracted home.tar.gz → /work/poc/run/files\n  [INFO] Restore completed from: termux_backup_evil\n```\n\nThe two control members were rejected and logged, which is the project's existing guards working. The two escapes are members that never leave the wider jail, so nothing rejects them. The log lines also show the separate destinations, `…/files/usr` for the config archive and `…/files` for the home archive, so each escape is independently attributable.\n\nThe mode survives `filter=\"data\"` and the replaced file runs:\n\n```text\n-rw-r--r-- 1 1000 1000  7 MARKER_from_home\n-rw-r--r-- 1 1000 1000  7 MARKER_from_usr_etc\n-rwxr-xr-x 1 1000 1000 34 sh\n---\nATTACKER_CODE_RUNS\n```\n\nExpected safe behaviour: a `usr_etc` archive can write only under `$PREFIX/etc`, and `$PREFIX/bin/sh` is untouched.\n\n## The narrow claim\n\nThe `home` variant is the weaker one. A `home` archive legitimately overwrites `$HOME/.bashrc`, which already gives code execution at the next login shell, so the escape adds less there.\n\nThe claim to keep is the `usr_etc` and `usr_lib` one. An attacker can ship a manifest that declares only `usr_etc`, with no `home` archive and nothing touching `$HOME`, and still take `$PREFIX/bin`. The victim consented to restoring configuration.\n\nOne related detail: `usr_lib` is in `BACKUP_ITEMS`, but `cmd_backup` only ever produces `home` and `usr_etc` archives (`:1394-1397`). A manifest containing a `usr_lib` key is therefore always forged, and it is accepted anyway.\n\n## Suggested fix\n\nJail each item to its own root instead of the parent, and drop the leading component when extracting. Alternatively keep extracting into the parent and require each member to start with the arcname that key would really produce, which is the smaller change and leaves the archive format alone:\n\n```python\nexpected = Path(item_root).name + \"/\"      # \"etc/\", \"lib/\", \"home/\"\nif member.name != expected.rstrip(\"/\") and not member.name.startswith(expected):\n    raise ValueError(...)\n```\n\n`_safe_extract_member` needs no change. A regression test fits next to `test_extract_rejects_hardlink_escaping_destination` in `tests/test_audit_fixes.py:200`: a `usr_etc` archive containing `bin/sh` must leave `$PREFIX/bin/sh` alone.\n\n## One thing that couldn't be tested\n\n`install_packages` (`:441-464`, called from `cmd_restore:1641`) passes manifest-supplied package names into `[\"pkg\", \"install\", \"-y\", pkg]`. A name starting with `-` would reach apt as an option rather than a package, and some apt options run commands. This could not be reproduced without Termux's `pkg` wrapper and a writable dpkg, so this is not claimed and not part of this report. A `--` separator before the package name would close it cheaply.\n\n## Scope of what was verified\n\nEverything above ran against the published 1.3.6 wheel, including the containment decision and the overwrite. The one simulated part is the filesystem layout: `$HOME` and `$PREFIX` point at container directories rather than a real Android install, and this wasn't run on a device.\n\nThe rest of the package appears clean. All ten `subprocess` call sites use argument lists with no `shell=True`. There is no `pickle`, `yaml.load`, `eval`, `exec` or `os.system` outside tests. Config is written 0o600 and re-chmodded (`:153-161`), `export-config` redacts the token (`:2319-2323`), and untrusted strings reaching the console go through `rich.markup.escape`. `tsctl` and `install.sh` extract a single member matched by name and clean up with a trap. The CI workflows take no untrusted PR content into a `run:` block.\n\n## Disclosure\n\nAI tooling was used while investigating and drafting this. Every measurement above comes from a run the reporter executed and checked, on the published package rather than a checkout, and the one simulated element is labelled where it appears.\n\n*Fix*: Fixed in 1.3.7. Restore now requires every archive member to start with the folder name the backup would have produced (`etc`, `lib`, `home`), and package names from the manifest are validated and passed to `pkg install` after `--`. Users should upgrade and only restore backups they created themselves.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:N/I:H/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "termux-sync"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "1.3.8"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 1.3.7"
    }
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/djunekz/termux-sync/security/advisories/GHSA-x9x8-xcv7-5x5g"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-141553"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/djunekz/termux-sync/commit/3dd44a266cc9fba816c684164067616c7c0ef61d"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/djunekz/termux-sync/commit/40a016331662c2c161f6045657b374fd00c05811"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/djunekz/termux-sync"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/djunekz/termux-sync/releases/tag/v1.3.8"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-22" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-12-03T02:36:05Z",
    "nvd_published_at" : "2026-12-02T20:20:40Z"
  }
}