Cookie Attribute Injection via Unescaped Semicolons in http.cookies.Morsel.OutputString()

Ouverte
#161,707 1 commentaire 1 réaction 0 personnes assignées Voir sur GitHub

Les mainteneurs répondent en général sous 1 jour

Personne n'a encore pris cette issue.

Évaluation

Difficulté
4/5
Temps estimé
1-2 jours
Accessibilité débutants
18/100
Type d'issue
Bug
Clarté
Plutôt claire
Activité
Active
Stack technique
python
Domaine
security

Piste de recherche

Start in Lib/http/cookies.py, at _has_control_character() and Morsel.OutputString(), to see how attribute values such as path, domain, samesite and version are validated and emitted. Then look at Lib/test/test_http_cookies.py for existing attribute tests. Done means semicolons in these values are rejected or quoted, with regression tests added. Pull request gh-161711 already targets this, so check it before starting.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

stdlib type-security
Bug report

@ikow reported that http.cookies.Morsel.OutputString() does not quote or escape semicolons in cookie attribute values for path, domain, samesite, and version. The _has_control_character() validator (added in the CVE-2026-0672 fix) only checks C0 control characters ([\x00-\x1F\x7F]) and does not reject semicolons (0x3B), which are the Set-Cookie attribute delimiter per RFC 6265.

When an application reflects untrusted input into these cookie attributes, an attacker can inject arbitrary Set-Cookie attributes such as Domain, SameSite, Secure, and HttpOnly. Given the combination of how Morsel outputs cookies and how they're parsed, this opens up two possible attacks: SameSite policy downgrade and parent Domain expansion.

CPython versions tested on:

CPython main branch

Operating systems tested on:

Linux

Linked PRs
  • gh-161711
  • gh-161893
  • gh-161894
  • gh-161901
  • gh-161902
  • gh-161903
Langage dominant
Python
Étoiles
78.2k
Forks
36.6k
Merge moyen
19 h 57 min
PR mergées (30 j)
630

Préparer son environnement

Ouvrir dans Codespaces

Lance le conteneur de développement du projet dans votre navigateur, avec votre propre compte GitHub.

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de python/cpython

Toutes les issues de python/cpython

Issues similaires

Plus d'issues Python

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.