aws-nitro-enclaves-sdk-c: kmstool_enclave_cli doesn't send attestation
I am trying to do decryption inside an enclave, and kmstool_enclave_cli fails by getting a 400 response from KMS. My error logs were identical to the ones in #67 , and after adding debug statements inside kms.c, I got the following error:
{\"__type\":\"AccessDeniedException\",\"Message\":\"User: arn:aws:sts::xxxxxxxxxxxx:assumed-role/enclave_role/i-09654650371b8eff3 is not authorized to perform: kms:Decrypt on resource: arn:aws:kms:eu-central-1:xxxxxxxxxxxx:key/e7b0fb1b-8903-4a44-afd9-baa76f246adc with an explicit deny in a resource-based policy\"}\\nCould not read response from KMS\\nCould not decrypt ciphertext\\nCould not decrypt\\n\\n')","s":"CC","tamperstatus":"Not tampered!","verify":true}
I have set an explicit deny in the policy for any decryption outside the enclave so that’s not a surprise, however it seems my policy which requires attestation is being ignored
{
Sid = "Allow EC2 to use the key",
Effect = "Allow",
Principal = {
AWS = "arn:aws:iam::${data.aws_caller_identity.current.account_id}:role/${aws_iam_role.enclave_role.name}"
},
Action = [
"kms:Encrypt",
"kms:Decrypt"
],
Resource = "*",
Condition = {
StringEquals = {
"kms:RecipientAttestation:PCR0" = "ABC" # PCR0 hash here
}
}
}
As soon as I remove the explicit deny, I can decrypt again, despite the condition needing a PCR0 of ABC, which is obviously not my PCR0. Same goes for decryption inside the parent instance but outside the enclave. Is there a way for me to check the attestation sent by the kmstool_enclave_cli tool? My other guess would be that the policy is somehow malformed, but I literally copy-pasted the condition from the nitro-enclave workshop, so I have no idea what could have went wrong.
About this issue
- Original URL
- State: closed
- Created a year ago
- Comments: 15 (3 by maintainers)
@xparticle I switched out the PCR0 to all 0’s, and it worked! A thousand thanks!! I was using the hex values which were output by
nitro-cli describe-enclaves, and it misleadingly showed the PCR values the enclave was supposed to have outside debug mode. I did read somewhere that the PCR-s are supposed to change to all 0’s, but that document was several years old, and given how the output ofdescribe-enclaveswas entirely different, I thought that it has been changed. I now also tested the enclave outside of debug mode, and it worked perfectly.A huge thanks to @jplock and @richardfan1126 too, for bearing with me! I will close this issue now, as it has been resolved. I’m also thinking that if they ever update
nitro-cli, it would be a really important quality of life change to actually show that the PCR-s are all 0 in debug mode, when usingdescribe-enclaves. I might try to open an issue about this on the respective repo.There is no such condition key
kms:RecipientAttestationWhat you may want to use in the null checking may be
kms:RecipientAttestation:ImageSha384orkms:RecipientAttestation:PCR0You can find all the available condition keys here: https://docs.aws.amazon.com/service-authorization/latest/reference/list_awskeymanagementservice.html#awskeymanagementservice-policy-keys