Skip to content

policy: do not set policy to open door if none is provided#1572

Merged
anmaxvl merged 1 commit intomicrosoft:mainfrom
anmaxvl:fix-empty-policy-measurement
Jan 5, 2023
Merged

policy: do not set policy to open door if none is provided#1572
anmaxvl merged 1 commit intomicrosoft:mainfrom
anmaxvl:fix-empty-policy-measurement

Conversation

@anmaxvl
Copy link
Contributor

@anmaxvl anmaxvl commented Nov 21, 2022

Currently hcsshim is setting an allow all open door policy if no security policy has been provided.
On the host side, the security policy is hashed and used as HostData when starting an SNP-uVM. However, guest receives the aforementioned "open_door" policy and computes hash over it. As a result, this has doesn't match the LaunchData which is returned by the attestation report and rightfully so, GCS rejects the security policy.

Fix this by not special handling empty security policy on the host side and let the guest decide what to do with it, thus ensuring that both host and guest compute the hash over the same thing.

Signed-off-by: Maksim An maksiman@microsoft.com

Currently hcsshim is setting an allow all open door policy if
no security policy has been provided.
On the host side, the security policy is hashed and used as
HostData when starting an SNP-uVM. However, guest receives the
aforementioned "open_door" policy and computes hash over it.
As a result, this has doesn't match the LaunchData which is
returned by the attestation report and rightfully so, GCS
rejects the security policy.

Fix this by not special handling empty security policy on the
host side and let the guest decide what to do with it, thus
ensuring that both host and guest compute the hash over the
same thing.

Signed-off-by: Maksim An <maksiman@microsoft.com>
@anmaxvl anmaxvl requested a review from a team as a code owner November 21, 2022 17:53
Copy link
Contributor

@helsaawy helsaawy left a comment

Choose a reason for hiding this comment

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

This means that now we would have to set a default policy in one isnt provided in uvmboot, since the guest may default to something that isnt opendoor policy?

@anmaxvl
Copy link
Contributor Author

anmaxvl commented Nov 21, 2022

This means that now we would have to set a default policy in one isnt provided in uvmboot, since the guest may default to something that isnt opendoor policy?

The guest should handle empty security policy and enforcer properly.

@helsaawy helsaawy self-assigned this Nov 30, 2022
@msscotb msscotb self-assigned this Nov 30, 2022
Comment on lines -24 to -31
if policy == "" {
openDoorPolicy := securitypolicy.NewOpenDoorPolicy()
policyString, err := openDoorPolicy.EncodeToString()
if err != nil {
return err
}
policy = policyString
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Should there at least be a check that policy isn't empty? Or do you end up with a deny all if policy is empty?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The default policy set will be determined by -initial-policy-stance flag that GCS binary accepts. In SNP case, we'll set it to deny. This PR enables the scenario where we want to boot from a VMGS file, but don't need a security policy. e.g. for debugging purposes or what not.

Copy link
Contributor

@msscotb msscotb left a comment

Choose a reason for hiding this comment

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

lgtm

@anmaxvl anmaxvl merged commit 6547959 into microsoft:main Jan 5, 2023
@anmaxvl anmaxvl deleted the fix-empty-policy-measurement branch January 5, 2023 00:37
princepereira pushed a commit to princepereira/hcsshim that referenced this pull request Aug 29, 2024
…#1572)

Currently hcsshim is setting an allow all open door policy if
no security policy has been provided.
On the host side, the security policy is hashed and used as
HostData when starting an SNP-uVM. However, guest receives the
aforementioned "open_door" policy and computes hash over it.
As a result, this has doesn't match the LaunchData which is
returned by the attestation report and rightfully so, GCS
rejects the security policy.

Fix this by not special handling empty security policy on the
host side and let the guest decide what to do with it, thus
ensuring that both host and guest compute the hash over the
same thing.

Signed-off-by: Maksim An <maksiman@microsoft.com>
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.

4 participants