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

Encryption method rsa-1.5 must be block-listed #738

Closed
peppelinux opened this issue Oct 25, 2020 · 4 comments
Closed

Encryption method rsa-1.5 must be block-listed #738

peppelinux opened this issue Oct 25, 2020 · 4 comments

Comments

@peppelinux
Copy link
Member

peppelinux commented Oct 25, 2020

Algorithm="http://www.w3.org/2001/04/xmlenc#rsa-1_5" must be blacklisted.
At this time it's instead the default one.

Code Version

master branch and previous releases

Expected Behavior

IdP should encrypt the Assertions in the Response using one of the available Encryption Algorithm in the Service Provider Metadata. For example, Shibboleth SP 3 exposes as default these:

      <md:EncryptionMethod Algorithm="http://www.w3.org/2009/xmlenc11#aes128-gcm"/>
      <md:EncryptionMethod Algorithm="http://www.w3.org/2009/xmlenc11#aes192-gcm"/>
      <md:EncryptionMethod Algorithm="http://www.w3.org/2009/xmlenc11#aes256-gcm"/>
      <md:EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#aes128-cbc"/>
      <md:EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#aes192-cbc"/>
      <md:EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#aes256-cbc"/>
      <md:EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#tripledes-cbc"/>
      <md:EncryptionMethod Algorithm="http://www.w3.org/2009/xmlenc11#rsa-oaep"/>
      <md:EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p"/>

Current Behavior

Digging in pysaml2 I found:

  • saml2.sigver
  • saml2./xml_template/template.xml (used in saml2.sigver.SecurityContext)

In sigver.py we have a default value here:
immagine

In saml2./xml_template/template.xml something more hardcoded:
immagine

Possible Solution

We should:

Steps to Reproduce

pySAML2 IdP encrypts or not the assertion depending by the arguments passed in the method saml2.server.Server.create_authn_response. We should be able to dynamically put encryption if SP have enc cert in its metadata (handled in uniAuth: https://github.com/UniversitaDellaCalabria/uniAuth/blob/7f514798f903ce212c680915f6dbdb22ffd100d8/uniauth/views.py#L472)

@c00kiemon5ter
Copy link
Member

Thanks @peppelinux for the report. I've noted all those things and this is what I'll be focusing on starting tomorrow.

None of the algos are configurable at this point. Some of them exist as variables (pointers to defaults), but others are hardcoded (ie, the transport). We need to create new configuration options for all of them along with block/allow-lists.

As you noted, we do have related issues and PRs about this. But, probably this will end up being bigger, as in a revamp on how we use and invoke xmlsec1 and consideration of moving away from it and towards something like python-xmlsec.

@c00kiemon5ter
Copy link
Member

c00kiemon5ter commented Oct 25, 2020

The goal is to do this in steps (where each step is a release):

  • change defaults to stronger ones (breaking)
  • introduce configuration options
  • introduce block/allow-lists
  • change defaults to meet saml2int (breaking)

@peppelinux
Copy link
Member Author

We could introduce configuration options as first step, then taking them OR default values.
once we defined the configuration option then we'll found the correct semantic to handle them, this way we'll just add f{option}_blacklist to have the blacklisted ones.

Regarding sha256 as default, please consider #597 in a way that

      for algorithm in ('signing_algorithm', 'digest_algorithm'):
            setattr(self, algorithm, self.config.getattr(algorithm, "sp", DEFAULT_ONE))

@peppelinux
Copy link
Member Author

This PR cover part of this issue as a temporary remediation
#754

@c00kiemon5ter c00kiemon5ter changed the title Encryption Algorithm "http://www.w3.org/2001/04/xmlenc#rsa-1_5" must be blacklisted Encryption Algorithm "http://www.w3.org/2001/04/xmlenc#rsa-1_5" must be block-listed May 18, 2021
@c00kiemon5ter c00kiemon5ter changed the title Encryption Algorithm "http://www.w3.org/2001/04/xmlenc#rsa-1_5" must be block-listed Encryption method rsa-1.5 must be block-listed May 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants