Skip to content

fix(update): use filter='data' on tarfile.extractall (CVE-2007-4559 / PEP 706)#2285

Open
ktwu01 wants to merge 1 commit into
MoonshotAI:mainfrom
ktwu01:fix/tarfile-extract-filter
Open

fix(update): use filter='data' on tarfile.extractall (CVE-2007-4559 / PEP 706)#2285
ktwu01 wants to merge 1 commit into
MoonshotAI:mainfrom
ktwu01:fix/tarfile-extract-filter

Conversation

@ktwu01
Copy link
Copy Markdown

@ktwu01 ktwu01 commented May 14, 2026

Resolves part of #2273 (the tarfile defense-in-depth piece).

Change

One-line addition of filter="data" to the auto-updater's tarfile.extractall call:

- tar.extractall(tmpdir)
+ tar.extractall(tmpdir, filter="data")  # PEP 706

Why

  • Python 3.12 deprecated extractall() without an explicit filter= argument; Python 3.14 (which .python-version pins) emits a DeprecationWarning, and a future release will raise.
  • filter="data" is the PEP 706-recommended default for trusted sources. It silences the deprecation, future-proofs the call, and provides defense-in-depth path-traversal protection (CVE-2007-4559 family).
  • Consistent with the existing zip-slip protections at src/kimi_cli/cli/plugin.py:73-77 and src/kimi_cli/vis/api/sessions.py:648-657 — the auto-updater was the lone outlier.

Scope

Strictly the 1-line filter addition. The larger SHA-256 / signature manifest piece of #2273 is intentionally not in this PR — that needs maintainer alignment on manifest format and is followed up separately in the issue.

Verification

  • File: src/kimi_cli/ui/shell/update.py:304
  • Code path: only invoked from the bundled-binary auto-updater (_do_update), not user-facing tar extraction.
  • No behavior change for legitimate tarballs Moonshot publishes; rejects malicious entries that would escape tmpdir or set absolute paths.

🤖 Generated with Claude Code


Open in Devin Review

… PEP 706)

The auto-updater extracted the downloaded release tarball without
specifying a filter. Python 3.12 deprecated this; Python 3.14 (which
.python-version pins) emits a DeprecationWarning, and a future
release will raise.

Adding filter='data' is the PEP 706-recommended default for trusted
sources. It silences the deprecation, future-proofs the call, and
provides defense-in-depth path-traversal protection consistent with
the explicit zip-slip checks already present at:

  - src/kimi_cli/cli/plugin.py:73-77
  - src/kimi_cli/vis/api/sessions.py:648-657

Refs MoonshotAI#2273.
Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 1 additional finding.

Open in Devin Review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants