Resources



Articles and Tutorials

Making Secure Requests to Amazon Web Services

Click for a printer friendly version of this document Printer Friendly Save to del.icio.us
 

Communication on the Internet is susceptible to eavesdropping and malicious tampering. Amazon Web Services recommends you take action to protect the API requests you send.

AWS Products Used: Amazon SQS, Amazon EC2, Amazon S3, Amazon Mechanical Turk, Amazon FPS, Amazon SimpleDB, Amazon DevPay
Date Published: 2008-12-17

This article outlines recommendations for making secure requests to Amazon Web Services and includes the following topics:

SSL: Your Best Protection

The best thing you can do to secure your requests is to use SSL (Secure Sockets Layer, e.g., HTTPS). SSL is a protocol for securing communication across the Internet. AWS uses a typical implementation that provides both confidentiality and integrity (through server authentication and encryption). This means:

  • You as the client can be sure you're talking to AWS
  • Your communication with AWS is encrypted, so others can't intercept it
  • You have verification that the message received is the same as the message sent

Although SSL enhances the security of your communication, the additional negotiation time required for the SSL client/server handshake can increase latency. Also, to use SSL, you need to use a programming language/library that supports it.

Support for SSL

Most AWS services accept HTTPS requests, including:

  • Amazon Associates Web Service
  • Amazon CloudFront (HTTPS is required for the control API; currently only HTTP is accepted for the request API)
  • Amazon DevPay (HTTPS is required for the License Service)
  • Amazon Elastic Compute Cloud
  • Amazon Flexible Payments Service (HTTPS is required)
  • Amazon Fulfillment Web Service (HTTPS is required)
  • Amazon Mechanical Turk
  • Amazon SimpleDB
  • Amazon Simple Queue Service
  • Amazon Simple Storage Service

HTTPS is recommended for the highest level of security for both SOAP and REST/Query requests. Using SOAP over HTTPS is required, so you should make sure the client or SOAP toolkit you're using is configured to use SSL. SOAP requests over HTTP are deprecated and will no longer be accepted after September 2009. The service WSDLs will continue to support both HTTP and HTTPS until September 2009, after which they will support only HTTPS.

The AWS libraries in the following table support the use of HTTPS by default with your requests. Note the table only covers AWS services that don't automatically require HTTPS for REST/Query requests.

AWS Libraries
Amazon EC2 Amazon SimpleDB Amazon SQS
Java
C#
VB.NET
Perl
PHP
Java
C#
VB.NET
Perl
PHP
Java
C#
VB.NET
Perl
PHP

If you're using Ruby or Python, these third-party libraries use HTTPS by default:

Securing HTTP Requests

We strongly recommend you use SSL for your authenticated requests to AWS. If you decide not to use SSL, you have different options for securing your requests depending on the AWS service. These options are described here.

Signature Version 2

If you're using one of the following services, you must use signature version 2 for your REST/Query requests:

  • Amazon Elastic Compute Cloud
  • Amazon SimpleDB
  • Amazon Simple Queue Service
The version refers to the particular algorithm for signing the request. These AWS services have deprecated the older, less-secure methods (signature versions 0 and 1) and will no longer allow them after September 2009.

If you're familiar with signature version 1, these are the main differences with signature version 2:

  • You form the string to sign in a different way (see the list that follows)
  • You can use HMAC-SHA256 when you sign the request (we prefer HMAC-SHA256, but we still support HMAC-SHA1)
  • You must set the SignatureMethod request parameter to either HmacSHA256 or HmacSHA1 to indicate which signing method you're using
  • You must set the SignatureVersion request parameter to 2

Here is what's different about forming the string to sign for signature version 2:

  • You include additional components of the request in the string to sign
  • You include the query string control parameters (the equals signs and ampersands) in the string to sign
  • You sort the query string parameters using byte ordering
  • You URL encode the query string parameters and their values before signing the request

For instructions on signing REST/Query requests using signature version 2, see the technical documentation for your service.

All of the AWS libraries for Amazon EC2, Amazon SimpleDB, and Amazon SQS (listed earlier in this article) use signature version 2 to sign the requests.

Replay Attacks

Replay attacks are an attack vector whereby a malicious user fraudulently repeats a request that has already been made, and/or delays the original request’s delivery.  The best mechanism for defense against a replay attack is to ensure all your requests are made over an SSL connection. If you cannot use SSL, then the mechanism available to you for prevention of replay attacks is the Expires parameter in signature version 2. This requires your client to be synchronized to atomic time (using NTP, or a similar synchronization protocol). If you do not use the Expires parameter, and rely only on the timestamp parameter, your requests are subject to a request expiration period, which varies by service, but can be as long as 15 minutes.

Securing Requests for Other Services

A few AWS services don't support signature version 2:

  • Amazon Simple Storage Service: You can still use HTTP with Amazon S3 and securely make authenticated requests. The service uses a different secure signing protocol.
  • Amazon Mechanical Turk: We recommend you use SSL with Amazon Mechanical Turk, because it provides the highest level of security available.

Using HTTP with the AWS Libraries

The AWS libraries in the preceding table also support signature version 2. The AWS libraries use HTTPS by default, but you can configure them to use HTTP for testing purposes or to avoid the added latency of HTTPS.

To configure one of the AWS libraries to use HTTP

  1. Locate the configuration file in the library's package.

    The following list shows the location of the configuration file in the AWS Amazon EC2 libraries. The files for the AWS Amazon SimpleDB and AWS Amazon SQS libraries have similar locations.

    • Java: /src/com/amazonaws/ec2/AmazonEC2Config.java
    • C#: \src\Amazon.EC2\Amazon.EC2\AmazonEC2Config.cs
    • VB.NET: \src\Amazon.EC2\Amazon.EC2\AmazonEC2Config.vb
    • Perl: /src/Amazon/EC2/client.pm
    • PHP: /src/Amazon/EC2/Client.php

  2. Open the file in a text editor and locate the line that sets the service URL (for Amazon EC2, the URL is https://ec2.amazonaws.com).
  3. Change the service URL to use http (for Amazon EC2, change it to http://ec2.amazonaws.com).
  4. Save the file.
  5. Rebuild/recompile as needed for your programming language.

The library now uses HTTP for the AWS requests.

Contacting AWS about Security Issues

If you have questions related to request security, please use the regular support channels to contact us:


Discussion

The 5 most recent discussion messages. View full discussion.

Glenn D Rempe
Posts: 22
Registered: 9/7/06
Making Secure Requests to Amazon Web Services
Posted: Dec 18, 2008 12:11 PM PST
 
  Click to reply to this thread Reply

Regarding your new web page with info about the new signature version 2. You only list the Rightscale library for Ruby (which is a fine choice I am sure!).

Please note though that the 'amazon-ec2' Ruby library (which was the first EC2 library for Ruby when EC2 was still in closed beta) also supports HTTPS connections to EC2 by default. It would be great if you could also link to this Ruby gem on the appropriate Amazon pages.

Please feel free to check it out here:

http://github.com/grempe/amazon-ec2/tree/master/README.rdoc

Cheers.

D. Kavanagh
RealName(TM)

Posts: 2,716
Registered: 5/25/06
Re: Making Secure Requests to Amazon Web Services
Posted: Jan 6, 2009 6:21 PM PST   in response to: Glenn D Rempe
 
  Click to reply to this thread Reply

I'd also like to point out that typica (a java AWS client) supports https by default and will support version 2 signing in the upcoming 1.5 release.

David

http://code.google.com/p/typica/

adtechsw
Posts: 8
Registered: 7/11/08
Re: Making Secure Requests to Amazon Web Services
Posted: Jan 7, 2009 9:29 AM PST   in response to: Glenn D Rempe
 
  Click to reply to this thread Reply

Last year I wrote a SOAP 1.1 client for EC2 that worked fine, authtenicating using the 3 SOAP headers described in http://docs.amazonwebservices.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/index.html?NotUsingWSSecurity.html.

I now find that it has stopped working; I get a fault " AWS was not able to authenticate the request: access credentials are missing"   - although tracing shows the 3 headers are present in the outgoing soap header.

Is this authentication method (still) supported for EC2, and if so does anyone know what new/modified headers I need to supply?

Thanks

psalvini
Posts: 2
Registered: 7/29/09
Re: Making Secure Requests to Amazon Web Services
Posted: Jul 29, 2009 8:36 AM PDT   in response to: Glenn D Rempe
 
  Click to reply to this thread Reply

Note that the sample EC2 Query interface for Python at http://developer.amazonwebservices.com/connect/entry.jspa?externalID=552 appears to still use signature version 1.



Reviews
Create Review Write a Review
Be the first to review this.
Welcome, Guest Help
Login Login