-
Notifications
You must be signed in to change notification settings - Fork 26
AddPCRProfile: add WithAllowSecurityLevelDowngraded #555
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
frederic-hoerni
wants to merge
5
commits into
master
Choose a base branch
from
feature/permit-ev-efi-action-security-level
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
3728b6a
efi: AddPCRProfile: add WithAllowSecurityLevelDowngraded
frederic-hoerni f9258d7
efi: simplify test option ThunderboltSecurityLevel0 to bool
frederic-hoerni 249a6de
efi: consider insufficient DMA protection and Thunderbolt security le…
frederic-hoerni c19422a
efi: fix TODO
frederic-hoerni 5f9fbdd
efi: add test for mutual exclusion DMA/Thunderbolt insufficient prote…
frederic-hoerni File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| // -*- Mode: Go; indent-tabs-mode: t -*- | ||
|
|
||
| /* | ||
| * Copyright (C) 2026 Canonical Ltd | ||
| * | ||
| * This program is free software: you can redistribute it and/or modify | ||
| * it under the terms of the GNU General Public License version 3 as | ||
| * published by the Free Software Foundation. | ||
| * | ||
| * This program is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| * GNU General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU General Public License | ||
| * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| * | ||
| */ | ||
|
|
||
| package efi | ||
|
|
||
| import ( | ||
| internal_efi "github.com/snapcore/secboot/internal/efi" | ||
| ) | ||
|
|
||
| const ( | ||
| // allowThunderboltSecurityLevel0ParamKey is used to allow for the "Security Level is Downgraded to 0" | ||
| // string in PCR7. | ||
| allowThunderboltSecurityLevel0ParamKey loadParamsKey = "allow_thunderbolt_security_level_0" | ||
|
|
||
| // includeThunderboltSecurityLevel0ParamKey is used to signal whether the "Security Level is Downgraded to 0" | ||
| // string should be reflected in the produced PCR profile. | ||
| // this is ignored if allowThunderboltSecurityLevel0 is false, as the presence of the event | ||
| // will lead to an error in that case. | ||
| includeThunderboltSecurityLevel0ParamKey = "include_thunderbolt_security_level_0" | ||
| ) | ||
|
|
||
| type allowThunderboltSecurityLevel0Option struct{} | ||
|
|
||
| func (o allowThunderboltSecurityLevel0Option) ApplyOptionTo(visitor internal_efi.PCRProfileOptionVisitor) error { | ||
| visitor.AddImageLoadParams(func(params ...loadParams) []loadParams { | ||
| var out []loadParams | ||
| for _, v := range []bool{false, true} { | ||
| var newParams []loadParams | ||
| for _, p := range params { | ||
| newParams = append(newParams, p.Clone()) | ||
| } | ||
| for _, p := range newParams { | ||
| p[allowThunderboltSecurityLevel0ParamKey] = true | ||
| p[includeThunderboltSecurityLevel0ParamKey] = v | ||
| } | ||
| out = append(out, newParams...) | ||
| } | ||
| return out | ||
| }) | ||
| return nil | ||
| } | ||
|
|
||
| // WithAllowThunderboltSecurityLevel0 can be supplied to AddPCRProfile to allow for | ||
| // PCR7 including the "Security Level is Downgraded to 0" event. While this reduces security, | ||
| // it is required on some devices. | ||
| // If this string is present in the event log, this option results in a creation of a | ||
| // branched PCR profile that has two branches at the Firmware load stage one including | ||
| // the event with the string, the another not. | ||
| // | ||
| // Rationale and context: | ||
| // Some old (2021) BIOS firmware on NUC8v5PNB devices measure an event of type EV_EFI_ACTION | ||
| // saying "Security Level is Downgraded to 0" to PCR7. | ||
| // By default this event makes secboot raise an error when computing the PCR policy, and this | ||
| // is relevant as this event denotes a situation where the platform may have a security issue. | ||
| // Moreover, the user who reported this issue said that this could be fixed either by | ||
| // configuring the BIOS to the most secure option for Thunderbolt, or by updating the firmware. | ||
| // This event should therefore not be allowed by default. | ||
| // | ||
| // That being said, there may be situations where users have this event and still want to use | ||
| // TPM-backed disk encryption. This is why we provide this option. | ||
| func WithAllowThunderboltSecurityLevel0() PCRProfileOption { | ||
| return allowThunderboltSecurityLevel0Option{} | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we might be able to set
allowInsufficientDMAProtectionto false here. And also setallowThunderboltSecurityLevel0to false in previous case. I think those 2 measurements (dma protection disabled and security level downgraded) are mutually exclusive, right?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does this change need a test?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will add a test for the "mutually exclusive" part.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
test added: TestMeasureImageStartErrAllowThunderboltSecurityLevel0WithInsufficientDMA