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

Upgrade snakeyaml to 2.0 #24636

Closed
wants to merge 1 commit into from
Closed

Conversation

zhfeng
Copy link
Contributor

@zhfeng zhfeng commented Mar 16, 2023

Fixes CVE-2022-1471

Changes proposed in this pull request:

  • upgrade snakeyaml to 2.0

Before committing this PR, I'm sure that I have checked the following options:

  • My code follows the code of conduct of this project.
  • I have self-reviewed the commit code.
  • I have (or in comment I request) added corresponding labels for the pull request.
  • I have passed maven check locally : ./mvnw clean install -B -T1C -Dmaven.javadoc.skip -Dmaven.jacoco.skip -e.
  • I have made corresponding changes to the documentation.
  • I have added corresponding unit tests for my changes.

@zhfeng
Copy link
Contributor Author

zhfeng commented Mar 16, 2023

The more information could be found here: https://www.veracode.com/blog/research/resolving-cve-2022-1471-snakeyaml-20-release-0

I'm not sure shardingsphere allows global tags? I run some related tests with Yaml and they all work.

@zhfeng
Copy link
Contributor Author

zhfeng commented Mar 16, 2023

The test fails

Error:  org.apache.shardingsphere.test.it.data.pipeline.scenario.consistencycheck.api.impl.ConsistencyCheckJobAPITest.assertDropByParentJobId  Time elapsed: 0.374 s  <<< ERROR!
java.lang.NoSuchMethodError: org.yaml.snakeyaml.representer.Representer: method 'void <init>()' not found
	at org.apache.shardingsphere.elasticjob.infra.yaml.representer.ElasticJobYamlRepresenter.<init>(ElasticJobYamlRepresenter.java:28)
	at org.apache.shardingsphere.elasticjob.infra.yaml.YamlEngine.marshal(YamlEngine.java:38)
	at org.apache.shardingsphere.elasticjob.lite.lifecycle.internal.settings.JobConfigurationAPIImpl.updateJobConfiguration(JobConfigurationAPIImpl.java:51)
	at org.apache.shardingsphere.data.pipeline.core.api.impl.AbstractPipelineJobAPIImpl.stop(AbstractPipelineJobAPIImpl.java:151)
	at org.apache.shardingsphere.data.pipeline.scenario.consistencycheck.api.impl.ConsistencyCheckJobAPI.dropByParentJobId(ConsistencyCheckJobAPI.java:207)
	at org.apache.shardingsphere.test.it.data.pipeline.scenario.consistencycheck.api.impl.ConsistencyCheckJobAPITest.assertDropByParentJobId(ConsistencyCheckJobAPITest.java:108)

It seems that we need to fix in shardingsphere-elasticjob as well.

@zhfeng
Copy link
Contributor Author

zhfeng commented Mar 16, 2023

Well, shardingsphere-elasticjob::elasticjob-lite-spring-boot-starter depends on spring-boot:2.3.x which has not been fixed. According to https://spring.io/projects/spring-boot#support, 2.3.x is EOL so I think we should consider to upgrade to 2.7.x at least.

@terrymanu
Copy link
Member

I am considering shading all dependencies of ShardingSphere at a later time so that I won't need to worry about compatibility issues with Spring or other third-party libraries.
However, this is a long-term job that may take several months to complete.

@zhfeng
Copy link
Contributor Author

zhfeng commented Mar 19, 2023

Thanks @terrymanu for taking care of the upgarding.

I did some works on shardingsphere-elasticjob to test with spring-boot 2.7.10-SNAPSHOT and snakeyaml 2.0. See zhfeng/shardingsphere-elasticjob@0c2d7b3

We need to be very careful about these CVE issues. Anyway, if I understand correctly, we only use snakeyaml for parsing the configuration files. So it could be low risk in this case.

@zhfeng
Copy link
Contributor Author

zhfeng commented Mar 19, 2023

Also do we consider to enable Vulnerability alerts in github which could notify us when our dependency libraies have some security issues which need to be fixed. Something like https://github.com/apache/camel/security/dependabot

Maybe we need to open a ticket for Apache Infra team?

@TeslaCN
Copy link
Member

TeslaCN commented Mar 20, 2023

Also do we consider to enable Vulnerability alerts in github which could notify us when our dependency libraies have some security issues which need to be fixed. Something like https://github.com/apache/camel/security/dependabot

Maybe we need to open a ticket for Apache Infra team?

Thanks for your suggestion. Vulnerability alerts was enabled in ShardingSphere repo.

@zhfeng
Copy link
Contributor Author

zhfeng commented Mar 20, 2023

Hmm, I can not see it because I'm not a committor?

@TeslaCN
Copy link
Member

TeslaCN commented Mar 20, 2023

Hmm, I can not see it because I'm not a committor?

I cannot see camel's security tab either.

@zhfeng
Copy link
Contributor Author

zhfeng commented Mar 20, 2023

Yeah, that makes sense. Anyway, CVE-2022-1471 is marked as High due to allow remote code execution. But in shardingshpere, I think we only use it to parse the yaml configuration files, so it might be low risk in this case?

@TeslaCN
Copy link
Member

TeslaCN commented Mar 21, 2023

Yeah, that makes sense. Anyway, CVE-2022-1471 is marked as High due to allow remote code execution. But in shardingshpere, I think we only use it to parse the yaml configuration files, so it might be low risk in this case?

Yes.

Copy link
Member

@linghengqian linghengqian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

@lizongbo lizongbo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes need upgrade to support snakeyml 1.33 to 2.1

@linghengqian
Copy link
Member

yes need upgrade to support snakeyml 1.33 to 2.1

  • @lizongbo Obviously we have two ways of thinking about dealing with downstream usage. One is to wait for the Release of ShardingSphere ElasticJob 3.0.4, and the other is to shade the SnakeYAML package, so that the downstream can use a higher version of the SnakeYAML API.

  • I assume you are interested in the first option, but I am not sure about the release plan of ShardingSphere ElasticJob 3.0.4. Would you like to start a discussion on the mailing list?

@github-actions github-actions bot removed the stale label Aug 19, 2023
@lizongbo
Copy link
Contributor

yes need upgrade to support snakeyml 1.33 to 2.1

  • @lizongbo Obviously we have two ways of thinking about dealing with downstream usage. One is to wait for the Release of ShardingSphere ElasticJob 3.0.4, and the other is to shade the SnakeYAML package, so that the downstream can use a higher version of the SnakeYAML API.
  • I assume you are interested in the first option, but I am not sure about the release plan of ShardingSphere ElasticJob 3.0.4. Would you like to start a discussion on the mailing list?

This changed code is fully compatible with snakeyml 1.33, 2.0, 2.1.

because The Representer class's old constructor Representer() was marked as Deprecated in 1.33 and then removed in version 2.0

"public Representer(DumperOptions options) " is exists in 1.33 ,2.0 and 2.1 .

@linghengqian
Copy link
Member

yes need upgrade to support snakeyml 1.33 to 2.1

  • @lizongbo Obviously we have two ways of thinking about dealing with downstream usage. One is to wait for the Release of ShardingSphere ElasticJob 3.0.4, and the other is to shade the SnakeYAML package, so that the downstream can use a higher version of the SnakeYAML API.
  • I assume you are interested in the first option, but I am not sure about the release plan of ShardingSphere ElasticJob 3.0.4. Would you like to start a discussion on the mailing list?

This changed code is fully compatible with snakeyml 1.33, 2.0, 2.1.

because The Representer class's old constructor Representer() was marked as Deprecated in 1.33 and then removed in version 2.0

"public Representer(DumperOptions options) " is exists in 1.33 ,2.0 and 2.1 .

@zhfeng
Copy link
Contributor Author

zhfeng commented Aug 21, 2023

So is there any update on a new release of ElasticJob? I think it has been upgrade.

@linghengqian
Copy link
Member

So is there any update on a new release of ElasticJob? I think it has been upgrade.

@zhfeng
Copy link
Contributor Author

zhfeng commented Aug 21, 2023

Thanks @linghengqian - Please raise this concern on the dev mailing list. It should be important to fix the security issue and hope it can be included in 5.4.1.

@linghengqian
Copy link
Member

Thanks @linghengqian - Please raise this concern on the dev mailing list. It should be important to fix the security issue and hope it can be included in 5.4.1.

  • @zhfeng I found that I wasn't quite sure how to rewrite the sender from outlook.com to my personal apache.org mailbox, outlook's PC client got a big update in August of this year.

  • I'm assuming you have time to send mail to the dev mailing list first?

@zhfeng
Copy link
Contributor Author

zhfeng commented Aug 22, 2023

@linghengqian NP - I will take care of it.

@zhfeng zhfeng force-pushed the upgrade_snakeyaml_2.0 branch from 0f4153b to f189047 Compare August 22, 2023 06:06
@TeslaCN
Copy link
Member

TeslaCN commented Sep 12, 2023

Hi @linghengqian Are you willing to release ElasticJob 3.0.4?

@linghengqian
Copy link
Member

Hi @linghengqian Are you willing to release ElasticJob 3.0.4?

  • @TeslaCN I have no experience working on releases at ASF, and my work has been scattered in recent months. I hope other committers can help with this process.

Copy link
Member

@linghengqian linghengqian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zhfeng
Copy link
Contributor Author

zhfeng commented Oct 19, 2023

@linghengqian feel free to rasie a new PR!

@linghengqian
Copy link
Member

@linghengqian feel free to rasie a new PR!

@zhfeng
Copy link
Contributor Author

zhfeng commented Oct 19, 2023

Thanks @linghengqian and I close this PR.

@zhfeng zhfeng closed this Oct 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants