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

Feat Attestation Token distribution. #74

Merged
merged 2 commits into from
May 5, 2023

Conversation

jialez0
Copy link
Member

@jialez0 jialez0 commented Apr 13, 2023

Fixed: #20

@jialez0 jialez0 marked this pull request as draft April 13, 2023 07:25
@jialez0 jialez0 marked this pull request as ready for review April 13, 2023 07:46
@jialez0 jialez0 requested review from sameo and Xynnn007 April 17, 2023 06:50
@Xynnn007
Copy link
Member

cc @surajssd

Copy link
Member

@sameo sameo left a comment

Choose a reason for hiding this comment

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

Thanks a lot for this work @jialez0 , this is going to allow us to support the passport model and close a gap with KBS.

src/api_server/src/http/confidential_api.rs Outdated Show resolved Hide resolved
src/api_server/src/http/confidential_api.rs Outdated Show resolved Hide resolved
src/api_server/src/http/confidential_api.rs Outdated Show resolved Hide resolved
src/api_server/src/http/confidential_api.rs Outdated Show resolved Hide resolved
src/api_server/src/token/mod.rs Outdated Show resolved Hide resolved
docs/kbs_attestation_protocol.md Outdated Show resolved Hide resolved
docs/kbs_attestation_protocol.md Outdated Show resolved Hide resolved
docs/kbs_attestation_protocol.md Outdated Show resolved Hide resolved
docs/kbs_attestation_protocol.md Outdated Show resolved Hide resolved
docs/kbs_attestation_protocol.md Outdated Show resolved Hide resolved
src/api_server/src/token/simple.rs Outdated Show resolved Hide resolved
src/api_server/src/http/mod.rs Outdated Show resolved Hide resolved
@jialez0 jialez0 force-pushed the token branch 2 times, most recently from da18b61 to 81ff52d Compare April 20, 2023 03:17
@jialez0
Copy link
Member Author

jialez0 commented Apr 20, 2023

@sameo Thanks for reviewing! Now the code is update and you can take a look again:-)

Copy link
Member

@sameo sameo left a comment

Choose a reason for hiding this comment

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

@jialez0 The PR looks good now, thanks a lot.
I had some further comments on the documentation part and the missing OpenAPI changes. I sent a PR instead for you at jialez0#1
Please review it and feel free to squash it into your PR. Once that's done we could go ahead and merge, unless @Xynnn007 or @surajssd have further comments.

@fitzthum
Copy link
Member

Haven't had a chance to really review, but I'm glad we're adding this feature. Will be very useful for more complex workloads. Including the public key of the TEE in the token will prevent replay, right?

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.

@jialez0 Thanks a lot for the great huge work! Also some comments...

src/api_server/src/token/mod.rs Outdated Show resolved Hide resolved
src/api_server/src/session.rs Outdated Show resolved Hide resolved
@sameo
Copy link
Member

sameo commented Apr 24, 2023

Haven't had a chance to really review, but I'm glad we're adding this feature. Will be very useful for more complex workloads. Including the public key of the TEE in the token will prevent replay, right?

Correct. And yes, this is going to be useful for many workloads, including e.g. the ML ones that were presented last Thursday.

Copy link
Member

@jepio jepio left a comment

Choose a reason for hiding this comment

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

I like the general direction this is headed, I suggest some changes for better compatibility with other attestation services and i think we need to think about the big picture a bit.

To implement the passport model we'll need to have:

  1. an actual "attestation-service" that acts as a RATS verifier. This could be implemented as a version of KBS which only exposes /attest and /token-certificate-chain endpoints, but giving it a proper name would be helpful for communication.
  2. a KBS that does not perform attestation itself and instead calls token.verify() acting as the RATS relying party.

In that case the relying-party-KBS could be stateless (no session/cookie), and the attestation token would be passed together with the /resource/... calls. The TEE would communicate separately with an attestation service and (1+) KBS.

Does this direction make sense?

Comment on lines 159 to 166
let protected_header = json!(
{
"alg": RSA_ALGORITHM.to_string(),
"enc": AES_GCM_256_ALGORITHM.to_string(),
});

Ok(Response {
protected: serde_json::to_string(&protected_header)?,
Copy link
Member

Choose a reason for hiding this comment

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

This header is not protected, while it should be passed to encrypt as AAD.

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't have much experience in this area, will the header here be unsafe? Specifically, how should it be encrypted?

Additionally, this is not the scope of this PR, we can create a new PR to fix it after this PR is merged.

@sameo What do you think?

Copy link
Member

Choose a reason for hiding this comment

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

The JWE spec defines that the "protected" field should be integrity protected. This is "additional authenticated data" in AES-GCM, the resulting tag goes in the "tag" field. It does not need to be encrypted.

Otherwise we the field should be called "unprotected".

I'm OK if we address this later. This will be a breaking change.

docs/kbs.yaml Outdated Show resolved Hide resolved
docs/kbs.yaml Outdated Show resolved Hide resolved
src/api_server/src/token/mod.rs Outdated Show resolved Hide resolved
src/api_server/src/http/attestation.rs Outdated Show resolved Hide resolved
src/api_server/src/token/mod.rs Outdated Show resolved Hide resolved
src/api_server/src/http/attestation.rs Outdated Show resolved Hide resolved
@jialez0 jialez0 force-pushed the token branch 2 times, most recently from 9dea9ce to 9239ad3 Compare May 5, 2023 03:17
@jialez0
Copy link
Member Author

jialez0 commented May 5, 2023

@jepio Thanks for reviewing, now this PR is update and resolved your comments. Please review it again, thanks.

@jialez0
Copy link
Member Author

jialez0 commented May 5, 2023

  • an actual "attestation-service" that acts as a RATS verifier. This could be implemented as a version of KBS which only exposes /attest and /token-certificate-chain endpoints, but giving it a proper name would be helpful for communication.
  • a KBS that does not perform attestation itself and instead calls token.verify() acting as the RATS relying party.

I agree with you, we do need a clear RATS verifier to issue attestation token and a clear KBS as RATS rely party that does not perform attestation itself. This means we may need to reorganize and split our existing code at the repository level, and carefully rename them. I think this is a necessary task, and we need to start considering it now. @sameo

Copy link
Member

@jepio jepio left a comment

Choose a reason for hiding this comment

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

LGTM, but with 2 small comments around schema remaining.

src/api/src/token/simple.rs Outdated Show resolved Hide resolved
src/api/src/http/attest.rs Outdated Show resolved Hide resolved
jialez0 and others added 2 commits May 5, 2023 16:54
Fixed: confidential-containers#20

This commit first categorizes the KBS HTTP API into three categories and reorganizes the code accordingly:
1. attest: RESTful APIs that related to attestation
2. resource: RESTful APIs that to get secret resources, need attestation verification
3. config: RESTful APIs that configure KBS and AS, require user authentication
4. public: RESTful APIs that is public

This commit then implement the Token distribution and verification function module.

Signed-off-by: Jiale Zhang <[email protected]>
Co-authored-by: Samuel Ortiz <[email protected]>
Co-authored-by: Jiale Zhang <[email protected]>
Signed-off-by: Jiale Zhang <[email protected]>
@jialez0 jialez0 merged commit 7334c49 into confidential-containers:main May 5, 2023
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.

Support Token distribution and verification.
5 participants