目录
Marius Knaust

rest: Validate the region before building the endpoint host name

When no explicit host name is configured, the endpoint is assembled as “service.service.region.$suffix” into a fixed 256-byte buffer and then used as the TLS server name for certificate validation and as the HTTP host header. In the enclave the region comes from the untrusted parent (the “AwsRegion” field of the SetupClient message) and s_read_region() only checks that it is a JSON string, imposing no length or character limit.

Dots on their own are not enough to matter: a region of “evil.com” yields “kms.evil.com.amazonaws.com”, which is still under a suffix only AWS can answer for. Length is what turns this into a takeover. A 251-character region needs 269 bytes, so the assembled name is truncated to 255 and the “.amazonaws.com” tail is dropped completely, leaving a name that ends in a domain the parent owns and can present a valid certificate for.

Reject the region unless it matches the AWS region grammar ([a-z0-9-], 1..32 chars). The charset already excludes dots, uppercase and any other delimiter, so length is the only remaining lever; capping it removes the truncation primitive at the source.

Why 32: “service” is the fixed literal “kms” (3 chars) and the longest DNS suffix is “amazonaws.com.cn” (16). The longest region in any partition today is “us-isof-south-1” (15), so 32 accepts every real region with room for longer future ones without another code change. It is also, on its own, provably far from the buffer limit: worst case is 3 + 1 + 32 + 1 + 16 = 53 characters plus a NUL = 54, against a 256-byte buffer (202 bytes of headroom). A 32-character region therefore cannot truncate regardless of the snprintf guard below.

Keep a check on the snprintf result as well: with the length cap in place this guard is unreachable, but the limit (here) and the buffer size (a separate declaration) could drift apart in a later change, so treat snprintf returning >= sizeof(host_name_str) as a hard error rather than relying on the two staying in agreement. Defense in depth, not the primary control.

Signed-off-by: Marius Knaust mknaust@amazon.com

3个月前184次提交

AWS Nitro Enclaves SDK for C

License

This project is licensed under the Apache-2.0 License.

Dependencies

name version link
aws-lc v1.12.0 https://github.com/awslabs/aws-lc/
s2n-tls v1.3.46 https://github.com/aws/s2n-tls.git
aws-c-common v0.8.0 https://github.com/awslabs/aws-c-common
aws-c-sdkutils v0.1.2 https://github.com/awslabs/aws-c-sdkutils
aws-c-io v0.11.0 https://github.com/awslabs/aws-c-io
aws-c-compression v0.2.14 https://github.com/awslabs/aws-c-compression
aws-c-http v0.7.6 https://github.com/awslabs/aws-c-http
aws-c-cal v0.5.18 https://github.com/awslabs/aws-c-cal
aws-c-auth v6.15.0 https://github.com/awslabs/aws-c-auth
aws-nitro-enclaves-nsm-api v0.4.0 https://github.com/aws/aws-nitro-enclaves-nsm-api
json-c json-c-0.16-20220414 https://github.com/json-c/json-c

Building

Linux - Using containers:

The simplest way to use this SDK is by using one of the available containers as a base:

docker build -f containers/Dockerfile.al2 --target builder -t aws-nitro-enclaves-sdk-c .

Windows

Note that this SDK is currently not supported on Windows. Only the client side sample application (kmstool_instance) is supported on Windows.

Samples

Security issue notifications

If you discover a potential security issue in the Nitro Enclaves SDK for C, we ask that you notify AWS Security via our vulnerability reporting page. Please do not create a public GitHub issue.

关于
645.0 KB
邀请码
    Gitlink(确实开源)
  • 加入我们
  • 官网邮箱:gitlink@ccf.org.cn
  • QQ群
  • QQ群
  • 公众号
  • 公众号

版权所有:中国计算机学会技术支持:开源发展技术委员会
京ICP备13000930号-9 京公网安备 11010802047560号