Skip to content

Don't print control characters from wheel contents to the terminal - #708

Open
varun3257 wants to merge 1 commit into
pypa:mainfrom
varun3257:info-escape-control-chars
Open

varun3257 wants to merge 1 commit into
pypa:mainfrom
varun3257:info-escape-control-chars

Conversation

@varun3257

Copy link
Copy Markdown
Contributor

wheel info is typically run on a wheel you don't trust yet, and it prints the WHEEL and METADATA header values, plus the archive member names with --verbose, exactly as they appear inside the archive. Nothing filters control characters, so a crafted wheel decides what the inspecting terminal gets to see: a Summary of innocent\x1b]52;c;aGFja2Vk\x07 writes the clipboard of OSC 52 capable terminals, and CSI sequences can hide or overwrite neighbouring output lines, letting the displayed metadata lie about the dependencies being shown (CWE-150, the class kubectl fixed as CVE-2021-25743). The same strings reach the terminal through two other spots: main() prints WheelError messages that embed text read from the archive, such as the hash algorithm name from RECORD, and wheel pack echoes a file name assembled from the unpacked .dist-info directory name and the WHEEL tags. The fix replaces non-printable characters with their printable backslash escapes at those output sites, so wheel info on the wheel above now shows the escape sequence as literal text instead of executing it. Messages that only echo paths the user already typed on the command line are left as they are. Includes a regression test covering the metadata fields, the verbose file listing and the error path, and a news entry.

wheel info prints WHEEL and METADATA header values (and archive member
names with --verbose) verbatim, main() prints WheelError messages that
embed strings read from RECORD, and wheel pack echoes a file name
assembled from the unpacked .dist-info directory name and WHEEL tags.
A crafted wheel can use these to emit ANSI/OSC escape sequences into
the terminal of whoever inspects it (clipboard writes via OSC 52,
hidden or overwritten output lines). Replace non-printable characters
with their printable backslash escapes at these output sites.
@codecov

codecov Bot commented Oct 14, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 63.84%. Comparing base (4ae6d07) to head (1a5f4a0).

Files with missing lines Patch % Lines
src/wheel/_commands/info.py 94.73% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #708      +/-   ##
==========================================
+ Coverage   63.54%   63.84%   +0.30%     
==========================================
  Files          15       15              
  Lines        1270     1278       +8     
==========================================
+ Hits          807      816       +9     
+ Misses        463      462       -1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

This branch has not been deployed

No deployments
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.

1 participant