Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SWATCH-718: Ensure SnakeYAML does not deserialize arbitrary classes #3859

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

awood
Copy link
Contributor

@awood awood commented Oct 15, 2024

Jira issue: SWATCH-718

Description

CVE-2022-1471 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.

Testing

Unit test only

@awood awood added the Dev Pull requests that need developer review label Oct 15, 2024
@awood awood added the QE Unneeded Pull request does not need QE approval label Oct 15, 2024
@Sgitario Sgitario added Dev/approved Pull requests that have been approved by all assigned developers and removed Dev Pull requests that need developer review labels Oct 16, 2024
@ntkathole
Copy link
Member

/retest

1 similar comment
@Sgitario
Copy link
Contributor

/retest

[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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Dev/approved Pull requests that have been approved by all assigned developers QE Unneeded Pull request does not need QE approval
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants