{"id":"CVE-2024-21664","aliases":["CVE-2024-21664","GHSA-pvcr-v8j8-j5q3","GO-2024-2454"],"related":["CGA-rg2f-wh8h-jrh5"],"kind":"vulnerability","state":"published","title":"Parsing JSON serialized payload without protected field can lead to segfault","summary":"jwx is a Go module implementing various JWx (JWA/JWE/JWK/JWS/JWT, otherwise known as JOSE) technologies. Calling `jws.Parse` with a JSON serialized payload where the `signature` field is present while `protected` is absent can lead to a nil pointer dereference. The vulnerability can be used to crash/DOS a system doing JWS verification. This vulnerability has been patched in versions 2.0.19 and 1.2.28.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"jwx is a Go module implementing various JWx (JWA/JWE/JWK/JWS/JWT, otherwise known as JOSE) technologies. Calling `jws.Parse` with a JSON serialized payload where the `signature` field is present while `protected` is absent can lead to a nil pointer dereference. The vulnerability can be used to crash/DOS a system doing JWS verification. This vulnerability has been patched in versions 2.0.19 and 1.2.28.","source":"cvelist"},{"lang":"en","text":"### Summary\n\nCalling `jws.Parse` with a JSON serialized payload where the `signature` field is present while `protected` is absent can lead to a nil pointer dereference.\n\n### Details\n\nThis seems to also affect other functions that calls `Parse` internally, like `jws.Verify`.\n\nMy understanding of these functions from the docs is that they are supposed to fail gracefully on invalid input and don't require any prior validation.\n\nBased on the stack trace in the PoC, the issue seems to be that the processing done in `jws/message.go:UnmarshalJSON()` assumes that if a `signature` field is present, then a `protected` field is also present. If this is not the case, then the subsequent call to `getB64Value(sig.protected)` will dereference `sig.protected`, which is `nil`.\n\n### PoC\n\nReproducer:\n\n```go\npackage poc\n\nimport (\n        \"testing\"\n\n        \"github.com/lestrrat-go/jwx/v2/jws\"\n)\n\nfunc TestPOC(t *testing.T) {\n        _, _ = jws.Parse([]byte(`{\"signature\": \"\"}`))\n}\n```\n\nResult:\n\n```\n$ go test        \n--- FAIL: TestPOC (0.00s)\npanic: runtime error: invalid memory address or nil pointer dereference [recovered]\n        panic: runtime error: invalid memory address or nil pointer dereference\n[signal SIGSEGV: segmentation violation code=0x1 addr=0x40 pc=0x5fd618]\n\ngoroutine 6 [running]:\ntesting.tRunner.func1.2({0x628800, 0x831030})\n        /usr/local/go/src/testing/testing.go:1545 +0x238\ntesting.tRunner.func1()\n        /usr/local/go/src/testing/testing.go:1548 +0x397\npanic({0x628800?, 0x831030?})\n        /usr/local/go/src/runtime/panic.go:914 +0x21f\ngithub.com/lestrrat-go/jwx/v2/jws.getB64Value({0x0?, 0x0?})\n        /home/fredrik/go/pkg/mod/github.com/lestrrat-go/jwx/v2@v2.0.18/jws/jws.go:484 +0x18\ngithub.com/lestrrat-go/jwx/v2/jws.(*Message).UnmarshalJSON(0xc0000a2140, {0xc0000ec000, 0x11, 0x200})\n        /home/fredrik/go/pkg/mod/github.com/lestrrat-go/jwx/v2@v2.0.18/jws/message.go:323 +0x4ad\nencoding/json.(*decodeState).object(0xc0000ea028, {0x64fa60?, 0xc0000a2140?, 0x16?})\n        /usr/local/go/src/encoding/json/decode.go:604 +0x6cc\nencoding/json.(*decodeState).value(0xc0000ea028, {0x64fa60?, 0xc0000a2140?, 0xc00006e630?})\n        /usr/local/go/src/encoding/json/decode.go:374 +0x3e\nencoding/json.(*decodeState).unmarshal(0xc0000ea028, {0x64fa60?, 0xc0000a2140?})\n        /usr/local/go/src/encoding/json/decode.go:181 +0x133\nencoding/json.(*Decoder).Decode(0xc0000ea000, {0x64fa60, 0xc0000a2140})\n        /usr/local/go/src/encoding/json/stream.go:73 +0x179\ngithub.com/lestrrat-go/jwx/v2/internal/json.Unmarshal({0xc00001a288, 0x11, 0x11}, {0x64fa60, 0xc0000a2140})\n        /home/fredrik/go/pkg/mod/github.com/lestrrat-go/jwx/v2@v2.0.18/internal/json/json.go:26 +0x97\ngithub.com/lestrrat-go/jwx/v2/jws.parseJSON({0xc00001a288, 0x11, 0x11})\n        /home/fredrik/go/pkg/mod/github.com/lestrrat-go/jwx/v2@v2.0.18/jws/jws.go:588 +0x50\ngithub.com/lestrrat-go/jwx/v2/jws.Parse({0xc00001a288, 0x11, 0x11}, {0x0?, 0xc00006e760?, 0x48450f?})\n        /home/fredrik/go/pkg/mod/github.com/lestrrat-go/jwx/v2@v2.0.18/jws/jws.go:525 +0x89\npoc.TestPOC(0x0?)\n        /home/fredrik/src/jwx_poc/poc_test.go:10 +0x57\ntesting.tRunner(0xc0000e4340, 0x68ef30)\n        /usr/local/go/src/testing/testing.go:1595 +0xff\ncreated by testing.(*T).Run in goroutine 1\n        /usr/local/go/src/testing/testing.go:1648 +0x3ad\nexit status 2\nFAIL    poc     0.005s\n```\n\n### Impact\n\nThe vulnerability can be used to crash / DOS a system doing JWS verification.","format":"markdown","source":"ghsa"},{"lang":"en","text":"Panic due to nil pointer dereference in github.com/lestrrat-go/jwx/v2","format":"markdown","source":"go"},{"lang":"es","text":"jwx es un módulo Go que implementa varias tecnologías JWx (JWA/JWE/JWK/JWS/JWT, también conocidas como JOSE). Llamar a `jws.Parse` con un payload serializado JSON donde el campo `signature` está presente mientras que `protected` está ausente puede provocar una desreferencia del puntero nulo. La vulnerabilidad se puede utilizar para bloquear/DOS un sistema que realiza la verificación JWS. Esta vulnerabilidad ha sido parcheada en la versión 2.0.19.","source":"nvd"}],"published":"2024-01-09T16:18:48.000Z","modified":"2026-09-10T03:50:05.133Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:N/A:L","score":4.3,"rating":"MEDIUM"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:N/A:L","score":4.3,"rating":"MEDIUM"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:N/A:L","score":4.3,"rating":"MEDIUM"},{"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"}],"cwes":["CWE-476"],"affected":[{"ranges":[{"version":">= 2.0.0, < 2.0.19","status":"affected"},{"version":">= 1.0.8, < 1.2.28","status":"affected"}],"vendor":"lestrrat-go","product":"jwx","source":"cvelist"},{"ranges":[{"type":"semver","introduced":"1.0.8","status":"affected","fixed":"1.2.28"}],"ecosystem":"Go","package":"github.com/lestrrat-go/jwx","purl":"pkg:golang/github.com/lestrrat-go/jwx","source":"ghsa"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","fixed":"2.0.19"}],"ecosystem":"Go","package":"github.com/lestrrat-go/jwx/v2","purl":"pkg:golang/github.com/lestrrat-go/jwx/v2","source":"ghsa"},{"ranges":[{"type":"semver","introduced":"1.0.8","status":"affected","fixed":"1.2.28"}],"ecosystem":"Go","package":"github.com/lestrrat-go/jwx","purl":"pkg:golang/github.com/lestrrat-go/jwx","source":"go"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","fixed":"2.0.19"}],"ecosystem":"Go","package":"github.com/lestrrat-go/jwx/v2","purl":"pkg:golang/github.com/lestrrat-go/jwx/v2","source":"go"},{"ranges":[{"status":"affected","fixed":"2.0.19"}],"vendor":"lestrrat-go","product":"jwx","cpe":"cpe:2.3:a:lestrrat-go:jwx:*:*:*:*:*:*:*:*","source":"nvd"}],"references":[{"url":"https://github.com/lestrrat-go/jwx/security/advisories/GHSA-pvcr-v8j8-j5q3","tags":["exploit","vendor-advisory","web","x-refsource-confirm","x-transferred"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/lestrrat-go/jwx/commit/0e8802ce6842625845d651456493e7c87625601f","tags":["fix","patch","web","x-refsource-misc","x-transferred"],"sources":["cvelist","ghsa","go","nvd"]},{"url":"https://github.com/lestrrat-go/jwx/commit/8c53d0ae52d5ab1e2b37c5abb67def9e7958fd65","tags":["web","x-refsource-misc","x-transferred"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/lestrrat-go/jwx/commit/d69a721931a5c48b9850a42404f18e143704adcd","tags":["fix","patch","web","x-refsource-misc","x-transferred"],"sources":["cvelist","ghsa","go","nvd"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2024-21664","tags":["advisory"],"sources":["ghsa","go"]},{"url":"https://github.com/lestrrat-go/jwx","tags":["package"],"sources":["ghsa"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"poc","automatable":"no","technicalImpact":"partial","date":"2024-01-09T21:08:07.994Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2024-21664","url":"https://www.cve.org/CVERecord?id=CVE-2024-21664","licence":"CVE Terms of Use","modified":"2025-06-17T20:59:10.877Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-pvcr-v8j8-j5q3","url":"https://github.com/advisories/GHSA-pvcr-v8j8-j5q3","licence":"CC-BY-4.0","modified":"2026-09-10T03:50:05.133Z"},{"source":"go","name":"Go Vulnerability Database","id":"GO-2024-2454","url":"https://pkg.go.dev/vuln/GO-2024-2454","licence":"CC-BY-4.0","modified":"2026-02-04T02:29:32.208Z"},{"source":"nvd","name":"NVD","id":"CVE-2024-21664","url":"https://nvd.nist.gov/vuln/detail/CVE-2024-21664","licence":"Public domain","modified":"2026-06-17T07:09:56.953Z"}],"updatedAt":"2026-11-25T22:58:36.003Z","epss":{"score":0.00864,"percentile":0.59694,"date":"2026-12-01T12:00:22.000Z"}}