Skip to content

Release 4.5.post1: CVE-2020-25658 for the Python 2.7 line - #3

Closed
icanhasmath wants to merge 3 commits into
version-4.3.xfrom
4.5.post1-security
Closed

icanhasmath wants to merge 3 commits into
version-4.3.xfrom
4.5.post1-security

Conversation

@icanhasmath

Copy link
Copy Markdown

rsa 4.5.post1: Python 2.7 security release

rsa 4.5 is the last release that supports Python 2.7. It is still exposed to CVE-2020-25658 (GHSA-xrx6-fmxq-rjj2, high), a Bleichenbacher-style timing oracle in PKCS#1 v1.5 decryption. Upstream fixed it only in 4.7, which needs Python 3. This branch was opened for that fix in 2023 (#1, #2) but was never released: it still says version 4.3.

This PR finishes the backport and cuts the release.

Commit What
ca9f489 CVE-2020-25658. Brings decrypt() to upstream 4.7's final form. #1 ported upstream dae8ce0 only; this adds 341e5c4 (the public length check raises at once) and f254895 (find() instead of index()/ValueError, so a missing separator takes the same path). Drops the unused import sys from #1. Adds regression tests that every malformed cleartext still raises DecryptionError.
4d9889e Upstream sybrenstuvel#164 (f878c37): reject padding shorter than 8 bytes (RFC 8017 7.2.2 step 3). Upstream's test, without its Python 3 annotation.
(release) Version 4.5.post1 in rsa/__init__.py and setup.py. The 4.3 & 4.5 changelog section, which #1 had rewritten, is restored, with a 4.5.post1 section on top.

Advisories against rsa

Advisory Range Status in 4.5.post1
CVE-2016-1494 / GHSA-8rjr-6qq5-pj9p < 3.3 Fixed upstream before the base
CVE-2020-13757 / GHSA-537h-rv9q-vvph < 4.1 Fixed in the 4.5 base (3283b12)
CVE-2020-25658 / GHSA-xrx6-fmxq-rjj2 >= 2.1, < 4.7 Patched here

OSV lists nothing against 4.7 through 4.9.1, so no later upstream fix needs carrying.

Verification (Python 2.7.18)

  • tests/: 97 passed. The base branch has 92; the 5 new tests account for the rest.
  • PaddingSizeTest fails without the pkcs1.py change and passes with it.
  • The CVE-2020-25658 tests check behaviour: a timing fix cannot be shown red-to-green in a unit test. They pin that the restructured checks still reject a bad marker, a missing separator and an over-long ciphertext, and that a valid block decrypts.
  • setup.py sdist bdist_wheel gives rsa-4.5.post1.tar.gz and rsa-4.5.post1-py2.py3-none-any.whl. rsa.__version__ is 4.5.post1.

After merge: tag version-4.5.post1 (the repo's tag style), a GitHub release (--latest=false), inventory rsa 4.5.0.1, and a CVE-scanner override row for CVE-2020-25658.

The fork's earlier backport (PR #1) ported upstream dae8ce0 only. Upstream
4.7 refined it in two follow-ups, ported here:

- 341e5c4: the ciphertext length check raises at once. Length and block
  size are public, so they need no side-channel-free comparison.
- f254895: bytes.find() instead of bytes.index() with a ValueError
  handler, so a missing separator takes the same path as a present one.

Also drops the unused 'import sys' that PR #1 added, and adds regression
tests that every malformed cleartext (bad 00 02 marker, no separator,
over-long ciphertext) still raises DecryptionError through the combined
check. Python 2.7: hmac.compare_digest exists from 2.7.7.
… (upstream f878c37)

RFC 8017 section 7.2.2 step 3 requires at least 8 bytes of padding, so the
00 separator must sit at index 10 or later. decrypt() accepted any
separator after the marker. Part of upstream 4.7's decryption hardening
alongside the CVE-2020-25658 fix. Upstream's test, without its Python 3
type annotation.
… 2.7 line

Sets the version to 4.5.post1 (the branch still said 4.3, the tag 4.5 was
cut from) and restores the 4.3 & 4.5 changelog section that the
CVE-2020-25658 backport had rewritten, with a 4.5.post1 section on top.
@icanhasmath

Copy link
Copy Markdown
Author

Superseded by #4: the same release rebuilt on the version-4.5 tag (new base branch version-4.5.x) instead of version-4.3.x, so its history contains upstream 4.5. The final tree is byte-identical to this PR's head (987fe91), and tests/ passes 97 of 97 on Python 2.7. The 4.5.post1-security branch is left in place for reference.

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.

1 participant