{"id":"CVE-2022-1471","aliases":["CVE-2022-1471","GHSA-mjmj-j48q-9wg2"],"related":[],"kind":"vulnerability","state":"published","title":"Remote Code execution in SnakeYAML","summary":"SnakeYaml's Constructor() class does not restrict types which can be instantiated during deserialization. Deserializing yaml content provided by an attacker can lead to remote code execution. We recommend using SnakeYaml's SafeConsturctor when parsing untrusted content to restrict deserialization. We recommend upgrading to version 2.0 and beyond.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"SnakeYaml's Constructor() class does not restrict types which can be instantiated during deserialization. Deserializing yaml content provided by an attacker can lead to remote code execution. We recommend using SnakeYaml's SafeConsturctor when parsing untrusted content to restrict deserialization. We recommend upgrading to version 2.0 and beyond.","source":"cvelist"},{"lang":"en","text":"### Summary\nSnakeYaml's `Constructor` class, which inherits from `SafeConstructor`, allows\nany type be deserialized given the following line:\n\nnew Yaml(new Constructor(TestDataClass.class)).load(yamlContent);\n\nTypes do not have to match the types of properties in the\ntarget class. A `ConstructorException` is thrown, but only after a malicious\npayload is deserialized.\n\n### Severity\nHigh, lack of type checks during deserialization allows remote code execution.\n\n### Proof of Concept\nExecute `bash run.sh`. The PoC uses Constructor to deserialize a payload\nfor RCE. RCE is demonstrated by using a payload which performs a http request to\nhttp://127.0.0.1:8000.\n\nExample output of successful run of proof of concept:\n\n```\n$ bash run.sh\n\n[+] Downloading snakeyaml if needed\n[+] Starting mock HTTP server on 127.0.0.1:8000 to demonstrate RCE\nnc: no process found\n[+] Compiling and running Proof of Concept, which a payload that sends a HTTP request to mock web server.\n[+] An exception is expected.\nException:\nCannot create property=payload for JavaBean=Main$TestDataClass@3cbbc1e0\n in 'string', line 1, column 1:\n    payload: !!javax.script.ScriptEn ... \n    ^\nCan not set java.lang.String field Main$TestDataClass.payload to javax.script.ScriptEngineManager\n in 'string', line 1, column 10:\n    payload: !!javax.script.ScriptEngineManag ... \n             ^\n\n\tat org.yaml.snakeyaml.constructor.Constructor$ConstructMapping.constructJavaBean2ndStep(Constructor.java:291)\n\tat org.yaml.snakeyaml.constructor.Constructor$ConstructMapping.construct(Constructor.java:172)\n\tat org.yaml.snakeyaml.constructor.Constructor$ConstructYamlObject.construct(Constructor.java:332)\n\tat org.yaml.snakeyaml.constructor.BaseConstructor.constructObjectNoCheck(BaseConstructor.java:230)\n\tat org.yaml.snakeyaml.constructor.BaseConstructor.constructObject(BaseConstructor.java:220)\n\tat org.yaml.snakeyaml.constructor.BaseConstructor.constructDocument(BaseConstructor.java:174)\n\tat org.yaml.snakeyaml.constructor.BaseConstructor.getSingleData(BaseConstructor.java:158)\n\tat org.yaml.snakeyaml.Yaml.loadFromReader(Yaml.java:491)\n\tat org.yaml.snakeyaml.Yaml.load(Yaml.java:416)\n\tat Main.main(Main.java:37)\nCaused by: java.lang.IllegalArgumentException: Can not set java.lang.String field Main$TestDataClass.payload to javax.script.ScriptEngineManager\n\tat java.base/jdk.internal.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:167)\n\tat java.base/jdk.internal.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:171)\n\tat java.base/jdk.internal.reflect.UnsafeObjectFieldAccessorImpl.set(UnsafeObjectFieldAccessorImpl.java:81)\n\tat java.base/java.lang.reflect.Field.set(Field.java:780)\n\tat org.yaml.snakeyaml.introspector.FieldProperty.set(FieldProperty.java:44)\n\tat org.yaml.snakeyaml.constructor.Constructor$ConstructMapping.constructJavaBean2ndStep(Constructor.java:286)\n\t... 9 more\n[+] Dumping Received HTTP Request. Will not be empty if PoC worked\nGET /proof-of-concept HTTP/1.1\nUser-Agent: Java/11.0.14\nHost: localhost:8000\nAccept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2\nConnection: keep-alive\n```\n\n### Further Analysis\nPotential mitigations include, leveraging SnakeYaml's SafeConstructor while parsing untrusted content.\n\nSee https://bitbucket.org/snakeyaml/snakeyaml/issues/561/cve-2022-1471-vulnerability-in#comment-64581479 for discussion on the subject.\n\n### Timeline\n**Date reported**: 4/11/2022\n**Date fixed**:  [30/12/2022](https://bitbucket.org/snakeyaml/snakeyaml/pull-requests/44)\n**Date disclosed**: 10/13/2022","format":"markdown","source":"ghsa"},{"lang":"es","text":"La clase Constructor() de SnakeYaml no restringe los tipos de los que se pueden crear instancias durante la deserialización. La deserialización del contenido yaml proporcionado por un atacante puede conducir a la ejecución remota de código. Recomendamos utilizar SafeConsturctor de SnakeYaml al analizar contenido que no es de confianza para restringir la deserialización. Recomendamos actualizar a la versión 2.0 y posteriores.","source":"nvd"}],"published":"2022-12-01T10:47:07.203Z","modified":"2026-09-10T03:49:50.365Z","severity":{"scorer":"Google","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:L","score":8.3,"rating":"HIGH"},"severities":[{"scorer":"Google","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:L","score":8.3,"rating":"HIGH"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:L","score":8.3,"rating":"HIGH"},{"scorer":"NVD","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H","score":9.8,"rating":"CRITICAL"}],"cwes":["CWE-20","CWE-502"],"affected":[{"ranges":[{"type":"custom","introduced":"0","lastAffected":"2.0","status":"affected"}],"vendor":"SnakeYAML","product":"SnakeYAML","source":"cvelist"},{"ranges":[{"type":"ecosystem","introduced":"0","status":"affected","fixed":"2.0"}],"ecosystem":"Maven","package":"org.yaml:snakeyaml","purl":"pkg:maven/org.yaml/snakeyaml","source":"ghsa"},{"ranges":[{"status":"affected","fixed":"2.0"}],"vendor":"snakeyaml_project","product":"snakeyaml","cpe":"cpe:2.3:a:snakeyaml_project:snakeyaml:*:*:*:*:*:*:*:*","source":"nvd"}],"references":[{"url":"https://github.com/google/security-research/security/advisories/GHSA-mjmj-j48q-9wg2","tags":["exploit","third-party-advisory","web","x-transferred"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://bitbucket.org/snakeyaml/snakeyaml/issues/561/cve-2022-1471-vulnerability-in#comment-64581479","tags":["issue-tracking","third-party-advisory","web","x-transferred"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/mbechler/marshalsec","tags":["exploit","third-party-advisory","web","x-transferred"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://www.github.com/mbechler/marshalsec/blob/master/marshalsec.pdf?raw=true","tags":["exploit","third-party-advisory","web","x-transferred"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://groups.google.com/g/kubernetes-security-announce/c/mwrakFaEdnc","tags":["web","x-transferred"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://security.netapp.com/advisory/ntap-20230818-0015/","tags":["x-transferred"],"sources":["cvelist","nvd"]},{"url":"http://packetstormsecurity.com/files/175095/PyTorch-Model-Server-Registration-Deserialization-Remote-Code-Execution.html","tags":["web","x-transferred"],"sources":["cvelist","ghsa","nvd"]},{"url":"http://www.openwall.com/lists/oss-security/2023/11/19/1","tags":["web","x-transferred"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://security.netapp.com/advisory/ntap-20240621-0006/","tags":["x-transferred"],"sources":["cvelist","nvd"]},{"url":"https://infosecwriteups.com/%EF%B8%8F-inside-the-160-comment-fight-to-fix-snakeyamls-rce-default-1a20c5ca4d4c","tags":["web"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://confluence.atlassian.com/security/cve-2022-1471-snakeyaml-library-rce-vulnerability-in-multiple-products-1296171009.html","tags":["web"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2022-1471","tags":["advisory"],"sources":["ghsa"]},{"url":"https://snyk.io/blog/unsafe-deserialization-snakeyaml-java-cve-2022-1471","tags":["web"],"sources":["ghsa"]},{"url":"https://security.netapp.com/advisory/ntap-20240621-0006","tags":["web"],"sources":["ghsa"]},{"url":"https://security.netapp.com/advisory/ntap-20230818-0015","tags":["web"],"sources":["ghsa"]},{"url":"https://bitbucket.org/snakeyaml/snakeyaml/wiki/CVE-2022-1471","tags":["web"],"sources":["ghsa"]},{"url":"https://bitbucket.org/snakeyaml/snakeyaml/issues/561/cve-2022-1471-vulnerability-in#comment-64876314","tags":["web"],"sources":["ghsa"]},{"url":"https://bitbucket.org/snakeyaml/snakeyaml/issues/561/cve-2022-1471-vulnerability-in#comment-64634374","tags":["web"],"sources":["ghsa"]},{"url":"https://bitbucket.org/snakeyaml/snakeyaml/commits/acc44099f5f4af26ff86b4e4e4cc1c874e2dc5c4","tags":["web"],"sources":["ghsa"]},{"url":"https://bitbucket.org/snakeyaml/snakeyaml/commits/5014df1a36f50aca54405bb8433bc99a8847f758","tags":["web"],"sources":["ghsa"]},{"url":"https://bitbucket.org/snakeyaml/snakeyaml","tags":["package"],"sources":["ghsa"]}],"credits":[],"assigner":"Google","ssvc":{"scorer":"CISA-ADP","exploitation":"poc","automatable":"no","technicalImpact":"total","date":"2024-08-07T18:13:22.155Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2022-1471","url":"https://www.cve.org/CVERecord?id=CVE-2022-1471","licence":"CVE Terms of Use","modified":"2025-06-18T08:32:58.546Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-mjmj-j48q-9wg2","url":"https://github.com/advisories/GHSA-mjmj-j48q-9wg2","licence":"CC-BY-4.0","modified":"2026-09-10T03:49:50.365Z"},{"source":"nvd","name":"NVD","id":"CVE-2022-1471","url":"https://nvd.nist.gov/vuln/detail/CVE-2022-1471","licence":"Public domain","modified":"2026-06-17T04:22:30.807Z"}],"updatedAt":"2026-11-25T22:58:17.156Z","epss":{"score":0.99501,"percentile":0.99943,"date":"2026-12-01T12:00:22.000Z"}}