Description
http.cookies.Morsel.js_output() returns an inline <script> snippet and only escapes " for JavaScript string context. It does not neutralize the HTML parser-sensitive sequence </script> inside the generated script element. Mitigation base64-encodes the cookie value to disallow escaping using cookie value.
Problem types
CWE-150 Improper neutralization of escape, meta, or control sequences
Product status
Any version before 3.15.0
Credits
oolongeya (https://github.com/komi22)
Seth Larson (https://github.com/sethmlarson)
References
github.com/python/cpython/pull/148848
github.com/python/cpython/issues/90309
mail.python.org/.../thread/IVNWGV2BBNC3RHQAFS22UP4DY56SAXX3/
github.com/...ommit/76b3923d688c0efc580658476c5f525ec8735104
github.com/...ommit/3c59b8b53fc75c7f9578d16fb8201ceb43e8f76c
github.com/...ommit/f795e042043dfe26c42e1971d4502c1cdc4c65b8