CVE-2022-1471: Snakeyaml Remote Code Execution Vulnerability

HIGH
Advisory Identifier: GHSA-mjmj-j48q-9wg2
CVSS 8.3
CWE-502 CWE-20
Published
Advisory Summary

CVE-2022-1471 is a HIGH (CVSS 8.3) remote code execution vulnerability (CWE-502: Deserialization of Untrusted Data) affecting Snakeyaml libraries in the Maven ecosystem. The issue involves snakeyaml constructor deserialization remote code execution. Remediation is available by upgrading affected packages to version 2.0.

CVE-2022-1471 at a Glance

CVE Identifier CVE-2022-1471
GHSA Identifier GHSA-mjmj-j48q-9wg2
Severity HIGH
CVSS v3.1 Base Score 8.3
CWE Classification CWE-502: Deserialization of Untrusted Data
Affected Product Snakeyaml
Package Ecosystem Maven
Published Date
Last Updated

Security Impact

CVSS: 8.3

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:L).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required Low (PR:L)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality High (C:H)
Integrity High (I:H)
Availability Low (A:L)

How to Fix CVE-2022-1471

To remediate this vulnerability, upgrade all affected Snakeyaml dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

org.yaml:snakeyaml fixed: 2.0
<dependency>
    <groupId>org.yaml</groupId>
    <artifactId>snakeyaml</artifactId>
    <version>2.0</version>
</dependency>
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

mvn dependency:tree -Dincludes=org.yaml

How to Check if You Are Affected

To determine whether your Java application is affected by CVE-2022-1471, inspect your build dependencies using the Maven Dependency Plugin:

mvn dependency:tree -Dincludes=org.yaml

Analyze the terminal output to locate any version of Snakeyaml in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 2.0), your application is affected.

Note: The mvn dependency:tree -Dincludes=org.yaml command inspects the resolved dependency graph declared in your project's POM files; it does not perform automated security scanning or inspect runtime dynamic classpaths. Always verify runtime container classpaths and shaded JARs.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-502: Deserialization of Untrusted Data, where the product deserializes untrusted data without sufficiently ensuring that the resulting data will be valid. In Snakeyaml, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

### Summary SnakeYaml's `Constructor` class, which inherits from `SafeConstructor`, allows any type be deserialized given the following line: new Yaml(new Constructor(TestDataClass.class)).load(yamlContent); Types do not have to match the types of properties in the target class. A `ConstructorException` is thrown, but only after a malicious payload is deserialized. ### Severity High, lack of type checks during deserialization allows remote code execution. ### Proof of Concept Execute `bash run.sh`. The PoC uses Constructor to deserialize a payload for RCE. RCE is demonstrated by using a payload which performs a http request to http://127.0.0.1:8000. Example output of successful run of proof of concept: ``` $ bash run.sh [+] Downloading snakeyaml if needed [+] Starting mock HTTP server on 127.0.0.1:8000 to demonstrate RCE nc: no process found [+] Compiling and running Proof of Concept, which a payload that sends a HTTP request to mock web server. [+] An exception is expected. Exception: Cannot create property=payload for JavaBean=Main$TestDataClass@3cbbc1e0 in 'string', line 1, column 1: payload: !!javax.script.ScriptEn ... ^ Can not set java.lang.String field Main$TestDataClass.payload to javax.script.ScriptEngineManager in 'string', line 1, column 10: payload: !!javax.script.ScriptEngineManag ... ^ at org.yaml.snakeyaml.constructor.Constructor$ConstructMapping.constructJavaBean2ndStep(Constructor.java:291) at org.yaml.snakeyaml.constructor.Constructor$ConstructMapping.construct(Constructor.java:172) at org.yaml.snakeyaml.constructor.Constructor$ConstructYamlObject.construct(Constructor.java:332) at org.yaml.snakeyaml.constructor.BaseConstructor.constructObjectNoCheck(BaseConstructor.java:230) at org.yaml.snakeyaml.constructor.BaseConstructor.constructObject(BaseConstructor.java:220) at org.yaml.snakeyaml.constructor.BaseConstructor.constructDocument(BaseConstructor.java:174) at org.yaml.snakeyaml.constructor.BaseConstructor.getSingleData(BaseConstructor.java:158) at org.yaml.snakeyaml.Yaml.loadFromReader(Yaml.java:491) at org.yaml.snakeyaml.Yaml.load(Yaml.java:416) at Main.main(Main.java:37) Caused by: java.lang.IllegalArgumentException: Can not set java.lang.String field Main$TestDataClass.payload to javax.script.ScriptEngineManager at java.base/jdk.internal.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:167) at java.base/jdk.internal.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:171) at java.base/jdk.internal.reflect.UnsafeObjectFieldAccessorImpl.set(UnsafeObjectFieldAccessorImpl.java:81) at java.base/java.lang.reflect.Field.set(Field.java:780) at org.yaml.snakeyaml.introspector.FieldProperty.set(FieldProperty.java:44) at org.yaml.snakeyaml.constructor.Constructor$ConstructMapping.constructJavaBean2ndStep(Constructor.java:286) ... 9 more [+] Dumping Received HTTP Request. Will not be empty if PoC worked GET /proof-of-concept HTTP/1.1 User-Agent: Java/11.0.14 Host: localhost:8000 Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2 Connection: keep-alive ``` ### Further Analysis Potential mitigations include, leveraging SnakeYaml's SafeConstructor while parsing untrusted content. See https://bitbucket.org/snakeyaml/snakeyaml/issues/561/cve-2022-1471-vulnerability-in#comment-64581479 for discussion on the subject. ### Timeline **Date reported**: 4/11/2022 **Date fixed**: [30/12/2022](https://bitbucket.org/snakeyaml/snakeyaml/pull-requests/44) **Date disclosed**: 10/13/2022

CVE-2022-1471 Affected Snakeyaml Versions

1 component(s)
Fixed Versions:
2.0
Product / Package Ecosystem Affected Versions Fixed Version
org.yaml:snakeyaml
Maven
< 2.0
2.0

References

GitHub Advisory / Wiki ADVISORY
https://github.com/google/security-research/security/advisories/GHSA-mjmj-j48q-9wg2
NVD — CVE-2022-1471 NVD
https://nvd.nist.gov/vuln/detail/CVE-2022-1471
Snakeyaml Source Repository REPOSITORY
https://www.github.com/mbechler/marshalsec/blob/master/marshalsec.pdf?raw=true
snyk.io/blog/unsafe-deseria... WEB
https://snyk.io/blog/unsafe-deserialization-snakeyaml-java-cve-2022-1471
Snakeyaml Security Information SECURITY
https://security.netapp.com/advisory/ntap-20240621-0006
Snakeyaml Security Information SECURITY
https://security.netapp.com/advisory/ntap-20230818-0015
infosecwriteups.com/️-inside-the-160-co... WEB
https://infosecwriteups.com/%EF%B8%8F-inside-the-160-comment-fight-to-fix-snakeyamls-rce-default-1a20c5ca4d4c
Snakeyaml Security Information SECURITY
https://groups.google.com/g/kubernetes-security-announce/c/mwrakFaEdnc
Snakeyaml Source Repository REPOSITORY
https://github.com/mbechler/marshalsec
Snakeyaml Security Information SECURITY
https://confluence.atlassian.com/security/cve-2022-1471-snakeyaml-library-rce-vulnerability-in-multiple-products-1296171009.html
bitbucket.org/snakeyaml/snakeyaml... WEB
https://bitbucket.org/snakeyaml/snakeyaml/wiki/CVE-2022-1471
bitbucket.org/snakeyaml/snakeyaml... WEB
https://bitbucket.org/snakeyaml/snakeyaml/issues/561/cve-2022-1471-vulnerability-in#comment-64876314
bitbucket.org/snakeyaml/snakeyaml... WEB
https://bitbucket.org/snakeyaml/snakeyaml/issues/561/cve-2022-1471-vulnerability-in#comment-64634374
bitbucket.org/snakeyaml/snakeyaml... WEB
https://bitbucket.org/snakeyaml/snakeyaml/issues/561/cve-2022-1471-vulnerability-in#comment-64581479
bitbucket.org/snakeyaml/snakeyaml... WEB
https://bitbucket.org/snakeyaml/snakeyaml/commits/acc44099f5f4af26ff86b4e4e4cc1c874e2dc5c4
bitbucket.org/snakeyaml/snakeyaml... WEB
https://bitbucket.org/snakeyaml/snakeyaml/commits/5014df1a36f50aca54405bb8433bc99a8847f758
bitbucket.org/snakeyaml/snakeyaml PACKAGE
https://bitbucket.org/snakeyaml/snakeyaml
Snakeyaml Security Information SECURITY
http://packetstormsecurity.com/files/175095/PyTorch-Model-Server-Registration-Deserialization-Remote-Code-Execution.html
Snakeyaml Security Information SECURITY
http://www.openwall.com/lists/oss-security/2023/11/19/1

Frequently Asked Questions

What is CVE-2022-1471?
CVE-2022-1471 is a security vulnerability in Snakeyaml involving SnakeYaml Constructor Deserialization Remote Code Execution under CWE-502: Deserialization of Untrusted Data.
Which Snakeyaml versions are affected?
Affected versions include releases prior to 2.0 across affected packages: org.yaml:snakeyaml.
What version fixes CVE-2022-1471?
Upgrading to 2.0 (or the latest patched release for your respective branch) resolves the vulnerability.
Is snakeyaml affected?
Yes, org.yaml:snakeyaml is affected in releases prior to 2.0. Upgrade your dependency to 2.0 or later.
What is the CVSS score of CVE-2022-1471?
CVE-2022-1471 has a CVSS v3.1 base score of 8.3 (HIGH) with vector string CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:L.
What CWE is associated with CVE-2022-1471?
CVE-2022-1471 is classified under CWE-502: Deserialization of Untrusted Data (The product deserializes untrusted data without sufficiently ensuring that the resulting data will be valid.).
How can I check Maven dependencies for CVE-2022-1471?
Run the dependency tree command: 'mvn dependency:tree -Dincludes=org.yaml'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-mjmj-j48q-9wg2",
  "modified" : "2025-06-18T17:45:18Z",
  "published" : "2022-12-12T21:19:47Z",
  "aliases" : [ "CVE-2022-1471" ],
  "summary" : "SnakeYaml Constructor Deserialization Remote Code Execution",
  "details" : "### 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",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:L"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Maven",
      "name" : "org.yaml:snakeyaml"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "2.0"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 1.33"
    }
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/google/security-research/security/advisories/GHSA-mjmj-j48q-9wg2"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2022-1471"
  }, {
    "type" : "WEB",
    "url" : "https://www.github.com/mbechler/marshalsec/blob/master/marshalsec.pdf?raw=true"
  }, {
    "type" : "WEB",
    "url" : "https://snyk.io/blog/unsafe-deserialization-snakeyaml-java-cve-2022-1471"
  }, {
    "type" : "WEB",
    "url" : "https://security.netapp.com/advisory/ntap-20240621-0006"
  }, {
    "type" : "WEB",
    "url" : "https://security.netapp.com/advisory/ntap-20230818-0015"
  }, {
    "type" : "WEB",
    "url" : "https://infosecwriteups.com/%EF%B8%8F-inside-the-160-comment-fight-to-fix-snakeyamls-rce-default-1a20c5ca4d4c"
  }, {
    "type" : "WEB",
    "url" : "https://groups.google.com/g/kubernetes-security-announce/c/mwrakFaEdnc"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/mbechler/marshalsec"
  }, {
    "type" : "WEB",
    "url" : "https://confluence.atlassian.com/security/cve-2022-1471-snakeyaml-library-rce-vulnerability-in-multiple-products-1296171009.html"
  }, {
    "type" : "WEB",
    "url" : "https://bitbucket.org/snakeyaml/snakeyaml/wiki/CVE-2022-1471"
  }, {
    "type" : "WEB",
    "url" : "https://bitbucket.org/snakeyaml/snakeyaml/issues/561/cve-2022-1471-vulnerability-in#comment-64876314"
  }, {
    "type" : "WEB",
    "url" : "https://bitbucket.org/snakeyaml/snakeyaml/issues/561/cve-2022-1471-vulnerability-in#comment-64634374"
  }, {
    "type" : "WEB",
    "url" : "https://bitbucket.org/snakeyaml/snakeyaml/issues/561/cve-2022-1471-vulnerability-in#comment-64581479"
  }, {
    "type" : "WEB",
    "url" : "https://bitbucket.org/snakeyaml/snakeyaml/commits/acc44099f5f4af26ff86b4e4e4cc1c874e2dc5c4"
  }, {
    "type" : "WEB",
    "url" : "https://bitbucket.org/snakeyaml/snakeyaml/commits/5014df1a36f50aca54405bb8433bc99a8847f758"
  }, {
    "type" : "PACKAGE",
    "url" : "https://bitbucket.org/snakeyaml/snakeyaml"
  }, {
    "type" : "WEB",
    "url" : "http://packetstormsecurity.com/files/175095/PyTorch-Model-Server-Registration-Deserialization-Remote-Code-Execution.html"
  }, {
    "type" : "WEB",
    "url" : "http://www.openwall.com/lists/oss-security/2023/11/19/1"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-20", "CWE-502" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2022-12-12T21:19:47Z",
    "nvd_published_at" : "2022-12-01T11:15:00Z"
  }
}