-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ensure that snakeyaml does not deserialize objects based on YAML tags
[CVE-2022-1471][1] describes an issue where versions of SnakeYAML prior to 2.0 would deserialize a YAML document and instantiate a class based on the document contents. This behavior can lead to issues like ``` !!javax.script.ScriptEngineManager [!!java.net.URLClassLoader [[!!java.net.URL ["http://localhost:8080/"]]]] ``` where untrusted code can be loaded over the internet into the ClassLoader. This issue is addressed in version 2.0 where SnakeYAML was altered to no longer allow so-called "global tags" which are the mechanism used for this arbitrary deserialization. There is also the `SafeConstructor` class which does not do any deserialization beyond primitive Java types and basic collections. We, however, need to deserialize to an object of our choice, SubscriptionRegistry, so this patch explicitly disables global tags (even though that is the default with SnakeYAML >2.0 anyway) and adds a test to ensure global tags are disabled. [1]: https://www.cve.org/CVERecord?id=CVE-2022-1471
- Loading branch information
Showing
4 changed files
with
56 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
swatch-product-configuration/src/test/resources/cve_2022_1471_product.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# From https://snyk.io/blog/unsafe-deserialization-snakeyaml-java-cve-2022-1471/ | ||
!!javax.script.ScriptEngineManager [!!java.net.URLClassLoader [[!!java.net.URL ["http://localhost:8080/"]]]] |
1 change: 1 addition & 0 deletions
1
swatch-product-configuration/src/test/resources/cve_2022_1471_swatch_config_index.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
cve_2022_1471_product.yaml |