[Bug 1983160] [NEW] Starting a salted session fails when using an RSA key in FIPS mode
Chris Coulson
1983160 at bugs.launchpad.net
Sat Jul 30 00:13:36 UTC 2022
Public bug reported:
When configuring SSH to use a TPM protected key for authentication using
tpm2-pkcs11 following the steps documented in
https://github.com/tpm2-software/tpm2-pkcs11/blob/master/docs/SSH.md, it
fails when trying to login on a system that is running in FIPS mode,
with the following error message:
WARNING:esys:src/tss2-esys/api/Esys_StartAuthSession.c:383:Esys_StartAuthSession_Finish() Received TPM Error
ERROR:esys:src/tss2-esys/api/Esys_StartAuthSession.c:136:Esys_StartAuthSession() Esys Finish ErrorCode (0x000002c4)
ERROR: Esys_StartAuthSession: tpm:parameter(2):value is out of range or is not correct for the context
ERROR: Could not start Auth Session with the TPM.
ERROR: Error unsealing wrapping key
C_Login failed: 5
login failed
pkcs11_get_key failed
sign_and_send_pubkey: signing failed for RSA "": error in libcrypto
Parameter 2 in this case is the encrypted salt supplied to the
TPM2_StartAuthSession command. tpm2-pkcs11 is creating a session that is
salted with a value which is encrypted with the public part of a TPM
protected RSA key before being sent to the TPM.
This encryption happens in iesys_cryptossl_pk_encrypt which has a bug in
the version in focal that was fixed accidentally in
https://github.com/tpm2-software/tpm2-tss/commit/362fda1daa398da2944e76013c215500761d46a5.
In focal, iesys_cryptossl_pk_encrypt generates a RSA key using openssl
and then overwrites the public modulus with the one associated with the
TPM key. This fails when running a FIPS certified version of openssl in
FIPS mode because openssl performs a test on the generated key, which
results in the Montgomery value associated with the generated public
modulus being cached. The cached value isn't updated when the public
modulus is changed, and the incorrect value is used in the subsequent
encryption operation.
[Impact]
It's not possible to use tpm2-pkcs11 on a system that is running in FIPS mode with the version of tpm2-tss in focal.
This is fixed by partially backporting
https://github.com/tpm2-software/tpm2-tss/commit/362fda1daa398da2944e76013c215500761d46a5
so that iesys_cryptossl_pk_encrypt does not perform an unnecessary key
generation.
[Test plan]
Follow the instructions detailed in https://github.com/tpm2-software/tpm2-pkcs11/blob/master/docs/SSH.md and verify that it is possible to login to localhost with the TPM protected key.
You will need to compile tpm2-pkcs11 from source. 1.6.0 is compatible
with the version of tpm2-tss in focal.
[Regression potential]
This is minimal - iesys_cryptossl_pk_encrypt is implemented this way already in releases after focal. It's also only used by StartAuthSession when called with a TPM key, which isn't that usual.
** Affects: tpm2-tss (Ubuntu)
Importance: Undecided
Status: Fix Released
** Affects: tpm2-tss (Ubuntu Focal)
Importance: Undecided
Status: Triaged
** Also affects: tpm2-tss (Ubuntu Focal)
Importance: Undecided
Status: New
** Changed in: tpm2-tss (Ubuntu)
Status: New => Fix Released
** Changed in: tpm2-tss (Ubuntu Focal)
Status: New => Triaged
--
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to tpm2-tss in Ubuntu.
https://bugs.launchpad.net/bugs/1983160
Title:
Starting a salted session fails when using an RSA key in FIPS mode
Status in tpm2-tss package in Ubuntu:
Fix Released
Status in tpm2-tss source package in Focal:
Triaged
Bug description:
When configuring SSH to use a TPM protected key for authentication
using tpm2-pkcs11 following the steps documented in
https://github.com/tpm2-software/tpm2-pkcs11/blob/master/docs/SSH.md,
it fails when trying to login on a system that is running in FIPS
mode, with the following error message:
WARNING:esys:src/tss2-esys/api/Esys_StartAuthSession.c:383:Esys_StartAuthSession_Finish() Received TPM Error
ERROR:esys:src/tss2-esys/api/Esys_StartAuthSession.c:136:Esys_StartAuthSession() Esys Finish ErrorCode (0x000002c4)
ERROR: Esys_StartAuthSession: tpm:parameter(2):value is out of range or is not correct for the context
ERROR: Could not start Auth Session with the TPM.
ERROR: Error unsealing wrapping key
C_Login failed: 5
login failed
pkcs11_get_key failed
sign_and_send_pubkey: signing failed for RSA "": error in libcrypto
Parameter 2 in this case is the encrypted salt supplied to the
TPM2_StartAuthSession command. tpm2-pkcs11 is creating a session that
is salted with a value which is encrypted with the public part of a
TPM protected RSA key before being sent to the TPM.
This encryption happens in iesys_cryptossl_pk_encrypt which has a bug
in the version in focal that was fixed accidentally in
https://github.com/tpm2-software/tpm2-tss/commit/362fda1daa398da2944e76013c215500761d46a5.
In focal, iesys_cryptossl_pk_encrypt generates a RSA key using openssl
and then overwrites the public modulus with the one associated with
the TPM key. This fails when running a FIPS certified version of
openssl in FIPS mode because openssl performs a test on the generated
key, which results in the Montgomery value associated with the
generated public modulus being cached. The cached value isn't updated
when the public modulus is changed, and the incorrect value is used in
the subsequent encryption operation.
[Impact]
It's not possible to use tpm2-pkcs11 on a system that is running in FIPS mode with the version of tpm2-tss in focal.
This is fixed by partially backporting
https://github.com/tpm2-software/tpm2-tss/commit/362fda1daa398da2944e76013c215500761d46a5
so that iesys_cryptossl_pk_encrypt does not perform an unnecessary key
generation.
[Test plan]
Follow the instructions detailed in https://github.com/tpm2-software/tpm2-pkcs11/blob/master/docs/SSH.md and verify that it is possible to login to localhost with the TPM protected key.
You will need to compile tpm2-pkcs11 from source. 1.6.0 is compatible
with the version of tpm2-tss in focal.
[Regression potential]
This is minimal - iesys_cryptossl_pk_encrypt is implemented this way already in releases after focal. It's also only used by StartAuthSession when called with a TPM key, which isn't that usual.
To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/tpm2-tss/+bug/1983160/+subscriptions
More information about the foundations-bugs
mailing list