IAM, STS and Encryption Flashcards

1
Q

We are setting up a lambda function which needs to communicate with a database by providing a user ID and a password. We need to encrypt these values so we have set up a CMK in KMS called ‘CipherDbConnectionValues’. In our environment variables section in Lambda we have selected encrypt in transit helpers, and the ‘CipherDbConnectionValues’. It appears that the encrypt side has worked, however when we call Decrypt in our lambda code we receive a message in the logs stating:”An error occurred (AccessDeniedException) when calling the Decrypt operation: The ciphertext refers to a customer master key that does not exist, does not exist in this region, or you are not allowed to access.We have checked the region and the key exists - what is wrong?

A

We need to give our lambda function permission in IAM to allow it call the Decrypt operation on the CipherDbConnectionValues key.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

I am creating an s3 buckey for my users within my organisation. I want to leverage IAM to do this. When I only had 2 users, this was simple as I created an IAM policy for each user assigning them R+W permission on a folder in my bucket - i.e. home/scott, home/sam. We are expanding however and are likely to 10’s to 100’s of staff and this is going to become unwieldy. How can I use IAM to assign permissions to a users folder WITHOUT creating multiple IAM policies?

A

You would use policy variables, specifically the ${aws:UserName} variable:”Action”:[“s3:”],”Effect”:”Allow”,”Resource”:[“arn:aws:s3:::the-bucket/home/${aws:username}/”]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

When using GetSessionToken with STS to return an MFA token, what FOUR things does the call return?

A

Session Token
Access Key
Secret Access Key
ExpirationDate

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is envelope encryption?

A

With envelope encryption, the key used to encrypt the message is itself encrypted with another key. The other key is the client master key managed by AWS KMS

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

At a high level, what three things are needed to encrypt data?

A
  1. Some data to encyrpt2. A method to encrypt the data3. A crypto alogorithm
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

In server side encryption, only the encryption happens on the server. Where does the decryption happen?

A

Also on the server

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is the maximum amount of data that can be encrypted by KMS per call? If I need to encrypt more data than this, what do I need to do?

A

4KB. If we need to encrypt more data then we will need to use GenerateDataKey and encrypt the data locally

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What does the Encrypt API do with respect to KMS and what is the maximum size of data we can encrypt?

A

Encrypt API is used to encrypt up to 4KB using a CMK

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

If I delete my IAM principal, what happens to any inline IAM policies assigned to that principal?

A

The inline policies will be deleted.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Assume I have an EBS volume in eu-west-2. This volume is encrypted with KMS Key A. I need to copy this volume to AP-SouthEast2. What do I need to do?

A

You can’t use Key A in ap-southeast2 as keys are region locked. You would need to take a snapshot of the EBS volume using Key A, and then copy to ap-southeast2 while re-encrypting with a key from ap-southeast2. You can then restore the snapshot using the ap-southeast2 key.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

How many physical users can you have per IAM user?

A

ONE

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Which encryption type does AWS use for encrypt/decrypt and sign/verify operations?

A

Asymmetric

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

You have been granted access (IAM) to an AWS parameter store and can retrieve an encrypted password. However when you try to decrypt the password, you get an error. Why?

A

IAM will get you access to the store - but you also need IAM permissions to KMS for decryption.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Where are AWS SSO user permissions and access managed from?

A

AWS Organisations.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is the maximum size for an IAM policy? What impacts could this have?

A

2KB. This means if you are using inline policies, you run the risk of exceeding this size

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Can policy use be audited?

A

Yes, this allows you to see who has been using the policy and what they have done

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

We have an IAM policy that allows principal * to stop and terminate EC2 instances. In this policy, there is a statement:”condition”:{“Bool”:{“aws:MultiFactorAuthPresent”: “true”}}What does this condition enforce, and what STS call would be used to return this policy?

A

This would be an StsGetSessionToken call as the MultiFactorAuthPresent condition requires the use of MFA to either stop or terminate an instance.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

With KMS, do you ever get access to the key unencrypted?

A

No. You never get access to the key unencrypted and all crypto ops need to be done via the KMS API

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

In terms of encryption - does SSE-S3 use KMS?

A

No. In SSE-S3 encryption is handled by S3 - NOT KMS.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

Can IAM policies be versioned?

A

Yes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

How is a policy defined (in terms of language) ?

A

JSON

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

If you don’t provide a specific KMS key policy when you create a key - what policy is created by default which user has access and what are the implications of this? Can a service such as cloud watch use the default key?

A

The default Key policy is created with access granted to the root user - which means users or roles in the entire AWS account can use the key. A service cannot by default use the default key policy as only users and roles have access.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

Can you access the unencrypted private key used for asymmetric encryption within AWS?

A

No.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

Where are Custom Key Stores stored in AWS (hint, not s3 or ebs) - think outside the box. Is this single or multi tennanted?

A

Single tenant CloudHSM

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
Q

What is a managed policy?

A

A predefined IAM policy created by Amazon

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
26
Q

What are the 3 IAM components?

A

Users, Groups, Roles

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
27
Q

In terms of Identity federation - what five sources can we federate with?

A
  • Custom built IdP
  • Cross Account Access
  • SAML
  • OIDC
  • MSAD
28
Q

I am attempting to encrypt a log group in cloudwatch using a customer created CMK. When I run the command to associate the CMK with the group, I get the following:An error occurred (AccessDeniedException) when calling the AssociateKmsKey operation: The specified KMS key does not exist or is not allowed to be used with LogGroup I havn’t had any trouble with users or roles accessing the KMS key. so why can’t this key be used with the log group and what do I need to do to fix it?

A

We need to update our KEY POLICY to allow for the cloud watch SERVICE to access. By default, the key policy will allow any users or roles to access the key, but not services.

29
Q

For an RDS database, can we encrypt the underlying FILE SYSTEM either at the block or the file level? If I wanted to ensure an extra level of encryption over and above RDS KMS, how would I go about this?

A

You can’t encrypt the underlying filesystem of an RDS db, as that file system is never exposed to us. For extra security you would need to encrypt the key fields in the database via your application.

30
Q

There are two ways to test a policy - one of these is the policy simulator. What is the other?

A

You can use the –dry-run flag in the aws cli for those API’s that support it (such as the Ec2 API) to test if a command executed under that policy will succeed. The dry-run flag will not execute the actual command, but will test it against the policy to see if it would have succeeded.

31
Q

Can you version control and roll back a customer managed IAM policy? Can I determine who has used a customer managed policy and for what?

A

Yes. Customer managed policies are versioned, have central change management and can be rolled back. Policy use can be audited.

32
Q

There are three options available when it comes to controlling access keys within the AWS Key management infrastructure. Each has a different set of responsibilites for us as the user, and AWS as the service. What are they?

A
  1. You control everything including the encryption method and the KMI
  2. You control the encryption method, AWS controls the storage of the keys, and you supply the key management
  3. AWS does everything.
33
Q

What is the role of LocalCryptoMaterialsCache, which encryption scheme uses it? What is the trade off?

A

The LocalCryptoMaterialsCache is an in memory data store which caches DEKs. Using this allows you to reduce the number of calls to KMS when using envelope encryption by caching the DEK. The trade off is that you are using the same DEK for multiple operations so there may be a security impact.

34
Q

Do changes to an IAM policy occur instantly?

A

No, policies may take time to replicate

35
Q

Are KMS Keys region based - I.e. Can you use a key created in one region in another region?

A

Keys are region based, and cannot be used across regions.

36
Q

How many IAM Roles should you have per application?

A

ONE

37
Q

Outside of KMS, can an EBS non-root volume be encrypted?

A

Yes, either at the block or the file system level via third party tools.

38
Q

Which of the following are asymmetric and symmetric encryption types?
AES-256
RSA
ECC KeyPairs

A

AES-256 is symmetric, the others are asymmetric

39
Q

What are the 3 types of customer master keys?

A

AWS Managed Key (default)User Created Keys in KMSUser imported keys

40
Q

I have a requirement to allow authentication functionality for AWS EC2 instances running linux between my on premise AD. Which AD connector type would I use for this?

A

AWS Simple AD will allow basic AD functions including auth against linux ec2 instances

41
Q

For cross account access in IAM - what two policies does the role in the TARGET account consist of and what do these specify? What needs to be set up in the SOURCE account in terms of IAM?

A

The TARGET account IAM consists of a PERMISSIONS policy to control access to AWS services and resources and a TRUST policy specifying who can assume a role and their external ID
The SOURCE account is given an IAM role which has a permissions policy allowing you to assume the TARGET role. The target issues short term credentials to allow access to the specified resources.

42
Q

Can you use third party tools to encrypt an instances ROOT volume via block level or file system level encryption?

A

No.

43
Q

Where would you use Identity Federation

A

Typically, if you are a large organisation with a number of users in a system such as AD, and you need to integrate this with AWS

44
Q

If I create my own CMK, how often will this be rotated?

A

every 12 months

45
Q

What is the output format of this command, and can I run decrypt directly on it?aws kms encrypt –key-id alias/TutorialKey –plaintext fileb://ExampleSecretFile.txt –output text –query CiphertextBlob –region ap-southeast-2 > ExampleSecretFileEncrypted.base64

A

the output is a Base64 representation of the encrypted data. You cannot run decrypt on this until you do a base64 decode to convert it to the binary blob.

46
Q

What is the difference between:
GenerateDataKey
GenerateDataKeyWithoutPlainText

and why would you use each? Are they symmetric or asymmetric keys?

A

GenerateDataKey is used for encrypting a file immediately. GenerateDataKeyWithoutPlainText is used when you want to encyrypt a file at some later stage and does not generate a plaintext DEK.

They are symmetric keys.

47
Q

What does the SecureTokenService (STS) allow for and over what time period?

A

STS a;llows the granting of limited temporary access to an aws resource for a period of 15 minutes to 1 hour

48
Q

If we receive a ThrottlingException for KMS, what 3 things can we do? (one is obvious, the other 2 not so much)

A
  1. Use exponential backoff (obvious)2. Request a limit increase 3. Use envelope encryption and DEK caching.
49
Q

I have two AWS accounts, production and development. The producution account stores application logs in an S3 bucket, and has an associated role called ReadOnlyLogAccess for troubleshooting and is used by my DevOpsSupportGroup users group. Recently there have been some production issues and some performance testers need access to the production logs. The testers are in a Group called PerformanceTestLimitedAccess in the development account. What would the admins in each account need to do, and what would the flow be to grant access to the S3 bucket WITHOUT adding the testers to the DevOps group? Assume we need one off access for a limited time.

A
  1. The admin in prod creates a role for the testers granting read only access to the bucket
  2. The admin in the dev account grants members of the performance tester group permission to assume the role created by the prod admin.
  3. Performance test user requests access to the role
  4. STS returns role credentials
  5. User accesses the bucket.
50
Q

if KMS operations use symmetric keys, then what is the use case for asymmetric keys with respect to AWS?

A

the use case for asymmetric encryption is for encryption outside of AWS by users who CANNOT CALL the KMS API.

51
Q

Why would you use AssumeRole vs AssumeRoleWithSAML when providing temporary credentials?

A

You would use AssumeRole to provide temp credentials for existing IAM users. You would use AssumeRoleWithSAML to provide credentials for a SAML based IDP and users external to IAM

52
Q

What is the principle of least privledge?

A

Giving the user the MINIMUM permissions to do their job

53
Q

If you don’t specify a key policy for a KMS key, can it be accessed?

A

No. A key policy is required to access a KMS key

54
Q

What standard does Identity Federation use?

A

SAML

55
Q

In client side encryption, the server must know our encryption scheme to accept the data - yes or no?

A

No, the data is encrypted client side so the server doesn’t need to know.

56
Q

What AWS service does the AssumeRole, DecodeAuthorisationMessage, GetSessionToken and GetCallerIdentity interact with? What do these calls do?

A

SecureTokenService.AssumeRole: Allows a role to be assumed by a user so they can interact with an AWS resource

DecodeAuthorisationMessage: Used to decode an error message returned from an API call

GetSessionToken: Retrieves an MFA token

GetCallerIdentity: Returns details about the IAM user or role used in the API call.

57
Q

What encryption technique requires the use of the GenerateDataKey API? What does this API return (2 things) ?

A

Envelope encryption uses GenerateDataKey to return1. A Data Encryption Key (DEK) in plain text.
2. A copy of the DEK encyrpted with the CMK

58
Q

There are 2 policies that need to be enacted to give a user access to KMS. One is an IAM policy allowing API calls to KMS. What is the other.

A

A Key policy allowing the user access to the key.

59
Q

With envelope encryption, what is the role of KMS when encrypting an object over 4kb in size?

A

In this case, the role of KMS is to encrypt your Data Encryption Key

60
Q

Does KMS use symmetric or asymmetric encryption? Whats the difference?

A

Symmetric. Symmetric requires a single key that needs to be shared among the people who need to receive the message while asymmetric encryption uses a pair of public key and a private key to encrypt and decrypt messages when communicating.

61
Q

Can I have more than one inline IAM policy per principal?

A

No. there is a strict 1:1 relationship between principal and inline policy

62
Q

By default, does an IAM user have access to Billing and Cost Management? If I needed to give a user access to cost management, what would I need to do?

A

By default, IAM users do not have access to the AWS Billing and Cost Management console. You or your account administrator must grant users access. You can do this by activating IAM user access to the Billing and Cost Management console and attaching an IAM policy to your users.

63
Q

When using STS - are the temporary credentials that are generated stored with you?

A

No. Temporary credentials are generated dynamically and provided on request.

64
Q

Do we need to create User Keys in KMS before using the encryption features for EBS, S3, etc?

A

No - we can use the default managed keys from AWS

65
Q

Can an ACL grant permissions to users in your account?

A

No. ACL’s can only grant cross account permissions