{"id":"CVE-2022-31116","aliases":["CVE-2022-31116","GHSA-wpqr-jcpx-745r","PYSEC-2026-1057"],"related":[],"kind":"vulnerability","state":"published","title":"Incorrect handling of invalid surrogate pair characters in ujson","summary":"UltraJSON is a fast JSON encoder and decoder written in pure C with bindings for Python 3.7+. Affected versions were found to improperly decode certain characters. JSON strings that contain escaped surrogate characters not part of a proper surrogate pair were decoded incorrectly. Besides corrupting strings, this allowed for potential key confusion and value overwriting in dictionaries. All users parsing JSON from untrusted sources are vulnerable. From version 5.4.0, UltraJSON decodes lone surrogates in the same way as the standard library's `json` module does, preserving them in the parsed output. Users are advised to upgrade. There are no known workarounds for this issue.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"UltraJSON is a fast JSON encoder and decoder written in pure C with bindings for Python 3.7+. Affected versions were found to improperly decode certain characters. JSON strings that contain escaped surrogate characters not part of a proper surrogate pair were decoded incorrectly. Besides corrupting strings, this allowed for potential key confusion and value overwriting in dictionaries. All users parsing JSON from untrusted sources are vulnerable. From version 5.4.0, UltraJSON decodes lone surrogates in the same way as the standard library's `json` module does, preserving them in the parsed output. Users are advised to upgrade. There are no known workarounds for this issue.","source":"cvelist"},{"lang":"en","text":"### Impact\n_What kind of vulnerability is it? Who is impacted?_\n\nAnyone parsing JSON from an untrusted source is vulnerable.\n\nJSON strings that contain escaped surrogate characters not part of a proper surrogate pair were decoded incorrectly. Besides corrupting strings, this allowed for potential key confusion and value overwriting in dictionaries.\n\nExamples:\n\n```python\n# An unpaired high surrogate character is ignored.\n>>> ujson.loads(r'\"\\uD800\"')\n''\n>>> ujson.loads(r'\"\\uD800hello\"')\n'hello'\n\n# An unpaired low surrogate character is preserved.\n>>> ujson.loads(r'\"\\uDC00\"')\n'\\udc00'\n\n# A pair of surrogates with additional non surrogate characters pair up in spite of being invalid.\n>>> ujson.loads(r'\"\\uD800foo bar\\uDC00\"')\n'foo bar𐀀'\n```\n\n### Patches\n_Has the problem been patched? What versions should users upgrade to?_\n\nUsers should upgrade to UltraJSON 5.4.0.\n\nFrom version 5.4.0, UltraJSON decodes lone surrogates in the same way as the standard library's `json` module does, preserving them in the parsed output:\n\n```python3\n>>> ujson.loads(r'\"\\uD800\"')\n'\\ud800'\n>>> ujson.loads(r'\"\\uD800hello\"')\n'\\ud800hello'\n>>> ujson.loads(r'\"\\uDC00\"')\n'\\udc00'\n>>> ujson.loads(r'\"\\uD800foo bar\\uDC00\"')\n'\\ud800foo bar\\udc00'\n```\n\n### Workarounds\n_Is there a way for users to fix or remediate the vulnerability without upgrading?_\n\nShort of switching to an entirely different JSON library, there are no safe alternatives to upgrading.\n\n### For more information\nIf you have any questions or comments about this advisory:\n* Open an issue in [UltraJSON](http://github.com/ultrajson/ultrajson/issues)","format":"markdown","source":"ghsa"},{"lang":"es","text":"UltraJSON es un codificador y decodificador JSON rápido escrito en C puro con enlaces para Python versiones 3.7+.&#xa0;Se encontró que las versiones afectadas descodificaban incorrectamente determinados caracteres.&#xa0;Las cadenas JSON que contienen caracteres suplentes escapados que no forman parte de un par suplente adecuado se decodificaron incorrectamente.&#xa0;Además de corromper las cadenas, esto permitió una posible confusión de claves y sobrescritura de valores en los diccionarios.&#xa0;Todos los usuarios que analizan JSON de fuentes que no son de confianza son vulnerables.&#xa0;A partir de la versión 5.4.0, UltraJSON decodifica sustitutos solitarios de la misma manera que lo hace el módulo \"json\" de la biblioteca estándar, conservándolos en la salida analizada.&#xa0;Se recomienda a los usuarios que actualicen.&#xa0;No se conocen mitigaciones adicionales para este problema","source":"nvd"}],"published":"2022-07-05T17:35:11.000Z","modified":"2026-07-07T11:56:38.194Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H","score":7.5,"rating":"HIGH"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H","score":7.5,"rating":"HIGH"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H","score":7.5,"rating":"HIGH"},{"scorer":"NVD","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H","score":7.5,"rating":"HIGH"},{"scorer":"NVD","scheme":"CVSS:2.0","vector":"AV:N/AC:L/Au:N/C:N/I:N/A:P","score":5,"rating":"MEDIUM"},{"scorer":"PyPA Advisory Database","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H","score":7.5,"rating":"HIGH"}],"cwes":["CWE-670"],"affected":[{"ranges":[{"version":"< 5.4.0","status":"affected"}],"vendor":"ultrajson","product":"ultrajson","source":"cvelist"},{"ranges":[{"type":"ecosystem","introduced":"0","status":"affected","fixed":"5.4.0"}],"ecosystem":"PyPI","package":"ujson","purl":"pkg:pypi/ujson","source":"ghsa"},{"ranges":[{"status":"affected","fixed":"5.4.0"}],"vendor":"ultrajson_project","product":"ultrajson","cpe":"cpe:2.3:a:ultrajson_project:ultrajson:*:*:*:*:*:python:*:*","source":"nvd"},{"ranges":[{"status":"affected","version":"35"},{"status":"affected","version":"36"}],"vendor":"fedoraproject","product":"fedora","cpe":"cpe:2.3:o:fedoraproject:fedora:35:*:*:*:*:*:*:*","source":"nvd"},{"ranges":[{"type":"ecosystem","introduced":"0","status":"affected","fixed":"5.4.0"}],"ecosystem":"PyPI","package":"ujson","purl":"pkg:pypi/ujson","source":"pysec"}],"references":[{"url":"https://github.com/ultrajson/ultrajson/security/advisories/GHSA-wpqr-jcpx-745r","tags":["exploit","third-party-advisory","web","x-refsource-confirm","x-transferred"],"sources":["cvelist","ghsa","nvd","pysec"]},{"url":"https://github.com/ultrajson/ultrajson/commit/67ec07183342589d602e0fcf7bb1ff3e19272687","tags":["patch","third-party-advisory","web","x-refsource-misc","x-transferred"],"sources":["cvelist","ghsa","nvd","pysec"]},{"url":"https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/OPPU5FZP3LCTXYORFH7NHUMYA5X66IA7/","tags":["vendor-advisory","x-refsource-fedora","x-transferred"],"sources":["cvelist","nvd"]},{"url":"https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/NAU5N4A7EUK2AMUCOLYDD5ARXAJYZBD2/","tags":["vendor-advisory","x-refsource-fedora","x-transferred"],"sources":["cvelist","nvd"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2022-31116","tags":["advisory"],"sources":["ghsa","pysec"]},{"url":"https://github.com/ultrajson/ultrajson","tags":["package"],"sources":["ghsa","pysec"]},{"url":"https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/NAU5N4A7EUK2AMUCOLYDD5ARXAJYZBD2","tags":["web"],"sources":["ghsa","pysec"]},{"url":"https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/OPPU5FZP3LCTXYORFH7NHUMYA5X66IA7","tags":["web"],"sources":["ghsa","pysec"]},{"url":"https://pypi.org/project/ujson","tags":["package"],"sources":["pysec"]},{"url":"https://github.com/advisories/GHSA-wpqr-jcpx-745r","tags":["advisory"],"sources":["pysec"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"poc","automatable":"yes","technicalImpact":"partial","date":"2025-04-22T15:40:30.720Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2022-31116","url":"https://www.cve.org/CVERecord?id=CVE-2022-31116","licence":"CVE Terms of Use","modified":"2025-04-22T17:52:13.305Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-wpqr-jcpx-745r","url":"https://github.com/advisories/GHSA-wpqr-jcpx-745r","licence":"CC-BY-4.0","modified":"2026-07-07T11:56:38.194Z"},{"source":"nvd","name":"NVD","id":"CVE-2022-31116","url":"https://nvd.nist.gov/vuln/detail/CVE-2022-31116","licence":"Public domain","modified":"2026-06-17T04:44:50.177Z"},{"source":"pysec","name":"PyPA Advisory Database","id":"PYSEC-2026-1057","url":"https://osv.dev/vulnerability/PYSEC-2026-1057","licence":"CC-BY-4.0","modified":"2026-07-07T11:46:02.505Z"}],"updatedAt":"2026-11-25T22:58:12.715Z","epss":{"score":0.02545,"percentile":0.8545,"date":"2026-12-01T12:00:22.000Z"}}