Skip to content

[Security] remove ujson package (CVE-2022-31116, CVE-2022-31117, CVE-2021-45958) - #1676

Open
PatStLouis wants to merge 5 commits into
hyperledger-indy:mainfrom
OpSecId:security-fix-testing-ujson-package-upgrade
Open

[Security] remove ujson package (CVE-2022-31116, CVE-2022-31117, CVE-2021-45958)#1676
PatStLouis wants to merge 5 commits into
hyperledger-indy:mainfrom
OpSecId:security-fix-testing-ujson-package-upgrade

Conversation

@PatStLouis

Copy link
Copy Markdown
Contributor

Signed-off-by: pstlouis <patrick.st-louis@opsecid.ca>
@PatStLouis
PatStLouis requested a review from a team July 26, 2024 14:32
@WadeBarnes

Copy link
Copy Markdown
Contributor

@PatStLouis, Please rebase this PR now that your fix for the failed action has been merged. Thanks

@crajapakshe

Copy link
Copy Markdown

@PatStLouis Here is the some notes for remediation process.
image

@PatStLouis

Copy link
Copy Markdown
Contributor Author

@crajapakshe pysha3 is a separate package, and we won't likely be able to update this package in a timely manner as there is some breaking changes introduced in >=1.0. Current installations use version 0.2.1.

PatStLouis and others added 2 commits September 13, 2024 14:08
Signed-off-by: pstlouis <patrick.st-louis@opsecid.ca>
@PatStLouis PatStLouis changed the title [Security] Bump ujson to 5.4.0 [Security] remove ujson package (CVE-2022-31116, CVE-2022-31117, CVE-2021-45958) Sep 13, 2024
Signed-off-by: pstlouis <patrick.st-louis@opsecid.ca>
kukgini added a commit to kukgini/indy-plenum that referenced this pull request Jul 2, 2026
Fixes layered on top of hyperledger-indy#1676's ujson removal (CVE-2022-31116,
CVE-2022-31117, CVE-2021-45958):

- channel.py: the lint fix in hyperledger-indy#1676 replaced `type(msg) != tuple` with
  `not isinstance(type(msg), tuple)`, which is always True and wrapped
  already-tuple messages into nested tuples, breaking handler routing.
  Restore the original semantics in a lint-clean form
  (`type(msg) is not tuple`), preserving NamedTuple wrapping.

- zstack serializeMsg: ujson emitted compact JSON; stdlib json's default
  separators add whitespace, growing every wire message and breaking the
  exact-size assertions in stp_zmq/test/test_zstack.py calibrated to
  MSG_LEN_LIMIT. Pass separators=(',', ':') to keep the wire format
  byte-compatible. (Applied to scripts/test_zmq's copy as well.)

- recorder: SimpleZStackWithRecorder records raw wire frames; ujson
  silently encoded bytes as UTF-8 strings while stdlib json raises
  TypeError, so recording mode (STACK_COMPANION=1) crashed on the first
  message. Add a bytes-decoding default hook and a bytes regression
  test.

- Add regression tests pinning JsonSerializer's exact byte output
  (key ordering, compact separators, raw-UTF-8 non-ASCII, float repr,
  int-key coercion, top-level-bytes base64) since it feeds
  signing/hashing, plus characterisation of the nested-bytes TypeError.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Signed-off-by: kukgini <kukgini@gmail.com>
kukgini added a commit to kukgini/indy-plenum that referenced this pull request Jul 2, 2026
Fixes layered on top of hyperledger-indy#1676's ujson removal. Dropping the dependency
resolves the four ujson CVEs affecting the previously pinned 1.33
(CVE-2022-31116, CVE-2022-31117, CVE-2026-44660, CVE-2026-54911;
CVE-2021-45958 cited in hyperledger-indy#1676 only affects ujson >= 1.34).

- channel.py: the lint fix in hyperledger-indy#1676 replaced `type(msg) != tuple` with
  `not isinstance(type(msg), tuple)`, which is always True and wrapped
  already-tuple messages into nested tuples, breaking handler routing.
  Restore the original semantics in a lint-clean form
  (`type(msg) is not tuple`), preserving NamedTuple wrapping.

- zstack serializeMsg: ujson emitted compact JSON; stdlib json's default
  separators add whitespace, growing every wire message and breaking the
  exact-size assertions in stp_zmq/test/test_zstack.py calibrated to
  MSG_LEN_LIMIT. Pass separators=(',', ':') to keep the wire format
  byte-compatible. (Applied to scripts/test_zmq's copy as well.)

- recorder: SimpleZStackWithRecorder records raw wire frames; ujson
  silently encoded bytes as UTF-8 strings while stdlib json raises
  TypeError, so recording mode (STACK_COMPANION=1) crashed on the first
  message. Add a bytes-decoding default hook and a bytes regression
  test.

- Add regression tests pinning JsonSerializer's exact byte output
  (key ordering, compact separators, raw-UTF-8 non-ASCII, float repr,
  int-key coercion, top-level-bytes base64) since it feeds
  signing/hashing, plus characterisation of the nested-bytes TypeError.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Signed-off-by: kukgini <kukgini@gmail.com>
kukgini added a commit to kukgini/indy-plenum that referenced this pull request Jul 2, 2026
Fixes layered on top of hyperledger-indy#1676's ujson removal. Dropping the dependency
resolves the four ujson CVEs affecting the previously pinned 1.33
(CVE-2022-31116, CVE-2022-31117, CVE-2026-44660, CVE-2026-54911;
CVE-2021-45958 cited in hyperledger-indy#1676 only affects ujson >= 1.34).

- channel.py: the lint fix in hyperledger-indy#1676 replaced `type(msg) != tuple` with
  `not isinstance(type(msg), tuple)`, which is always True and wrapped
  already-tuple messages into nested tuples, breaking handler routing.
  Restore the original semantics in a lint-clean form
  (`type(msg) is not tuple`), preserving NamedTuple wrapping.

- zstack serializeMsg: ujson emitted compact JSON; stdlib json's default
  separators add whitespace, growing every wire message and breaking the
  exact-size assertions in stp_zmq/test/test_zstack.py calibrated to
  MSG_LEN_LIMIT. Pass separators=(',', ':') to keep the wire format
  byte-compatible. (Applied to scripts/test_zmq's copy as well.)

- recorder: SimpleZStackWithRecorder records raw wire frames; ujson
  silently encoded bytes as UTF-8 strings while stdlib json raises
  TypeError, so recording mode (STACK_COMPANION=1) crashed on the first
  message. Add a shared bytes-decoding default hook
  (plenum.common.util.json_default_bytes_to_str) and a bytes regression
  test.

- Add regression tests pinning JsonSerializer's exact byte output
  (key ordering, compact separators, raw-UTF-8 non-ASCII, float repr,
  int-key coercion, top-level-bytes base64) since it feeds
  signing/hashing, plus characterisation of the nested-bytes TypeError.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Signed-off-by: kukgini <kukgini@gmail.com>
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.

3 participants