Every CVESearch/Get API key

CVE-2026-141553

termux-sync: Restore extracts archive members outside the backed-up directory because the extraction jail is the parent of each backup root (PyPI)

Explain with AI
ChatGPTClaudeGoogle AI
Severity
5.5Medium
Local attack, no privileges, needs user interactionCVSS 3.1, CVE List
Exploitation
Unknown
No source reports exploitation yet.
Exploit chance
0.33% in 30 days
Percentile27th
EPSS, scored
Listed fix
1.3.8 for termux-sync
From GitHub Advisories and OSV

Overview

termux-sync is an open source tool for backing up and restoring a Termux environment across devices. Prior to 1.3.8, termux-sync checks restored archive members against the parent of each backed-up directory instead of the directory itself. An attacker who controls a backup that a user restores can write files to other locations under the Termux installation prefix, including replacing executables. This can result in arbitrary code execution with the privileges of the Termux user when a replaced executable is run. This issue is fixed in version 1.3.8.

CVSS 3.1 vector

Exploitability

Attack vector
Local
Complexity
Low
Privileges needed
None
User interaction
Required

Impact

Scope
Unchanged
Confidentiality
None
Integrity
High
Availability
None
CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:N/I:H/A:N

Exploit chance over time

Unchanged since Dec 3, 2026
EPSS score 0.33% every day from Dec 3, 2026 to Dec 4, 2026.

Affected

Packages 1

Affected packages
PackageAffectedFixed
termux-sync
PyPI
through 1.3.7
1.3.8
before 1.3.8, plus listed versions
1.1.01.1.11.1.21.2.01.2.1
Show 9 more versionsShow less
1.2.21.2.31.2.41.2.61.2.81.3.01.3.51.3.61.3.7
1.3.8

Products 1

Sources

CVE List Score usedCVSS 3.15.5

termux-sync: Restore extracts archive members outside the backed-up directory because the extraction jail is the parent of each backup root

termux-sync is an open source tool for backing up and restoring a Termux environment across devices. Prior to 1.3.8, termux-sync checks restored archive members against the parent of each backed-up directory instead of the directory itself. An attacker who controls a backup that a user restores can write files to other locations under the Termux installation prefix, including replacing executables. This can result in arbitrary code execution with the privileges of the Termux user when a replaced executable is run. This issue is fixed in version 1.3.8.

Record
CVE-2026-141553
CVSS 3.1
5.5 MediumCVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:N/I:H/A:N
Weakness
CWE-22
Updated
2026-12-03
EUVDEUVD-2026-141822CVSS 3.15.5

termux-sync is an open source tool for backing up and restoring a Termux environment across devices. Prior to 1.3.8, termux-sync checks restored archive members against the parent of each backed-up directory instead of the directory itself. An attacker who controls a backup that a user restores can write files to other locations under the Termux installation prefix, including replacing executables. This can result in arbitrary code execution with the privileges of the Termux user when a replaced executable is run. This issue is fixed in version 1.3.8.

Record
EUVD-2026-141822
CVSS 3.1
5.5 MediumCVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:N/I:H/A:N
Updated
2026-12-03
GitHub AdvisoriesGHSA-x9x8-xcv7-5x5gCVSS 3.15.5

termux-sync: Restore extracts archive members outside the backed-up directory because the extraction jail is the parent of each backup root

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):

        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:

    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…

Record
GHSA-x9x8-xcv7-5x5g
CVSS 3.1
5.5 MediumCVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:N/I:H/A:N
Weakness
CWE-22
Updated
2026-12-03
NVDCVSS 3.15.5

termux-sync is an open source tool for backing up and restoring a Termux environment across devices. Prior to 1.3.8, termux-sync checks restored archive members against the parent of each backed-up directory instead of the directory itself. An attacker who controls a backup that a user restores can write files to other locations under the Termux installation prefix, including replacing executables. This can result in arbitrary code execution with the privileges of the Termux user when a replaced executable is run. This issue is fixed in version 1.3.8.

Record
CVE-2026-141553
CVSS 3.1
5.5 MediumCVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:N/I:H/A:N
Weakness
CWE-22
Updated
2026-12-03
OSVCVSS 3.15.5

termux-sync: Restore extracts archive members outside the backed-up directory because the extraction jail is the parent of each backup root

termux-sync is an open source tool for backing up and restoring a Termux environment across devices. Prior to 1.3.8, termux-sync checks restored archive members against the parent of each backed-up directory instead of the directory itself. An attacker who controls a backup that a user restores can write files to other locations under the Termux installation prefix, including replacing executables. This can result in arbitrary code execution with the privileges of the Termux user when a replaced executable is run. This issue is fixed in version 1.3.8.

Record
CVE-2026-141553
CVSS 3.1
5.5 MediumCVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:N/I:H/A:N
Weakness
CWE-22
Updated
2026-12-03
OSVGHSA-x9x8-xcv7-5x5gCVSS 3.15.5

termux-sync: Restore extracts archive members outside the backed-up directory because the extraction jail is the parent of each backup root

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):

        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:

    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…

Record
GHSA-x9x8-xcv7-5x5g
CVSS 3.1
5.5 MediumCVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:N/I:H/A:N
Weakness
CWE-22
Updated
2026-12-03

The JSON record also has the rest of 2 source descriptions.

History

Recorded by Every CVE

Changes recorded by Every CVE
DayChangedSources
Published dateCVE List, EUVD, NVD
Published dateEUVD
Affected packages, referencesOSV
Affected packages, key facts, referencesGitHub Advisories
Other IDs, referencesOSV
Other IDs, published dateEUVD, NVD
First indexedCVE List

Upstream dates may differ.

References

MoveEnter Open