Skip to content

Release 3.1.0.post1: CVE-2026-118669, CVE-2026-49264 and CVE-2026-49265 for the Python 2.7 line - #1

Merged
icanhasmath merged 4 commits into
3.1.0.xfrom
3.1.0-security
Nov 10, 2026
Merged

icanhasmath merged 4 commits into
3.1.0.xfrom
3.1.0-security

Conversation

@icanhasmath

Copy link
Copy Markdown
Collaborator

oauthlib 3.1.0 is the last release line that supports Python 2.7. Upstream fixed these three advisories in 4.0.0, which requires Python 3. This backports them as 3.1.0.post1, one commit per CVE. The base branch 3.1.0.x is the upstream v3.1.0 tag.

CVE GHSA Level Fix
CVE-2026-118669 GHSA-7984-qgvg-3j9c High client_id bound to the authenticated client
CVE-2026-49264 GHSA-hj66-6f7g-4r5v Moderate JSONP callback validated
CVE-2026-49265 GHSA-xpv3-w29h-x7cv Moderate PKCE verifier compared in constant time

Where this differs from upstream

Each difference keeps 3.1.0's API, so a post-release doesn't break callers.

  • CVE-2026-118669. The client_credentials and password grants now take client_id from request.client after authentication. A different client_id in the body raises ServerError, as upstream does. In client_credentials, the binding now happens before validate_grant_type.
    • Upstream c951a1d also reorganised authorization_code, refresh_token and device_code. In those grants the code or refresh token is already validated against request.client.
    • That reorganisation changes 3.1.0's behaviour for public clients and breaks 18 existing tests, so this backport is narrowed to the two grants the advisory names.
    • test_scope_handling's fixture gets upstream's own change: its validate_user set mismatched ids.
  • CVE-2026-49264. Upstream removed JSONP support (c888359). That deletes the enable_jsonp parameter, so instead the callback is now used only when it is a dotted JavaScript identifier (package.callback). Otherwise the endpoint returns the plain body.
  • CVE-2026-49265. Upstream (Improve PKCE code comparison oauthlib/oauthlib#963) uses hmac.compare_digest. That needs Python 2.7.7 and rejects mixed str/unicode arguments on Python 2, so the backport uses oauthlib's existing common.safe_string_equals.

Tests

  • Python 2.7.18, full suite: 549 passed, 7 failed. The untouched v3.1.0 has the same 7 failures (blinker not installed, and other environment issues).
  • Each fix adds a regression test, and each of those tests fails with its library change reverted.
  • setup.py sdist bdist_wheel gives oauthlib-3.1.0.post1.tar.gz and oauthlib-3.1.0.post1-py2.py3-none-any.whl.

Tracking: Linear PROD-2448.

icanhasmath and others added 4 commits November 9, 2026 23:10
GHSA-7984-qgvg-3j9c. The client_credentials and password grants
authenticated one client and then kept a client_id from the request body
(request.client_id or request.client.client_id), so an authenticated
low-privilege client could name another client and have the grant type and
scopes validated as that client.

Both grants now take client_id from request.client after authentication.
A different client_id in the request raises ServerError, as upstream does.
In client_credentials the binding now happens before validate_grant_type.

Backported from upstream c951a1d (oauthlib 4.0.0), narrowed to the two
grants the advisory names: upstream also reorganised authorization_code,
refresh_token and device_code, where the code or refresh token is already
validated against request.client, and that reorganisation changes 3.1.0
behaviour for public clients. test_scope_handling's fixture gets upstream's
change (its validate_user set mismatched ids).

Co-Authored-By: Claude <[email protected]>
GHSA-hj66-6f7g-4r5v. With enable_jsonp=True, RevocationEndpoint wrote the
request's callback parameter into the response body unchecked, on both the
success and the error path, so a caller could make the endpoint return
arbitrary JavaScript.

The callback is now used only when it is a dotted JavaScript identifier
(package.callback); otherwise the response is the plain body, as if no
callback had been given.

Upstream fixed this by removing JSONP support (c888359, oauthlib 4.0.0,
PR oauthlib#951). That removes the enable_jsonp parameter, which would break
callers of a post-release, so this backport keeps the parameter and
restricts the callback instead.

Co-Authored-By: Claude <[email protected]>
GHSA-xpv3-w29h-x7cv. code_challenge_method_plain and
code_challenge_method_s256 compared the verifier (or its S256 digest) with
the stored challenge using ==, which stops at the first differing
character and so leaks the length of the matching prefix.

Both now use oauthlib.common.safe_string_equals, oauthlib's existing
constant-time comparison.

Backported from upstream PR oauthlib#963 (74664d3, oauthlib 4.0.0), which uses
hmac.compare_digest. That needs Python 2.7.7 and rejects mixed str and
unicode arguments on Python 2, so the backport uses the helper oauthlib
already ships for signature checks.

Co-Authored-By: Claude <[email protected]>

@ezequielp-activestate ezequielp-activestate left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approve: 0 blockers.

🔴 Blockers

None.

Checked

  • The base 31cae75c9d is the upstream v3.1.0 tag.

  • CVE-2026-118669:

    • _bind_client_id has the same logic as the binding in upstream c951a1d's validate_client_confidential/validate_client_public: fill client_id from request.client when it's empty, and raise ServerError when it differs.
    • In both grants, the binding now runs before validate_grant_type.
    • Limiting the fix to client_credentials and password matches the advisory, which names only those two grants.
  • CVE-2026-49264: the _JSONP_CALLBACK_RE check (dotted identifier, anchored with \Z) guards both the error and the success paths.

    • Upstream's 8f7db80 (the client side refusing callback=) only follows from upstream removing JSONP, so it isn't needed while JSONP is kept.
  • CVE-2026-49265: both PKCE methods now use common.safe_string_equals. It's safe on Python 2 with mixed str/unicode, and it's only reached when code_challenge is not None.

  • Upstream follow-ups: I checked the upstream history after the fixes, through v4.0.1 and master.

    • 4.0.1's CVE-2026-49272 and master's 5edac41 are in the device flow, which 3.1.0 doesn't have.
    • a34239c (host_from_uri IPv6) is a functional fix, not a security one.
  • OSV: for oauthlib 3.1.0, it lists exactly these three advisories.

  • Tests:

    base + this PR's tests PR
    Python 2.7 9 failed, 547 passed 556 passed
    Python 3.8 9 failed, 547 passed 556 passed

    On both versions, every base failure is a new regression test, and the PR passes all of them.

  • Probe on Python 2.7:

    base PR
    client_credentials request authenticated as low with client_id=admin in the body 200, and validate_grant_type received admin 400 before validate_grant_type runs
    Revocation with callback=alert(document.cookie)// body alert(document.cookie)//(); empty body
    Revocation with callback=pkg.cb pkg.cb(); pkg.cb();
  • Build: setup.py sdist bdist_wheel gives oauthlib-3.1.0.post1.tar.gz and oauthlib-3.1.0.post1-py2.py3-none-any.whl, and oauthlib.__version__ is 3.1.0.post1.

⚪ Notes

  • safe_string_equals returns early when the lengths differ, so the comparison time still reveals whether the length is right. hmac.compare_digest upstream behaves the same way, so this matches upstream.

Not assessed

  • I didn't measure PKCE comparison timing.
  • I didn't run the docs build.

@icanhasmath
icanhasmath marked this pull request as ready for review November 10, 2026 16:09
@icanhasmath
icanhasmath merged commit db928db into 3.1.0.x Nov 10, 2026
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.

2 participants