AWS Security & Encryption: KMS, SSM Parameter Store, Shield and WAF
Alex Enson
IT Professional | AWS Certified | CompTIA Cloud+ | CompTIA Network+ | CompTIA A+ | CompTIA CCAP | CompTIA CIOS | Experienced 1st/2nd Line Support - IT Service Desk Analyst | #CloudWhistler Community
In this article we will go through the different security measures you can implement in order to secure your cloud services.
Encryption Overview
?
Encryption in Transit
Encryption in transit, often referred to as TLS (Transport Layer Security) or SSL (Secure Sockets Layer), ensures that data is encrypted before being transmitted and decrypted upon arrival. TLS is the latest version of SSL and is widely used to secure communication between clients and servers over a network.
A common example is HTTPS, which indicates that a website uses TLS certificates to encrypt the connection. This prevents unauthorized parties from intercepting or modifying data during transmission.
Encryption in transit is crucial, especially when data travels across public networks and multiple servers. Without encryption, attackers could perform a man-in-the-middle attack, intercepting and analyzing the transmitted data. By using HTTPS, TLS, or SSL, we ensure that only the intended recipient can decrypt and read the data.
For example, when logging into a server, a client sends a username and password. TLS encryption automatically secures this information before it leaves the client’s device. Once transmitted, no intermediary server can decrypt the data—only the target server, using the appropriate TLS decryption mechanism, can process the login credentials securely.
Server-Side Encryption at Rest
Server-side encryption protects data once it has been received by the server. After receiving and processing data, the server encrypts it before storing it securely. When the data is needed again, the server decrypts it before sending it back to the client.
Encryption at rest relies on encryption keys, typically referred to as data keys. The management of these keys is critical, as the server needs controlled access to them for encryption and decryption operations.
For example, in Amazon S3, a client uploads an object over HTTPS (ensuring encryption in transit). Once received, the service encrypts the object using a data key, securing it at rest. When the object is requested, the server retrieves the encrypted file, decrypts it using the data key, and transmits it securely over HTTPS. Since encryption and decryption occur entirely on the server, this is classified as server-side encryption.
Client-Side Encryption
Client-side encryption ensures that data is encrypted before it leaves the client’s device, and the server never has access to the decryption key. This approach is useful in scenarios where the client does not fully trust the storage provider.
In this model, encryption and decryption are handled exclusively on the client side. The encrypted data is then stored on a remote service such as an FTP server, Amazon S3, or an EBS volume. Since the encryption key is kept on the client’s device, the server cannot decrypt the stored data.
When retrieving the data, the client receives the encrypted object and must use its own encryption key to decrypt it. Without access to the key, neither the storage provider nor any intermediary entity can read the data.
?
AWS KMS Overview
What is AWS KMS?
AWS Key Management Service (KMS) is a managed service that allows AWS users to create, store, and manage encryption keys. Whenever encryption is mentioned in AWS services, it is most likely handled by KMS. The key benefit of KMS is that AWS manages encryption keys on your behalf, reducing operational overhead.
KMS is fully integrated with IAM (Identity and Access Management), making it easy to control access to encrypted data. Additionally, every API call involving KMS keys is logged in AWS CloudTrail, allowing for complete auditing and monitoring.
KMS seamlessly integrates with many AWS services, including:
Users can also interact with KMS directly via API calls, AWS CLI, or AWS SDK. This allows encrypting sensitive information—such as secrets, credentials, or sensitive files—before storing them in environment variables or application code, ensuring security best practices.
Types of KMS Keys
AWS KMS provides two main types of encryption keys:
1. Symmetric KMS Keys
2. Asymmetric KMS Keys
For example, an external party can encrypt data using the public key and send it to an AWS user, who can then decrypt it using their private key within KMS.
Types of KMS Key Ownership
AWS provides different types of KMS keys, depending on management preferences and control requirements:
1.??? AWS-Owned Keys
2.??? AWS-Managed Keys
3.??? Customer-Managed Keys (CMKs)
KMS Key Policies
KMS keys require key policies to control access, similar to S3 bucket policies. Without a policy, no one can access the key. There are two types of key policies:
1.??? Default Key Policy
2.??? Custom Key Policy
Cross-Account Key Sharing Example
To share an encrypted snapshot between AWS accounts:
KMS Key Scope & Regional Constraints
KMS keys are region-specific, meaning a key created in one AWS region cannot be used in another. To move encrypted data across regions, you must:
AWS automates this re-encryption step, ensuring secure cross-region data transfers.
?
?
?
KMS Multi-Region Keys
AWS KMS (Key Management Service) supports Multi-Region keys, allowing encryption keys to be replicated across different AWS Regions. This means that a primary key is created in one Region, such as us-east-1, and then replicated to other Regions like us-west-2, eu-west-1, or ap-southeast-2. The replicated keys share the same key material and key ID, making them functionally identical across Regions.
Benefits of Multi-Region Keys
Key Considerations
While Multi-Region keys are useful, they are not global keys. Each key instance is tied to a specific Region. AWS generally recommends using Region-specific keys unless there is a specific use case requiring Multi-Region keys.
Use Cases for Multi-Region Keys
Multi-Region Keys with DynamoDB Global Tables
When using DynamoDB Global Tables with client-side encryption, specific attributes—such as Social Security numbers—can be encrypted before storing them. This ensures that even database administrators without KMS access cannot decrypt sensitive data.
Example Workflow:
This approach improves security and ensures decryption can happen without cross-Region API calls, reducing latency.
Multi-Region Keys with Global Aurora Databases
A similar encryption strategy can be applied to Amazon Aurora Global Databases, where the AWS Encryption SDK is used to encrypt sensitive columns.
Example Workflow:
By using Multi-Region keys, the database administrators in ap-southeast-2 cannot access the sensitive data unless they have permission to use the KMS key. This approach improves security while reducing latency for applications that operate across multiple AWS Regions.
?
S3 Replication with Encryption
Let’s explore S3 Replication and how it interacts with encrypted objects.
When S3 Replication is enabled between two buckets, unencrypted objects and those encrypted using SSE-S3 are replicated by default. Additionally, objects encrypted with SSE-C (using a customer-provided key) can also be replicated.
However, objects encrypted with SSE-KMS are not replicated by default. To enable replication for these objects, you must explicitly configure it. This involves specifying the KMS key to encrypt the replicated objects in the destination bucket, updating the KMS key policy for the target key, and creating an IAM role that grants the S3 Replication service permission to:
Since this process involves frequent encryption and decryption, you may encounter KMS throttling errors. If this happens, you may need to request a service quota increase.
A common question is whether multi-region keys should be used for S3 Replication. According to AWS documentation, multi-region keys can be used, but they are still treated as independent keys by the S3 service. This means that even with a multi-region key, objects are first decrypted and then re-encrypted, rather than being seamlessly replicated without decryption.
?
Encrypted AMI Sharing Process
To share an Amazon Machine Image (AMI) with another AWS account while keeping it encrypted with a KMS key, follow these steps:
By following these steps, account B can successfully use the encrypted AMI from account A to launch EC2 instances.
?
SSM Parameter Store Overview
Let’s dive into the SSM Parameter Store. It serves as a secure storage solution for your configurations and secrets. You can optionally encrypt these configurations, turning them into secrets, by utilizing the KMS service. SSM Parameter Store is serverless, scalable, durable, and its SDK is user-friendly. Additionally, any changes you make to your parameters are tracked with version history.
Security is managed through IAM, and you’ll receive notifications via Amazon EventBridge under certain circumstances. It integrates seamlessly with CloudFormation, meaning you can use parameters from the Parameter Store as input for your CloudFormation stacks.
Example Use Case
Imagine you have an application, and you want to store configurations in the SSM Parameter Store. You can store plain-text configurations directly, with IAM permissions controlling access. For example, your EC2 instance role will be checked, or you can choose to store encrypted configurations, which will be encrypted and decrypted using KMS. It’s important that your applications have access to the required KMS keys for encryption and decryption.
Parameter Hierarchy
The Parameter Store allows you to organize parameters with a hierarchical structure. For example, you could define a path like /my-department/my-app/dev/ and store parameters like DB-URL and DB-password under that. Similarly, you can define parameters for different environments such as /prod/DB-URL and /prod/DB-password. This hierarchy provides flexibility in organizing parameters and simplifies IAM policies, enabling applications to access parameters at different levels like an entire department, app, or specific environment.
You can also reference secrets from Secrets Manager within the Parameter Store using a reference like: /aws/reference/secretsmanager/secret_ID_in_Secrets_Manager.
AWS also provides public parameters, which are useful for accessing specific values like the latest AMI for Amazon Linux 2 in your region through an API call in the Parameter Store.
Example with Lambda Functions
For instance, you could have a Dev Lambda function with an IAM role allowing access to the Dev DB-URL and DB-password. Similarly, a Prod Lambda function, with a separate IAM policy, could access the Prod DB-URL and DB-password from another path, perhaps with different environment variables.
Parameter Tiers
There are two types of parameter tiers in Systems Manager: Standard and Advanced. The main differences are:
Parameter Policies
Available only for advanced parameters, parameter policies allow you to assign a time-to-live (TTL) to a parameter, meaning it will expire at a specified date and time. This feature ensures that sensitive data, such as passwords, is updated or deleted when necessary. You can apply multiple policies to a parameter at once. For example, an expiration policy could specify that a parameter must be deleted by a particular timestamp.
?
Through the EventBridge integration, EventBridge will receive notifications about the parameter's status. For instance, 15 days before a parameter expires, EventBridge will send a notification, giving us ample time to update the parameter and ensure it doesn't get deleted due to the TTL.
?
Sometimes, you might want to ensure that parameters are updated periodically. In such cases, you can set up a "no change" notification in EventBridge. This way, if a parameter hasn't been updated for 20 days, you'll receive a notification. The Parameter Store offers a lot of flexibility, allowing you to get creative with how you manage your parameters.
?
AWS Secrets Manager – Overview
AWS Secrets Manager is a simple yet powerful service designed for securely storing and managing secrets. Unlike the SSM Parameter Store, Secrets Manager allows you to enforce automatic rotation of secrets at a specified interval, ensuring better security and management.
A key advantage of Secrets Manager is its ability to automate the generation and rotation of secrets. This is achieved by defining a Lambda function that generates new secrets automatically. Additionally, Secrets Manager integrates seamlessly with various AWS services, including Amazon RDS for MySQL, PostgreSQL, SQL Server, and Aurora, as well as other databases. With this integration, database credentials—such as usernames and passwords—are securely stored, rotated, and managed within Secrets Manager.
Secrets stored in Secrets Manager can also be encrypted using AWS Key Management Service (KMS), adding an extra layer of security. Whenever you come across secret management for RDS, Aurora, or other AWS services, think of Secrets Manager as the go-to solution.
Multi-Region Secrets
Another important feature of Secrets Manager is multi-region secrets replication. This allows you to replicate secrets across multiple AWS regions while keeping them synchronized with the primary secret. For example, if you create a secret in one region, it can be automatically replicated to a secondary region.
Why is this useful?
By leveraging AWS Secrets Manager, organizations can enhance security, automate secret rotation, and ensure seamless multi-region management.
?
?
AWS Certificate Manager (ACM) – Overview
AWS Certificate Manager (ACM) is a service that simplifies the provisioning, management, and deployment of TLS certificates on AWS. TLS (often referred to as SSL) is essential for encrypting data in transit, securing websites, and enabling HTTPS connections.
For example, when you visit a website using HTTPS, the "S" indicates that a TLS certificate is in place to secure the communication. In AWS, ACM integrates seamlessly with services like Application Load Balancers (ALBs) to provide secure HTTPS endpoints. By associating an ALB with ACM, you can automatically provision and manage TLS certificates, ensuring encrypted connections for your applications and APIs.
Key Features of ACM
Requesting a Public Certificate
To obtain a public TLS certificate through ACM, follow these steps:
Handling Imported Certificates
If you generate a TLS certificate outside ACM, you can import it into ACM. However, imported certificates do not support automatic renewal. Before expiration, you must manually import a new certificate.
To monitor expiration, ACM sends daily expiration notifications starting 45 days before expiry via Amazon EventBridge. You can configure EventBridge to trigger actions (e.g., sending alerts via SNS or renewing certificates using Lambda). Additionally, AWS Config offers a managed rule (ACM-certificate-expiration-check) to track expiring certificates and flag non-compliant ones.
ACM Integration with AWS Services
Conclusion
AWS Certificate Manager (ACM) simplifies TLS certificate management, automating issuance, renewal, and deployment across AWS services. Whether securing an ALB, API Gateway, or CloudFront distribution, ACM helps maintain encrypted connections effortlessly while reducing administrative overhead.
?
?
?
Your API Gateway operates within a single AWS region, but distribution is handled through CloudFront. Since CloudFront is based in the us-east-1 region, all ACM certificates used with it must also be created and stored there. To complete the setup, you need to configure a CNAME or alias record in Route 53.
?
?
Regional endpoints are designed for clients within the same region as your API Gateway. Since there is no CloudFront distribution involved, the TLS certificate must be imported directly into API Gateway within the same region as the API stage. In this example, ACM is hosted in ap-southeast-2. Finally, a CNAME or alias record is configured in Route 53 to map the domain to your API Gateway.
?
AWS Web Application Firewall (WAF) – Overview
AWS Web Application Firewall (WAF) is designed to protect web applications from common HTTP-based attacks at Layer 7 of the OSI model. Unlike Layer 4, which handles TCP and UDP traffic, WAF specifically protects against HTTP threats such as SQL injection and cross-site scripting (XSS).
Where Can You Deploy AWS WAF?
AWS WAF can be deployed on:
Note: WAF cannot be deployed on a Network Load Balancer (NLB) since NLB operates at Layer 4 while WAF is designed for Layer 7 traffic.
Web ACLs & Rule-Based Protection
Once WAF is deployed, you define Web Access Control Lists (Web ACLs) to enforce security rules. These rules allow you to:
Regional vs. Global Scope:
Additionally, Rule Groups allow you to create reusable sets of rules that can be applied across multiple Web ACLs for easier management.
Using AWS WAF with a Fixed IP Application
One common challenge is obtaining a fixed IP address for applications while using WAF with an Application Load Balancer (ALB). Since ALB does not provide fixed IPs, the solution is to use AWS Global Accelerator in front of ALB.
Architecture for Fixed IP with WAF & ALB
By integrating Global Accelerator with WAF on ALB, you achieve a fixed IP for your application while maintaining advanced security.
?
AWS Shield – Overview
AWS Shield is a service designed to protect your infrastructure from DDoS (Distributed Denial of Service) attacks.
What is DDoS? DDoS attacks occur when a network or application is flooded with a large number of requests from multiple computers across the globe. The goal is to overwhelm and overload the target infrastructure, making it unable to serve legitimate users, resulting in a "denial of service."
AWS Shield Protection Options
Additional Features of AWS Shield Advanced
?
?
AWS Firewall Manager – Overview
Now let’s discuss AWS Firewall Manager, a service designed to help you manage firewall rules across all accounts within an AWS organization. With this service, you can easily apply security policies and manage rules on a large scale, making it much easier to maintain consistent security across multiple accounts.
Key Features of AWS Firewall Manager
WAF, Shield, and Firewall Manager – How They Work Together
You might wonder how WAF, Shield, and Firewall Manager interact. These services complement each other to provide comprehensive protection:
Summary
In summary, Firewall Manager helps centralize and automate the application of security policies across multiple AWS accounts, ensuring that your resources stay protected. It works seamlessly with WAF and Shield Advanced to provide layered, comprehensive protection across all your accounts.
?
?
Amazon Guard Duty
Let’s dive into Amazon GuardDuty.
GuardDuty is a service designed to help you discover threats intelligently and protect your AWS accounts. It uses machine learning, anomaly detection, and third-party data to identify potential security issues. Enabling GuardDuty is simple—just a single click, and you get a 30-day trial with no need for any software installation.
GuardDuty analyzes various types of input data, including CloudTrail event logs, where it looks for unusual API calls or unauthorized deployments. It also monitors management and data events. For instance, on the management side, it tracks activities like creating VPC subnets, while on the S3 side, it watches for actions such as retrieving or deleting objects. It also reviews VPC flow logs for abnormal internet traffic, and suspicious IP addresses. For DNS logs, GuardDuty identifies any EC2 instances sending encoded data within DNS queries, which could indicate a compromise.
In addition, you can enable optional features to examine more data sources, including EKS audit logs, RDS and Aurora login events, Lambda, EBS, and S3 data events. To make it easier, you can set up EventBridge rules to automatically notify you if any findings are detected. These notifications can trigger various targets, such as Lambda functions or SNS topics.
A key feature of GuardDuty is its ability to detect cryptocurrency attacks, and it has specific findings dedicated to identifying such threats.
To recap, GuardDuty works with various data sources, including VPC flow logs, CloudTrail logs, and DNS logs, which are always part of its analysis. You can also enable additional features like EBS, Lambda, RDS, Aurora, and EKS logs. Whenever GuardDuty detects a finding, it generates an event in Amazon EventBridge. From there, you can automate responses or send alerts via Lambda or SNS, depending on your configured rules.
?
?Amazon Inspector
Let's discuss Amazon Inspector.
Amazon Inspector is a service designed to automate security assessments for a variety of AWS resources. It performs security checks on EC2 instances, container images, and Lambda functions.
For EC2 instances, Amazon Inspector works with the Systems Manager agent installed on the instance to continuously assess its security. It checks for vulnerabilities by evaluating network accessibility and the operating system for known issues.
When it comes to container images, Amazon Inspector scans Docker images pushed to Amazon ECR. It analyzes these images for any known vulnerabilities, ensuring your containers are secure.
For Lambda functions, Amazon Inspector performs assessments on the function code and its dependencies as they're deployed. It checks for any software vulnerabilities present in the deployed code and package dependencies.
Once the assessments are complete, Amazon Inspector sends its findings to AWS Security Hub and also creates events in Amazon EventBridge. This integration allows you to centrally track vulnerabilities and, with EventBridge, automate responses or workflows based on these findings.
Amazon Inspector evaluates the security of running EC2 instances, container images in ECR, and Lambda functions. It continuously scans for vulnerabilities based on CVE (Common Vulnerabilities and Exposures) data and checks network reachability for EC2 instances. If the CVE database is updated, Amazon Inspector automatically reruns assessments to ensure your infrastructure stays up-to-date. Each run results in a risk score for the identified vulnerabilities, helping you prioritize fixes.
?
Amazon Macie
Let's now discuss Macie.
Macie is a fully managed service for data security and privacy that leverages machine learning and pattern matching to discover and protect sensitive information within AWS. Its primary function is to identify and alert you about sensitive data, specifically personally identifiable information (PII).
Essentially, Macie will scan your S3 buckets to detect PII, such as names, addresses, and credit card numbers. Once it identifies this sensitive data, it sends notifications through EventBridge, which you can integrate with SNS topics, Lambda functions, and more.
The process is straightforward—simply enable Macie with one click, specify the S3 buckets you want it to analyze, and Macie takes care of the rest. Its sole purpose is to discover sensitive data within your S3 buckets.
? ?? Open for New Opportunities in Cloud/AI ? AWSCloudClubPICT Member ? 1x AWS AI | 1x CEH | 1x CCNA | Tech & Content Writer ? ?? Community Advocate
2 周Insightful ! Thankyou for sharing
Software Engineer | AWS Certified (x3) – SAA, DVA, CCP | DevOps & Cloud Enthusiast
2 周Very informative