AWS Compute Blog
Announcing server-side encryption with Amazon Simple Queue Service -managed encryption keys (SSE-SQS) by default
This post is written by Sofiya Muzychko (Sr Product Manager), Nipun Chagari (Principal Solutions Architect), and Hardik Vasa (Senior Solutions Architect).
Amazon Simple Queue Service (SQS) now provides server-side encryption (SSE) using SQS-owned encryption (SSE-SQS) by default. This feature further simplifies the security posture to encrypt the message body in SQS queues.
SQS is a fully managed message queuing service that enables you to decouple and scale microservices, distributed systems, and serverless applications. Customers are increasingly decoupling their monolithic applications to microservices and moving sensitive workloads to SQS, such as financial and healthcare applications, whose compliance regulations mandate data encryption.
SQS already supports server-side encryption with customer-provided encryption keys using the AWS Key Management Service (SSE-KMS) or using SQS-owned encryption keys (SSE-SQS). Both encryption options greatly reduce the operational burden and complexity involved in protecting data. Additionally, with the SSE-SQS encryption type, you do not need to create, manage, or pay for SQS-managed encryption keys.
Using the default encryption
With this feature, all newly created queues using HTTPS (TLS) and Signature Version 4 endpoints are encrypted using SQS-owned encryption (SSE-SQS) by default, enhancing the protection of your data against unauthorized access. Any new queue created using the non-TLS endpoint will not enable SSE-SQS encryption by default. We hence encourage you to create SQS queues using HTTPS endpoints as a security best practice.
The SSE-SQS default encryption is available for both standard and FIFO. You do not need to make any code or application changes to encrypt new queues. This does not affect existing queues. You can however change the encryption option for existing queues at any time using the SQS console, AWS Command Line Interface, or API.
The preceding image shows the SQS queue creation console wizard with configuration options for encryption. As you can see, server-side encryption is enabled by default with encryption key type SSE-SQS option selected.
Creating a new SQS queue with SSE-SQS encryption using AWS CloudFormation
Default SSE-SQS encryption is also supported in AWS CloudFormation. To learn more, see this documentation page.
Here is the sample CloudFormation template to create an SQS standard queue with SQS owned Server Side Encryption (SSE-SQS) explicitly enabled.
AWSTemplateFormatVersion: "2010-09-09"
Description: SSE-SQS Cloudformation template
Resources:
SQSEncryptionQueue:
Type: AWS::SQS::Queue
Properties:
MaximumMessageSize: 262144
MessageRetentionPeriod: 86400
QueueName: SSESQSQueue
SqsManagedSseEnabled: true
KmsDataKeyReusePeriodSeconds: 900
VisibilityTimeout: 30
Note that if the SqsManagedSseEnabled: true
property is not specified, SSE-SQS is enabled by default.
Configuring SSE-SQS encryption for existing queues vis AWS Management Console
To configure SSE-SQS encryption for an existing queue using the SQS console:
- Navigate to the SQS console at https://console.aws.amazon.com/sqs/.
- In the navigation pane, choose Queues.
- Select a queue, and then choose Edit.
- Under the Encryption dialog box, for Server-side encryption, choose Enabled.
- Select Amazon SQS key (SSE-SQS).
- Choose Save.
To configure SSE-SQS encryption for an existing queue using the AWS CLI
To enable SSE-SQS to an existing queue with no encryption, use the following AWS CLI command
aws sqs set-queue-attributes --queue-url <queueURL> --attributes SqsManagedSseEnabled=true
Replace <queueURL> with the URL of your SQS queue.
To disable SSE-SQS for an existing queue using the AWS CLI, run:
aws sqs set-queue-attributes --queue-url <queueURL> --attributes SqsManagedSseEnabled=false
Testing the queue with the SSE-SQS encryption enabled
To test sending message to the SQS queue with SSE-SQS enabled, run:
aws sqs send-message --queue-url <queueURL> --message-body test-message
Replace <queueURL>
with the URL of your SQS queue. You see the following response, which means the message is successfully sent to the queue:
{
"MD5OfMessageBody": "beaa0032306f083e847cbf86a09ba9b2",
"MessageId": "6e53de76-7865-4c45-a640-f058c24a619b"
}
Default SSE-SQS and encrypted messages
Encrypting a message makes its contents unavailable to unauthorized or anonymous users. Anonymous requests are requests made to a queue that is open to a public network without any authentication. Note, if you are using anonymous SendMessage and ReceiveMessage requests to the newly created queues, the requests will now be rejected with SSE-SQS enabled by default.
Making anonymous requests to SQS queues does not follow SQS security best practices. We strongly recommend updating your policy to make signed requests to SQS queues using AWS SDK or AWS CLI and to continue using SSE-SQS enabled by default.
Look at the SQS service response for anonymous messages when SSE-SQS encryption is enabled. For an existing queue, you can change the queue policy to grant all users (anonymous users) SendMessage permission for a queue named EncryptionQueue:
{
"Version": "2012-10-17",
"Id": "Queue1_Policy_UUID",
"Statement": [
{
"Sid": "Queue1_SendMessage",
"Effect": "Allow",
"Principal": "*",
"Action": "sqs:SendMessage",
"Resource": "<queueARN>"
}
]
}
You can then make an anonymous request against the queue:
curl <queueURL> -d 'Action=SendMessage&MessageBody=Hello'
You get an error message similar to the following:
<?xml version="1.0"?>
<ErrorResponse
xmlns="http://queue.amazonaws.com/doc/2012-11-05/">
<Error>
<Type>Sender</Type>
<Code>AccessDenied</Code>
<Message>Access to the resource The specified queue does not exist or you do not have access to it. is denied.</Message>
<Detail/>
</Error>
<RequestId> RequestID </RequestId>
</ErrorResponse>
However, for any reason if you want to continue using anonymous requests to the newly created queues in the future, you must create or update the queue with SSE-SQS encryption disabled.
SqsManagedSseEnabled=false
You can also disable the SSE-SQS using the Amazon SQS console.
Encrypting SQS queues with your own encryption keys
You can always change the default of SSE-SQS queues encryption and use your own keys. To encrypt SQS queues with your own encryption keys using the AWS Key Management Service (SSE-KMS), the default encryption with SSE-SQS can be overwritten to SSE-KMS during the queue creation process or afterwards.
You can update the SQS queue Server-side encryption key type using the Amazon SQS console, AWS Command Line Interface, or API.
Benefits of SQS owned encryption (SSE-SQS)
There are a number of significant benefits to encrypting your data with SQS owned encryption (SSE-SQS):
- SSE-SQS lets you transmit data more securely and improve your security posture commonly required for compliance and regulations with no additional overhead, as you do not need to create and manage encryption keys.
- Encryption at rest using the default SSE-SQS is provided at no additional charge.
- The encryption and decryption of your data are handled transparently and continue to deliver the same performance you expect.
- Data is encrypted using the 256-bit Advanced Encryption Standard (AES-256 GCM algorithm), so that only authorized roles and services can access data.
In addition, customers can enable CloudWatch Alarms to alarm on activities such as authorization failures, AWS Identity and Access Management (IAM) policy changes, or tampering with CloudTrail logs to help detect and stay on top of security incidents in the customer application (to learn more, see Amazon CloudWatch User Guide).
Conclusion
SQS now provides server-side encryption (SSE) using SQS-owned encryption (SSE-SQS) by default. This enhancement makes it easier to create SQS queues, while greatly reducing the operational burden and complexity involved in protecting data.
Encryption at rest using the default SSE-SQS is provided at no additional charge and is supported for both Standard and FIFO SQS queues using HTTPS endpoints. The default SSE-SQS encryption is available now.
To learn more about Amazon Simple Queue Service (SQS), see Getting Started with Amazon SQS and Amazon Simple Queue Service Developer Guide.
For more serverless learning resources, visit Serverless Land.