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

Feature: allow to revoke or disable device CA #324

Merged
merged 12 commits into from
Nov 14, 2023
Merged

Conversation

vkhoroz
Copy link
Member

@vkhoroz vkhoroz commented Oct 20, 2023

Currently, an API allows to simply remove the device CA from a list of CAs.

This change implements the device CA removal via the X.509 certificate revocation.
That way, a user is required to crypto-sign the operation using the factory root CA.
Thus, we both obtain an cryptographic conscent from the user for this operation and protect against several scenarios:

  • An accidental device CA removal by passing a wrong file to "keys ca update".
  • An intentional device CA removal by bad admin who does not possess the factory root CA.

After this change, the API will be changed to require the "ca-crt" field to contain all device CAs which:

  • Are already present in the "ca-crt" list on the backend.
  • And are not explicitly listed in the "ca-revoke-crl" list.

There are two new operations introduced:

  • disable device CA: Tell the backend to disallow registering new devices using this CA; already registered devices (using this CA) can still connect and use FoundriesFactory.
  • revoke device CA: Tell the backend to remove this CA from the list of trusted device CAs; devices with client certs issued by this CA can no longer connect and use FoundriesFactory.

Signed-off-by: Volodymyr Khoroz volodymyr.khoroz@foundries.io

x509/common.go Show resolved Hide resolved
@mike-sul
Copy link
Contributor

LGTM. It makes sense to me. I'll finalize this PR review after the corresponding API PR is posted.

@mike-sul
Copy link
Contributor

If a user wants to add a new device CA then maybe it would be more convenient for a user to add just a new device ca to the "ca-crt" field, instead of

After this change, the API will be changed to require the "ca-crt" field to contain all device CAs which:

    Are already present in the "ca-crt" list on the backend.

?

@vkhoroz
Copy link
Member Author

vkhoroz commented Oct 31, 2023

If a user wants to add a new device CA then maybe it would be more convenient for a user to add just a new device ca to the "ca-crt" field ...

The API will continue to require the client to upload the full CA list, as it is now.
But, the Fioctl allows the user to add just one CA using fioctl keys ca add-device-ca command.

What is changed:

  • currently, the user can overwrite the list of device CAs with some garbage (completely new list of CAs) by mistake.
  • after the change that will be no longer possible, as that list becomes append-only; with remove operation being accomplished via the crypto-signed CRL.

@mike-sul
Copy link
Contributor

The API will continue to require the client to upload the full CA list

Not sure it's convenient from a user perspective since it requires to fetch the online device CA before making the update request.

@vkhoroz
Copy link
Member Author

vkhoroz commented Nov 6, 2023

@doanac @mike-sul @StealthyCoder I'm almost done with this one.

I will take a look why PKI tests failed; they were passing for me locally.
A commit list is not ideal yet; so don't rush reviewing this - I'll clean it up tomorrow.
Also, I did not yet test this end-2-end fully - will continue tomorrow as well.

@vkhoroz vkhoroz changed the title PoC: Feature: allow to revoke device CA Feature: allow to revoke or disable device CA Nov 8, 2023
@vkhoroz
Copy link
Member Author

vkhoroz commented Nov 8, 2023

@doanac @mike-sul @StealthyCoder @camilamacedo86

This was tested with the API version currently deployed to our staging MEDS instance.
I added and tested all planned featurettes:

  • Device CA can be disabled or revoked.
  • Dry-run and pretty options work as expected.
  • When disabled, device CA shows as disabled in keys ca show.
  • When disabled, I can no longer register devices using API with this CA.
  • When revoked, devices using this CA cannot connect to device gateway, failing mTLS handshake.

What still needs to be implemented:

  • The device gateway part for the auto-registration is pending.

Copy link
Contributor

@mike-sul mike-sul left a comment

Choose a reason for hiding this comment

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

LGTM

@vkhoroz
Copy link
Member Author

vkhoroz commented Nov 10, 2023

@kprosise @vanmaegima @angolini do you want to give a grammar check to the new commands descriptions?

I believe that by Tuesday @doanac and/or @mike-sul will approve this; so it is stable enough for the literacy polish.

Copy link
Contributor

@kprosise kprosise left a comment

Choose a reason for hiding this comment

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

Some minor suggestions, overall the text LGTM

subcommands/keys/ca_revoke_device_ca.go Outdated Show resolved Hide resolved
subcommands/keys/ca_revoke_device_ca.go Outdated Show resolved Hide resolved
subcommands/keys/ca_revoke_device_ca.go Outdated Show resolved Hide resolved
subcommands/keys/ca_revoke_device_ca.go Outdated Show resolved Hide resolved
I need to use this routine for the "key ca revoke-device-ca" command.

Signed-off-by: Volodymyr Khoroz <volodymyr.khoroz@foundries.io>
…how"

This is a no-op change, as the big.Int is printed as base 10 by default.
This commit simply makes that explicit, so that we are protected from future changes.
It is important for the device CA revocation, as users are going to copy-paste CA serials.

Signed-off-by: Volodymyr Khoroz <volodymyr.khoroz@foundries.io>
Currently, an API allows to simply remove the device CA from a list of CAs.

This change proposes to implement device CA removal via the X.509 certificate revocation.
That way, a user is required to crypto-sign the operation using the factory root CA.
Thus, we both obtain an cryptographic conscent from the user for this operation and protect against several scenarios:
- An accidental device CA removal by passing a wrong file to "keys ca update".
- An intentional device CA removal by bad admin who does not possess the factory root CA.

After this change, the API will be changed to require the "ca-crt" field to contain all device CAs which:
- Are already present in the "ca-crt" list on the backend.
- And are not explicitly listed in the "ca-revoke-crl" list.

Signed-off-by: Volodymyr Khoroz <volodymyr.khoroz@foundries.io>
This is a soft variant of the device CA revocation.
A difference is that already registered devices can continue to connect and use FoundriesFactory.

This is handy when the device CA is compromised, as it allows to act immediately so that things does not get worse.

Signed-off-by: Volodymyr Khoroz <volodymyr.khoroz@foundries.io>
We need this in order to be able to sign the CRL for the device CA revocation.

For old factory CAs already in the field, a workaround is to artificially set this bit at runtime.
The API needs to be smart to not check this bit of the factory root CA when validating the CRL.

Signed-off-by: Volodymyr Khoroz <volodymyr.khoroz@foundries.io>
Signed-off-by: Volodymyr Khoroz <volodymyr.khoroz@foundries.io>
This is called to make the user experience even safer.
Before generating the CRL, we check if provided serials are known to the server as device CAs.

Signed-off-by: Volodymyr Khoroz <volodymyr.khoroz@foundries.io>
…rver

Signed-off-by: Volodymyr Khoroz <volodymyr.khoroz@foundries.io>
This helps me to introduce a logic for the disabled device CAs with less code.

Signed-off-by: Volodymyr Khoroz <volodymyr.khoroz@foundries.io>
Signed-off-by: Volodymyr Khoroz <volodymyr.khoroz@foundries.io>
…M data

This was found while reviewing the copy-pasted code; so need to fix the original.

Signed-off-by: Volodymyr Khoroz <volodymyr.khoroz@foundries.io>
This will be reused for to validate if the revoked/disabled cert is present in the actual device CAs list.

Signed-off-by: Volodymyr Khoroz <volodymyr.khoroz@foundries.io>
@vkhoroz
Copy link
Member Author

vkhoroz commented Nov 13, 2023

Rebased, squashed fixups, and applied all wording corrections.

@vkhoroz vkhoroz merged commit f3a96bd into main Nov 14, 2023
8 checks passed
@vkhoroz vkhoroz deleted the vkhoroz-revoke-device-ca branch November 14, 2023 13:43
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.

9 participants