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

[Backport][ipa-4-6] Vault: Migrate to RSA-OAEP #7212

Open
wants to merge 5 commits into
base: ipa-4-6
Choose a base branch
from

Conversation

f-trivino
Copy link
Contributor

This PR was opened manually because PR #6959 was pushed to master and backport to ipa-4-6 is required.

@f-trivino f-trivino added the WIP Work in progress - not ready yet for review label Jan 31, 2024
@f-trivino
Copy link
Contributor Author

WIP as I need to test well.

@f-trivino f-trivino removed the WIP Work in progress - not ready yet for review label Feb 1, 2024
@f-trivino
Copy link
Contributor Author

Hi @rcritten, @flo-renaud

I spawned RHEL7.9 server and client:

RHEL7.9 server/client with the patches in normal mode (KRA uses PKCS1v15), keyWrap.useOAEP is not in the CS.cfg file:

  • vault-add works from the server
  • vault-archive works from the server
  • vault-retrieve works from the server
  • vault-del works from the server
  • vault-add works from the client
  • vault-archive works from the client
  • vault-retrieve works from the client
  • vault-del works from the client

I manually added UseOAEP in the KRA, and restarted pki-tomcatd@pki-tomcat.service, then:

  • vault-add works from the server
  • vault-archive works from the server
  • vault-retrieve works from the server
  • vault-del works from the server
  • vault-add works from the client
  • vault-archive works from the client
  • vault-retrieve works from the client
  • vault-del works from the client

running with pki-kra-10.5.18-27.el7_9.noarch.

@flo-renaud
Copy link
Contributor

Hi @f-trivino
I applied the patch on a RHEL 7.9 server in FIPS mode and tried to call ipa vault-add from a fedora38 FIPS client using source code from the master branch (with dnf copr enable @freeipa/freeipa-master-nightly). ipa vault-add is failing because the following patches were not backported to RHEL 7.9:
Support AES for KRA archival wrapping
Set AES as default for KRA archival wrapping

The 7.9 server answers to vaultconfig-show with a result containing only the transport cert. With recent versions the result also contains wrapping_supported_algorithms and wrapping_default_algorithm.
If this info is not present in the result of vaultconfig-show, the client assumes that the wrapping algo is 3DES and fails:

# python3  /usr/bin/ipa vault-add clientvault --password Secret123
ipa: ERROR: non-public: ValueError: non-generic 'ValidationError' needs format=None; got format="'des-ede3-cbc' is not a supported vault wrapping algorithm"
Traceback (most recent call last):
  File "/usr/lib/python3.11/site-packages/ipalib/backend.py", line 141, in execute
    return self.Command[_name](*args, **options)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/ipalib/frontend.py", line 471, in __call__
    return self.__do_call(*args, **options)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/ipalib/frontend.py", line 499, in __do_call
    ret = self.run(*args, **options)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/ipalib/frontend.py", line 1224, in run
    return self.forward(*args, **options)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/ipaclient/plugins/vault.py", line 356, in forward
    self.api.Command.vault_archive(*args, **opts)
  File "/usr/lib/python3.11/site-packages/ipalib/frontend.py", line 471, in __call__
    return self.__do_call(*args, **options)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/ipalib/frontend.py", line 499, in __do_call
    ret = self.run(*args, **options)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/ipalib/frontend.py", line 1224, in run
    return self.forward(*args, **options)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/ipaclient/plugins/vault.py", line 963, in forward
    self.api.Command.vault_retrieve(*args, **opts)
  File "/usr/lib/python3.11/site-packages/ipalib/frontend.py", line 471, in __call__
    return self.__do_call(*args, **options)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/ipalib/frontend.py", line 499, in __do_call
    ret = self.run(*args, **options)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/ipalib/frontend.py", line 1224, in run
    return self.forward(*args, **options)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/ipaclient/plugins/vault.py", line 1156, in forward
    algo = self._generate_session_key(wrapping_algo)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/ipaclient/plugins/vault.py", line 659, in _generate_session_key
    raise errors.ValidationError(msg.format(algo=repr(name)))
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/ipalib/errors.py", line 269, in __init__
    messages.process_message_arguments(self, format, message, **kw)
  File "/usr/lib/python3.11/site-packages/ipalib/messages.py", line 61, in process_message_arguments
    raise ValueError(
ValueError: non-generic 'ValidationError' needs format=None; got format="'des-ede3-cbc' is not a supported vault wrapping algorithm"
ipa: ERROR: an internal error has occurred

ipalib/constants.py Outdated Show resolved Hide resolved
ipalib/constants.py Outdated Show resolved Hide resolved
@f-trivino f-trivino added the WIP Work in progress - not ready yet for review label Feb 12, 2024
@f-trivino f-trivino force-pushed the backport_pr6959_ipa-4-6 branch 3 times, most recently from a6b32e5 to 799176e Compare February 13, 2024 12:45
tiran and others added 5 commits February 13, 2024 15:53
The vault plugin has used TripleDES (des-ede3-cbc) as default wrapping
algorithm since the plugin was introduced. Allow use of AES-128-CBC as
alternative wrapping algorithm for transport of secrets.

Fixes: https://pagure.io/freeipa/issue/6524

Signed-off-by: Christian Heimes <cheimes@redhat.com>
Reviewed-By: Alexander Bokovoy <abokovoy@redhat.com>
Reviewed-By: Christian Heimes <cheimes@redhat.com>
This commit sets AES-128-CBC as default wrapping algorithm as
TripleDES (des-ede3-cbc) is not supported anymore in C9S.

Fixes: https://pagure.io/freeipa/issue/6524

Signed-off-by: Francisco Trivino <ftrivino@redhat.com>
Reviewed-By: Alexander Bokovoy <abokovoy@redhat.com>
Reviewed-By: Christian Heimes <cheimes@redhat.com>
AES-128-CBC was recently enabled as default wrapping algorithm for transport of secrets.
This change was done in favor of FIPS as crypto-policies disabled 3DES in RHEL9, but
setting AES as default ended-up breaking backwards compatibility with older RHEL systems.

This commit is tuning some defaults so that interoperability with older RHEL systems
works again. The new logic reflects:

- when an old client is calling a new server, it doesn't send any value for wrapping_algo
  and the old value is used (3DES), so that the client can decrypt using 3DES.

- when a new client is calling a new server, it sends wrapping_algo = AES128_CBC

- when a new client is calling an old server, it doesn't send any value and the default is
  to use 3DES.

Finally, as this logic is able to handle overlapping wrapping algorithm between server and
client, the Option "--wrapping-algo" is hidden from "ipa vault-archive --help" and "ipa
vault-retrieve --help" commands.

Fixes: https://pagure.io/freeipa/issue/9259
Signed-off-by: Francisco Trivino <ftrivino@redhat.com>
Reviewed-By: Florence Blanc-Renaud <frenaud@redhat.com>
Reviewed-By: Rob Crittenden <rcritten@redhat.com>
None of the FIPS certified modules in RHEL support PKCS#1 v1.5 as FIPS
approved mechanism. This commit adds support for RSA-OAEP padding as a
fallback.

Fixes: https://pagure.io/freeipa/issue/9191

Signed-off-by: Francisco Trivino <ftrivino@redhat.com>
If a vault operation fails, the error message just says "InternalError". This commit
improves error handling of key archival and retrieval calls by catching the PKIException
error and raising it as an IPA error.

Related: https://pagure.io/freeipa/issue/9191

Signed-off-by: Francisco Trivino <ftrivino@redhat.com>
@f-trivino
Copy link
Contributor Author

@flo-renaud I believe this is ready now. I'm removing temp_commit (passing tests are here: http://freeipa-org-pr-ci.s3-website.eu-central-1.amazonaws.com/jobs/3974dc32-ca6f-11ee-9f92-fa163eeea21a/)

I also did some manual testing with rhel7.9 server and rhel9.4 client with all patches:

Without FIPS:

  • vaultconfig-show (from client and server)
  • vault-(add, archive, retrieve, del) type standard (from client and server)
  • vault-(add, archive, retrieve, del) type symmetric (from client and server)
  • vault-(add, archive, retrieve, del) type asymmetric (from client and server)

With FIPS:

  • vaultconfig-show (server)
  • vault-(add, archive, retrieve, del) type standard (server)
  • vault-(add, archive, retrieve, del) type symmetric (server)
  • vault-(add, archive, retrieve, del) type asymmetric (server)

@f-trivino f-trivino added needs review Pull Request is waiting for a review and removed WIP Work in progress - not ready yet for review labels Feb 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs review Pull Request is waiting for a review
Projects
None yet
3 participants