1
$\begingroup$

Those keys are too short to be public/private RSA keys. What are they? How does it use them to authenticate the client?

My guess is:

  1. AWS access key ID is a form of unique user/account identifier
  2. AWS secret key is like private key
  3. When AWS CLI sends a API request, the payload is signed by generating an HMAC with the secret key as the key
  4. The HMAC, AccessKeyID and the payload is sent to AWS service
  5. AWS service verifies the identity of the sender and integrity of the message by recomputing the HMAC code.
  6. If it's verified the request is accepted and processed.

Is this accurate? Why does AWS do this instead of asking user to upload a RSA public key? Why is this safer?

EDIT: I think this is how it works -- https://docs.aws.amazon.com/AmazonS3/latest/dev/RESTAuthentication.html#ConstructingTheAuthenticationHeader

$\endgroup$
  • $\begingroup$ While I don't know whether your description of the scheme is accurate, I can point out one advantage: Speed. HMAC is really fast compared to asymmetric signing algorithms (even when comparing to EcDSA), which obviously uses less ressources on the server side, but also allows small clients like microcontrollers used in IoT to create requests. Furthermore, HMAC is easier to use right than most asymmetric schemes since there are less fatal implementation flaws like nonce reuse. $\endgroup$ – VincBreaker Mar 18 at 11:21
1
$\begingroup$

Your description is accurate. I can't speak on behalf of Amazon but I'm sure the main reason why they chose to use this rather than using X.509 certificates; and I mean it with all due respect: People are stupid.

The main targeted user base has no knowledge about this sort of thing (just look at the thousands of "open" MongoDB-instances where you can read all the personal data of millions of people without authentication), so requiring the creation of private keys and public certificates will lead to a lot of troubles, security and support wise. With the implementation as it is Amazon can provide you with keys that are created by using "good random" and a short documentation how to use it to access their services.

Just google for any description, how to set up TLS-client authentication that includes the creation of the certificates and compare it with the documents explaining how to set up the same for AWS. Amazon wants you to be able to use their services as fast as possible so you can start paying money as fast as possible and don't bother looking for other service providers that might offer the same.

Another reason is that asymmetric ciphers require by large factors more resources than symmetric ciphers or hashing algorithms without any additional benefit for this particular use case. Amazon already knows who you are and doesn't need all the fancy stuff that can be implemented with X.509 (key usages, CRL-lists, etc.)

$\endgroup$
  • 3
    $\begingroup$ Far be it from me to defend Amazon's unscrupulous business practices and concentration of power—but that's not what this question is about. You say that there's a lot of complexity in X.509 and the tooling around it and computational cost; and you say that it provides no additional benefit for this particular use case over HMAC authenticators. Can you expand on those parts—what would a public-key variant cost_ what properties could it provide, why doesn't the Amazon use case need those properties—and trim the derision of Amazon customers' intelligence? $\endgroup$ – Squeamish Ossifrage Mar 18 at 23:17
1
$\begingroup$

AWS has designed their own custom authentication algorithm. You are referencing the older signature version (v2), a newer one (v4) was released in 2014. Details are outlined here: Authenticating Requests (AWS Signature Version 4) . A major difference is that the request is not signed with the secret itself, but with a signing key which is generated using the secret. It also uses HMAC-SHA256 for signing.

Signature Generation

Why does AWS do this instead of asking user to upload a RSA public key? Why is this safer?

Using asymmetric keys would be safer since AWS would only store a public key instead of the secret, which is stored by both the user and AWS.

$\endgroup$
0
$\begingroup$

Question/answer one by one:

  1. AWS access key ID is a form of unique user/account identifier
  • Correct, AWS access key is a unique identifier for a user. BTW, in some cases, it could be considered as sensitive data, sharing access key can lead to tracking like who accesses which systems and when, check this post for more details. If you are an administrator, regularly rotate the access keys for IAM users
  1. AWS secret key is like private key
  • Correct, consider your Access key as user name and Secret key as the password.
  1. When AWS CLI sends a API request, the payload is signed by generating an HMAC with the secret key as the key
  2. The HMAC, AccessKeyID and the payload is sent to AWS service

aws-cli using signing API Requests technique. It sends HTTP Authorization header with the next payload:

  • Algorithm you used for signing (AWS4-HMAC-SHA256)
  • Credential scope (with your access key ID)
  • List of signed headers
  • Calculated signature. The signature is based on your request information, and you use your AWS secret access key to produce the signature. The signature confirms your identity to AWS.

Example:

GET https://iam.amazonaws.com/?Action=ListUsers&Version=2010-05-08 HTTP/1.1
Authorization: AWS4-HMAC-SHA256 Credential=AKIDEXAMPLE/20150830/us-east-1/iam/aws4_request, SignedHeaders=content-type;host;x-amz-date, Signature=5d672d79c15b13162d9279b0855cfba6789a8edb4c82c400e06b5924a6f2b5d7
content-type: application/x-www-form-urlencoded; charset=utf-8
host: iam.amazonaws.com
x-amz-date: 20150830T123600Z

Another option is to use a query string, in this case, the content of HTTP Authorization header will be encoded in URL.

Both aws-cli and aws sdk already provide these steps under the hood. But if you want to make your own software for low level interacting with AWS, follow these steps:

Under the hood, tools like aws-cli rely on boto-core. Here you can find the implementation of steps above.

  1. AWS service verifies the identity of the sender and integrity of the message by recomputing the HMAC code.
  2. If it's verified the request is accepted and processed.
  • Both statements are correct.

Why does AWS do this instead of asking user to upload a RSA public key?

More or less I agree with @Lothar's reflections.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.