← Back to Pull requests

Reject malformed wheel record paths #14257

Open
unknown opened this pull request with 313 lines diff across 3 files
View on GitHub
unknown unknown commented on Aug 17, 2026 01:57 UTC
Author

<!---
Thank you for your pull request! Before submitting, please make sure you've:

  • Read the CONTRIBUTING.md file carefully

  • Added a news file fragment (see https://pip.pypa.io/en/latest/development/contributing/#news-entries)

  • -->

    What does this PR do?

    Fixes #10118.

    A malformed wheel RECORD entry such as ./ can cause pip to treat the installation root as package-owned.

    A later update, reinstall, or uninstall can then remove unrelated files from site-packages.

    This PR hardens RECORD path handling.

    On install:

    empty paths are rejected;
    absolute wheel paths are rejected;
    paths that resolve to the installation root are rejected;
    validation happens before installation file operations begin.

    On uninstall:

    entries that resolve to the installation root are rejected;
    entries that name real directories are rejected;
    valid relative file paths continue to work;
    valid absolute installed RECORD file paths continue to work;
    symlinks continue to identify the symlink itself rather than the directory they point to.

    Absolute paths are valid in an installed RECORD. This includes Windows cases where pip cannot make a path relative because the file and lib_dir are on different logical disks.

    The tests cover these cases directly.

    Verification

    The exact submitted commit was independently verified with FalseGreen against a frozen verification contract.

    The verification covers:

    relative and absolute paths resolving to the installation root;
    relative and absolute real-directory entries;
    valid relative file entries;
    valid absolute installed RECORD file entries;
    Windows different-logical-disk path conversion;
    relative and absolute symlink-directory entries;
    the original malformed ./ install and uninstall regression.

    6/6 verification criteria passed.

    Verified source:

    a650ad175ea02c5d0fd5a17b8000736c75af0e3e

    The verification is scoped to these criteria. It does not claim broader correctness of pip.

    PR Checklist:

  • I agree to follow the PSF Code of Conduct.

  • I have read and have followed the CONTRIBUTING.md file.

  • I have added a news file fragment (or this PR does not need one).

  • I have read and followed the AI_POLICY.md file, and if any AI tools were used, I have disclosed it below.
  • Assisted-by: Codex

    Diff: 313 lines (+234 / -79) across 3 files Reviewer: 2ykwang Review duration: 153555m
    All Vouch review confidence checks passed
    Residual risk 0.28 = Change Risk (0.47) × (1 − Review Confidence (0.41)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.47 · 313 lines diff across 3 files
    0.47
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    40%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.344
    Shallow Review Depth shallow_review_depth
    0.344
    Real PR Conversation Timeline
    1 comments
    "Review active on #14257"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 40.9% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 47.3% (MEDIUM) · Higher = larger blast radius
    47.3%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 40.9% · Lower = rushed or shallow review
    40.9%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 27.9% · Safe to merge
    27.9%
    Repository