← Back to Pull requests

Reject author credits if encoded #20649

Closed
JacobCoffee closed this pull request without merging on Oct 27, 2026 05:04 UTC
View on GitHub
JacobCoffee JacobCoffee commented on Oct 02, 2026 16:36 UTC
Author

Some build backends (I think only PDM, really) emit MIME-encoded author and maintainer metadata that PyPI displays literally, so this rejects values containing ?= at upload time and requires plain Unicode instead.

Alternative to #20622

Closes #20622
Fixes #18930

Diff: 16 lines (+15 / -1) across 2 files Reviewer: JacobCoffee Review duration: 35307m
All Vouch review confidence checks passed
Residual risk 0.10 = Change Risk (0.59) × (1 − Review Confidence (0.83)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.59 · 16 lines diff across 2 files
0.59
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.70 · 5 substantive comment(s)
0.70
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 50%
83%
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.170
Self Review self_review
0.140
Sensitive Paths sensitive_paths
0.059
Real PR Conversation Timeline
16 items
chatgpt-codex-connector[bot] chatgpt-codex-connector[bot] commented on Oct 02, 2026 16:36 UTC
Bot

<!-- codex-pull-request-review-summary -->

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

| Review | Status | Commit | Review trigger |
| --- | --- | --- | --- |
| 📝 Code Review | ✅ Completed <relative-time datetime="2026-10-02T16:39:08.492021Z">2026-10-02T16:39:08.492021Z</relative-time> | 219d94e | PR opened |

<details> <summary>ℹ️ About Codex in GitHub</summary>
<br/>

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review

  • Mark a draft as ready

  • Comment "@codex review" or "@codex security review".
  • Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

    </details>

    JacobCoffee JacobCoffee commented on code on Oct 02, 2026 16:38 UTC
    Code Review
    warehouse/forklift/metadata.py:1
    @@ -197,6 +136,15 @@ def _validate_metadata(metadata: Metadata, *, backfill: bool = False):
                     )
                 )
     
    +    errors.extend(

    🤖 suggested this below but i did whats present instead, happy to go either way or no way (close pr) or whatever we think is best in an effort to not do that decoding thing in #20622

    # Require plain Unicode credits rather than MIME encoded-words.
    for field in ("author", "author_email", "maintainer", "maintainer_email"):
        if (value := getattr(metadata, field)) is not None and "?=" in value:
            email_name = _RAW_TO_EMAIL_MAPPING[field]
            errors.append(
                InvalidMetadata(
                    email_name,
                    f"{email_name!r} field must not contain '?='. "
                    "Use plain Unicode instead of MIME encoded-words.",
                )
            )
    

    chatgpt-codex-connector[bot] chatgpt-codex-connector[bot] commented on code on Oct 02, 2026 16:39 UTC
    Code Review
    warehouse/forklift/metadata.py:1
    @@ -136,6 +136,15 @@ def _validate_metadata(metadata: Metadata, *, backfill: bool = False):
                     )
                 )
     
    +    errors.extend(
    +        InvalidMetadata(
    +            _RAW_TO_EMAIL_MAPPING[field],
    +            "'?=' is not allowed. Use plain Unicode instead of MIME encoding.",
    +        )
    +        for field in ("author", "author_email", "maintainer", "maintainer_email")
    +        if "?=" in (getattr(metadata, field) or "")

    <sub><sub>!P2 Badge</sub></sub> Match MIME encoded words instead of every ?=

    When a legitimate plain-text credit contains these adjacent characters, such as Author: Why?= Research Group, this condition rejects the upload even though the value is not MIME-encoded and already uses plain text. Author and maintainer names are free-form strings, so the validation should recognize the complete encoded-word structure (beginning with =? and including its charset/encoding sections) rather than treating the terminator alone as proof of encoding.

    Useful? React with 👍 / 👎.

    chatgpt-codex-connector[bot] chatgpt-codex-connector[bot] commented on Oct 02, 2026 16:39 UTC
    Reviewer

    💡 Codex Review

    Here are some automated review suggestions for this pull request.

    Reviewed commit: 219d94e604

    <details> <summary>ℹ️ About Codex in GitHub</summary>
    <br/>

    Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review

  • Mark a draft as ready

  • Comment "@codex review".
  • If Codex has suggestions, it will comment; otherwise it will react with 👍.

    Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

    </details>

    JacobCoffee JacobCoffee commented on code on Oct 02, 2026 16:58 UTC
    Code Review
    warehouse/forklift/metadata.py:1
    @@ -136,6 +136,15 @@ def _validate_metadata(metadata: Metadata, *, backfill: bool = False):
                     )
                 )
     
    +    errors.extend(
    +        InvalidMetadata(
    +            _RAW_TO_EMAIL_MAPPING[field],
    +            "'?=' is not allowed. Use plain Unicode instead of MIME encoding.",
    +        )
    +        for field in ("author", "author_email", "maintainer", "maintainer_email")
    +        if "?=" in (getattr(metadata, field) or "")

    well.. isnt tht what we are trying to do mr robot?

    woodruffw woodruffw commented on Oct 02, 2026 21:03 UTC
    Reviewer

    The change itself seems fine, but I can imagine we might want to measure for this first for a while before hard-banning it 🙂 -- maybe we collect metrics/stats only for now?

    woodruffw woodruffw commented on code on Oct 02, 2026 21:06 UTC
    Code Review
    warehouse/forklift/metadata.py:1
    @@ -197,6 +197,15 @@ def _validate_metadata(metadata: Metadata, *, backfill: bool = False):
                     )
                 )
     
    +    errors.extend(
    +        InvalidMetadata(
    +            _RAW_TO_EMAIL_MAPPING[field],
    +            "'?=' is not allowed. Use plain Unicode instead of MIME encoding.",

    Maybe:

                "MIME encoded-word syntax is not allowed. Use plain Unicode instead.",
    

    (Since it's not just any MIME encoding, it's specifically the weird RFC 2822 "encoded-word" format.)

    JacobCoffee JacobCoffee commented on code on Oct 02, 2026 23:21 UTC
    Code Review
    warehouse/forklift/legacy.py:1
    @@ -108,6 +108,9 @@ def _valid_platform_tag(platform_tag):
     
     _dist_file_re = re.compile(r".+?(?P<extension>\.(tar\.gz|zip|whl))$", re.IGNORECASE)
     
    +# Detect encoded-word syntax without decoding untrusted metadata.
    +_MIME_ENCODED_WORD_RE = re.compile(r"=\?[^?\s]+\?[bq]\?[^?\s]+\?=", re.IGNORECASE)

    matches stuff like

    =?utf-8?q?Jos=C3=A9?=
    =?UTF-8?B?Sm9zw6k=?=
    

    JacobCoffee JacobCoffee commented on code on Oct 02, 2026 23:23 UTC
    Code Review
    warehouse/forklift/metadata.py:1
    @@ -197,6 +197,15 @@ def _validate_metadata(metadata: Metadata, *, backfill: bool = False):
                     )
                 )
     
    +    errors.extend(
    +        InvalidMetadata(
    +            _RAW_TO_EMAIL_MAPPING[field],
    +            "'?=' is not allowed. Use plain Unicode instead of MIME encoding.",

    rm'd the error message for now to gather metrics

    JacobCoffee JacobCoffee commented on Oct 22, 2026 22:47 UTC
    Author

    req. for review @woodruffw - ive updated to just add metrics for now and ill dashboard it up so we can track

    pawamoy pawamoy commented on Oct 23, 2026 23:15 UTC
    Contributor

    so this rejects values containing ?= at upload time and requires plain Unicode instead.

    Does it mean it will simply block uploads for dists built with pdm-backend? Do we have workarounds? A script that patches the metadata while waiting for a change in pdm-backend?

    JacobCoffee JacobCoffee commented on Oct 23, 2026 23:58 UTC
    Author

    @pawamoy in the original commits initially yes (see e886b0bc77d54dc23), but we've decided that it's unsafe for us to do this (see https://github.com/pypi/warehouse/issues/16496#issuecomment-6356358470) so this just adds metrics to track it in some panes (we could pull in DB, too so im not certain we even need this PR)

    I think as mentioned in https://github.com/pypi/warehouse/issues/18930#issuecomment-6375647566 we will probably just no render the section if it has this issue

    pawamoy pawamoy commented on Oct 24, 2026 00:37 UTC
    Contributor

    I see, thank you 🙏

    pawamoy pawamoy commented on Oct 25, 2026 09:44 UTC
    Contributor

    FYI, pdm-backend upgraded its vendored pyproject-metadata in v2.5.0 (released last month), meaning it won't MIME-encode these fields anymore.

    JacobCoffee JacobCoffee commented on Oct 27, 2026 05:04 UTC
    Author

    will close for now, can see db for data - still need PR to handle not showing the data if bad

    Reviewers
    Assignees
    JacobCoffee JacobCoffee
    Labels
    risk: low confidence: 83.2% reviewed sensitive_module
    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: 58.6% (MEDIUM) · Higher = larger blast radius
    58.6%
    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: 83.2% · Lower = rushed or shallow review
    83.2%
    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: 9.8% · Safe to merge
    9.8%
    Repository