Open rainit2006 opened 3 years ago
KMS 的key不是跨region的。
Deleting CMK has no immediate effect on the EC2 instance or the EBS volume. The reason is that Amazon EC2 is using the plaintext data key—not the CMK—to encrypt all disk I/O while the volume is attached to the instance.
However, when the encrypted EBS volume is detached from the EC2 instance, Amazon EBS removes the plaintext key from memory. The next time the encrypted EBS volume is attached to an EC2 instance, the attachment fails, because Amazon EBS cannot use the CMK to decrypt the volume's encrypted data key
Solution:
Option 1: Allow the IAM role/user to access the KMS key
Option 2: Allow the IAM role/user to execute kms:CreateGrant This policy will allow the IAM role/user to grant permission to AWS to use the KMS key.
Details: EC2 must be granted access to the CMK in order to use it. That access is granted by your users implicitly when launching instances that require the key. Therefore, your IAM users must have permission for the key.
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [ "kms:CreateGrant" ],
"Resource": [
"arn:aws:kms:REGION:123456789012:key/key-id"
],
"Condition": {
"Bool": { "kms:GrantIsForAWSResource": true }
}
}
]
}
This policy allows the user to delegate access to other AWS resources, such as EC2.
grant: 授权者
grantee: 被赋予者
create_grant(**kwargs) Adds a grant to a customer master key (CMK). The grant allows the grantee principal to use the CMK when the conditions specified in the grant are met. When setting permissions, grants are an alternative to key policies.
Response Syntax
{
'GrantToken': 'string',
'GrantId': 'string'
}
grant: For example, the following command calls the GenerateDataKey operation.
aws kms generate-data-key \
--key-id 1234abcd-12ab-34cd-56ef-1234567890ab \
--key-spec AES_256 \
--grant-token $token
AWS KMS supports two grant constraints, EncryptionContextEquals and EncryptionContextSubset, both of which involve the encryption context in a request for a cryptographic operation.
Revoking and retiring a grant both delete the grant. But retiring is done by a principal specified in the grant. Revoking is typically done by a key administrator.
Use KMS automatic key rotation to replace the master key, and use this new master key for future encryption operations without re-encrypting previously encrypted data.
When you use a VPC endpoint, communication between your VPC and AWS KMS is conducted entirely within the AWS network.
To create an automated process to disable IAM user access keys that are more than three months old. A: Create an Amazon CloudWatch alarm to detect aged access keys and use an AWS Lambda function to disable the keys older than 90 days.
To allow the team to manage AWS KMS permissions in IAM without the complexity of editing individual key policies A: Newly created CMKs must allow the root principal to perform the kms CreateGrant API operation.
The solution must be highly scalable without requiring continual management. Additionally, the organization must be able to immediately delete the encryption keys. A: Use KMS with AWS imported key material and then use the DeletelmportedKeyMaterial API to remove the key material if necessary.
Which steps must be taken if the CMK has been deleted and CMK was used for EBS. A: Copy the data directly from the EBS encrypted volume before the volume is detached from the EC2 instance.
Use additional authenticated data (AAD) to prevent tampering with ciphertext by CMK A: Use kms:EncryptionContext as a condition when defining IAM policies for the CMK.
The Security policy states that communications between the company's VPC and KMS must travel entirely within the AWS network and not use public service endpoints. A: (1) Add the aws:sourceVpce condition to the AWS KMS key policy referencing the company's VPC endpoint ID. (2) Create a VPC endpoint for AWS KMS with private DNS enabled.
Requires encrypting each file using a different key instead of a single key. Using a different key would limit the security impact of a single exposed key. A: Place all the files in the same S3 bucket. Use server-side encryption with AWS KMS-managed keys (SSE-KMS) to encrypt the data.
A security engineer must ensure that annual global key rotation is enabled for the key without making changes to the application. A:Enable automatic annual key rotation for the existing customer managed CMKs. Update the application encryption library to use a new key ID for all encryption operations. Fall back to the old key ID to decrypt data that was encrypted with previous versions of the key.
Three categories:
Treat missing data points as any of the following:
Amazon CloudFrontの機能。CloudFrontのエッジロケーションにおいて、Lambdaを使って細かいルールを自由に設定できるサービスです。 Lambda@Edge lets you run Node.js and Python Lambda functions to customize content that CloudFront delivers, executing the functions in AWS locations closer to the viewer. You can use Lambda functions to change CloudFront requests and responses at the following points: 1, After CloudFront receives a request from a viewer (viewer request) 2,Before CloudFront forwards the request to the origin (origin request)
You can also generate responses to viewers without ever sending the request to the origin.
Solution:
Whenever an AWS principal issues a request to S3, the authorization decision depends on the union of all the IAM policies, S3 bucket policies, and S3 ACLs that apply.
An S3 Lifecycle configuration is a set of rules that define actions that Amazon S3 applies to a group of objects. There are two types of actions:
Basic rule: to allow access there must be a explict allow and no explict deny in either S3 Bucket Policy, S3 ACL, Key Policy and IAM policy.
Customer Service Policy for Penetration Testing
CIS benchmarks are configuration baselines and best practices for securely configuring a system. Each of the guidance recommendations references one or more CIS controls that were developed to help organizations improve their cyberdefense capabilities. CIS controls map to many established standards and regulatory frameworks, including the NIST Cybersecurity Framework (CSF) and NIST SP 800-53, the ISO 27000 series of standards, PCI DSS, HIPAA, and others.
Note: Security Hub requires AWS Config to be enabled. AWS Config must be enabled in the same account where you enabled AWS Security Hub.
A trail can only send events to either S3 or CloudWatch
For Storage location, choose Create new S3 bucket to create a bucket. When you create a bucket, CloudTrail creates and applies the required bucket policies. Give your bucket a name, such as my-bucket-for-storing-cloudtrail-logs.
CloudTrail provides 90 days of event history information for management events in the CloudTrail console without creating a trail, it is not a permanent record, and it does not provide information about all possible types of events. For an ongoing record, and for a record that contains all the event types you specify, you must create a trail, which delivers log files to an Amazon S3 bucket that you specify.
CloudTrail events provide a history of both API and non-API account activity made through the AWS Management Console, AWS SDKs, command line tools, and other AWS services.
There are three types of events that can be logged in CloudTrail:
When you create a trail, you enable ongoing delivery of events as log files to an Amazon S3 bucket that you specify.
You can configure CloudTrail with CloudWatch Logs to monitor your trail logs and be notified when specific activity occurs.
you can create a trail that will log all events for all AWS accounts in that organization. This is sometimes referred to as an organization trail. When you create an organization trail, a trail with the name that you give it will be created in every AWS account that belongs to your organization.
Precondition:
By default, when you create a trail in the console, the trail logs all regions. Logging all regions in your account is a recommended best practice.
It uses threat intelligence feeds, such as lists of malicious IP addresses and domains, and machine learning to identify unexpected and potentially unauthorized and malicious activity within your AWS environment.
DNS logs:
AWS Firewall Manager を使用すると、AWS WAF ルール、AWS Shield Advanced 保護、Amazon VPC セキュリティグループで管理およびメンテナンスタスクを簡略化できます。
Use AWS Firewall Manager to create a security group policy, enable the policy feature to identify and revert local changes, and enable automatic remediation.
A web access control list (web ACL) gives you fine-grained control over the web requests that your protected resource responds to. After you create your web ACL, you can associate it with one or more AWS resources.
Logging: You can enable logging to get detailed information about traffic that is analyzed by your web ACL. You send logs from your web ACL to an Amazon Kinesis Data Firehose with a configured storage destination. After you enable logging, AWS WAF delivers logs to your storage destination through the HTTPS endpoint of Kinesis Data Firehose.
(2) Client-Side Encryption
https://aws.amazon.com/premiumsupport/knowledge-center/custom-ssl-certificate-cloudfront/
aws iam upload-server-certificate --server-certificate-name CertificateName
--certificate-body file://public_key_certificate_file --private-key file://privatekey.pem
--certificate-chain file://certificate_chain_file --path /cloudfront/DistributionName/
You don’t have to manually set up user accounts, passwords, or SSH keys on the instances and you don’t have to open up any inbound ports.
Session Manager communicates with the instances via the SSM Agent across an encrypted tunnel that originates on the instance, and does not require a bastion host.
You use IAM policies and users to control access to your instances, and don’t need to distribute SSH keys.
The SSM Agent running on the EC2 instances must be able to connect to Session Manager’s public endpoint.
You can also set up a PrivateLink connection to allow instances running in private VPCs (without Internet access or a public IP address) to connect to Session Manager.
Reason:
Check:
An outbound rule must be added to the network ACL to allow the response to be sent to the client on the ephemeral port range.
IAM:
Resource-based policies can provide additional permissions to the user.
Organizations SCPs
Session policies – Session policies are advanced policies that you pass as a parameter when you programmatically create a temporary session for a role or federated user.
Trusted Advisor for Best practices. AWS Trusted Advisor is an AWS tool that provides you real-time assistance to help you provision your resources following AWS best practices.
Four categories: Cost Optimization, Performance, Security, Fault Tolerance, Trusted Advisor は無料で使えます。
it's like Security hub , guarduty in organization, you send an invitation if the account isn't member of guarduty.
You can't launch a new instance using a deleted key pair, but you can continue to connect to any instances that you launched using a deleted key pair, as long as you still have the private key (.pem) file. (Even if you delete the key pair the backup key will remain in EC2)
You should use the EC2 RunCommand to modify the authorized_keys file on any EC2 instance that is using the key. Modify authorized_keys with new key. It will save lot of time and there will be no need to stop the running instance.
Assess the impact of the key exposure and ensure that the credentials were not misused A: (1). Analyze AWS CloudTrail for activity. (2). Download and analyze a credential report from IAM.
Leverage their existing on-premises Active Directory as an identity provider for AWS. A: (1). Create IAM roles with permissions corresponding to each Active Directory group. (2). Configure Active Directory to add relying party trust between Active Directory and AWS.
A2: (1)Create IAM roles with permissions corresponding to each Active Directory group. (2)Create a SAML provider with IAM. (3)Configure AWS as a trusted relying party for the Active Directory。
Relying party trust is a term used in Microsoft Windows Server system to identify service providers that can communicate with an AD FS endpoint.
[EC2][CloudWatch]Issues:some Amazon EC2 instances have not been sending Amazon CloudWatch logs. A: (1)Connect to the EC2 instances that are not sending the appropriate logs and verify that the CloudWatch Logs agent is running. (2)Verify that the EC2 instances have a route to the public AWS API endpoints. If you use Amazon Virtual Private Cloud (Amazon VPC) to host your AWS resources, you can establish a private connection between your VPC and CloudWatch Logs. You can use this connection to send logs to CloudWatch Logs without sending them through the internet." Hence, without a private connection through a interface VPC endpoint, even though CloudWatch is native service you still have to route it through internet API call via an internet gateway.
[CloudTrail][CloudWatch]Issues:making a configuration change to the security group but did not receive any alerts from Cloudwatch that is for AWS CloudTrail log events. A:Verify that a metric filter was created and then mapped to an alarm. Check the alarm notification action.
[EC2]Issues: The system must then alert the Security Engineer of the modification of file on EC2 host. A: Install host-based IDS software to check for file integrity. Export the logs to Amazon CloudWatch Logs for monitoring and alerting. Note: CloudWatch Log is not suitable to detect granular file system change. It will require system tools such as IDS or use an OS audit package to do so.
Issues: It wants to be alerted when any resources are launched in unapproved regions. A: Develop an alerting mechanism based on processing AWS CloudTrail logs.
Issues: Concerned about attacking other AWS account resources by using the EC2 instance metadata service. A: Implement iptables-based restrictions on the instances.
[LB][EC2]Issue: It is suspected that the EC2 instance has been compromised. A: (1)Initiate an Amazon Elastic Block Store volume snapshot of all volumes on the EC2 instance. (2) De-register the EC2 instance from the ALB and detach it from the Auto Scaling group. (3) Attach a security group that has restrictive ingress and egress rules to the EC2 instance.
[Lamdba][CloudWatch]Issue: Cannot find any logs created by the Lambda function in Amazon CloudWatch Logs. A: The execution role for the Lambda function did not grant permissions to write log data to CloudWatch Logs. (X) The execution role for the Lambda function did not grant permissions to write to the Amazon S3 bucket where CloudWatch Logs stores the logs. ----> Cloudwatch is the one that writes logs to S3, not the Lambda.
[GuardDuty]Issue: GuardDuty fail to alert to the behavior that a EC2 instances is attempting to communicate with a known command-and-control server but failing. A: GuardDuty does not see these DNS requests. ---- > If you use AWS DNS resolvers for your EC2 instances (the default setting), then GuardDuty can access and process your request and response DNS logs through the internal AWS DNS resolvers. If you are using a 3rd party DNS resolver, for example, OpenDNS or GoogleDNS, or if you set up your own DNS resolvers, then GuardDuty cannot access and process data from this data source.
[IAM] Concerned that one of AnyCompany's other customers might deduce Example Corp.'s role ARN and potentially compromise the company's account. A: Request an external ID from AnyCompany and add a condition with sts:Externald to the role's trust policy.
[Cognito] Enable users that already exist in a directory to be authenticated into the web application and call APIs. A: (1) Configure a SAML identity provider in Amazon Cognito to map attributes to the Amazon Cognito user pool attributes. (2) Configure the SAML identity provider to add the Amazon Cognito user pool as a relying party. (3) Update API Gateway to use a COGNITO_USER_POOLS authorizer.
[EC2 key pair] Identify which current Linux EC2 instances were deployed and used the compromised key pair. A: Obtain the list of instances by directly querying Amazon EC2 using: aws ec2 describe-instances --filters "Name=key- name,Values=KEYNAMEHERE".
[Shell access]Requires that SSH commands used to access its AWS instance be traceable to the user who executed each command. A: Deny inbound access on port 22 at the security group attached to the instance. Use AWS Systems Manager Session Manager for shell access to Amazon EC2 instances with the user tag defined. Enable Amazon CloudWatch logging for Systems Manager sessions.
[DX][VPN] wants to encrypt the private network between its on-premises environment and AWS. A: VPN over DX connection using public VIF. Create your DX connection. Create a public virtual interface for your DX connection. For Prefixes you want to advertise, enter your customer gateway device’s public IP address and any network prefixes that you want to advertise.
[EC2][Access key] a malicious actor used API access keys intended for the EC2 instance from a country where the company does not operate. The security engineer needs to deny access to the malicious actor. A: Open the IAM console and revoke all IAM sessions that are associated with the instance profile.
[launch constraint ]A company is setting up products to deploy in AWS Service Catalog. Management is concerned that when users launch products, elevated IAM privileges will be required to create resources. A: Add a launch constraint to each product in the portfolio.
203(不能选A:无法edit既存的VPC flow format)
https://www.examtopics.com/exams/amazon/aws-certified-security-specialty/view/12/ 10,14,16,20,23,33、 42, 51(root does not apply to roles, it applies to IAM users and root user), 72(You can use this connection to send logs to CloudWatch Logs without sending them through the internet.), 81,98, 99, 103,104,110, 118, 126, 128, 136(Place all the files in the same S3 bucket. Use server-side encryption with AWS KMS-managed keys (SSE-KMS) to encrypt the data.) 141, 143, 154, ⭐️166(VPN over DX connection using public VIF), 169(!), 171(!), 173, 178(EC2 Auto Scaling groups + KMS), 179(!), 181 (没个靠谱的答案), 183(route table in VPC peering), 189,191, 201(Edit the existing trail in the Organizations master account and apply it to the organization.), 208(Systems Manager Agent), 209(Use AWS Firewall Manager for SG setting and automatic remediation.), 233(!), 237,