Skip to content

Create DBus method to dump the certificate #1285

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

sanapci
Copy link

@sanapci sanapci commented Nov 22, 2023

The changes will create a new DBus method, for other applications to get the certificate chain from a bundle.

There is a command which prints a readable format from CLI, but with these changes we could be able to retrieve certificate chain programmatically and work on the "consumer" side.

What do you use the feature for? Get the certificate from a bundle and validate it outside of the RAUC .
How does RAUC benefit from the feature? This could be useful also for other users if want to handle certificates outside of the RAUC, in their application. For example, let's say there are multiple signing certificates and we want to get from the bundle which one was used and interpret behavior based on this.
How did you verify the feature works? Used OpenSSL commands to generate the certificate chain and compared it with the one from the output of the changes. Also the output of the changes can be parsed and printed with OpenSSL commands and print it in readable format.
If hardware is needed for the feature, which hardware is supported and which
hardware did you test with?
No hardware required, only a created bundle required.

Copy link

codecov bot commented Nov 22, 2023

Codecov Report

Attention: 29 lines in your changes are missing coverage. Please review.

Comparison is base (fab63c2) 79.90% compared to head (3e3feeb) 80.03%.
Report is 40 commits behind head on master.

❗ Current head 3e3feeb differs from pull request most recent head e942178. Consider uploading reports for the commit e942178 to get more accurate results

Files Patch % Lines
src/service.c 62.79% 16 Missing ⚠️
src/signature.c 78.33% 13 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1285      +/-   ##
==========================================
+ Coverage   79.90%   80.03%   +0.13%     
==========================================
  Files          67       67              
  Lines       19892    20075     +183     
==========================================
+ Hits        15894    16068     +174     
- Misses       3998     4007       +9     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ejoerns
Copy link
Member

ejoerns commented Nov 22, 2023

@sanapci Thank you for sharing your work!

How does RAUC benefit from the feature? This could be useful also for other users if want to handle certificates outside of the RAUC, in their application. For example, let's say there are multiple signing certificates and we want to get from the bundle which one was used and interpret behavior based on this.

I guess with 'multiple signing certificates' you mean alternative ones, since RAUC at the moment does not support multiple signers (at once), right?
Could you give an insight on what kind of interpretation you would do based on the signer?
Does it have to be done before invoking the installation?

From inside the bundle one could for example use hooks and the exported SPKI hashes to perform actions based on the kind of certificate used for signing: https://rauc.readthedocs.io/en/latest/advanced.html#switching-the-keyring-spki-hashes

@jluebbe
Copy link
Member

jluebbe commented Nov 23, 2023

This approach would make it easy to have a TOC/TOU vulnerability, as there is no guarantee that an installation started after calling this method would use the same bundle.

As @ejoerns mentioned, we'll need more details on your use case and an explanation why you see this approach is the best solution for it.

@jluebbe jluebbe added the enhancement Adds new functionality or enhanced handling to RAUC label Nov 23, 2023
Signed-off-by: Elek, David <dave.elek.96@gmail.com>
@sanapci
Copy link
Author

sanapci commented Nov 23, 2023

@ejoerns

I guess with 'multiple signing certificates' you mean alternative ones, since RAUC at the moment does not support multiple signers (at once), right?

Yes, you are right, I meant to have alternative ones and not in one bundle.

Could you give an insight on what kind of interpretation you would do based on the signer?

Let's say, the bundle validation fails with the installed trustchain. In this case, maybe an update required for the trustchain on the system because it is an outdated one and the installation fails.

Does it have to be done before invoking the installation?

Yes, this could be a prevention for a scenario, where the bundle installation fails.

From inside the bundle one could for example use hooks and the exported SPKI hashes to perform actions based on the kind of certificate used for signing: https://rauc.readthedocs.io/en/latest/advanced.html#switching-the-keyring-spki-hashes

With the hashes it is required to get the certificate with the same hash from the internet, otherwise it would not be possible to do verifications and checks with the certificate.

@jluebbe

This approach would make it easy to have a TOC/TOU vulnerability, as there is no guarantee that an installation started after calling this method would use the same bundle.

This feature is not intended to take over the verification from the installation process. If the install is trigerred the internal verification still executed.

@sanapci sanapci force-pushed the add_dumpcert_dbus_method branch from 8d3841f to 0e825e9 Compare November 23, 2023 15:09
Signed-off-by: Elek, David <dave.elek.96@gmail.com>
@sanapci sanapci removed their assignment Nov 27, 2023
@sanapci
Copy link
Author

sanapci commented Nov 30, 2023

@ejoerns @jluebbe Could you give an update (remarks, opinions, etc.) about this based on my previous comment?

…oding in hexadecimal

Signed-off-by: Elek, David <dave.elek.96@gmail.com>
@jluebbe
Copy link
Member

jluebbe commented Dec 1, 2023

@ejoerns @jluebbe Could you give an update (remarks, opinions, etc.) about this based on my previous comment?

Sorry, but the scenario doesn't make sense to me, yet.

How do you authenticate the new certificate?

Could you give an insight on what kind of interpretation you would do based on the signer?

Let's say, the bundle validation fails with the installed trustchain. In this case, maybe an update required for the trustchain on the system because it is an outdated one and the installation fails.

To know that you keyring is outdated, you shouldn't need the certificates, but just a dedicated error result from InstallBundle or InspectBundle. If you see that error, you'd know that an update is needed and the correct CA certificate could be fetched over a separate authenticated channel.

At that point I'm wondering though: If you have a way to authenticate the new CA certificate, why not just use the same certificate to authenticate RAUC bundles and avoid the whole issue from the start?

@sanapci
Copy link
Author

sanapci commented Nov 7, 2024

The changes in the pull requests are containing some errors and needs to be updated if required.

The details maybe were a bit misleading, so to be clear:
There is a root CA, an intermediate CA and the certificate used for bundle creation. By using the --intermediate, the bundle can be used with the root CA, what is more the intermediate CA can be extracted also. If the CA is updated online, but the system is offline or used offline, the certificate extraction from the bundle can be a solution to install new CA via an update bundle.

The extracted CA and certificate is verified with the root CA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Adds new functionality or enhanced handling to RAUC
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants