Skip to content

Conversation

@jialez0
Copy link
Member

@jialez0 jialez0 commented Jan 30, 2024

No description provided.

@jialez0 jialez0 requested a review from Xynnn007 January 30, 2024 09:44
.body(res))
// If public key is included in claims, use JWE to wrap resource byte,
// else check if HTTPS is enabled.
match get_pkey(claims) {
Copy link
Contributor

Choose a reason for hiding this comment

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

If I understand correctly we want to support requests without public key for KBS deployments without HTTPs. In this case there would never be a be pkey, right? Does it still make sense to attempt to fetch it or should we rather start the with the HttpsEnabled == false check and return the unwrapped resource? (Instead of swallowing the get_pkey() error).

Copy link
Member Author

Choose a reason for hiding this comment

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

As you mentioned, this PR hopes to support requests without pubkey in KBS with HTTPS enabled. However, "HTTPS enabled" is a minimum security measure. Even if HTTPS is enabled, pubkeys may still exist. In this case, the returned resource data is protected by both HTTPS and JWE. Only when the pubkey cannot be found, data will be returned when HTTPS is enabled. If HTTPS is not enabled, it is completely unsafe, and KBS will refuse to return data.

Copy link
Contributor

Choose a reason for hiding this comment

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

I see. thanks for clarifying. So, it looks like having no pubkey in the claims is a legitimate code path, i.e. the signature is actually something like: fn get_pkey() => Option<Result<TeePubKey>>. A result should capture unexpected states. An alternative would be to match on a concrete error type:

Err(err) => {
   if let err = Error:NoPubkeyInClaims && https.enabled {
   ....
   }
   Err(Error::InsecureResponse)
}

Failing to parse ( TeePubKey::deserialize(pkey_value)) should probably result in an error and not in a fallback to https, because this shouldn't happen in any case.

If customized_claims is specified as always having runtime_data.tee-pubkey we probably want to error out, too.

.body(res))
// If public key is included in claims, use JWE to wrap resource byte,
// else check if HTTPS is enabled.
match get_pkey(claims) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I see. thanks for clarifying. So, it looks like having no pubkey in the claims is a legitimate code path, i.e. the signature is actually something like: fn get_pkey() => Option<Result<TeePubKey>>. A result should capture unexpected states. An alternative would be to match on a concrete error type:

Err(err) => {
   if let err = Error:NoPubkeyInClaims && https.enabled {
   ....
   }
   Err(Error::InsecureResponse)
}

Failing to parse ( TeePubKey::deserialize(pkey_value)) should probably result in an error and not in a fallback to https, because this shouldn't happen in any case.

If customized_claims is specified as always having runtime_data.tee-pubkey we probably want to error out, too.


pub(crate) fn get_pkey(claims: Value) -> Result<TeePubKey> {
let pkey_value = claims
.get("customized_claims")
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we define/reuse a type CustomizedClaim instead of manually performing the parsing by stepping through properties?

return Err(Error::InsecureResponse);
}
let res = URL_SAFE_NO_PAD.encode(resource_byte);
Ok(HttpResponse::Ok().body(res))
Copy link
Member

Choose a reason for hiding this comment

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

I am confused by this PR. Isn't it fundamental that the secure channel is bound to the hw evidence? In other words, doesn't the KBS want to know that when it encrypts a value using a public key, it can only be decrypted inside the enclave that has the corresponding private key? I'm not sure it's valid to support secret delivery without this. What use case are you looking at?

Copy link
Member Author

@jialez0 jialez0 Feb 1, 2024

Choose a reason for hiding this comment

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

@fitzthum I am trying to get CDH to support calling AA to obtain a token from AS, and then using this token to access KBS to obtain resources. However, currently, AA does not carry a pubkey in the tokens obtained from AS.

Another possible path is to add a runtime data parameter to the API for obtaining AS tokens for AA to pass the pubkey, and CDH is responsible for generating and managing this pubkey, so that KBS can still wrap and return resources using JWE.

Copy link
Member Author

@jialez0 jialez0 Feb 1, 2024

Choose a reason for hiding this comment

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

Here is the PR for AA to add runtime data parameter. If we accept that, maybe this PR can be closed.

cc @mkulke

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.

3 participants