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

many: add passphrase authentication support #14918

Conversation

ZeyadYasser
Copy link
Contributor

This PR implements passphrase authentication support during installation. Currently all volumes created during installation are passphrase encrypted, i.e. ubuntu-data and ubuntu-save.

The implications of having ubuntu-save optionally passphrase-protected is that a factory reset would require a passphrase to be entered to work. This is still an open question on what is optimal from a UX perspective.

Note: This is still not exposed through the API until target system and entropy checks are added. This is done by not including passphrase-auth in the list of supported encryption features (Check SD201).

I tested the implementation against the spread test from #14867.

@ZeyadYasser ZeyadYasser added Needs Samuele review Needs a review from Samuele before it can land Run nested The PR also runs tests inluded in nested suite FDE Manager Pull requests that target FDE manager branch labels Jan 10, 2025
@pedronis pedronis force-pushed the fde-manager-features branch from 5802840 to 5ec2e43 Compare January 13, 2025 09:50
This is still not exposed through the API until target
system and entropy checks are added.

Signed-off-by: Zeyad Gouda <[email protected]>
@ZeyadYasser ZeyadYasser force-pushed the fde-passphrase-support branch from 8b6b37c to 7da02d3 Compare January 13, 2025 12:04
Copy link
Collaborator

@pedronis pedronis left a comment

Choose a reason for hiding this comment

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

question and small comment

@@ -1356,7 +1357,7 @@ func createSaveBootstrappedContainer(saveNode string) (secboot.BootstrappedConta
return nil, err
}

return secbootCreateBootstrappedContainer(secboot.DiskUnlockKey(saveEncryptionKey), saveNode), nil
return secbootCreateBootstrappedContainer(secboot.DiskUnlockKey(saveEncryptionKey), saveNode, nil), nil
Copy link
Collaborator

Choose a reason for hiding this comment

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

shouldn't we take the value from the cache passed it in? is the test currently only dealing with mocked stuff?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

createSaveBootstrappedContainer is only called during factory reset

saveBoostrapContainer, err := createSaveBootstrappedContainer(saveNode)

The value is passed from cache in EncryptPartitions() in the install code path.

Copy link
Collaborator

@pedronis pedronis Jan 15, 2025

Choose a reason for hiding this comment

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

can you point to the relevant code for EncryptPartitions?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ahh yes, my bad

encryptionSetupData, err := installEncryptPartitions(onVolumes, volumesAuth, encType, systemAndSeeds.Model, mntPtForType[snap.TypeGadget], mntPtForType[snap.TypeKernel], perfTimings)

Copy link
Collaborator

Choose a reason for hiding this comment

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

return nil
}

func kdfOptions(volumesAuth device.VolumesAuthOptions) (sb.KDFOptions, error) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

this probably should take a pointer as well to device.VolumesAuthOptions)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated, thanks!

@ZeyadYasser ZeyadYasser requested a review from pedronis January 15, 2025 13:44
Copy link

codecov bot commented Jan 15, 2025

Codecov Report

Attention: Patch coverage is 93.97590% with 5 lines in your changes missing coverage. Please review.

Please upload report for BASE (fde-manager-features@5ec2e43). Learn more about missing BASE report.
Report is 8 commits behind head on fde-manager-features.

Files with missing lines Patch % Lines
secboot/secboot_tpm.go 95.65% 2 Missing and 1 partial ⚠️
secboot/bootstrap_container.go 66.66% 1 Missing ⚠️
secboot/bootstrap_container_sb.go 80.00% 1 Missing ⚠️
Additional details and impacted files
@@                   Coverage Diff                   @@
##             fde-manager-features   #14918   +/-   ##
=======================================================
  Coverage                        ?   78.16%           
=======================================================
  Files                           ?     1166           
  Lines                           ?   154990           
  Branches                        ?        0           
=======================================================
  Hits                            ?   121149           
  Misses                          ?    26330           
  Partials                        ?     7511           
Flag Coverage Δ
unittests 78.16% <93.97%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

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

Copy link
Collaborator

@pedronis pedronis left a comment

Choose a reason for hiding this comment

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

thank you

Copy link
Contributor

@valentindavid valentindavid left a comment

Choose a reason for hiding this comment

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

This looks fine apart from putting the volume auth options into the bootstrapped container. It should be one set options for the whole system. In the extreme, it could make sense to have different options for every slot. Or a middle ground for each key role. But not per volume, it does not make sense. The run save key and the run data key should have the same configuration. The recover boot key and the recover save key should have the same configuration.

Not related totally related to this PR, but I think the idea that installation is what sets a passphrase is wrong for user experience. It should be the first boot that does it.

Install should be about hardware (including keyboard mapping), software and default locale. Not user configuration. The first boot is where anything from the user can be configured. That means a passphrase should be set during first boot. There is nothing to protect anyway before the user has stored any personal configuration.
If you do not split the install from the first boot. You cannot possibly have factory reset.
Then you also need also the code to work both for installation context and changes. Which is twice the amount of bugs.
You cannot have a (real) OEM installation.
It is a weird thing that some Linux distributions still mix up those 2 phases. Other operating systems do it correctly.

@@ -490,15 +572,6 @@ func SealKeys(keys []SealKeyRequest, params *SealKeysParams) ([]byte, error) {
return nil, fmt.Errorf("at least one set of model-specific parameters is required")
}

tpm, err := sbConnectToDefaultTPM()
Copy link
Contributor

Choose a reason for hiding this comment

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

would it be a problem if the withTPMConnection() wrapper was called here?

@@ -481,6 +483,86 @@ func ProvisionForCVM(initramfsUbuntuSeedDir string) error {
return nil
}

func withTPMConnection(fn func(tpm *sb_tpm2.Connection)) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
func withTPMConnection(fn func(tpm *sb_tpm2.Connection)) error {
func withSingleTPMConnection(fn func(tpm *sb_tpm2.Connection)) error {

@@ -481,6 +483,86 @@ func ProvisionForCVM(initramfsUbuntuSeedDir string) error {
return nil
}

func withTPMConnection(fn func(tpm *sb_tpm2.Connection)) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

the function likely needs a comment explaining how the global state is changed

@ZeyadYasser
Copy link
Contributor Author

@pedronis @valentindavid @bboozzoo I opened #14954 in favor of this PR to implement suggestions from #14918 (review), changes were big enough to warrant a separate PR to avoid confusing diffs.

@ZeyadYasser
Copy link
Contributor Author

Closed in favor of #14954

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
FDE Manager Pull requests that target FDE manager branch Needs Samuele review Needs a review from Samuele before it can land Run nested The PR also runs tests inluded in nested suite
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants