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 CXF to latest version to get rid of CVE-2022-46364 and #197

Closed
wants to merge 2 commits into from

Conversation

post-svejk
Copy link

@post-svejk post-svejk commented Dec 20, 2022

CVE-2022-46363

Also upgrade WSS4J to 2.4.1 which is supposed to work with CXF >= 3.4.*.

Pull Request Description

Fixes the above two vulnerabilities being reported against Oxalis-AS4 5.4.0 by snyk and Trivy.
I have barely tested a snapshot of it with Oxalis 5.4.0 in a test environment at Digipost (both inbound and outbound processes), but haven't found any isses so far.

Not 100% sure yet if the upgrade breaks anything else.

Type of Pull Request

  • New feature/Enhancement - non-breaking change which adds functionality
  • Bug fix
  • Breaking change (Require Major version change?)

Type of Change

  • OpenPeppol AS4 specification
  • Oxalis software change or enhancement
  • CEF change

Pull Request Checklist:

  • My code follows the style guidelines of this project
  • [NA] I have commented my code, particularly in hard-to-understand areas. But did not added unnecessary annotation/comment say @author name etc
  • I have checked my code for variable and method name and corrected grammar/spelling mistakes if any
  • [NA] I have made corresponding changes to the documentation where needed
  • My changes generate no new/additional warnings
  • [?] My change is not breaking or creating conflict with associated dependencies
  • I have performed a self-review of my own code
  • I ran mvn clean install before commit and all tests run successfully
  • I conducted basic QA to assure all features are working fine
  • My pull request generate no conflicts with master branch
  • I requested code review from other team members

CVE-2022-46363

Also upgrade WSS4J to 2.4.1 which is supposed to work with CXF >= 3.4.*.
@post-svejk
Copy link
Author

@aaron-kumar : Can you have a look at this?

}

OxalisAlgorithmSuite(final SPConstants.SPVersion version, final Policy nestedPolicy) {
super(version, nestedPolicy);
this.setAsymmetricSignature("http://www.w3.org/2001/04/xmldsig-more#rsa-sha256");
Copy link

Choose a reason for hiding this comment

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

I do not understand this change - does it relate to the topic of PR?

Copy link
Author

Choose a reason for hiding this comment

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

The API of WSS4J have changed. The method setAsymmetricSignature appears to have been moved from the top level class AlgorithmSuite to the nested class AlgorithmSuiteType.

Copy link

Choose a reason for hiding this comment

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

OK, good! But could it be that AsymmetricSignature is not set to "http://www.w3.org/2001/04/xmldsig-more#rsa-sha256" for
BASIC_128_GCM_SHA_256
but only for
BASIC_128_GCM_SHA_256_MGF_SHA_256?

In previous version, it was defined on a OxalisAlgorithmSuite level, in a new version - on AlgorithmSuiteType, but in

algorithmSuiteType.setAsymmetricSignature("http://www.w3.org/2001/04/xmldsig-more#rsa-sha256");
it is set only for BASIC_128_GCM_SHA_256_MGF_SHA_256, right?

May be we miss similar line for BASIC_128_GCM_SHA_256?

If we make mistake here, it will be quite difficult to find it out...

Copy link
Author

Choose a reason for hiding this comment

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

Yes. The asymmetric signature is now only set for the second custom AlgorithmSuiteType, BASIC_128_GCM_SHA_256_MGF_SHA_256. It might well be that it is needed for the first one, too.

I put it on the second suite type, since it already had a couple of customizations, guessing that the first one might not need customisation. But I don't know these WSS4J APIs, I just did the bare minimum to get it to compile against newer CXF and WSS4J. And it appears to be working in our test environment, but that might be a false positive, if some default asymmetric signature with weaker security is used instead...

Do you think its safer to assign the asymmetric signature on both?

Copy link
Author

Choose a reason for hiding this comment

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

From the WSS4J code, the algorithm suite gets a default asymmetric signature, when we don't specify it. So it's probably safest to set it on both suites. I have added that in the last commit.

Copy link

Choose a reason for hiding this comment

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

Thank you! Yes, this looks safer - better to keep the same logic as much as possible during upgrades.
I think it is ok now - although I would write it like before, without extracting to a variable algorithmSuiteType for only one of suites:

ALGORITHM_SUITE_TYPES.get(BASIC_128_GCM_SHA_256_MGF_SHA_256).setMGFAlgo(MGF_SHA256);
ALGORITHM_SUITE_TYPES.get(BASIC_128_GCM_SHA_256_MGF_SHA_256).setEncryptionDigest(SPConstants.SHA256);
ALGORITHM_SUITE_TYPES.get(BASIC_128_GCM_SHA_256_MGF_SHA_256)
	.setAsymmetricSignature("http://www.w3.org/2001/04/xmldsig-more#rsa-sha256");

ALGORITHM_SUITE_TYPES.get(BASIC_128_GCM_SHA_256)
	.setAsymmetricSignature("http://www.w3.org/2001/04/xmldsig-more#rsa-sha256");

In this case, the commit diff would clearly highlight, that you just added .setAsymmetricSignature("http://www.w3.org/2001/04/xmldsig-more#rsa-sha256"); to both suite types because it is removed from Suite.
But it is just a question of styling :)

Anyway, let's see @aaron-kumar review too :)

Copy link
Author

Choose a reason for hiding this comment

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

Ok, seems like @aaron-kumar did a superset of these changes in the latest release, and also added code to adjust the signature algorithm.

(was: ommitted). If we don't set it explicitly, a default asymmetric
signature gets used, so we probably should do it.
@post-svejk post-svejk closed this Jan 4, 2023
@post-svejk post-svejk deleted the upgrade-cxf branch January 4, 2023 13:01
@aaron-kumar aaron-kumar added the dependencies Pull requests that update a dependency file label Jan 16, 2023
@aaron-kumar aaron-kumar added this to the 5.x.x milestone Jan 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Pull requests that update a dependency file
Projects
Status: Completed
Development

Successfully merging this pull request may close these issues.

3 participants