aws / aws-nitro-enclaves-sdk-c

This repo provides a C API for AWS Nitro Enclaves, including a KMS SDK that integrates it with attestation.
Apache License 2.0
99 stars 75 forks source link

kmstool-enclave-cli: fix uninitialized pointer dereference. #63

Closed oreparaz closed 3 years ago

oreparaz commented 3 years ago

In kmstool-enclave-cli/main.c, if the call to decrypt() fails, the program proceeds to printf() the contents of ciphertext_decrypted_b64.buffer, which may be uninitialized. This sad path is triggered for example when KMS returns an HTTP code 400 (bad credentials, for instance).

This commit fixes this.

Issue #, if available:

Example of a buggy execution within an enclave:

[...]
Got non-200 answer from KMS: 400
[ 1039.835800] traps: kmstool_enclave[634] general protection ip:4ff0b0 sp:7fff80428c70 error:0 in kmstool_enclave_cli[400000+30a000]
/bin/bash: line 3:   634 Segmentation fault      /kmstool_enclave_cli

Description of changes:

Bubble up error code of decrypt in kmstool-enclave-cli/main.c

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.