Improper Handling of Syntactically Invalid Structure Affecting ujson package, versions [,5.4.0)


Severity

Recommended
0.0
medium
0
10

CVSS assessment made by Snyk's Security Team. Learn more

Threat Intelligence

Exploit Maturity
Proof of concept
EPSS
0.21% (59th percentile)

Do your applications use this vulnerable package?

In a few clicks we can analyze your entire application and see what components are vulnerable in your application, and suggest you quick fixes.

Test your applications
  • Snyk IDSNYK-PYTHON-UJSON-2942122
  • published6 Jul 2022
  • disclosed6 Jul 2022
  • creditJustAnotherArchivist, the-bumble

Introduced: 6 Jul 2022

CVE-2022-31116  (opens in a new tab)
CWE-228  (opens in a new tab)

How to fix?

Upgrade ujson to version 5.4.0 or higher.

Overview

ujson is an Ultra fast JSON encoder and decoder for Python

Affected versions of this package are vulnerable to Improper Handling of Syntactically Invalid Structure due to incorrect decoding of JSON strings that contain escaped surrogate characters that are not part of a proper surrogate pair. This allows data corruption, and therefore impacts the integrity of the target application, as well as potentially impacting the availability of dictionary data.

PoC:


>>> ujson.loads(r'"\uD800"')
' '
>>> ujson.loads(r'"\uD800hello"')
'hello'

# An unpaired low surrogate character is preserved.
>>> ujson.loads(r'"\uDC00"')
'\udc00'

# A pair of surrogates with additional non-surrogate characters pair up in spite of being invalid.
>>> ujson.loads(r'"\uD800foo bar\uDC00"')
'foo bar𐀀

CVSS Scores

version 3.1