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

Verifier: Add IBM Secure Execution driver framework #345

Merged
merged 4 commits into from
Jun 11, 2024

Conversation

huoqifeng
Copy link

@huoqifeng huoqifeng commented Mar 6, 2024

Fixes: #342
This is kbs side code and related with PR: confidential-containers/guest-components#492
Depends on:

The IBM SE Remote Attestation flow:

image
  • The verifier generate the encrypted attestation-request based on hkd, CA, signing_key, a measurement key and a nonce, the encrypted data is protected by a symmetric attestation request protection key, which is encrypted using the Host-key document
  • Verifier sends the request to attester
  • Firmware on the Attester's system decrypts the request via private host-key and calculates the evidence based on the encrpted part of the request (Measurement key + nonce)
  • Attester send the evidence to verifier
  • Verifier recalculates the evidence based on the Configuration UID, Additional data, user-data, guest image hashes, and nonce. (its a HMAC-SHA512 with the measurement key as secret)
  • if both HMACs, the one from the Firmware and the calculated one from the verifier match -> attestation success

@huoqifeng huoqifeng requested a review from sameo as a code owner March 6, 2024 03:20
@huoqifeng huoqifeng changed the title Verifier: Add IBM Secure Execution verifier driver framework [WIP] Verifier: Add IBM Secure Execution verifier driver framework Mar 6, 2024
@huoqifeng huoqifeng force-pushed the s390x-verifier branch 3 times, most recently from c723db8 to 52f0b09 Compare March 7, 2024 01:15
@huoqifeng huoqifeng marked this pull request as draft March 7, 2024 06:49
@huoqifeng huoqifeng changed the title [WIP] Verifier: Add IBM Secure Execution verifier driver framework [WIP] Verifier: Add IBM Secure Execution driver framework Mar 7, 2024
@huoqifeng huoqifeng force-pushed the s390x-verifier branch 8 times, most recently from 47fbb1a to abdf68f Compare March 8, 2024 02:42
@huoqifeng huoqifeng force-pushed the s390x-verifier branch 2 times, most recently from 231177c to c0b4061 Compare March 15, 2024 06:09
@huoqifeng
Copy link
Author

@Xynnn007 @fitzthum I'd like start the review process of the API change to support IBM SE. May you please help on that?

@huoqifeng huoqifeng changed the title [WIP] Verifier: Add IBM Secure Execution driver framework Verifier: Add IBM Secure Execution driver framework Mar 15, 2024
@Xynnn007
Copy link
Member

Xynnn007 commented Mar 15, 2024

Oh. I am still worried about the breakage for the PR. As it couple the KBS logic and AS logic to prepare an attreq.bin. After some reading of https://www.ibm.com/docs/en/linuxonibm/pdf/l130se03.pdf, I think of some different design ways for this and I must ignore something.

Way 1:

Con: We need to embed the host cert key chain (host key doc, CA cert, IBM_sign_key_cert) into the guest image

The logic of attester side:

  1. After receiving challenge, generate an arp.key by HKDF(challenge || host_key_doc || CA cert || IBM_sign_key_cert)
  2. Generate a report using the arp.key and other materials using pvattest

The logic of verifier side:

  1. Use the same host key doc, CA cert, IBM_sign_key_cert and challenge to generate a same arp.key, and verify with pvattest verify -i attresp.bin --arpk arp.key --hdr hdr.bin

Rationality:
Looking at the entire attestation protocol of pvattest, the most critical thing is this arp.key, which is used for anti-replay, similar to the Nonce of other architectures, so we combine platform information host_key_doc || intermediate CA certificate || IBM sign key cert together with challenge. The strong binding information is used as the derivation factor of this key to ensure that the attester cannot use an instance on another platform to forge evidence that can pass verification - because the arp.key of the verifier side must be based on the certificate of the target environment.

BTW, if SE guest could support initdata (either though hostdata mechanism or vTPM), we could inject those documents when launching the guest without embed them inside the guest.

Way 2: Add a get_challenge to the verifier API

This is the current implementation.

Con: get_challenge() might mean nothing to other platforms.

This means every time KBS receives a RCAR request, it should first call the backend AS to call get_challenge().

This hints that CoCoAS should also support 4-pass protocol besides current 2-pass protocol, s.t. two ways to use CoCoAS

  1. get_challenge() and then evaluate()
  2. directly evaluate()

cc @jialez0

Way 3: Integrite IBM SE verifier logic inside KBS, and attester logic in KBS-client

Con: No se plugin will be support in attester and verifier crate, and thus not be support by AS. KBS should store arp.keys and se_guest.hdrs

This is based on a different attestation protocol of SE. We can introduce some conditional judgement for SE on the both KBS and KBS client side.

Way 4: Integrite IBM SE verifier logic inside KBS but attester logic in attester crate

Con: KBS should store arp.keys and se_guest.hdrs.

On the attester side, we can reuse report_data/challenge field for SE to present the host key doc, CA cert, IBM_sign_key_cert and attreq.bin bundle and generate an attresp.bin

On the verifier side, KBS will implement the generation of attreq.bin, and the verification of attresp.bin.

@huoqifeng
Copy link
Author

Oh. I am still worried about the breakage for the PR. As it couple the KBS logic and AS logic to prepare an attreq.bin. After some reading of https://www.ibm.com/docs/en/linuxonibm/pdf/l130se03.pdf, I think of some different design ways for this and I must ignore something.

Way 1:

Con: We need to embed the host cert key chain (host key doc, CA cert, IBM_sign_key_cert) into the guest image

The logic of attester side:

1. After receiving `challenge`, generate an `arp.key` by `HKDF(challenge || host_key_doc || CA cert || IBM_sign_key_cert)`

2. Generate a report using the `arp.key` and other materials using `pvattest`

The logic of verifier side:

1. Use the same `host key doc`, `CA cert`, `IBM_sign_key_cert` and `challenge` to generate a same `arp.key`, and verify with `pvattest verify -i attresp.bin --arpk arp.key --hdr hdr.bin`

Rationality: Looking at the entire attestation protocol of pvattest, the most critical thing is this arp.key, which is used for anti-replay, similar to the Nonce of other architectures, so we combine platform information host_key_doc || intermediate CA certificate || IBM sign key cert together with challenge. The strong binding information is used as the derivation factor of this key to ensure that the attester cannot use an instance on another platform to forge evidence that can pass verification - because the arp.key of the verifier side must be based on the certificate of the target environment.

BTW, if SE guest could support initdata (either though hostdata mechanism or vTPM), we could inject those documents when launching the guest without embed them inside the guest.

Way 2: Add a get_challenge to the verifier API

This is the current implementation.

Con: get_challenge() might mean nothing to other platforms.

This means every time KBS receives a RCAR request, it should first call the backend AS to call get_challenge().

This hints that CoCoAS should also support 4-pass protocol besides current 2-pass protocol, s.t. two ways to use CoCoAS

1. `get_challenge()` and then [evaluate()](https://github.com/confidential-containers/trustee/blob/main/attestation-service/protos/attestation.proto#L92)

2. directly [evaluate()](https://github.com/confidential-containers/trustee/blob/main/attestation-service/protos/attestation.proto#L92)

cc @jialez0

Way 3: Integrite IBM SE verifier logic inside KBS, and attester logic in KBS-client

Con: No se plugin will be support in attester and verifier crate, and thus not be support by AS. KBS should store arp.keys and se_guest.hdrs

This is based on a different attestation protocol of SE. We can introduce some conditional judgement for SE on the both KBS and KBS client side.

Way 4: Integrite IBM SE verifier logic inside KBS but attester logic in attester crate

Con: KBS should store arp.keys and se_guest.hdrs.

On the attester side, we can reuse report_data/challenge field for SE to present the host key doc, CA cert, IBM_sign_key_cert and attreq.bin bundle and generate an attresp.bin

On the verifier side, KBS will implement the generation of attreq.bin, and the verification of attresp.bin.

Thanks @Xynnn007 for good suggestions, I think way 2 approach is used in this PR, generate_challenge_extra_params is added in verifier with a default impplementation. I'm happy to chnage the function name. CC @jialez0

@huoqifeng
Copy link
Author

@Xynnn007 @jialez0 we also want to add the extra-params in Attestation like https://github.com/huoqifeng/kbs-types/blob/271ef4bac54035fb25fa44b24e5bbca844cd057c/src/lib.rs#L74-L75, how do you think?

@fitzthum
Copy link
Member

This is a tricky one. If we get this extra challenge information from the AS, does that mean that the AS will have to maintain some per-connection state?

@huoqifeng
Copy link
Author

This is a tricky one. If we get this extra challenge information from the AS, does that mean that the AS will have to maintain some per-connection state?

@fitzthum No need keep the state. For IBM SE, the attester will embed the original encrypted attestation request in evidence also, the verifier will extract the request first and then perform the verifying.

@huoqifeng
Copy link
Author

@fitzthum @Xynnn007 CCC-Attestation/meetings#32, slides 9~18 describes the details of IBM SE attestation and also answers why we have attestation-request needed. The record is coming soon.

Copy link
Contributor

@mkulke mkulke left a comment

Choose a reason for hiding this comment

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

lgtm.

I'll suggest to wait for the attester module to be merged first and then bump the kbs/tools/client guest-component dependency revision for e2e tests

BbolroC added a commit to BbolroC/trustee that referenced this pull request Jun 3, 2024
We are encountering an issue on s390x when compiling AS with
`all-verifier`. The error message is as follows:

```
error: failed to run custom build command for `tss-esapi-sys v0.5.0`
```

A platform-specific verifier (e.g., `se-verifier`) is used here.
(confidential-containers#345)

Although we can easily configure the verifier using `--features`,
this approach lacks flexibility when the crate is selectively called
from outside (e.g., kbs) based on `target_arch`.

The optimal solution would be to open up room for configuring the
verifier at a `dependencies` level rather than a `features` level.
This commit aims to remove `all-verifier` from the default feature
set and configure it differently for s390x.

Signed-off-by: Hyounggyu Choi <Hyounggyu.Choi@ibm.com>
Copy link
Member

@Xynnn007 Xynnn007 left a comment

Choose a reason for hiding this comment

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

Thanks. lgtm. Let's get this merged after confidential-containers/guest-components#492

attestation-service/verifier/Cargo.toml Outdated Show resolved Hide resolved
attestation-service/verifier/Cargo.toml Outdated Show resolved Hide resolved
attestation-service/verifier/Cargo.toml Outdated Show resolved Hide resolved
attestation-service/verifier/src/lib.rs Outdated Show resolved Hide resolved
attestation-service/verifier/src/se/mod.rs Outdated Show resolved Hide resolved
attestation-service/verifier/src/se/ibmse.rs Outdated Show resolved Hide resolved
@huoqifeng
Copy link
Author

@mkulke @Xynnn007 thank you very much for reviewing the PR and gave so many useful suggestions! thanks for your approval.

* Verifier: Add IBM Secure Execution verifier driver framework

Signed-off-by: Qi Feng Huo <huoqif@cn.ibm.com>

* kbs/attestation: support attestation service to generate Challenge

Related to confidential-containers#162 .1  This commit allows the Challenge step in RCAR
handshake to be generated due to backend attestation service. For
typical attestation services, a nonce will be generated.

This commit also covers IBM SE + CoCoAS case. In this case, CoCoAS must
be accessed to get a challenge which is specificly used by IBM SE.

Signed-off-by: Xynnn007 <xynnn@linux.alibaba.com>

---------

Signed-off-by: Qi Feng Huo <huoqif@cn.ibm.com>
Signed-off-by: Xynnn007 <xynnn@linux.alibaba.com>
Co-authored-by: Xynnn007 <xynnn@linux.alibaba.com>
@huoqifeng
Copy link
Author

Squashed commits.

Copy link
Member

@Xynnn007 Xynnn007 left a comment

Choose a reason for hiding this comment

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

lgtm

attestation-service/README.md Outdated Show resolved Hide resolved
@huoqifeng huoqifeng force-pushed the s390x-verifier branch 2 times, most recently from 5651d3e to af3d0b5 Compare June 5, 2024 05:05
…ents

Signed-off-by: Qi Feng Huo <huoqif@cn.ibm.com>
attestation-service/docs/parsed_claims.md Outdated Show resolved Hide resolved
attestation-service/docs/parsed_claims.md Outdated Show resolved Hide resolved
attestation-service/docs/parsed_claims.md Outdated Show resolved Hide resolved
attestation-service/verifier/Cargo.toml Outdated Show resolved Hide resolved
attestation-service/verifier/src/lib.rs Show resolved Hide resolved
attestation-service/verifier/src/se/ibmse.rs Outdated Show resolved Hide resolved
attestation-service/verifier/src/se/ibmse.rs Outdated Show resolved Hide resolved
attestation-service/verifier/src/se/ibmse.rs Show resolved Hide resolved
attestation-service/verifier/src/se/ibmse.rs Outdated Show resolved Hide resolved
attestation-service/verifier/src/se/ibmse.rs Show resolved Hide resolved
Copy link
Member

@fitzthum fitzthum left a comment

Choose a reason for hiding this comment

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

Looks pretty good. A few comments.

attestation-service/verifier/src/se/mod.rs Outdated Show resolved Hide resolved
attestation-service/verifier/src/se/mod.rs Outdated Show resolved Hide resolved
kbs/src/api/src/attestation/coco/grpc.rs Outdated Show resolved Hide resolved
kbs/src/api/src/attestation/mod.rs Show resolved Hide resolved
attestation-service/verifier/src/se/ibmse.rs Outdated Show resolved Hide resolved
…ents

Signed-off-by: Qi Feng Huo <huoqif@cn.ibm.com>
Copy link
Member

@fitzthum fitzthum left a comment

Choose a reason for hiding this comment

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

LGTM

I do want to emphasize that since this verifier does not check the report data, it is not secure. Hopefully that will be addressed in a follow-up. I think this PR is fine for getting all the support code in.

@huoqifeng
Copy link
Author

LGTM

I do want to emphasize that since this verifier does not check the report data, it is not secure. Hopefully that will be addressed in a follow-up. I think this PR is fine for getting all the support code in.

Thank you! @fitzthum , yes, the checking algorithm checks the evidence from TEE guest and re-calculated value from verifier, which also based on same SE OS Image. We'll add additional check in a follow up PR.

@Xynnn007
Copy link
Member

Signed-off-by: Qi Feng Huo <huoqif@cn.ibm.com>
@Xynnn007 Xynnn007 merged commit 8867039 into confidential-containers:main Jun 11, 2024
17 checks passed
BbolroC added a commit to BbolroC/trustee that referenced this pull request Jun 12, 2024
We are encountering an issue on s390x when compiling AS with
`all-verifier`. The error message is as follows:

```
error: failed to run custom build command for `tss-esapi-sys v0.5.0`
```

A platform-specific verifier (e.g., `se-verifier`) is used here.
(confidential-containers#345)

Although we can easily configure the verifier using `--features`,
this approach lacks flexibility when the crate is selectively called
from outside (e.g., kbs) based on `target_arch`.

The optimal solution would be to open up room for configuring the
verifier at a `dependencies` level rather than a `features` level.
This commit aims to remove `all-verifier` from the default feature
set and configure it differently for s390x.

Signed-off-by: Hyounggyu Choi <Hyounggyu.Choi@ibm.com>
Xynnn007 pushed a commit that referenced this pull request Jun 13, 2024
We are encountering an issue on s390x when compiling AS with
`all-verifier`. The error message is as follows:

```
error: failed to run custom build command for `tss-esapi-sys v0.5.0`
```

A platform-specific verifier (e.g., `se-verifier`) is used here.
(#345)

Although we can easily configure the verifier using `--features`,
this approach lacks flexibility when the crate is selectively called
from outside (e.g., kbs) based on `target_arch`.

The optimal solution would be to open up room for configuring the
verifier at a `dependencies` level rather than a `features` level.
This commit aims to remove `all-verifier` from the default feature
set and configure it differently for s390x.

Signed-off-by: Hyounggyu Choi <Hyounggyu.Choi@ibm.com>
pawelpros pushed a commit to pawelpros/trustee that referenced this pull request Jun 14, 2024
We are encountering an issue on s390x when compiling AS with
`all-verifier`. The error message is as follows:

```
error: failed to run custom build command for `tss-esapi-sys v0.5.0`
```

A platform-specific verifier (e.g., `se-verifier`) is used here.
(confidential-containers#345)

Although we can easily configure the verifier using `--features`,
this approach lacks flexibility when the crate is selectively called
from outside (e.g., kbs) based on `target_arch`.

The optimal solution would be to open up room for configuring the
verifier at a `dependencies` level rather than a `features` level.
This commit aims to remove `all-verifier` from the default feature
set and configure it differently for s390x.

Signed-off-by: Hyounggyu Choi <Hyounggyu.Choi@ibm.com>
Signed-off-by: Pawel Proskurnicki <pawel.proskurnicki@intel.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.

Attestation-Service: Add IBM Secure Execution verifier driver
7 participants