CIS Google Cloud Platform Foundation Benchmark v3.0.0
The CIS Google Cloud Platform Foundations Benchmark provides prescriptive guidance for configuring security options for a subset of GCP with an emphasis on foundational, testable, and architecture agnostic settings.
Run this compliance with Prowler
Run in Prowler Cloudprowler gcp --compliance cis_3.0_gcpRequirements (84)
1 Identity and Access Management1712
1.1Ensure that Corporate Login Credentials are Used0
Attributes
- Profile
Level 1
- Section
1 Identity and Access Management
- Description
Use corporate login credentials instead of consumer accounts, such as Gmail accounts.
- Default Value
By default, no email addresses outside the organization's domain have access to its Google Cloud deployments, but any user email account can be added to the IAM policy for Google Cloud Platform projects, folders, or organizations.
- Audit Procedure
For each Google Cloud Platform project, list the accounts that have been granted access to that project:From Google Cloud CLI
gcloud projects get-iam-policy PROJECT_IDAlso list the accounts added on each folder:gcloud resource-manager folders get-iam-policy FOLDER_IDAnd list your organization's IAM policy:gcloud organizations get-iam-policy ORGANIZATION_IDNo email accounts outside the organization domain should be granted permissions in the IAM policies. This excludes Google-owned service accounts.- Impact Statement
There will be increased overhead as maintaining accounts will now be required. For smaller organizations, this will not be an issue, but will balloon with size.
- Assessment Status
Manual
- Rationale Statement
It is recommended fully-managed corporate Google accounts be used for increased visibility, auditing, and controlling access to Cloud Platform resources. Email accounts based outside of the user's organization, such as consumer accounts, should not be used for business purposes.
- Remediation Procedure
Remove all consumer Google accounts from IAM policies. Follow the documentation and setup corporate login accounts.**Prevention:**To ensure that no email addresses outside the organization can be granted IAM permissions to its Google Cloud projects, folders or organization, turn on the Organization Policy for
Domain Restricted Sharing. Learn more at: https://cloud.google.com/resource-manager/docs/organization-policy/restricting-domains
1.2Ensure that Multi-Factor Authentication is 'Enabled' for All Non-Service Accounts0
Attributes
- Profile
Level 1
- Section
1 Identity and Access Management
- Description
Setup multi-factor authentication for Google Cloud Platform accounts.
- Default Value
By default, multi-factor authentication is not set.
- Audit Procedure
From Google Cloud ConsoleFor each Google Cloud Platform project, folder, or organization:1. Identify non-service accounts.1. Manually verify that multi-factor authentication for each account is set.
- Assessment Status
Manual
- Rationale Statement
Multi-factor authentication requires more than one mechanism to authenticate a user. This secures user logins from attackers exploiting stolen or weak credentials.
- Remediation Procedure
From Google Cloud ConsoleFor each Google Cloud Platform project:1. Identify non-service accounts.1. Setup multi-factor authentication for each account.
1.3Ensure that Security Key Enforcement is Enabled for All Admin Accounts0
Attributes
- Profile
Level 2
- Section
1 Identity and Access Management
- Description
Setup Security Key Enforcement for Google Cloud Platform admin accounts.
- Default Value
By default, Security Key Enforcement is not enabled for Organization Administrators.
- Audit Procedure
- Identify users with Organization Administrator privileges:
gcloud organizations get-iam-policy ORGANIZATION_IDLook for members granted the role "roles/resourcemanager.organizationAdmin".2. Manually verify that Security Key Enforcement has been enabled for each account.
- Identify users with Organization Administrator privileges:
- Impact Statement
If an organization administrator loses access to their security key, the user could lose access to their account. For this reason, it is important to set up backup security keys.
- Assessment Status
Manual
- Rationale Statement
Google Cloud Platform users with Organization Administrator roles have the highest level of privilege in the organization. These accounts should be protected with the strongest form of two-factor authentication: Security Key Enforcement. Ensure that admins use Security Keys to log in instead of weaker second factors like SMS or one-time passwords (OTP). Security Keys are actual physical keys used to access Google Organization Administrator Accounts. They send an encrypted signature rather than a code, ensuring that logins cannot be phished.
- Remediation Procedure
- Identify users with the Organization Administrator role.2. Setup Security Key Enforcement for each account. Learn more at: https://cloud.google.com/security-key/
1.4Ensure That There Are Only GCP-Managed Service Account Keys for Each Service Account1
Attributes
- Profile
Level 1
- Section
1 Identity and Access Management
- Description
User-managed service accounts should not have user-managed keys.
- Default Value
By default, there are no user-managed keys created for user-managed service accounts.
- Audit Procedure
From Google Cloud Console1. Go to the IAM page in the GCP Console using
https://console.cloud.google.com/iam-admin/iam2. In the left navigation pane, clickService accounts. All service accounts and their corresponding keys are listed.3. Click the service accounts and check if keys exist.From Google Cloud CLIList All the service accounts:gcloud iam service-accounts listIdentify user-managed service accounts which have an accountEMAILending withiam.gserviceaccount.comFor each user-managed service account, list the keys managed by the user:gcloud iam service-accounts keys list --iam-account=<Service Account> --managed-by=userNo keys should be listed.- Impact Statement
Deleting user-managed service account keys may break communication with the applications using the corresponding keys.
- Assessment Status
Automated
- Rationale Statement
Anyone who has access to the keys will be able to access resources through the service account. GCP-managed keys are used by Cloud Platform services such as App Engine and Compute Engine. These keys cannot be downloaded. Google will keep the keys and automatically rotate them on an approximately weekly basis.User-managed keys are created, downloadable, and managed by users. They expire 10 years from creation.For user-managed keys, the user has to take ownership of key management activities which include:- Key storage- Key distribution- Key revocation- Key rotation- Protecting the keys from unauthorized users- Key recoveryEven with key owner precautions, keys can be easily leaked by common development malpractices like checking keys into the source code or leaving them in the Downloads directory, or accidentally leaving them on support blogs/channels.It is recommended to prevent user-managed service account keys.
- Remediation Procedure
From Google Cloud Console1. Go to the IAM page in the GCP Console using
https://console.cloud.google.com/iam-admin/iam2. In the left navigation pane, clickService accounts. All service accounts and their corresponding keys are listed.3. Click the service account.4. Click theeditand delete the keys.From Google Cloud CLITo delete a user managed Service Account Key,gcloud iam service-accounts keys delete --iam-account=<user-managed-service-account-EMAIL> <KEY-ID>**Prevention:**You can disable service account key creation through theDisable service account key creationOrganization policy by visiting https://console.cloud.google.com/iam-admin/orgpolicies/iam-disableServiceAccountKeyCreation. Learn more at: https://cloud.google.com/resource-manager/docs/organization-policy/restricting-service-accountsIn addition, if you do not need to have service accounts in your project, you can also prevent the creation of service accounts through theDisable service account creationOrganization policy: https://console.cloud.google.com/iam-admin/orgpolicies/iam-disableServiceAccountCreation.- Additional Information
A user-managed key cannot be created on GCP-Managed Service Accounts.
1.5Ensure That Service Account Has No Admin Privileges1
Attributes
- Profile
Level 1
- Section
1 Identity and Access Management
- Description
A service account is a special Google account that belongs to an application or a VM, instead of to an individual end-user. The application uses the service account to call the service's Google API so that users aren't directly involved. It's recommended not to use admin access for ServiceAccount.
- Default Value
User Managed (and not user-created) default service accounts have the
Editor (roles/editor)role assigned to them to support GCP services they offer. By default, there are no roles assigned toUser Managed User createdservice accounts.- Audit Procedure
From Google Cloud Console1. Go to
IAM & admin/IAMusinghttps://console.cloud.google.com/iam-admin/iam2. Under theIAMTab look forVIEW BY PRINCIPALS3. FilterPRINCIPALSusingtype : Service account4. Look for the Service Account with the nomenclature:SERVICE_ACCOUNT_NAME@PROJECT_ID.iam.gserviceaccount.com5. Ensure that there are no such Service Accounts with roles containing*Adminor*adminor role matchingEditoror role matchingOwnerunderRolecolumn.From Google Cloud CLI1. Get the policy that you want to modify, and write it to a JSON file:gcloud projects get-iam-policy PROJECT_ID --format json > iam.json2. The contents of the JSON file will look similar to the following. Note thatroleof members group associated with eachserviceaccountdoes not contain*Adminor*adminor does not matchroles/editoror does not matchroles/owner.This recommendation is only applicable toUser-Managed user-createdservice accounts. These accounts have the nomenclature:SERVICE_ACCOUNT_NAME@PROJECT_ID.iam.gserviceaccount.com. Note that some Google-managed, Google-created service accounts have the same naming format, and should be excluded (e.g.,appsdev-apps-dev-script-auth@system.gserviceaccount.comwhich needs the Owner role).Sample Json output: { "bindings": [ { "members": [ "serviceAccount:our-project-123@appspot.gserviceaccount.com", ], "role": "roles/appengine.appAdmin" }, { "members": [ "user:email1@gmail.com" ], "role": "roles/owner" }, { "members": [ "serviceAccount:our-project-123@appspot.gserviceaccount.com", "serviceAccount:123456789012-compute@developer.gserviceaccount.com" ], "role": "roles/editor" } ], "etag": "BwUjMhCsNvY=", "version": 1 }- Impact Statement
Removing
*Adminor*adminorEditororOwnerrole assignments from service accounts may break functionality that uses impacted service accounts. Required role(s) should be assigned to impacted service accounts in order to restore broken functionalities.- Assessment Status
Automated
- Rationale Statement
Service accounts represent service-level security of the Resources (application or a VM) which can be determined by the roles assigned to it. Enrolling ServiceAccount with Admin rights gives full access to an assigned application or a VM. A ServiceAccount Access holder can perform critical actions like delete, update change settings, etc. without user intervention. For this reason, it's recommended that service accounts not have Admin rights.
- Remediation Procedure
From Google Cloud Console1. Go to
IAM & admin/IAMusinghttps://console.cloud.google.com/iam-admin/iam2. Under theIAMTab look forVIEW BY PRINCIPALS3. FilterPRINCIPALSusingtype : Service account4. Look for the Service Account with the Principal nomenclature:SERVICE_ACCOUNT_NAME@PROJECT_ID.iam.gserviceaccount.com5. IdentifyUser-Managed user createdservice account with roles containing*Adminor*adminor role matchingEditoror role matchingOwnerunderRoleColumn.6. Click onEdit (Pencil Icon)for the Service Account, it will open all the roles which are assigned to the Service Account.7. Click theDelete binicon to remove the role from the Principal (service account in this case)From Google Cloud CLIgcloud projects get-iam-policy PROJECT_ID --format json > iam.json1. Using a text editor, RemoveRolewhich containsroles/*Adminorroles/*adminor matchedroles/editoror matches 'roles/owner. Add a role to the bindings array that defines the group members and the role for those members. For example, to grant the role roles/appengine.appViewer to theServiceAccount` which is roles/editor, you would change the example shown below as follows: { "bindings": [ { "members": [ "serviceAccount:our-project-123@appspot.gserviceaccount.com", ], "role": "roles/appengine.appViewer" }, { "members": [ "user:email1@gmail.com" ], "role": "roles/owner" }, { "members": [ "serviceAccount:our-project-123@appspot.gserviceaccount.com", "serviceAccount:123456789012-compute@developer.gserviceaccount.com" ], "role": "roles/editor" } ], "etag": "BwUjMhCsNvY=" }2. Update the project's IAM policy:gcloud projects set-iam-policy PROJECT_ID iam.json- Additional Information
Default (user-managed but not user-created) service accounts have the
Editor (roles/editor)role assigned to them to support GCP services they offer. Such Service accounts are:PROJECT_NUMBER-compute@developer.gserviceaccount.com,PROJECT_ID@appspot.gserviceaccount.com.
1.6Ensure That IAM Users Are Not Assigned the Service Account User or Service Account Token Creator Roles at Project Level1
Attributes
- Profile
Level 1
- Section
1 Identity and Access Management
- Description
It is recommended to assign the
Service Account User (iam.serviceAccountUser)andService Account Token Creator (iam.serviceAccountTokenCreator)roles to a user for a specific service account rather than assigning the role to a user at project level.- Default Value
By default, users do not have the Service Account User or Service Account Token Creator role assigned at project level.
- Audit Procedure
From Google Cloud Console1. Go to the IAM page in the GCP Console by visiting https://console.cloud.google.com/iam-admin/iam2. Click on the filter table text bar, Type
Role: Service Account User.3. Ensure no user is listed as a result of the filter.4. Click on the filter table text bar, TypeRole: Service Account Token Creator.3. Ensure no user is listed as a result of the filter.From Google Cloud CLITo ensure IAM users are not assigned Service Account User role at the project level:gcloud projects get-iam-policy PROJECT_ID --format json | jq '.bindings[].role' | grep "roles/iam.serviceAccountUser"gcloud projects get-iam-policy PROJECT_ID --format json | jq '.bindings[].role' | grep "roles/iam.serviceAccountTokenCreator"These commands should not return any output.- Impact Statement
After revoking
Service Account UserorService Account Token Creatorroles at the project level from all impacted user account(s), these roles should be assigned to a user(s) for specific service account(s) according to business needs.- Assessment Status
Automated
- Rationale Statement
A service account is a special Google account that belongs to an application or a virtual machine (VM), instead of to an individual end-user. Application/VM-Instance uses the service account to call the service's Google API so that users aren't directly involved.In addition to being an identity, a service account is a resource that has IAM policies attached to it. These policies determine who can use the service account.Users with IAM roles to update the App Engine and Compute Engine instances (such as App Engine Deployer or Compute Instance Admin) can effectively run code as the service accounts used to run these instances, and indirectly gain access to all the resources for which the service accounts have access. Similarly, SSH access to a Compute Engine instance may also provide the ability to execute code as that instance/Service account.Based on business needs, there could be multiple user-managed service accounts configured for a project. Granting the
iam.serviceAccountUseroriam.serviceAccountTokenCreatorroles to a user for a project gives the user access to all service accounts in the project, including service accounts that may be created in the future. This can result in elevation of privileges by using service accounts and correspondingCompute Engine instances.In order to implementleast privilegesbest practices, IAM users should not be assigned theService Account UserorService Account Token Creatorroles at the project level. Instead, these roles should be assigned to a user for a specific service account, giving that user access to the service account. TheService Account Userallows a user to bind a service account to a long-running job service, whereas theService Account Token Creatorrole allows a user to directly impersonate (or assert) the identity of a service account.- Remediation Procedure
From Google Cloud Console1. Go to the IAM page in the GCP Console by visiting: https://console.cloud.google.com/iam-admin/iam.2. Click on the filter table text bar. Type
Role: Service Account User3. Click theDelete Binicon in front of the roleService Account Userfor every user listed as a result of a filter.4. Click on the filter table text bar. TypeRole: Service Account Token Creator5. Click theDelete Binicon in front of the roleService Account Token Creatorfor every user listed as a result of a filter.From Google Cloud CLI1. Using a text editor, remove the bindings with theroles/iam.serviceAccountUserorroles/iam.serviceAccountTokenCreator. For example, you can use the iam.json file shown below as follows: { "bindings": [ { "members": [ "serviceAccount:our-project-123@appspot.gserviceaccount.com", ], "role": "roles/appengine.appViewer" }, { "members": [ "user:email1@gmail.com" ], "role": "roles/owner" }, { "members": [ "serviceAccount:our-project-123@appspot.gserviceaccount.com", "serviceAccount:123456789012-compute@developer.gserviceaccount.com" ], "role": "roles/editor" } ], "etag": "BwUjMhCsNvY=" }2. Update the project's IAM policy:gcloud projects set-iam-policy PROJECT_ID iam.json- Additional Information
To assign the role
roles/iam.serviceAccountUserorroles/iam.serviceAccountTokenCreatorto a user role on a service account instead of a project:1. Go to https://console.cloud.google.com/projectselector/iam-admin/serviceaccounts2. SelectTarget Project3. Selecttarget service account. ClickPermissionson the top bar. It will open permission pane on right side of the page4. Add desired members withService Account UserorService Account Token Creatorrole.
1.7Ensure User-Managed/External Keys for Service Accounts Are Rotated Every 90 Days or Fewer1
Attributes
- Profile
Level 1
- Section
1 Identity and Access Management
- Description
Service Account keys consist of a key ID (Private_key_Id) and Private key, which are used to sign programmatic requests users make to Google cloud services accessible to that particular service account. It is recommended that all Service Account keys are regularly rotated.
- Default Value
GCP does not provide an automation option for External (user-managed) Service key rotation.
- Audit Procedure
From Google Cloud Console1. Go to
APIs & Services\Credentialsusinghttps://console.cloud.google.com/apis/credentials2. In the sectionService Account Keys, for every External (user-managed) service account key listed ensure thecreation dateis within the past 90 days.From Google Cloud CLI1. List all Service accounts from a project.gcloud iam service-accounts list2. For every service account list service account keys.gcloud iam service-accounts keys list --iam-account [Service_Account_Email_Id] --format=json3. Ensure every service account key for a service account has a"validAfterTime"value within the past 90 days.- Impact Statement
Rotating service account keys will break communication for dependent applications. Dependent applications need to be configured manually with the new key
IDdisplayed in theService account keyssection and theprivate keydownloaded by the user.- Assessment Status
Automated
- Rationale Statement
Rotating Service Account keys will reduce the window of opportunity for an access key that is associated with a compromised or terminated account to be used. Service Account keys should be rotated to ensure that data cannot be accessed with an old key that might have been lost, cracked, or stolen.Each service account is associated with a key pair managed by Google Cloud Platform (GCP). It is used for service-to-service authentication within GCP. Google rotates the keys daily.GCP provides the option to create one or more user-managed (also called external key pairs) key pairs for use from outside GCP (for example, for use with Application Default Credentials). When a new key pair is created, the user is required to download the private key (which is not retained by Google). With external keys, users are responsible for keeping the private key secure and other management operations such as key rotation. External keys can be managed by the IAM API, gcloud command-line tool, or the Service Accounts page in the Google Cloud Platform Console. GCP facilitates up to 10 external service account keys per service account to facilitate key rotation.
- Remediation Procedure
**From Google Cloud Console****Delete any external (user-managed) Service Account Key older than 90 days:**1. Go to
APIs & Services\Credentialsusinghttps://console.cloud.google.com/apis/credentials2. In the SectionService Account Keys, for every external (user-managed) service account key wherecreation dateis greater than or equal to the past 90 days, clickDelete Bin IcontoDelete Service Account key**Create a new external (user-managed) Service Account Key for a Service Account:**1. Go toAPIs & Services\Credentialsusinghttps://console.cloud.google.com/apis/credentials2. ClickCreate Credentialsand SelectService Account Key.3. Choose the service account in the drop-down list for which an External (user-managed) Service Account key needs to be created.4. Select the desired key type format amongJSONorP12.5. ClickCreate. It will download theprivate key. Keep it safe. 6. ClickCloseif prompted. 7. The site will redirect to theAPIs & Services\Credentialspage. Make a note of the newIDdisplayed in theService account keyssection.- Additional Information
For user-managed Service Account key(s), key management is entirely the user's responsibility.
1.8Ensure That Separation of Duties Is Enforced While Assigning Service Account Related Roles to Users1
Attributes
- Profile
Level 2
- Section
1 Identity and Access Management
- Description
It is recommended that the principle of 'Separation of Duties' is enforced while assigning service-account related roles to users.
- Audit Procedure
From Google Cloud Console1. Go to
IAM & Admin/IAMusinghttps://console.cloud.google.com/iam-admin/iam.2. Ensure no member has the rolesService Account AdminandService account Userassigned together.From Google Cloud CLI1. List all users and role assignments:gcloud projects get-iam-policy [Project_ID] --format json | \ jq -r '[ (["Service_Account_Admin_and_User"] | (., map(length*"-"))), ( [ .bindings[] | select(.role == "roles/iam.serviceAccountAdmin" or .role == "roles/iam.serviceAccountUser").members[] ] | group_by(.) | map({User: ., Count: length}) | .[] | select(.Count == 2).User | unique ) ] | .[] | @tsv'2. All common users listed underService_Account_Admin_and_Userare assigned both theroles/iam.serviceAccountAdminandroles/iam.serviceAccountUserroles.- Impact Statement
The removed role should be assigned to a different user based on business needs.
- Assessment Status
Automated
- Rationale Statement
The built-in/predefined IAM role
Service Account adminallows the user/identity to create, delete, and manage service account(s).The built-in/predefined IAM roleService Account Userallows the user/identity (with adequate privileges on Compute and App Engine) to assign service account(s) to Apps/Compute Instances.Separation of duties is the concept of ensuring that one individual does not have all necessary permissions to be able to complete a malicious action. In Cloud IAM - service accounts, this could be an action such as using a service account to access resources that user should not normally have access to.Separation of duties is a business control typically used in larger organizations, meant to help avoid security or privacy incidents and errors. It is considered best practice.No user should haveService Account AdminandService Account Userroles assigned at the same time.- Remediation Procedure
From Google Cloud Console1. Go to
IAM & Admin/IAMusinghttps://console.cloud.google.com/iam-admin/iam.2. For any member having bothService Account AdminandService account Userroles granted/assigned, click theDelete Binicon to remove either role from the member.Removal of a role should be done based on the business requirements.- Additional Information
Users granted with Owner (roles/owner) and Editor (roles/editor) have privileges equivalent to
Service Account AdminandService Account User. To avoid the misuse, Owner and Editor roles should be granted to very limited users and Use of these primitive privileges should be minimal. These requirements are addressed in separate recommendations.
1.9Ensure That Cloud KMS Cryptokeys Are Not Anonymously or Publicly Accessible1
Attributes
- Profile
Level 1
- Section
1 Identity and Access Management
- Description
It is recommended that the IAM policy on Cloud KMS
cryptokeysshould restrict anonymous and/or public access.- Default Value
By default Cloud KMS does not allow access to
allUsersorallAuthenticatedUsers.- Audit Procedure
From Google Cloud CLI1. List all Cloud KMS
Cryptokeys.gcloud kms keys list --keyring=[key_ring_name] --location=global --format=json | jq '.[].name'2. Ensure the below command's output does not containallUsersorallAuthenticatedUsers.gcloud kms keys get-iam-policy [key_name] --keyring=[key_ring_name] --location=global --format=json | jq '.bindings[].members[]'- Impact Statement
Removing the binding for
allUsersandallAuthenticatedUsersmembers denies accessingcryptokeysto anonymous or public users.- Assessment Status
Automated
- Rationale Statement
Granting permissions to
allUsersorallAuthenticatedUsersallows anyone to access the dataset. Such access might not be desirable if sensitive data is stored at the location. In this case, ensure that anonymous and/or public access to a Cloud KMScryptokeyis not allowed.- Remediation Procedure
From Google Cloud CLI1. List all Cloud KMS
Cryptokeys.gcloud kms keys list --keyring=[key_ring_name] --location=global --format=json | jq '.[].name'2. Remove IAM policy binding for a KMS key to remove access toallUsersandallAuthenticatedUsersusing the below command.gcloud kms keys remove-iam-policy-binding [key_name] --keyring=[key_ring_name] --location=global --member='allAuthenticatedUsers' --role='[role]'gcloud kms keys remove-iam-policy-binding [key_name] --keyring=[key_ring_name] --location=global --member='allUsers' --role='[role]'- Additional Information
[key_ring_name] : Is the resource ID of the key ring, which is the fully-qualified Key ring name. This value is case-sensitive and in the form: projects/PROJECT_ID/locations/LOCATION/keyRings/KEY_RINGYou can retrieve the key ring resource ID using the Cloud Console:1. Open the
Cryptographic Keyspage in the Cloud Console.2. For the key ring whose resource ID you are retrieving, click theMore icon (3 vertical dots).3. ClickCopy Resource ID. The resource ID for the key ring is copied to your clipboard.[key_name] : Is the resource ID of the key, which is the fully-qualified CryptoKey name. This value is case-sensitive and in the form: projects/PROJECT_ID/locations/LOCATION/keyRings/KEY_RING/cryptoKeys/KEYYou can retrieve the key resource ID using the Cloud Console:1. Open theCryptographic Keyspage in the Cloud Console.2. Click the name of the key ring that contains the key.3. For the key whose resource ID you are retrieving, click theMore icon (3 vertical dots).4. ClickCopy Resource ID. The resource ID for the key is copied to your clipboard.[role] : The role to remove the member from.
1.10Ensure KMS Encryption Keys Are Rotated Within a Period of 90 Days1
Attributes
- Profile
Level 1
- Section
1 Identity and Access Management
- Description
Google Cloud Key Management Service stores cryptographic keys in a hierarchical structure designed for useful and elegant access control management. The format for the rotation schedule depends on the client library that is used. For the gcloud command-line tool, the next rotation time must be in
ISOorRFC3339format, and the rotation period must be in the formINTEGER[UNIT], where units can be one of seconds (s), minutes (m), hours (h) or days (d).- Default Value
By default, KMS encryption keys are rotated every 90 days.
- Audit Procedure
From Google Cloud Console1. Go to
Cryptographic Keysby visiting: https://console.cloud.google.com/security/kms.2. Click on each key ring, then ensure each key in the keyring hasNext Rotationset for less than 90 days from the current date.From Google Cloud CLI1. Ensure rotation is scheduled byROTATION_PERIODandNEXT_ROTATION_TIMEfor each key :gcloud kms keys list --keyring=<KEY_RING> --location=<LOCATION> --format=json'(rotationPeriod)'Ensure outcome values forrotationPeriodandnextRotationTimesatisfy the below criteria:rotationPeriod is <= 129600mrotationPeriod is <= 7776000srotationPeriod is <= 2160hrotationPeriod is <= 90dnextRotationTime is <= 90daysfrom current DATE- Impact Statement
After a successful key rotation, the older key version is required in order to decrypt the data encrypted by that previous key version.
- Assessment Status
Automated
- Rationale Statement
Set a key rotation period and starting time. A key can be created with a specified
rotation period, which is the time between when new key versions are generated automatically. A key can also be created with a specified next rotation time. A key is a named object representing acryptographic keyused for a specific purpose. The key material, the actual bits used forencryption, can change over time as new key versions are created.A key is used to protect somecorpus of data. A collection of files could be encrypted with the same key and people withdecryptpermissions on that key would be able to decrypt those files. Therefore, it's necessary to make sure therotation periodis set to a specific time.- Remediation Procedure
From Google Cloud Console1. Go to
Cryptographic Keysby visiting: https://console.cloud.google.com/security/kms.2. Click on the specific key ring3. From the list of keys, choose the specific key and Click onRight side pop up the blade (3 dots).4. Click onEdit rotation period.5. On the pop-up window,Select a new rotation periodin days which should be less than 90 and then chooseStarting ondate (date from which the rotation period begins).From Google Cloud CLI1. Update and schedule rotation byROTATION_PERIODandNEXT_ROTATION_TIMEfor each key:gcloud kms keys update new --keyring=KEY_RING --location=LOCATION --next-rotation-time=NEXT_ROTATION_TIME --rotation-period=ROTATION_PERIOD- Additional Information
'- Key rotation does NOT re-encrypt already encrypted data with the newly generated key version. If you suspect unauthorized use of a key, you should re-encrypt the data protected by that key and then disable or schedule destruction of the prior key version.- It is not recommended to rely solely on irregular rotation, but rather to use irregular rotation if needed in conjunction with a regular rotation schedule.
1.11Ensure That Separation of Duties Is Enforced While Assigning KMS Related Roles to Users1
Attributes
- Profile
Level 2
- Section
1 Identity and Access Management
- Description
It is recommended that the principle of 'Separation of Duties' is enforced while assigning KMS related roles to users.
- Audit Procedure
From Google Cloud Console1. Go to
IAM & Admin/IAMby visiting: https://console.cloud.google.com/iam-admin/iam2. Ensure no member has the rolesCloud KMS Adminand any of theCloud KMS CryptoKey Encrypter/Decrypter,Cloud KMS CryptoKey Encrypter,Cloud KMS CryptoKey Decrypterassigned.From Google Cloud CLI1. List all users and role assignments:gcloud projects get-iam-policy PROJECT_ID2. Ensure that there are no common users found in the member section for rolescloudkms.adminand any one ofCloud KMS CryptoKey Encrypter/Decrypter,Cloud KMS CryptoKey Encrypter,Cloud KMS CryptoKey Decrypter- Impact Statement
Removed roles should be assigned to another user based on business needs.
- Assessment Status
Automated
- Rationale Statement
The built-in/predefined IAM role
Cloud KMS Adminallows the user/identity to create, delete, and manage service account(s).The built-in/predefined IAM roleCloud KMS CryptoKey Encrypter/Decrypterallows the user/identity (with adequate privileges on concerned resources) to encrypt and decrypt data at rest using an encryption key(s).The built-in/predefined IAM roleCloud KMS CryptoKey Encrypterallows the user/identity (with adequate privileges on concerned resources) to encrypt data at rest using an encryption key(s).The built-in/predefined IAM roleCloud KMS CryptoKey Decrypterallows the user/identity (with adequate privileges on concerned resources) to decrypt data at rest using an encryption key(s).Separation of duties is the concept of ensuring that one individual does not have all necessary permissions to be able to complete a malicious action. In Cloud KMS, this could be an action such as using a key to access and decrypt data a user should not normally have access to. Separation of duties is a business control typically used in larger organizations, meant to help avoid security or privacy incidents and errors. It is considered best practice.No user(s) should haveCloud KMS Adminand any of theCloud KMS CryptoKey Encrypter/Decrypter,Cloud KMS CryptoKey Encrypter,Cloud KMS CryptoKey Decrypterroles assigned at the same time.- Remediation Procedure
From Google Cloud Console1. Go to
IAM & Admin/IAMusinghttps://console.cloud.google.com/iam-admin/iam2. For any member havingCloud KMS Adminand any of theCloud KMS CryptoKey Encrypter/Decrypter,Cloud KMS CryptoKey Encrypter,Cloud KMS CryptoKey Decrypterroles granted/assigned, click theDelete Binicon to remove the role from the member.Note: Removing a role should be done based on the business requirement.- Additional Information
Users granted with Owner (roles/owner) and Editor (roles/editor) have privileges equivalent to
Cloud KMS AdminandCloud KMS CryptoKey Encrypter/Decrypter. To avoid misuse, Owner and Editor roles should be granted to a very limited group of users. Use of these primitive privileges should be minimal.
1.12Ensure API Keys Only Exist for Active Services1
Attributes
- Profile
Level 2
- Section
1 Identity and Access Management
- Description
API Keys should only be used for services in cases where other authentication methods are unavailable. Unused keys with their permissions in tact may still exist within a project. Keys are insecure because they can be viewed publicly, such as from within a browser, or they can be accessed on a device where the key resides. It is recommended to use standard authentication flow instead.
- Default Value
By default, API keys are not created for a project.
- Audit Procedure
**From Console:**1. From within the Project you wish to audit Go to
APIs & Services\Credentials. 1. In the sectionAPI Keys, no API key should be listed.From Google Cloud Command Line1. Run the following from within the project you wish to auditgcloud services api-keys list --filter.1. There should be no keys listed at the project level.- Impact Statement
Deleting an API key will break dependent applications (if any).
- Assessment Status
Automated
- Rationale Statement
To avoid the security risk in using API keys, it is recommended to use standard authentication flow instead. Security risks involved in using API-Keys appear below:- API keys are simple encrypted strings- API keys do not identify the user or the application making the API request- API keys are typically accessible to clients, making it easy to discover and steal an API key
- Remediation Procedure
**From Console:**1. Go to
APIs & Services\Credentialsusing1. In the sectionAPI Keys, to delete API Keys: Click theDelete Bin Iconin front of everyAPI Key Name.From Google Cloud Command Line1. Run the following from within the project you wish to audit **gcloud services api-keys list --filter**1. **Pipe the results into **gcloud alpha services api-keys delete- Additional Information
Google recommends using the standard authentication flow instead of using API keys. However, there are limited cases where API keys are more appropriate. For example, if there is a mobile application that needs to use the Google Cloud Translation API, but doesn't otherwise need a backend server, API keys are the simplest way to authenticate to that API.If a business requires API keys to be used, then the API keys should be secured properly.
1.13Ensure API Keys Are Restricted To Use by Only Specified Hosts and Apps0
Attributes
- Profile
Level 2
- Section
1 Identity and Access Management
- Description
API Keys should only be used for services in cases where other authentication methods are unavailable. In this case, unrestricted keys are insecure because they can be viewed publicly, such as from within a browser, or they can be accessed on a device where the key resides. It is recommended to restrict API key usage to trusted hosts, HTTP referrers and apps. It is recommended to use the more secure standard authentication flow instead.
- Default Value
By default,
Application Restrictionsare set toNone.- Audit Procedure
From Google Cloud Console1. Go to
APIs & Services\Credentialsusinghttps://console.cloud.google.com/apis/credentials1. In the sectionAPI Keys, Click theAPI Key Name. The API Key properties display on a new page.1. For every API Key, ensure the sectionKey restrictionsparameterApplication restrictionsis not set toNone.Or,1. EnsureApplication restrictionsis set toHTTP referrersand the referrer is not set to wild-cards(* or *.[TLD] or *.[TLD]/*) allowing access to any/wide HTTP referrer(s)Or,1. EnsureApplication restrictionsis set toIP addressesand referrer is not set toany host (0.0.0.0 or 0.0.0.0/0 or ::0)From Google Cloud Command Line1. Run the following from within the project you wish to auditgcloud services api-keys list --filter="-restrictions:*" --format="table[box](displayName:label='Key With No Restrictions')- Impact Statement
Setting
Application Restrictionsmay break existing application functioning, if not done carefully.- Assessment Status
Manual
- Rationale Statement
Security risks involved in using API-Keys appear below:- API keys are simple encrypted strings- API keys do not identify the user or the application making the API request- API keys are typically accessible to clients, making it easy to discover and steal an API keyIn light of these potential risks, Google recommends using the standard authentication flow instead of API keys. However, there are limited cases where API keys are more appropriate. For example, if there is a mobile application that needs to use the Google Cloud Translation API, but doesn't otherwise need a backend server, API keys are the simplest way to authenticate to that API.In order to reduce attack vectors, API-Keys can be restricted only to trusted hosts, HTTP referrers and applications.
- Remediation Procedure
From Google Cloud ConsoleLeaving Keys in Place1. Go to
APIs & Services\Credentialsusinghttps://console.cloud.google.com/apis/credentials2. In the sectionAPI Keys, Click theAPI Key Name. The API Key properties display on a new page.3. In theKey restrictionssection, set the application restrictions to any ofHTTP referrers, IP addresses, Android apps, iOS apps.4. ClickSave.1. Repeat steps 2,3,4 for every unrestricted API key.Note: Do not setHTTP referrersto wild-cards (* or *.[TLD] or .[TLD]/) allowing access to any/wide HTTP referrer(s)Do not setIP addressesand referrer toany host (0.0.0.0 or 0.0.0.0/0 or ::0)Removing KeysAnother option is to remove the keys entirely.1. Go toAPIs & Services\Credentialsusinghttps://console.cloud.google.com/apis/credentials2. In the sectionAPI Keys, select the checkbox next to each key you wish to remove3. SelectDeleteand confirm.
1.14Ensure API Keys Are Restricted to Only APIs That Application Needs Access1
Attributes
- Profile
Level 2
- Section
1 Identity and Access Management
- References
- https://cloud.google.com/docs/authentication/api-keys:https://cloud.google.com/apis/docs/overview
- Description
API Keys should only be used for services in cases where other authentication methods are unavailable. API keys are always at risk because they can be viewed publicly, such as from within a browser, or they can be accessed on a device where the key resides. It is recommended to restrict API keys to use (call) only APIs required by an application.
- Default Value
By default,
API restrictionsare set toNone.- Audit Procedure
**From Console:**1. Go to
APIs & Services\Credentialsusinghttps://console.cloud.google.com/apis/credentials2. In the sectionAPI Keys, Click theAPI Key Name. The API Key properties display on a new page.3. For every API Key, ensure the sectionKey restrictionsparameterAPI restrictionsis not set toNone.Or, EnsureAPI restrictionsis not set toGoogle Cloud APIsNote:Google Cloud APIsrepresents the API collection of all cloud services/APIs offered by Google cloud.From Google Cloud CLI1. List all API Keys.gcloud services api-keys listEach key should have a line that saysrestrictions:followed by varying parameters and NOT have a line saying- service: cloudapis.googleapis.comas shown hererestrictions: apiTargets: - service: cloudapis.googleapis.com- Impact Statement
Setting
API restrictionsmay break existing application functioning, if not done carefully.- Assessment Status
Automated
- Rationale Statement
Security risks involved in using API-Keys are below:- API keys are simple encrypted strings- API keys do not identify the user or the application making the API request- API keys are typically accessible to clients, making it easy to discover and steal an API keyIn light of these potential risks, Google recommends using the standard authentication flow instead of API-Keys. However, there are limited cases where API keys are more appropriate. For example, if there is a mobile application that needs to use the Google Cloud Translation API, but doesn't otherwise need a backend server, API keys are the simplest way to authenticate to that API.In order to reduce attack surfaces by providing
least privileges, API-Keys can be restricted to use (call) only APIs required by an application.- Remediation Procedure
From Console:1. Go to
APIs & Services\Credentialsusinghttps://console.cloud.google.com/apis/credentials2. In the sectionAPI Keys, Click theAPI Key Name. The API Key properties display on a new page.3. In theKey restrictionssection go toAPI restrictions.4. Click theSelect APIdrop-down to choose an API.5. ClickSave.6. Repeat steps 2,3,4,5 for every unrestricted API keyNote: Do not setAPI restrictionstoGoogle Cloud APIs, as this option allows access to all services offered by Google cloud.From Google Cloud CLI1. List all API keys.gcloud services api-keys list2. Note theUIDof the key to add restrictions to.3. Run the update command with the appropriate flags to add the required restrictions.gcloud alpha services api-keys update <UID> <restriction_flags>Note- Flags can be found by runninggcloud alpha services api-keys update --helpor in this documentationhttps://cloud.google.com/sdk/gcloud/reference/alpha/services/api-keys/update- Additional Information
Some of the gcloud commands listed are currently in alpha and might change without notice.
1.15Ensure API Keys Are Rotated Every 90 Days1
Attributes
- Profile
Level 2
- Section
1 Identity and Access Management
- Description
API Keys should only be used for services in cases where other authentication methods are unavailable. If they are in use it is recommended to rotate API keys every 90 days.
- Audit Procedure
From Google Cloud Console1. Go to
APIs & Services\Credentialsusinghttps://console.cloud.google.com/apis/credentials2. In the sectionAPI Keys, for every key ensure thecreation dateis less than 90 days.From Google Cloud CLITo list keys, use the commandgcloud services api-keys listEnsure the date increateTimeis within 90 days.- Impact Statement
Regenerating Keymay break existing client connectivity as the client will try to connect with older API keys they have stored on devices.- Assessment Status
Automated
- Rationale Statement
Security risks involved in using API-Keys are listed below:- API keys are simple encrypted strings- API keys do not identify the user or the application making the API request- API keys are typically accessible to clients, making it easy to discover and steal an API keyBecause of these potential risks, Google recommends using the standard authentication flow instead of API Keys. However, there are limited cases where API keys are more appropriate. For example, if there is a mobile application that needs to use the Google Cloud Translation API, but doesn't otherwise need a backend server, API keys are the simplest way to authenticate to that API.Once a key is stolen, it has no expiration, meaning it may be used indefinitely unless the project owner revokes or regenerates the key. Rotating API keys will reduce the window of opportunity for an access key that is associated with a compromised or terminated account to be used. API keys should be rotated to ensure that data cannot be accessed with an old key that might have been lost, cracked, or stolen.
- Remediation Procedure
From Google Cloud Console1. Go to
APIs & Services\Credentialsusinghttps://console.cloud.google.com/apis/credentials2. In the sectionAPI Keys, Click theAPI Key Name. The API Key properties display on a new page.3. ClickREGENERATE KEYto rotate API key.4. ClickSave.5. Repeat steps 2,3,4 for every API key that has not been rotated in the last 90 days.Note: Do not setHTTP referrersto wild-cards (* or *.[TLD] or .[TLD]/) allowing access to any/wide HTTP referrer(s)Do not setIP addressesand referrer toany host (0.0.0.0 or 0.0.0.0/0 or ::0)From Google Cloud CLIThere is not currently a way to regenerate and API key using gcloud commands. To 'regenerate' a key you will need to create a new one, duplicate the restrictions from the key being rotated, and delete the old key.1. List existing keys.gcloud services api-keys list2. Note theUIDand restrictions of the key to regenerate.3. Run this command to create a new API key. <key_name> is the display name of the new key.gcloud alpha services api-keys create --display-name="<key_name>"Note theUIDof the newly created key4. Run the update command to add required restrictions. Note - the restriction may vary for each key. Refer to this documentation for the appropriate flags.https://cloud.google.com/sdk/gcloud/reference/alpha/services/api-keys/updategcloud alpha services api-keys update <UID of new key>5. Delete the old key.gcloud alpha services api-keys delete <UID of old key>- Additional Information
There is no option to automatically regenerate (rotate) API keys periodically.
1.16Ensure Essential Contacts is Configured for Organization1
Attributes
- Profile
Level 1
- Section
1 Identity and Access Management
- Description
It is recommended that Essential Contacts is configured to designate email addresses for Google Cloud services to notify of important technical or security information.
- Default Value
By default, there are no Essential Contacts configured.In the absence of an Essential Contact, the following IAM roles are used to identify users to notify for the following categories:- Legal:
roles/billing.admin- Security:roles/resourcemanager.organizationAdmin- Suspension:roles/owner- Technical:roles/owner- Technical Incidents:roles/owner- Audit Procedure
From Google Cloud Console1. Go to
Essential Contactsby visiting https://console.cloud.google.com/iam-admin/essential-contacts2. Make sure the organization appears in the resource selector at the top of the page. The resource selector tells you what project, folder, or organization you are currently managing contacts for.3. Ensure that appropriate email addresses are configured for each of the following notification categories:-Legal-Security-Suspension-TechnicalAlternatively, appropriate email addresses can be configured for theAllnotification category to receive all possible important notifications.From Google Cloud CLI1. To list all configured organization Essential Contacts run a command:gcloud essential-contacts list --organization=<ORGANIZATION_ID>2. Ensure at least one appropriate email address is configured for each of the following notification categories:-LEGAL-SECURITY-SUSPENSION-TECHNICALAlternatively, appropriate email addresses can be configured for theALLnotification category to receive all possible important notifications.- Impact Statement
There is no charge for Essential Contacts except for the 'Technical Incidents' category that is only available to premium support customers.
- Assessment Status
Automated
- Rationale Statement
Many Google Cloud services, such as Cloud Billing, send out notifications to share important information with Google Cloud users. By default, these notifications are sent to members with certain Identity and Access Management (IAM) roles. With Essential Contacts, you can customize who receives notifications by providing your own list of contacts.
- Remediation Procedure
From Google Cloud Console1. Go to
Essential Contactsby visiting https://console.cloud.google.com/iam-admin/essential-contacts2. Make sure the organization appears in the resource selector at the top of the page. The resource selector tells you what project, folder, or organization you are currently managing contacts for.3. Click+Add contact4. In theEmailandConfirm Emailfields, enter the email address of the contact.5. From theNotification categoriesdrop-down menu, select the notification categories that you want the contact to receive communications for.6. ClickSaveFrom Google Cloud CLI1. To add an organization Essential Contacts run a command:gcloud essential-contacts create --email="<EMAIL>" \ --notification-categories="<NOTIFICATION_CATEGORIES>" \ --organization=<ORGANIZATION_ID>
1.17Ensure Secrets are Not Stored in Cloud Functions Environment Variables by Using Secret Manager0
Attributes
- Profile
Level 1
- Section
1 Identity and Access Management
- Description
Google Cloud Functions allow you to host serverless code that is executed when an event is triggered, without the requiring the management a host operating system. These functions can also store environment variables to be used by the code that may contain authentication or other information that needs to remain confidential.
- Default Value
By default Secret Manager is not enabled.
- Audit Procedure
Determine if Confidential Information is Stored in your Functions in CleartextFrom Google Cloud Console1. Within the project you wish to audit, select the Navigation hamburger menu in the top left. Scroll down to under the heading 'Serverless', then select 'Cloud Functions'1. Click on a function name from the list1. Open the Variables tab and you will see both buildEnvironmentVariables and environmentVariables1. Review the variables whether they are secrets1. Repeat step 3-5 until all functions are reviewedFrom Google Cloud CLI1. To view a list of your cloud functions run
gcloud functions list2. For each cloud function in the list run the following command.gcloud functions describe <function_name>3. Review the settings of the buildEnvironmentVariables and environmentVariables. Determine if this is data that should not be publicly accessible.Determine if Secret Manager API is 'Enabled' for your ProjectFrom Google Cloud Console1. Within the project you wish to audit, select the Navigation hamburger menu in the top left. Hover over 'APIs & Services' to under the heading 'Serverless', then select 'Enabled APIs & Services' in the menu that opens up.1. Click the button '+ Enable APIS and Services'1. In the Search bar, search for 'Secret Manager API' and select it.1. If it is enabled, the blue box that normally says 'Enable' will instead say 'Manage'.From Google Cloud CLI1. Within the project you wish to audit, run the following command.gcloud services list2. If 'Secret Manager API' is in the list, it is enabled.- Impact Statement
There should be no impact on the Cloud Function. There are minor costs after 10,000 requests a month to the Secret Manager API as well for a high use of other functions. Modifying the Cloud Function to use the Secret Manager may prevent it running to completion.
- Assessment Status
Manual
- Rationale Statement
It is recommended to use the Secret Manager, because environment variables are stored unencrypted, and accessible for all users who have access to the code.
- Remediation Procedure
Enable Secret Manager API for your ProjectFrom Google Cloud Console1. Within the project you wish to enable, select the Navigation hamburger menu in the top left. Hover over 'APIs & Services' to under the heading 'Serverless', then select 'Enabled APIs & Services' in the menu that opens up.2. Click the button '+ Enable APIS and Services'3. In the Search bar, search for 'Secret Manager API' and select it.4. Click the blue box that says 'Enable'.From Google Cloud CLI1. Within the project you wish to enable the API in, run the following command.
gcloud services enable Secret Manager APIReviewing Environment Variables That Should Be Migrated to Secret ManagerFrom Google Cloud Console1. Log in to the Google Cloud Web Portal (https://console.cloud.google.com/)1. Go to Cloud Functions1. Click on a function name from the list1. Click on Edit and review the Runtime environment for variables that should be secrets. Leave this list open for the next step.From Google Cloud CLI1. To view a list of your cloud functions rungcloud functions list2. For each cloud function run the following command.gcloud functions describe <function_name>3. Review the settings of the buildEnvironmentVariables and environmentVariables. Keep this information for the next step.Migrating Environment Variables to Secrets within the Secret ManagerFrom Google Cloud Console1. Go to the Secret Manager page in the Cloud Console.1. On the Secret Manager page, click Create Secret.1. On the Create secret page, under Name, enter the name of the Environment Variable you are replacing. This will then be the Secret Variable you will reference in your code.1. You will also need to add a version. This is the actual value of the variable that will be referenced from the code. To add a secret version when creating the initial secret, in the Secret value field, enter the value from the Environment Variable you are replacing.1. Leave the Regions section unchanged.1. Click the Create secret button.1. Repeat for all Environment VariablesFrom Google Cloud CLI1. Run the following command with the Environment Variable name you are replacing in the<secret-id>. It is most secure to point this command to a file with the Environment Variable value located in it, as if you entered it via command line it would show up in your shell’s command history.gcloud secrets create <secret-id> --data-file="/path/to/file.txt"Granting your Runtime's Service Account Access to SecretsFrom Google Cloud Console1. Within the project containing your runtime login with account that has the 'roles/secretmanager.secretAccessor' permission. 2. Select the Navigation hamburger menu in the top left. Hover over 'Security' to under the then select 'Secret Manager' in the menu that opens up.3. Click the name of a secret listed in this screen.4. If it is not already open, click Show Info Panel in this screen to open the panel.5.In the info panel, click Add principal.6.In the New principals field, enter the service account your function uses for its identity. (If you need help locating or updating your runtime's service account, please see the 'docs/securing/function-identity#runtime_service_account' reference.)7. In the Select a role dropdown, choose Secret Manager and then Secret Manager Secret Accessor.From Google Cloud CLIAs of the time of writing, using Google CLI to list Runtime variables is only in beta. Because this is likely to change we are not including it here.Modifying the Code to use the Secrets in Secret ManagerFrom Google Cloud ConsoleThis depends heavily on which language your runtime is in. For the sake of the brevity of this recommendation, please see the '/docs/creating-and-accessing-secrets#access' reference for language specific instructions.From Google Cloud CLIThis depends heavily on which language your runtime is in. For the sake of the brevity of this recommendation, please see the' /docs/creating-and-accessing-secrets#access' reference for language specific instructions.Deleting the Insecure Environment VariablesBe certain to do this step last. Removing variables from code actively referencing them will prevent it from completing successfully.From Google Cloud Console1. Select the Navigation hamburger menu in the top left. Hover over 'Security' then select 'Secret Manager' in the menu that opens up.1. Click the name of a function. Click Edit.1. Click Runtime, build and connections settings to expand the advanced configuration options.1. Click 'Security’. Hover over the secret you want to remove, then click 'Delete'.1. Click Next. Click Deploy. The latest version of the runtime will now reference the secrets in Secret Manager.From Google Cloud CLIgcloud functions deploy <Function name>--remove-env-vars <env vars>If you need to find the env vars to remove, they are from the step where ‘gcloud functions describe<function_name>’ was run.- Additional Information
There are slight additional costs to using the Secret Manager API. Review the documentation to determine your organizations' needs.
2 Logging and Monitoring1614
2.1Ensure That Cloud Audit Logging Is Configured Properly1
Attributes
- Profile
Level 1
- Section
2 Logging and Monitoring
- Description
It is recommended that Cloud Audit Logging is configured to track all admin activities and read, write access to user data.
- Default Value
Admin Activity logs are always enabled. They cannot be disabled.Data Access audit logs are disabled by default because they can be quite large.
- Audit Procedure
From Google Cloud Console1. Go to
Audit Logsby visiting https://console.cloud.google.com/iam-admin/audit.2. Ensure that Admin Read, Data Write, and Data Read are enabled for all Google Cloud services and that no exemptions are allowed.From Google Cloud CLI1. List the Identity and Access Management (IAM) policies for the project, folder, or organization:gcloud organizations get-iam-policy ORGANIZATION_IDgcloud resource-manager folders get-iam-policy FOLDER_IDgcloud projects get-iam-policy PROJECT_ID2. Policy should have a default auditConfigs section which has the logtype set to DATA_WRITES and DATA_READ for all services. Note that projects inherit settings from folders, which in turn inherit settings from the organization. When called, projects get-iam-policy, the result shows only the policies set in the project, not the policies inherited from the parent folder or organization. Nevertheless, if the parent folder has Cloud Audit Logging enabled, the project does as well. Sample output for default audit configs may look like this:auditConfigs: - auditLogConfigs: - logType: ADMIN_READ - logType: DATA_WRITE - logType: DATA_READ service: allServices3. Any of the auditConfigs sections should not have parameter "exemptedMembers:" set, which will ensure that Logging is enabled for all users and no user is exempted.- Impact Statement
There is no charge for Admin Activity audit logs.Enabling the Data Access audit logs might result in your project being charged for the additional logs usage.
- Assessment Status
Automated
- Rationale Statement
Cloud Audit Logging maintains two audit logs for each project, folder, and organization: Admin Activity and Data Access.1. Admin Activity logs contain log entries for API calls or other administrative actions that modify the configuration or metadata of resources. Admin Activity audit logs are enabled for all services and cannot be configured.2. Data Access audit logs record API calls that create, modify, or read user-provided data. These are disabled by default and should be enabled. There are three kinds of Data Access audit log information: - Admin read: Records operations that read metadata or configuration information. Admin Activity audit logs record writes of metadata and configuration information that cannot be disabled. - Data read: Records operations that read user-provided data. - Data write: Records operations that write user-provided data.It is recommended to have an effective default audit config configured in such a way that:1. logtype is set to DATA_READ (to log user activity tracking) and DATA_WRITES (to log changes/tampering to user data).2. audit config is enabled for all the services supported by the Data Access audit logs feature.3. Logs should be captured for all users, i.e., there are no exempted users in any of the audit config sections. This will ensure overriding the audit config will not contradict the requirement.
- Remediation Procedure
From Google Cloud Console1. Go to
Audit Logsby visiting https://console.cloud.google.com/iam-admin/audit.2. Follow the steps at https://cloud.google.com/logging/docs/audit/configure-data-access to enable audit logs for all Google Cloud services. Ensure that no exemptions are allowed.From Google Cloud CLI1. To read the project's IAM policy and store it in a file run a command:gcloud projects get-iam-policy PROJECT_ID > /tmp/project_policy.yamlAlternatively, the policy can be set at the organization or folder level. If setting the policy at the organization level, it is not necessary to also set it for each folder or project.gcloud organizations get-iam-policy ORGANIZATION_ID > /tmp/org_policy.yamlgcloud resource-manager folders get-iam-policy FOLDER_ID > /tmp/folder_policy.yaml2. Edit policy in /tmp/policy.yaml, adding or changing only the audit logs configuration to:Note: Admin Activity Logs are enabled by default, and cannot be disabled. So they are not listed in these configuration changes.auditConfigs:- auditLogConfigs: - logType: DATA_WRITE - logType: DATA_READ service: allServicesNote:exemptedMembers:is not set as audit logging should be enabled for all the users3. To write new IAM policy run command:gcloud organizations set-iam-policy ORGANIZATION_ID /tmp/org_policy.yamlgcloud resource-manager folders set-iam-policy FOLDER_ID /tmp/folder_policy.yamlgcloud projects set-iam-policy PROJECT_ID /tmp/project_policy.yamlIf the preceding command reports a conflict with another change, then repeat these steps, starting with the first step.- Additional Information
'- Log type
DATA_READis equally important to that ofDATA_WRITEto track detailed user activities.- BigQuery Data Access logs are handled differently from other data access logs. BigQuery logs are enabled by default and cannot be disabled. They do not count against logs allotment and cannot result in extra logs charges.
2.2Ensure That Sinks Are Configured for All Log Entries1
Attributes
- Profile
Level 1
- Section
2 Logging and Monitoring
- Description
It is recommended to create a sink that will export copies of all the log entries. This can help aggregate logs from multiple projects and export them to a Security Information and Event Management (SIEM).
- Default Value
By default, there are no sinks configured.
- Audit Procedure
From Google Cloud Console1. Go to
Logs Routerby visiting https://console.cloud.google.com/logs/router.2. For every sink, click the 3-dot button for Menu options and selectView sink details.3. Ensure there is at least one sink with anemptyInclusion filter.4. Additionally, ensure that the resource configured asDestinationexists.From Google Cloud CLI1. Ensure that a sink with anempty filterexists. List the sinks for the project, folder or organization. If sinks are configured at a folder or organization level, they do not need to be configured for each project:gcloud logging sinks list --folder=FOLDER_ID | --organization=ORGANIZATION_ID | --project=PROJECT_IDThe output should list at least one sink with anempty filter.2. Additionally, ensure that the resource configured asDestinationexists.See https://cloud.google.com/sdk/gcloud/reference/beta/logging/sinks/list for more information.- Impact Statement
There are no costs or limitations in Cloud Logging for exporting logs, but the export destinations charge for storing or transmitting the log data.
- Assessment Status
Automated
- Rationale Statement
Log entries are held in Cloud Logging. To aggregate logs, export them to a SIEM. To keep them longer, it is recommended to set up a log sink. Exporting involves writing a filter that selects the log entries to export, and choosing a destination in Cloud Storage, BigQuery, or Cloud Pub/Sub. The filter and destination are held in an object called a sink. To ensure all log entries are exported to sinks, ensure that there is no filter configured for a sink.Sinks can be created in projects, organizations, folders, and billing accounts.
- Remediation Procedure
From Google Cloud Console1. Go to
Logs Routerby visiting https://console.cloud.google.com/logs/router.2. Click on the arrow symbol withCREATE SINKtext.3. Fill out the fields forSink details.4. Choose Cloud Logging bucket in the Select sink destination drop down menu.5. Choose a log bucket in the next drop down menu.6. If an inclusion filter is not provided for this sink, all ingested logs will be routed to the destination provided above. This may result in higher than expected resource usage.7. ClickCreate Sink.For more information, see https://cloud.google.com/logging/docs/export/configure_export_v2#dest-create.From Google Cloud CLITo create a sink to export all log entries in a Google Cloud Storage bucket:gcloud logging sinks create <sink-name> storage.googleapis.com/DESTINATION_BUCKET_NAMESinks can be created for a folder or organization, which will include all projects.gcloud logging sinks create <sink-name> storage.googleapis.com/DESTINATION_BUCKET_NAME --include-children --folder=FOLDER_ID | --organization=ORGANIZATION_IDNote: 1. A sink created by the command-line above will export logs in storage buckets. However, sinks can be configured to export logs into BigQuery, or Cloud Pub/Sub, orCustom Destination.2. While creating a sink, the sink option--log-filteris not used to ensure the sink exports all log entries.3. A sink can be created at a folder or organization level that collects the logs of all the projects underneath bypassing the option--include-childrenin the gcloud command.- Additional Information
For Command-Line Audit and Remediation, the sink destination of type
Cloud Storage Bucketis considered. However, the destination could be configured toCloud Storage BucketorBigQueryorCloud Pub\SuborCustom Destination. Command Line Interface commands would change accordingly.
2.3Ensure That Retention Policies on Cloud Storage Buckets Used for Exporting Logs Are Configured Using Bucket Lock1
Attributes
- Profile
Level 2
- Section
2 Logging and Monitoring
- Description
Enabling retention policies on log buckets will protect logs stored in cloud storage buckets from being overwritten or accidentally deleted. It is recommended to set up retention policies and configure Bucket Lock on all storage buckets that are used as log sinks.
- Default Value
By default, storage buckets used as log sinks do not have retention policies and Bucket Lock configured.
- Audit Procedure
From Google Cloud Console1. Open the Cloud Storage browser in the Google Cloud Console by visiting https://console.cloud.google.com/storage/browser.2. In the Column display options menu, make sure
Retention policyis checked.3. In the list of buckets, the retention period of each bucket is found in theRetention policycolumn. If the retention policy is locked, an image of a lock appears directly to the left of the retention period.From Google Cloud CLI1. To list all sinks destined to storage buckets:gcloud logging sinks list --folder=FOLDER_ID | --organization=ORGANIZATION_ID | --project=PROJECT_ID2. For every storage bucket listed above, verify that retention policies and Bucket Lock are enabled:gsutil retention get gs://BUCKET_NAMEFor more information, see https://cloud.google.com/storage/docs/using-bucket-lock#view-policy.- Impact Statement
Locking a bucket is an irreversible action. Once you lock a bucket, you cannot remove the retention policy from the bucket or decrease the retention period for the policy. You will then have to wait for the retention period for all items within the bucket before you can delete them, and then the bucket.
- Assessment Status
Automated
- Rationale Statement
Logs can be exported by creating one or more sinks that include a log filter and a destination. As Cloud Logging receives new log entries, they are compared against each sink. If a log entry matches a sink's filter, then a copy of the log entry is written to the destination.Sinks can be configured to export logs in storage buckets. It is recommended to configure a data retention policy for these cloud storage buckets and to lock the data retention policy; thus permanently preventing the policy from being reduced or removed. This way, if the system is ever compromised by an attacker or a malicious insider who wants to cover their tracks, the activity logs are definitely preserved for forensics and security investigations.
- Remediation Procedure
From Google Cloud Console1. If sinks are not configured, first follow the instructions in the recommendation:
Ensure that sinks are configured for all Log entries.2. For each storage bucket configured as a sink, go to the Cloud Storage browser athttps://console.cloud.google.com/storage/browser/<BUCKET_NAME>.3. Select the Bucket Lock tab near the top of the page.4. In the Retention policy entry, click the Add Duration link. TheSet a retention policydialog box appears.5. Enter the desired length of time for the retention period and clickSave policy.6. Set theLock statusfor this retention policy toLocked.From Google Cloud CLI1. To list all sinks destined to storage buckets:gcloud logging sinks list --folder=FOLDER_ID | --organization=ORGANIZATION_ID | --project=PROJECT_ID2. For each storage bucket listed above, set a retention policy and lock it:gsutil retention set [TIME_DURATION] gs://[BUCKET_NAME]gsutil retention lock gs://[BUCKET_NAME]For more information, visit https://cloud.google.com/storage/docs/using-bucket-lock#set-policy.- Additional Information
Caution: Locking a retention policy is an irreversible action. Once locked, you must delete the entire bucket in order to "remove" the bucket's retention policy. However, before you can delete the bucket, you must be able to delete all the objects in the bucket, which itself is only possible if all the objects have reached the retention period set by the retention policy.
2.4Ensure Log Metric Filter and Alerts Exist for Project Ownership Assignments/Changes1
Attributes
- Profile
Level 1
- Section
2 Logging and Monitoring
- Description
In order to prevent unnecessary project ownership assignments to users/service-accounts and further misuses of projects and resources, all
roles/Ownerassignments should be monitored.Members (users/Service-Accounts) with a role assignment to primitive roleroles/Ownerare project owners.The project owner has all the privileges on the project the role belongs to. These are summarized below:- All viewer permissions on all GCP Services within the project- Permissions for actions that modify the state of all GCP services within the project- Manage roles and permissions for a project and all resources within the project- Set up billing for a projectGranting the owner role to a member (user/Service-Account) will allow that member to modify the Identity and Access Management (IAM) policy. Therefore, grant the owner role only if the member has a legitimate purpose to manage the IAM policy. This is because the project IAM policy contains sensitive access control data. Having a minimal set of users allowed to manage IAM policy will simplify any auditing that may be necessary.- Audit Procedure
**From Google Cloud ConsoleEnsure that the prescribed log metric is present:**1. Go to
Logging/Log-based Metricsby visiting https://console.cloud.google.com/logs/metrics.2. In theUser-defined Metricssection, ensure that at least one metric<Log_Metric_Name>is present with filter text:(protoPayload.serviceName="cloudresourcemanager.googleapis.com") AND (ProjectOwnership OR projectOwnerInvitee) OR (protoPayload.serviceData.policyDelta.bindingDeltas.action="REMOVE" AND protoPayload.serviceData.policyDelta.bindingDeltas.role="roles/owner") OR (protoPayload.serviceData.policyDelta.bindingDeltas.action="ADD" AND protoPayload.serviceData.policyDelta.bindingDeltas.role="roles/owner")**Ensure that the prescribed Alerting Policy is present:**3. Go toAlertingby visiting https://console.cloud.google.com/monitoring/alerting.4. Under thePoliciessection, ensure that at least one alert policy exists for the log metric above. Clicking on the policy should show that it is configured with a condition. For example,Violates when: Any logging.googleapis.com/user/<Log Metric Name> streamis above a threshold of zero(0) for greater than zero(0) secondsmeans that the alert will trigger for any new owner change. Verify that the chosen alerting thresholds make sense for your organization.5. Ensure that the appropriate notifications channels have been set up.**From Google Cloud CLIEnsure that the prescribed log metric is present:**1. List the log metrics:gcloud logging metrics list --format json2. Ensure that the output contains at least one metric with filter set to:(protoPayload.serviceName="cloudresourcemanager.googleapis.com") AND (ProjectOwnership OR projectOwnerInvitee) OR (protoPayload.serviceData.policyDelta.bindingDeltas.action="REMOVE" AND protoPayload.serviceData.policyDelta.bindingDeltas.role="roles/owner") OR (protoPayload.serviceData.policyDelta.bindingDeltas.action="ADD" AND protoPayload.serviceData.policyDelta.bindingDeltas.role="roles/owner")3. Note the value of the propertymetricDescriptor.typefor the identified metric, in the formatlogging.googleapis.com/user/<Log Metric Name>.**Ensure that the prescribed alerting policy is present:**4. List the alerting policies:gcloud alpha monitoring policies list --format json5. Ensure that the output contains an least one alert policy where:-conditions.conditionThreshold.filteris set tometric.type=\"logging.googleapis.com/user/<Log Metric Name>\"- ANDenabledis set totrue- Impact Statement
Enabling of logging may result in your project being charged for the additional logs usage.
- Assessment Status
Automated
- Rationale Statement
Project ownership has the highest level of privileges on a project. To avoid misuse of project resources, the project ownership assignment/change actions mentioned above should be monitored and alerted to concerned recipients.- Sending project ownership invites- Acceptance/Rejection of project ownership invite by user- Adding
role\Ownerto a user/service-account- Removing a user/Service account fromrole\Owner- Remediation Procedure
**From Google Cloud Console****Create the prescribed log metric:**1. Go to
Logging/Logs-based Metricsby visiting https://console.cloud.google.com/logs/metrics and click "CREATE METRIC".2. Click the down arrow symbol on theFilter Barat the rightmost corner and selectConvert to Advanced Filter.3. Clear any text and add:(protoPayload.serviceName="cloudresourcemanager.googleapis.com") AND (ProjectOwnership OR projectOwnerInvitee) OR (protoPayload.serviceData.policyDelta.bindingDeltas.action="REMOVE" AND protoPayload.serviceData.policyDelta.bindingDeltas.role="roles/owner") OR (protoPayload.serviceData.policyDelta.bindingDeltas.action="ADD" AND protoPayload.serviceData.policyDelta.bindingDeltas.role="roles/owner")4. ClickSubmit Filter. The logs display based on the filter text entered by the user.5. In theMetric Editormenu on the right, fill out the name field. SetUnitsto1(default) and theTypetoCounter. This ensures that the log metric counts the number of log entries matching the advanced logs query.6. ClickCreate Metric. Create the display prescribed Alert Policy: 1. Identify the newly created metric under the sectionUser-defined Metricsat https://console.cloud.google.com/logs/metrics.2. Click the 3-dot icon in the rightmost column for the desired metric and selectCreate alert from Metric. A new page opens.3. Fill out the alert policy configuration and clickSave. Choose the alerting threshold and configuration that makes sense for the user's organization. For example, a threshold of zero(0) for the most recent value will ensure that a notification is triggered for every owner change in the project:Set `Aggregator` to `Count`Set `Configuration`:- Condition: above- Threshold: 0- For: most recent value4. Configure the desired notifications channels in the sectionNotifications.5. Name the policy and clickSave.From Google Cloud CLICreate a prescribed Log Metric:- Use the command: gcloud beta logging metrics create - Reference for Command Usage: https://cloud.google.com/sdk/gcloud/reference/beta/logging/metrics/createCreate prescribed Alert Policy - Use the command: gcloud alpha monitoring policies create- Reference for Command Usage: https://cloud.google.com/sdk/gcloud/reference/alpha/monitoring/policies/create- Additional Information
- Project ownership assignments for a user cannot be done using the gcloud utility as assigning project ownership to a user requires sending, and the user accepting, an invitation. 2. Project Ownership assignment to a service account does not send any invites. SetIAMPolicy to
role/owneris directly performed on service accounts.
- Project ownership assignments for a user cannot be done using the gcloud utility as assigning project ownership to a user requires sending, and the user accepting, an invitation. 2. Project Ownership assignment to a service account does not send any invites. SetIAMPolicy to
2.5Ensure That the Log Metric Filter and Alerts Exist for Audit Configuration Changes1
Attributes
- Profile
Level 1
- Section
2 Logging and Monitoring
- Description
Google Cloud Platform (GCP) services write audit log entries to the Admin Activity and Data Access logs to help answer the questions of, "who did what, where, and when?" within GCP projects.Cloud audit logging records information includes the identity of the API caller, the time of the API call, the source IP address of the API caller, the request parameters, and the response elements returned by GCP services. Cloud audit logging provides a history of GCP API calls for an account, including API calls made via the console, SDKs, command-line tools, and other GCP services.
- Audit Procedure
**From Google Cloud ConsoleEnsure the prescribed log metric is present:**1. Go to
Logging/Logs-based Metricsby visiting https://console.cloud.google.com/logs/metrics.2. In theUser-defined Metricssection, ensure that at least one metric<Log_Metric_Name>is present with the filter text:protoPayload.methodName="SetIamPolicy" ANDprotoPayload.serviceData.policyDelta.auditConfigDeltas:***Ensure that the prescribed alerting policy is present:**3. Go toAlertingby visiting https://console.cloud.google.com/monitoring/alerting.4. Under thePoliciessection, ensure that at least one alert policy exists for the log metric above. Clicking on the policy should show that it is configured with a condition. For example,Violates when: Any logging.googleapis.com/user/<Log Metric Name> streamis above a threshold of 0 for greater than zero(0) seconds, means that the alert will trigger for any new owner change. Verify that the chosen alerting thresholds make sense for the user's organization.5. Ensure that appropriate notifications channels have been set up.**From Google Cloud CLIEnsure that the prescribed log metric is present:**1. List the log metrics:gcloud beta logging metrics list --format json2. Ensure that the output contains at least one metric with the filter set to:protoPayload.methodName="SetIamPolicy" ANDprotoPayload.serviceData.policyDelta.auditConfigDeltas:*3. Note the value of the propertymetricDescriptor.typefor the identified metric, in the formatlogging.googleapis.com/user/<Log Metric Name>.**Ensure that the prescribed alerting policy is present:**4. List the alerting policies:gcloud alpha monitoring policies list --format json5. Ensure that the output contains at least one alert policy where:-conditions.conditionThreshold.filteris set tometric.type=\"logging.googleapis.com/user/<Log Metric Name>\"- ANDenabledis set totrue- Impact Statement
Enabling of logging may result in your project being charged for the additional logs usage.
- Assessment Status
Automated
- Rationale Statement
Admin activity and data access logs produced by cloud audit logging enable security analysis, resource change tracking, and compliance auditing.Configuring the metric filter and alerts for audit configuration changes ensures the recommended state of audit configuration is maintained so that all activities in the project are audit-able at any point in time.
- Remediation Procedure
**From Google Cloud Console****Create the prescribed log metric:**1. Go to
Logging/Logs-based Metricsby visiting https://console.cloud.google.com/logs/metrics and click "CREATE METRIC".2. Click the down arrow symbol on theFilter Barat the rightmost corner and selectConvert to Advanced Filter.3. Clear any text and add:protoPayload.methodName="SetIamPolicy" ANDprotoPayload.serviceData.policyDelta.auditConfigDeltas:*4. ClickSubmit Filter. Display logs appear based on the filter text entered by the user.5. In theMetric Editormenu on the right, fill out the name field. SetUnitsto1(default) andTypetoCounter. This will ensure that the log metric counts the number of log entries matching the user's advanced logs query.6. ClickCreate Metric. Create a prescribed Alert Policy: 1. Identify the new metric the user just created, under the sectionUser-defined Metricsat https://console.cloud.google.com/logs/metrics.2. Click the 3-dot icon in the rightmost column for the new metric and selectCreate alert from Metric. A new page opens.3. Fill out the alert policy configuration and clickSave. Choose the alerting threshold and configuration that makes sense for the organization. For example, a threshold of zero(0) for the most recent value will ensure that a notification is triggered for every owner change in the project:Set `Aggregator` to `Count`Set `Configuration`:- Condition: above- Threshold: 0- For: most recent value4. Configure the desired notifications channels in the sectionNotifications.5. Name the policy and clickSave.From Google Cloud CLICreate a prescribed Log Metric:- Use the command: gcloud beta logging metrics create - Reference for command usage: https://cloud.google.com/sdk/gcloud/reference/beta/logging/metrics/createCreate prescribed Alert Policy - Use the command: gcloud alpha monitoring policies create- Reference for command usage: https://cloud.google.com/sdk/gcloud/reference/alpha/monitoring/policies/create
2.6Ensure That the Log Metric Filter and Alerts Exist for Custom Role Changes1
Attributes
- Profile
Level 1
- Section
2 Logging and Monitoring
- Description
It is recommended that a metric filter and alarm be established for changes to Identity and Access Management (IAM) role creation, deletion and updating activities.
- Audit Procedure
**From Console:****Ensure that the prescribed log metric is present:**1. Go to
Logging/Logs-based Metricsby visiting https://console.cloud.google.com/logs/metrics.2. In theUser-defined Metricssection, ensure that at least one metric<Log_Metric_Name>is present with filter text:resource.type="iam_role" AND (protoPayload.methodName="google.iam.admin.v1.CreateRole" OR protoPayload.methodName="google.iam.admin.v1.DeleteRole" OR protoPayload.methodName="google.iam.admin.v1.UpdateRole")**Ensure that the prescribed alerting policy is present:**3. Go toAlertingby visiting https://console.cloud.google.com/monitoring/alerting.4. Under thePoliciessection, ensure that at least one alert policy exists for the log metric above. Clicking on the policy should show that it is configured with a condition. For example,Violates when: Any logging.googleapis.com/user/<Log Metric Name> streamis above a threshold of zero(0) for greater than zero(0) secondsmeans that the alert will trigger for any new owner change. Verify that the chosen alerting thresholds make sense for the user's organization.5. Ensure that the appropriate notifications channels have been set up.From Google Cloud CLIEnsure that the prescribed log metric is present:1. List the log metrics:gcloud logging metrics list --format json2. Ensure that the output contains at least one metric with the filter set to:resource.type="iam_role"AND (protoPayload.methodName = "google.iam.admin.v1.CreateRole" ORprotoPayload.methodName="google.iam.admin.v1.DeleteRole" ORprotoPayload.methodName="google.iam.admin.v1.UpdateRole")3. Note the value of the propertymetricDescriptor.typefor the identified metric, in the formatlogging.googleapis.com/user/<Log Metric Name>.**Ensure that the prescribed alerting policy is present:**4. List the alerting policies:gcloud alpha monitoring policies list --format json5. Ensure that the output contains an least one alert policy where:-conditions.conditionThreshold.filteris set tometric.type=\"logging.googleapis.com/user/<Log Metric Name>\"- ANDenabledis set totrue.- Impact Statement
Enabling of logging may result in your project being charged for the additional logs usage.
- Assessment Status
Automated
- Rationale Statement
Google Cloud IAM provides predefined roles that give granular access to specific Google Cloud Platform resources and prevent unwanted access to other resources. However, to cater to organization-specific needs, Cloud IAM also provides the ability to create custom roles. Project owners and administrators with the Organization Role Administrator role or the IAM Role Administrator role can create custom roles. Monitoring role creation, deletion and updating activities will help in identifying any over-privileged role at early stages.
- Remediation Procedure
**From Console:****Create the prescribed log metric:**1. Go to
Logging/Logs-based Metricsby visiting https://console.cloud.google.com/logs/metrics and click "CREATE METRIC".1. Click the down arrow symbol on theFilter Barat the rightmost corner and selectConvert to Advanced Filter.1. Clear any text and add:resource.type="iam_role" AND (protoPayload.methodName = "google.iam.admin.v1.CreateRole" OR protoPayload.methodName="google.iam.admin.v1.DeleteRole" OR protoPayload.methodName="google.iam.admin.v1.UpdateRole")1. ClickSubmit Filter. Display logs appear based on the filter text entered by the user.1. In theMetric Editormenu on the right, fill out the name field. SetUnitsto1(default) andTypetoCounter. This ensures that the log metric counts the number of log entries matching the advanced logs query.1. ClickCreate Metric. Create a prescribed Alert Policy: 1. Identify the new metric that was just created under the sectionUser-defined Metricsat https://console.cloud.google.com/logs/metrics.2. Click the 3-dot icon in the rightmost column for the metric and selectCreate alert from Metric. A new page displays.3. Fill out the alert policy configuration and clickSave. Choose the alerting threshold and configuration that makes sense for the user's organization. For example, a threshold of zero(0) for the most recent value ensures that a notification is triggered for every owner change in the project:Set `Aggregator` to `Count`Set `Configuration`:- Condition: above- Threshold: 0- For: most recent value1. Configure the desired notification channels in the sectionNotifications.1. Name the policy and clickSave.From Google Cloud CLICreate the prescribed Log Metric:- Use the command: gcloud logging metrics create Create the prescribed Alert Policy: - Use the command: gcloud alpha monitoring policies create <policy name>
2.7Ensure That the Log Metric Filter and Alerts Exist for VPC Network Firewall Rule Changes1
Attributes
- Profile
Level 2
- Section
2 Logging and Monitoring
- Description
It is recommended that a metric filter and alarm be established for Virtual Private Cloud (VPC) Network Firewall rule changes.
- Audit Procedure
**From Google Cloud ConsoleEnsure that the prescribed log metric is present:**1. Go to
Logging/Logs-based Metricsby visiting https://console.cloud.google.com/logs/metrics.2. In theUser-defined Metricssection, ensure at least one metric<Log_Metric_Name>is present with this filter text:resource.type="gce_firewall_rule" AND (protoPayload.methodName:"compute.firewalls.patch" OR protoPayload.methodName:"compute.firewalls.insert"OR protoPayload.methodName:"compute.firewalls.delete")**Ensure that the prescribed alerting policy is present:**3. Go toAlertingby visiting https://console.cloud.google.com/monitoring/alerting.4. Under thePoliciessection, ensure that at least one alert policy exists for the log metric above. Clicking on the policy should show that it is configured with a condition. For example,Violates when: Any logging.googleapis.com/user/<Log Metric Name> streamis above a threshold of zero(0) for greater than zero(0) secondsmeans that the alert will trigger for any new owner change. Verify that the chosen alerting thresholds make sense for the user's organization.5. Ensure that appropriate notification channels have been set up.**From Google Cloud CLIEnsure that the prescribed log metric is present:**1. List the log metrics:gcloud logging metrics list --format json2. Ensure that the output contains at least one metric with the filter set to:resource.type="gce_firewall_rule" AND (protoPayload.methodName:"compute.firewalls.patch" OR protoPayload.methodName:"compute.firewalls.insert"OR protoPayload.methodName:"compute.firewalls.delete")3. Note the value of the propertymetricDescriptor.typefor the identified metric, in the formatlogging.googleapis.com/user/<Log Metric Name>.**Ensure that the prescribed alerting policy is present:**4. List the alerting policies:gcloud alpha monitoring policies list --format json5. Ensure that the output contains an least one alert policy where:-conditions.conditionThreshold.filteris set tometric.type=\"logging.googleapis.com/user/<Log Metric Name>\"- ANDenabledis set totrue- Impact Statement
Enabling of logging may result in your project being charged for the additional logs usage. These charges could be significant depending on the size of the organization.
- Assessment Status
Automated
- Rationale Statement
Monitoring for Create or Update Firewall rule events gives insight to network access changes and may reduce the time it takes to detect suspicious activity.
- Remediation Procedure
**From Google Cloud Console****Create the prescribed log metric:**1. Go to
Logging/Logs-based Metricsby visiting https://console.cloud.google.com/logs/metrics and click "CREATE METRIC".2. Click the down arrow symbol on theFilter Barat the rightmost corner and selectConvert to Advanced Filter.3. Clear any text and add:resource.type="gce_firewall_rule" AND (protoPayload.methodName:"compute.firewalls.patch" OR protoPayload.methodName:"compute.firewalls.insert"OR protoPayload.methodName:"compute.firewalls.delete")4. ClickSubmit Filter. Display logs appear based on the filter text entered by the user.5. In theMetric Editormenu on the right, fill out the name field. SetUnitsto1(default) andTypetoCounter. This ensures that the log metric counts the number of log entries matching the advanced logs query.6. ClickCreate Metric. Create the prescribed Alert Policy: 1. Identify the newly created metric under the sectionUser-defined Metricsat https://console.cloud.google.com/logs/metrics.2. Click the 3-dot icon in the rightmost column for the new metric and selectCreate alert from Metric. A new page displays.3. Fill out the alert policy configuration and clickSave. Choose the alerting threshold and configuration that makes sense for the user's organization. For example, a threshold of zero(0) for the most recent value ensures that a notification is triggered for every owner change in the project:Set `Aggregator` to `Count`Set `Configuration`:- Condition: above- Threshold: 0- For: most recent value4. Configure the desired notifications channels in the sectionNotifications.5. Name the policy and clickSave.From Google Cloud CLICreate the prescribed Log Metric- Use the command: gcloud logging metrics create Create the prescribed alert policy: - Use the command: gcloud alpha monitoring policies create
2.8Ensure That the Log Metric Filter and Alerts Exist for VPC Network Route Changes1
Attributes
- Profile
Level 2
- Section
2 Logging and Monitoring
- Description
It is recommended that a metric filter and alarm be established for Virtual Private Cloud (VPC) network route changes.
- Audit Procedure
**From Google Cloud ConsoleEnsure that the prescribed Log metric is present:**1. Go to
Logging/Logs-based Metricsby visiting https://console.cloud.google.com/logs/metrics.2. In theUser-defined Metricssection, ensure that at least one metric<Log_Metric_Name>is present with the filter text:resource.type="gce_route" AND (protoPayload.methodName:"compute.routes.delete" OR protoPayload.methodName:"compute.routes.insert")**Ensure the prescribed alerting policy is present:**3. Go toAlertingby visiting: https://console.cloud.google.com/monitoring/alerting.4. Under thePoliciessection, ensure that at least one alert policy exists for the log metric above. Clicking on the policy should show that it is configured with a condition. For example,Violates when: Any logging.googleapis.com/user/<Log Metric Name> streamis above a threshold of 0 for greater than zero(0) secondsmeans that the alert will trigger for any new owner change. Verify that the chosen alert thresholds make sense for the user's organization.5. Ensure that the appropriate notification channels have been set up.**From Google Cloud CLIEnsure the prescribed log metric is present:**1. List the log metrics:gcloud logging metrics list --format json2. Ensure that the output contains at least one metric with the filter set to:resource.type="gce_route" AND (protoPayload.methodName:"compute.routes.delete" OR protoPayload.methodName:"compute.routes.insert")3. Note the value of the propertymetricDescriptor.typefor the identified metric, in the formatlogging.googleapis.com/user/<Log Metric Name>.**Ensure that the prescribed alerting policy is present:**4. List the alerting policies:gcloud alpha monitoring policies list --format json5. Ensure that the output contains an least one alert policy where:-conditions.conditionThreshold.filteris set tometric.type=\"logging.googleapis.com/user/<Log Metric Name>\"- ANDenabledis set totrue- Impact Statement
Enabling of logging may result in your project being charged for the additional logs usage. These charges could be significant depending on the size of the organization.
- Assessment Status
Automated
- Rationale Statement
Google Cloud Platform (GCP) routes define the paths network traffic takes from a VM instance to another destination. The other destination can be inside the organization VPC network (such as another VM) or outside of it. Every route consists of a destination and a next hop. Traffic whose destination IP is within the destination range is sent to the next hop for delivery. Monitoring changes to route tables will help ensure that all VPC traffic flows through an expected path.
- Remediation Procedure
**From Google Cloud Console****Create the prescribed Log Metric:**1. Go to
Logging/Logs-based Metricsby visiting https://console.cloud.google.com/logs/metrics and click "CREATE METRIC".2. Click the down arrow symbol on theFilter Barat the rightmost corner and selectConvert to Advanced Filter3. Clear any text and add:resource.type="gce_route" AND (protoPayload.methodName:"compute.routes.delete" OR protoPayload.methodName:"compute.routes.insert")4. ClickSubmit Filter. Display logs appear based on the filter text entered by the user.5. In theMetric Editormenu on the right, fill out the name field. SetUnitsto1(default) andTypetoCounter. This ensures that the log metric counts the number of log entries matching the user's advanced logs query.6. ClickCreate Metric. Create the prescribed alert policy: 1. Identify the newly created metric under the sectionUser-defined Metricsat https://console.cloud.google.com/logs/metrics.2. Click the 3-dot icon in the rightmost column for the new metric and selectCreate alert from Metric. A new page displays.3. Fill out the alert policy configuration and clickSave. Choose the alerting threshold and configuration that makes sense for the user's organization. For example, a threshold of zero(0) for the most recent value ensures that a notification is triggered for every owner change in the project:Set `Aggregator` to `Count`Set `Configuration`:- Condition: above- Threshold: 0- For: most recent value4. Configure the desired notification channels in the sectionNotifications.5. Name the policy and clickSave.From Google Cloud CLICreate the prescribed Log Metric:- Use the command: gcloud logging metrics create Create the prescribed the alert policy: - Use the command: gcloud alpha monitoring policies create
2.9Ensure That the Log Metric Filter and Alerts Exist for VPC Network Changes1
Attributes
- Profile
Level 2
- Section
2 Logging and Monitoring
- Description
It is recommended that a metric filter and alarm be established for Virtual Private Cloud (VPC) network changes.
- Audit Procedure
**From Google Cloud ConsoleEnsure the prescribed log metric is present:**1. Go to
Logging/Logs-based Metricsby visiting https://console.cloud.google.com/logs/metrics.2. In theUser-defined Metricssection, ensure at least one metric<Log_Metric_Name>is present with filter text:resource.type="gce_network" AND (protoPayload.methodName:"compute.networks.insert" OR protoPayload.methodName:"compute.networks.patch" OR protoPayload.methodName:"compute.networks.delete" OR protoPayload.methodName:"compute.networks.removePeering" OR protoPayload.methodName:"compute.networks.addPeering")**Ensure the prescribed alerting policy is present:**3. Go toAlertingby visiting https://console.cloud.google.com/monitoring/alerting.4. Under thePoliciessection, ensure that at least one alert policy exists for the log metric above. Clicking on the policy should show that it is configured with a condition. For example,Violates when: Any logging.googleapis.com/user/<Log Metric Name> streamis above a threshold of 0 for greater than 0 secondsmeans that the alert will trigger for any new owner change. Verify that the chosen alerting thresholds make sense for the user's organization.5. Ensure that appropriate notification channels have been set up.**From Google Cloud CLIEnsure the log metric is present:**1. List the log metrics:gcloud logging metrics list --format json2. Ensure that the output contains at least one metric with filter set to:resource.type="gce_network" AND protoPayload.methodName="beta.compute.networks.insert" OR protoPayload.methodName="beta.compute.networks.patch" OR protoPayload.methodName="v1.compute.networks.delete" OR protoPayload.methodName="v1.compute.networks.removePeering" OR protoPayload.methodName="v1.compute.networks.addPeering"3. Note the value of the propertymetricDescriptor.typefor the identified metric, in the formatlogging.googleapis.com/user/<Log Metric Name>.**Ensure the prescribed alerting policy is present:**4. List the alerting policies:gcloud alpha monitoring policies list --format json5. Ensure that the output contains at least one alert policy where:-conditions.conditionThreshold.filteris set tometric.type=\"logging.googleapis.com/user/<Log Metric Name>\"- ANDenabledis set totrue- Impact Statement
Enabling of logging may result in your project being charged for the additional logs usage. These charges could be significant depending on the size of the organization.
- Assessment Status
Automated
- Rationale Statement
It is possible to have more than one VPC within a project. In addition, it is also possible to create a peer connection between two VPCs enabling network traffic to route between VPCs. Monitoring changes to a VPC will help ensure VPC traffic flow is not getting impacted.
- Remediation Procedure
**From Google Cloud Console****Create the prescribed log metric:**1. Go to
Logging/Logs-based Metricsby visiting https://console.cloud.google.com/logs/metrics and click "CREATE METRIC".2. Click the down arrow symbol onFilter Barat the rightmost corner and selectConvert to Advanced Filter.3. Clear any text and add:resource.type="gce_network" AND (protoPayload.methodName:"compute.networks.insert" OR protoPayload.methodName:"compute.networks.patch" OR protoPayload.methodName:"compute.networks.delete" OR protoPayload.methodName:"compute.networks.removePeering" OR protoPayload.methodName:"compute.networks.addPeering")4. ClickSubmit Filter. Display logs appear based on the filter text entered by the user.5. In theMetric Editormenu on the right, fill out the name field. SetUnitsto1(default) andTypetoCounter. This ensures that the log metric counts the number of log entries matching the user's advanced logs query.6. ClickCreate Metric. Create the prescribed alert policy: 1. Identify the newly created metric under the sectionUser-defined Metricsat https://console.cloud.google.com/logs/metrics.2. Click the 3-dot icon in the rightmost column for the new metric and selectCreate alert from Metric. A new page appears.3. Fill out the alert policy configuration and clickSave. Choose the alerting threshold and configuration that makes sense for the user's organization. For example, a threshold of 0 for the most recent value will ensure that a notification is triggered for every owner change in the project:Set `Aggregator` to `Count`Set `Configuration`:- Condition: above- Threshold: 0- For: most recent value4. Configure the desired notification channels in the sectionNotifications.5. Name the policy and clickSave.From Google Cloud CLICreate the prescribed Log Metric:- Use the command: gcloud logging metrics create Create the prescribed alert policy: - Use the command: gcloud alpha monitoring policies create
2.10Ensure That the Log Metric Filter and Alerts Exist for Cloud Storage IAM Permission Changes1
Attributes
- Profile
Level 2
- Section
2 Logging and Monitoring
- Description
It is recommended that a metric filter and alarm be established for Cloud Storage Bucket IAM changes.
- Audit Procedure
**From Google Cloud ConsoleEnsure the prescribed log metric is present:**1. For each project that contains cloud storage buckets, go to
Logging/Logs-based Metricsby visiting https://console.cloud.google.com/logs/metrics.2. In theUser-defined Metricssection, ensure at least one metric<Log_Metric_Name>is present with the filter text:resource.type="gcs_bucket"AND protoPayload.methodName="storage.setIamPermissions"**Ensure that the prescribed alerting policy is present:**3. Go toAlertingby visiting https://console.cloud.google.com/monitoring/alerting.4. Under thePoliciessection, ensure that at least one alert policy exists for the log metric above. Clicking on the policy should show that it is configured with a condition. For example,Violates when: Any logging.googleapis.com/user/<Log Metric Name> streamis above a threshold of 0 for greater than 0 secondsmeans that the alert will trigger for any new owner change. Verify that the chosen alerting thresholds make sense for the user's organization.5. Ensure that the appropriate notifications channels have been set up.**From Google Cloud CLIEnsure that the prescribed log metric is present:**1. List the log metrics:gcloud logging metrics list --format json2. Ensure that the output contains at least one metric with the filter set to:resource.type=gcs_bucket AND protoPayload.methodName="storage.setIamPermissions"3. Note the value of the propertymetricDescriptor.typefor the identified metric, in the formatlogging.googleapis.com/user/<Log Metric Name>.**Ensure the prescribed alerting policy is present:**4. List the alerting policies:gcloud alpha monitoring policies list --format json5. Ensure that the output contains an least one alert policy where:-conditions.conditionThreshold.filteris set tometric.type=\"logging.googleapis.com/user/<Log Metric Name>\"- ANDenabledis set totrue- Impact Statement
Enabling of logging may result in your project being charged for the additional logs usage. These charges could be significant depending on the size of the organization.
- Assessment Status
Automated
- Rationale Statement
Monitoring changes to cloud storage bucket permissions may reduce the time needed to detect and correct permissions on sensitive cloud storage buckets and objects inside the bucket.
- Remediation Procedure
**From Google Cloud Console****Create the prescribed log metric:**1. Go to
Logging/Logs-based Metricsby visiting https://console.cloud.google.com/logs/metrics and click "CREATE METRIC".2. Click the down arrow symbol on theFilter Barat the rightmost corner and selectConvert to Advanced Filter.3. Clear any text and add:resource.type="gcs_bucket" AND protoPayload.methodName="storage.setIamPermissions"4. ClickSubmit Filter. Display logs appear based on the filter text entered by the user.5. In theMetric Editormenu on right, fill out the name field. SetUnitsto1(default) andTypetoCounter. This ensures that the log metric counts the number of log entries matching the user's advanced logs query.6. ClickCreate Metric. Create the prescribed Alert Policy: 1. Identify the newly created metric under the sectionUser-defined Metricsat https://console.cloud.google.com/logs/metrics.2. Click the 3-dot icon in the rightmost column for the new metric and selectCreate alert from Metric. A new page appears.3. Fill out the alert policy configuration and clickSave. Choose the alerting threshold and configuration that makes sense for the user's organization. For example, a threshold of zero(0) for the most recent value will ensure that a notification is triggered for every owner change in the project:Set `Aggregator` to `Count`Set `Configuration`:- Condition: above- Threshold: 0- For: most recent value4. Configure the desired notifications channels in the sectionNotifications.5. Name the policy and clickSave.From Google Cloud CLICreate the prescribed Log Metric:- Use the command: gcloud beta logging metrics create Create the prescribed alert policy: - Use the command: gcloud alpha monitoring policies create
2.11Ensure That the Log Metric Filter and Alerts Exist for SQL Instance Configuration Changes1
Attributes
- Profile
Level 2
- Section
2 Logging and Monitoring
- Description
It is recommended that a metric filter and alarm be established for SQL instance configuration changes.
- Audit Procedure
**From Google Cloud ConsoleEnsure the prescribed log metric is present:**1. For each project that contains Cloud SQL instances, go to
Logging/Logs-based Metricsby visiting https://console.cloud.google.com/logs/metrics.2. In theUser-defined Metricssection, ensure that at least one metric<Log_Metric_Name>is present with the filter text:protoPayload.methodName="cloudsql.instances.update"**Ensure that the prescribed alerting policy is present:**3. Go toAlertingby visiting https://console.cloud.google.com/monitoring/alerting.4. Under thePoliciessection, ensure that at least one alert policy exists for the log metric above. Clicking on the policy should show that it is configured with a condition. For example,Violates when: Any logging.googleapis.com/user/<Log Metric Name> streamis above a threshold of zero(0) for greater than zero(0) secondsmeans that the alert will trigger for any new owner change. Verify that the chosen alerting thresholds make sense for the user's organization.5. Ensure that the appropriate notifications channels have been set up.**From Google Cloud CLIEnsure that the prescribed log metric is present:**1. List the log metrics:gcloud logging metrics list --format json2. Ensure that the output contains at least one metric with the filter set toprotoPayload.methodName="cloudsql.instances.update"3. Note the value of the propertymetricDescriptor.typefor the identified metric, in the formatlogging.googleapis.com/user/<Log Metric Name>.**Ensure that the prescribed alerting policy is present:**4. List the alerting policies:gcloud alpha monitoring policies list --format json5. Ensure that the output contains at least one alert policy where:-conditions.conditionThreshold.filteris set tometric.type=\"logging.googleapis.com/user/<Log Metric Name>\"- ANDenabledis set totrue- Impact Statement
Enabling of logging may result in your project being charged for the additional logs usage. These charges could be significant depending on the size of the organization.
- Assessment Status
Automated
- Rationale Statement
Monitoring changes to SQL instance configuration changes may reduce the time needed to detect and correct misconfigurations done on the SQL server. Below are a few of the configurable options which may the impact security posture of an SQL instance:- Enable auto backups and high availability: Misconfiguration may adversely impact business continuity, disaster recovery, and high availability - Authorize networks: Misconfiguration may increase exposure to untrusted networks
- Remediation Procedure
**From Google Cloud Console****Create the prescribed Log Metric:**1. Go to
Logging/Logs-based Metricsby visiting https://console.cloud.google.com/logs/metrics and click "CREATE METRIC".2. Click the down arrow symbol on theFilter Barat the rightmost corner and selectConvert to Advanced Filter.3. Clear any text and add:protoPayload.methodName="cloudsql.instances.update"4. ClickSubmit Filter. Display logs appear based on the filter text entered by the user.5. In theMetric Editormenu on right, fill out the name field. SetUnitsto1(default) andTypetoCounter. This ensures that the log metric counts the number of log entries matching the user's advanced logs query.6. ClickCreate Metric. Create the prescribed alert policy: 1. Identify the newly created metric under the sectionUser-defined Metricsat https://console.cloud.google.com/logs/metrics.2. Click the 3-dot icon in the rightmost column for the new metric and selectCreate alert from Metric. A new page appears.3. Fill out the alert policy configuration and clickSave. Choose the alerting threshold and configuration that makes sense for the user's organization. For example, a threshold of zero(0) for the most recent value will ensure that a notification is triggered for every owner change in the user's project:Set `Aggregator` to `Count`Set `Configuration`:- Condition: above- Threshold: 0- For: most recent value4. Configure the desired notification channels in the sectionNotifications.5. Name the policy and clickSave.From Google Cloud CLICreate the prescribed log metric:- Use the command: gcloud logging metrics create Create the prescribed alert policy: - Use the command: gcloud alpha monitoring policies create- Reference for command usage: https://cloud.google.com/sdk/gcloud/reference/alpha/monitoring/policies/create
2.12Ensure That Cloud DNS Logging Is Enabled for All VPC Networks0
Attributes
- Profile
Level 1
- Section
2 Logging and Monitoring
- Description
Cloud DNS logging records the queries from the name servers within your VPC to Stackdriver. Logged queries can come from Compute Engine VMs, GKE containers, or other GCP resources provisioned within the VPC.
- Default Value
Cloud DNS logging is disabled by default on each network.
- Audit Procedure
From Google Cloud CLI1. List all VPCs networks in a project:
gcloud compute networks list --format="table[box,title='All VPC Networks'](name:label='VPC Network Name')"2. List all DNS policies, logging enablement, and associated VPC networks:gcloud dns policies list --flatten="networks[]" --format="table[box,title='All DNS Policies By VPC Network'](name:label='Policy Name',enableLogging:label='Logging Enabled':align=center,networks.networkUrl.basename():label='VPC Network Name')"Each VPC Network should be associated with a DNS policy with logging enabled.- Impact Statement
Enabling of Cloud DNS logging might result in your project being charged for the additional logs usage.
- Assessment Status
Automated
- Rationale Statement
Security monitoring and forensics cannot depend solely on IP addresses from VPC flow logs, especially when considering the dynamic IP usage of cloud resources, HTTP virtual host routing, and other technology that can obscure the DNS name used by a client from the IP address. Monitoring of Cloud DNS logs provides visibility to DNS names requested by the clients within the VPC. These logs can be monitored for anomalous domain names, evaluated against threat intelligence, and Note: For full capture of DNS, firewall must block egress UDP/53 (DNS) and TCP/443 (DNS over HTTPS) to prevent client from using external DNS name server for resolution.
- Remediation Procedure
From Google Cloud CLI****Add New DNS Policy With Logging EnabledFor each VPC network that needs a DNS policy with logging enabled:
gcloud dns policies create enable-dns-logging --enable-logging --description="Enable DNS Logging" --networks=VPC_NETWORK_NAMEThe VPC_NETWORK_NAME can be one or more networks in comma-separated listEnable Logging for Existing DNS PolicyFor each VPC network that has an existing DNS policy that needs logging enabled:gcloud dns policies update POLICY_NAME --enable-logging --networks=VPC_NETWORK_NAMEThe VPC_NETWORK_NAME can be one or more networks in comma-separated list- Additional Information
Additional Info- Only queries that reach a name server are logged. Cloud DNS resolvers cache responses, queries answered from caches, or direct queries to an external DNS resolver outside the VPC are not logged.
2.13Ensure Cloud Asset Inventory Is Enabled1
Attributes
- Profile
Level 1
- Section
2 Logging and Monitoring
- Description
GCP Cloud Asset Inventory is services that provides a historical view of GCP resources and IAM policies through a time-series database. The information recorded includes metadata on Google Cloud resources, metadata on policies set on Google Cloud projects or resources, and runtime information gathered within a Google Cloud resource.Cloud Asset Inventory Service (CAIS) API enablement is not required for operation of the service, but rather enables the mechanism for searching/exporting CAIS asset data directly.
- Default Value
The Cloud Asset Inventory API is disabled by default in each project.
- Audit Procedure
From Google Cloud ConsoleEnsure that the Cloud Asset API is enabled:1. Go to
API & Services/Libraryby visiting https://console.cloud.google.com/apis/library2. Search forCloud Asset APIand select the result for _Cloud Asset API_3. Ensure thatAPI Enabledis displayed.From Google Cloud CLIEnsure that the Cloud Asset API is enabled:1. Query enabled services:gcloud services list --enabled --filter=name:cloudasset.googleapis.comIf the API is listed, then it is enabled. If the response isListed 0 itemsthe API is not enabled.- Assessment Status
Automated
- Rationale Statement
The GCP resources and IAM policies captured by GCP Cloud Asset Inventory enables security analysis, resource change tracking, and compliance auditing.It is recommended GCP Cloud Asset Inventory be enabled for all GCP projects.
- Remediation Procedure
From Google Cloud ConsoleEnable the Cloud Asset API:1. Go to
API & Services/Libraryby visiting https://console.cloud.google.com/apis/library2. Search forCloud Asset APIand select the result for _Cloud Asset API_3. Click theENABLEbutton.From Google Cloud CLIEnable the Cloud Asset API:1. Enable the Cloud Asset API through the services interface:gcloud services enable cloudasset.googleapis.com- Additional Information
Additional info- Cloud Asset Inventory only keeps a five-week history of Google Cloud asset metadata. If a longer history is desired, automation to export the history to Cloud Storage or BigQuery should be evaluated.Users need not enable CAI API if they don't have any plans to export.
2.14Ensure 'Access Transparency' is 'Enabled'0
Attributes
- Profile
Level 2
- Section
2 Logging and Monitoring
- Description
GCP Access Transparency provides audit logs for all actions that Google personnel take in your Google Cloud resources.
- Default Value
By default Access Transparency is not enabled.
- Audit Procedure
From Google Cloud Console****Determine if Access Transparency is Enabled1. From the Google Cloud Home, click on the Navigation hamburger menu in the top left. Hover over the IAM & Admin Menu. Select
settingsin the middle of the column that opens.2. The status will be under the headingAccess Transparency. Status should beEnabled- Impact Statement
To use Access Transparency your organization will need to have at one of the following support level: Premium, Enterprise, Platinum, or Gold. There will be subscription costs associated with support, as well as increased storage costs for storing the logs. You will also not be able to turn Access Transparency off yourself, and you will need to submit a service request to Google Cloud Support.
- Assessment Status
Manual
- Rationale Statement
Controlling access to your information is one of the foundations of information security. Given that Google Employees do have access to your organizations' projects for support reasons, you should have logging in place to view who, when, and why your information is being accessed.
- Remediation Procedure
From Google Cloud Console****Add privileges to enable Access Transparency1. From the Google Cloud Home, within the project you wish to check, click on the Navigation hamburger menu in the top left. Hover over the 'IAM and Admin'. Select
IAMin the top of the column that opens. 2. Click the blue button the says+addat the top of the screen.3. In theprincipalsfield, select a user or group by typing in their associated email address.4. Click on therolefield to expand it. In the filter field enterAccess Transparency Adminand select it.5. Clicksave.Verify that the Google Cloud project is associated with a billing account1. From the Google Cloud Home, click on the Navigation hamburger menu in the top left. SelectBilling.2. If you seeThis project is not associated with a billing accountyou will need to enter billing information or switch to a project with a billing account.Enable Access Transparency1. From the Google Cloud Home, click on the Navigation hamburger menu in the top left. Hover over the IAM & Admin Menu. Selectsettingsin the middle of the column that opens.2. Click the blue button labeled EnableAccess Transparency for Organization- Additional Information
To enable Access Transparency for your Google Cloud organization, your Google Cloud organization must have one of the following customer support levels: Premium, Enterprise, Platinum, or Gold.
2.15Ensure 'Access Approval' is 'Enabled'1
Attributes
- Profile
Level 2
- Section
2 Logging and Monitoring
- Description
GCP Access Approval enables you to require your organizations' explicit approval whenever Google support try to access your projects. You can then select users within your organization who can approve these requests through giving them a security role in IAM. All access requests display which Google Employee requested them in an email or Pub/Sub message that you can choose to Approve. This adds an additional control and logging of who in your organization approved/denied these requests.
- Default Value
By default Access Approval and its dependency of Access Transparency are not enabled.
- Audit Procedure
From Google Cloud Console****Determine if Access Transparency is Enabled as it is a Dependency1. From the Google Cloud Home inside the project you wish to audit, click on the Navigation hamburger menu in the top left. Hover over the
IAM & AdminMenu. Selectsettingsin the middle of the column that opens.2. The status should be "Enabled' under the headingAccess TransparencyDetermine if Access Approval is Enabled1. From the Google Cloud Home, within the project you wish to check, click on the Navigation hamburger menu in the top left. Hover over theSecurityMenu. SelectAccess Approvalin the middle of the column that opens. 2. The status will be displayed here. If you see a screen saying you need to enroll in Access Approval, it is not enabled.From Google Cloud CLI****Determine if Access Approval is Enabled1. From within the project you wish to audit, run the following command.gcloud access-approval settings get2. The status will be displayed in the output.IF Access Approval is not enabled you should get this output:API [accessapproval.googleapis.com] not enabled on project [-----]. Would you like to enable and retry (this will take a few minutes)? (y/N)?After enteringYif you get the following output, it means thatAccess Transparencyis not enabled:ERROR: (gcloud.access-approval.settings.get) FAILED_PRECONDITION: Precondition check failed.- Impact Statement
To use Access Approval your organization will need have enabled Access Transparency and have at one of the following support level: Enhanced or Premium. There will be subscription costs associated with these support levels, as well as increased storage costs for storing the logs. You will also not be able to turn the Access Transparency which Access Approval depends on, off yourself. To do so you will need to submit a service request to Google Cloud Support. There will also be additional overhead in managing user permissions. There may also be a potential delay in support times as Google Personnel will have to wait for their access to be approved.
- Assessment Status
Automated
- Rationale Statement
Controlling access to your information is one of the foundations of information security. Google Employees do have access to your organizations' projects for support reasons. With Access Approval, organizations can then be certain that their information is accessed by only approved Google Personnel.
- Remediation Procedure
From Google Cloud Console1. From the Google Cloud Home, within the project you wish to enable, click on the Navigation hamburger menu in the top left. Hover over the
SecurityMenu. SelectAccess Approvalin the middle of the column that opens. 2. The status will be displayed here. On this screen, there is an option to clickEnroll. If it is greyed out and you see an error bar at the top of the screen that saysAccess Transparency is not enabledplease view the corresponding reference within this section to enable it.3. In the second screen clickEnroll.Grant an IAM Group or User the role with permissions to Add Users to be Access Approval message Recipients1. From the Google Cloud Home, within the project you wish to enable, click on the Navigation hamburger menu in the top left. Hover over theIAM and Admin. SelectIAMin the middle of the column that opens. 2. Click the blue button the says+ ADDat the top of the screen.3. In theprincipalsfield, select a user or group by typing in their associated email address.4. Click on the role field to expand it. In the filter field enterAccess Approval Approverand select it.5. Clicksave.Add a Group or User as an Approver for Access Approval Requests1. As a user with theAccess Approval Approverpermission, within the project where you wish to add an email address to which request will be sent, click on the Navigation hamburger menu in the top left. Hover over theSecurityMenu. SelectAccess Approvalin the middle of the column that opens. 2. ClickManage Settings3. UnderSet up approval notifications, enter the email address associated with a Google Cloud User or Group you wish to send Access Approval requests to. All future access approvals will be sent as emails to this address.From Google Cloud CLI1. To update all services in an entire project, run the following command from an account that has permissions as an 'Approver for Access Approval Requests'gcloud access-approval settings update --project=<project name> --enrolled_services=all --notification_emails='<email recipient for access approval requests>@<domain name>'- Additional Information
The recipients of Access Requests will also need to be logged into a Google Cloud account associated with an email address in this list. To approve requests they can click approve within the email. Or they can view requests at the the Access Approval page within the Security submenu.
2.16Ensure Logging is enabled for HTTP(S) Load Balancer1
Attributes
- Profile
Level 2
- Section
2 Logging and Monitoring
- Description
Logging enabled on a HTTPS Load Balancer will show all network traffic and its destination.
- Default Value
By default logging for https load balancing is disabled. When logging is enabled it sets the default sample rate as 1.0 or 100%. Ensure this value fits the need of your organization to avoid high storage costs.
- Audit Procedure
From Google Cloud Console1. From Google Cloud home open the Navigation Menu in the top left.1. Under the
Networkingheading selectNetwork services.1. Select the HTTPS load-balancer you wish to audit.1. SelectEditthenBackend Configuration. 1. SelectEditon the corresponding backend service.1. Ensure thatEnable Loggingis selected. Also ensure thatSample Rateis set to an appropriate level for your needs.From Google Cloud CLI1. Run the following commandgcloud compute backend-services describe <serviceName>1. Ensure thatenable-loggingis enabled andsample rateis set to your desired level.- Impact Statement
On high use systems with a high percentage sample rate, the logging file may grow to high capacity in a short amount of time. Ensure that the sample rate is set appropriately so that storage costs are not exorbitant.
- Assessment Status
Automated
- Rationale Statement
Logging will allow you to view HTTPS network traffic to your web applications.
- Remediation Procedure
From Google Cloud Console1. From Google Cloud home open the Navigation Menu in the top left.1. Under the
Networkingheading selectNetwork services.1. Select the HTTPS load-balancer you wish to audit.1. SelectEditthenBackend Configuration. 1. SelectEditon the corresponding backend service.1. ClickEnable Logging.1. SetSample Rateto a desired value. This is a percentage as a decimal point. 1.0 is 100%.From Google Cloud CLI1. Run the following commandgcloud compute backend-services update <serviceName> --region=REGION --enable-logging --logging-sample-rate=<percentageAsADecimal>
3 Networking108
3.1Ensure That the Default Network Does Not Exist in a Project1
Attributes
- Profile
Level 2
- Section
3 Networking
- Description
To prevent use of
defaultnetwork, a project should not have adefaultnetwork.- Default Value
By default, for each project, a
defaultnetwork is created.- Audit Procedure
From Google Cloud Console1. Go to the
VPC networkspage by visiting: https://console.cloud.google.com/networking/networks/list.2. Ensure that a network with the namedefaultis not present.From Google Cloud CLI1. Set the project name in the Google Cloud Shell:gcloud config set project PROJECT_ID2. List the networks configured in that project:gcloud compute networks listIt should not listdefaultas one of the available networks in that project.- Impact Statement
When an organization deletes the default network, it will need to remove all asests from that network and migrate them to a new network.
- Assessment Status
Automated
- Rationale Statement
The
defaultnetwork has a preconfigured network configuration and automatically generates the following insecure firewall rules: - default-allow-internal: Allows ingress connections for all protocols and ports among instances in the network.- default-allow-ssh: Allows ingress connections on TCP port 22(SSH) from any source to any instance in the network.- default-allow-rdp: Allows ingress connections on TCP port 3389(RDP) from any source to any instance in the network.- default-allow-icmp: Allows ingress ICMP traffic from any source to any instance in the network.These automatically created firewall rules do not get audit logged by default. Furthermore, the default network is an auto mode network, which means that its subnets use the same predefined range of IP addresses, and as a result, it's not possible to use Cloud VPN or VPC Network Peering with the default network. Based on organization security and networking requirements, the organization should create a new network and delete thedefaultnetwork.- Remediation Procedure
From Google Cloud Console1. Go to the
VPC networkspage by visiting: https://console.cloud.google.com/networking/networks/list.2. Click the network nameddefault.2. On the network detail page, clickEDIT.3. ClickDELETE VPC NETWORK.4. If needed, create a new network to replace the default network.From Google Cloud CLIFor each Google Cloud Platform project,1. Delete the default network:gcloud compute networks delete default2. If needed, create a new network to replace it:gcloud compute networks create NETWORK_NAME**Prevention:**The user can prevent the default network and its insecure default firewall rules from being created by setting up an Organization Policy toSkip default network creationat https://console.cloud.google.com/iam-admin/orgpolicies/compute-skipDefaultNetworkCreation.
3.2Ensure Legacy Networks Do Not Exist for Older Projects1
Attributes
- Profile
Level 1
- Section
3 Networking
- Description
In order to prevent use of legacy networks, a project should not have a legacy network configured. As of now, Legacy Networks are gradually being phased out, and you can no longer create projects with them. This recommendation is to check older projects to ensure that they are not using Legacy Networks.
- Default Value
By default, networks are not created in the
legacymode.- Audit Procedure
From Google Cloud CLIFor each Google Cloud Platform project,1. Set the project name in the Google Cloud Shell:
gcloud config set project <Project-ID>2. List the networks configured in that project:gcloud compute networks listNone of the listed networks should be in thelegacymode.- Impact Statement
None.
- Assessment Status
Automated
- Rationale Statement
Legacy networks have a single network IPv4 prefix range and a single gateway IP address for the whole network. The network is global in scope and spans all cloud regions. Subnetworks cannot be created in a legacy network and are unable to switch from legacy to auto or custom subnet networks. Legacy networks can have an impact for high network traffic projects and are subject to a single point of contention or failure.
- Remediation Procedure
From Google Cloud CLIFor each Google Cloud Platform project,1. Follow the documentation and create a non-legacy network suitable for the organization's requirements.2. Follow the documentation and delete the networks in the
legacymode.
3.3Ensure That DNSSEC Is Enabled for Cloud DNS1
Attributes
- Profile
Level 1
- Section
3 Networking
- Description
Cloud Domain Name System (DNS) is a fast, reliable and cost-effective domain name system that powers millions of domains on the internet. Domain Name System Security Extensions (DNSSEC) in Cloud DNS enables domain owners to take easy steps to protect their domains against DNS hijacking and man-in-the-middle and other attacks.
- Default Value
By default DNSSEC is not enabled.
- Audit Procedure
From Google Cloud Console1. Go to
Cloud DNSby visiting https://console.cloud.google.com/net-services/dns/zones.2. For each zone ofTypePublic, ensure thatDNSSECis set toOn.From Google Cloud CLI1. List all the Managed Zones in a project:gcloud dns managed-zones list2. For each zone ofVISIBILITYpublic, get its metadata:gcloud dns managed-zones describe ZONE_NAME3. Ensure thatdnssecConfig.stateproperty ison.- Assessment Status
Automated
- Rationale Statement
Domain Name System Security Extensions (DNSSEC) adds security to the DNS protocol by enabling DNS responses to be validated. Having a trustworthy DNS that translates a domain name like www.example.com into its associated IP address is an increasingly important building block of today’s web-based applications. Attackers can hijack this process of domain/IP lookup and redirect users to a malicious site through DNS hijacking and man-in-the-middle attacks. DNSSEC helps mitigate the risk of such attacks by cryptographically signing DNS records. As a result, it prevents attackers from issuing fake DNS responses that may misdirect browsers to nefarious websites.
- Remediation Procedure
From Google Cloud Console1. Go to
Cloud DNSby visiting https://console.cloud.google.com/net-services/dns/zones.2. For each zone ofTypePublic, setDNSSECtoOn.From Google Cloud CLIUse the below command to enableDNSSECfor Cloud DNS Zone Name.gcloud dns managed-zones update ZONE_NAME --dnssec-state on
3.4Ensure That RSASHA1 Is Not Used for the Key-Signing Key in Cloud DNS DNSSEC1
Attributes
- Profile
Level 1
- Section
3 Networking
- Description
NOTE: Currently, the SHA1 algorithm has been removed from general use by Google, and, if being used, needs to be whitelisted on a project basis by Google and will also, therefore, require a Google Cloud support contract.DNSSEC algorithm numbers in this registry may be used in CERT RRs. Zone signing (DNSSEC) and transaction security mechanisms (SIG(0) and TSIG) make use of particular subsets of these algorithms. The algorithm used for key signing should be a recommended one and it should be strong.
- Audit Procedure
From Google Cloud CLIEnsure the property algorithm for keyType keySigning is not using
RSASHA1. gcloud dns managed-zones describe ZONENAME --format="json(dnsName,dnssecConfig.state,dnssecConfig.defaultKeySpecs)"- Assessment Status
Automated
- Rationale Statement
Domain Name System Security Extensions (DNSSEC) algorithm numbers in this registry may be used in CERT RRs. Zonesigning (DNSSEC) and transaction security mechanisms (SIG(0) and TSIG) make use of particular subsets of these algorithms.The algorithm used for key signing should be a recommended one and it should be strong. When enabling DNSSEC for a managed zone, or creating a managed zone with DNSSEC, the user can select the DNSSEC signing algorithms and the denial-of-existence type. Changing the DNSSEC settings is only effective for a managed zone if DNSSEC is not already enabled. If there is a need to change the settings for a managed zone where it has been enabled, turn DNSSEC off and then re-enable it with different settings.
- Remediation Procedure
From Google Cloud CLI1. If it is necessary to change the settings for a managed zone where it has been enabled, DNSSEC must be turned off and re-enabled with different settings. To turn off DNSSEC, run the following command:
gcloud dns managed-zones update ZONE_NAME --dnssec-state off2. To update key-signing for a reported managed DNS Zone, run the following command:gcloud dns managed-zones update ZONE_NAME --dnssec-state on --ksk-algorithm KSK_ALGORITHM --ksk-key-length KSK_KEY_LENGTH --zsk-algorithm ZSK_ALGORITHM --zsk-key-length ZSK_KEY_LENGTH --denial-of-existence DENIAL_OF_EXISTENCESupported algorithm options and key lengths are as follows. Algorithm KSK Length ZSK Length --------- ---------- ---------- RSASHA1 1024,2048 1024,2048 RSASHA256 1024,2048 1024,2048 RSASHA512 1024,2048 1024,2048 ECDSAP256SHA256 256 256 ECDSAP384SHA384 384 384- Additional Information
- RSASHA1 key-signing support may be required for compatibility reasons.2. Remediation CLI works well with gcloud-cli version 221.0.0 and later.
3.5Ensure That RSASHA1 Is Not Used for the Zone-Signing Key in Cloud DNS DNSSEC1
Attributes
- Profile
Level 1
- Section
3 Networking
- Description
NOTE: Currently, the SHA1 algorithm has been removed from general use by Google, and, if being used, needs to be whitelisted on a project basis by Google and will also, therefore, require a Google Cloud support contract.DNSSEC algorithm numbers in this registry may be used in CERT RRs. Zone signing (DNSSEC) and transaction security mechanisms (SIG(0) and TSIG) make use of particular subsets of these algorithms. The algorithm used for key signing should be a recommended one and it should be strong.
- Audit Procedure
From Google Cloud CLIEnsure the property algorithm for keyType zone signing is not using RSASHA1.
gcloud dns managed-zones describe --format="json(dnsName,dnssecConfig.state,dnssecConfig.defaultKeySpecs)"- Assessment Status
Automated
- Rationale Statement
DNSSEC algorithm numbers in this registry may be used in CERT RRs. Zone signing (DNSSEC) and transaction security mechanisms (SIG(0) and TSIG) make use of particular subsets of these algorithms.The algorithm used for key signing should be a recommended one and it should be strong. When enabling DNSSEC for a managed zone, or creating a managed zone with DNSSEC, the DNSSEC signing algorithms and the denial-of-existence type can be selected. Changing the DNSSEC settings is only effective for a managed zone if DNSSEC is not already enabled. If the need exists to change the settings for a managed zone where it has been enabled, turn DNSSEC off and then re-enable it with different settings.
- Remediation Procedure
From Google Cloud CLI1. If the need exists to change the settings for a managed zone where it has been enabled, DNSSEC must be turned off and then re-enabled with different settings. To turn off DNSSEC, run following command:
gcloud dns managed-zones update ZONE_NAME --dnssec-state off2. To update zone-signing for a reported managed DNS Zone, run the following command:gcloud dns managed-zones update ZONE_NAME --dnssec-state on --ksk-algorithm KSK_ALGORITHM --ksk-key-length KSK_KEY_LENGTH --zsk-algorithm ZSK_ALGORITHM --zsk-key-length ZSK_KEY_LENGTH --denial-of-existence DENIAL_OF_EXISTENCESupported algorithm options and key lengths are as follows. Algorithm KSK Length ZSK Length --------- ---------- ---------- RSASHA1 1024,2048 1024,2048 RSASHA256 1024,2048 1024,2048 RSASHA512 1024,2048 1024,2048 ECDSAP256SHA256 256 384 ECDSAP384SHA384 384 384- Additional Information
- RSASHA1 zone-signing support may be required for compatibility reasons.2. The remediation CLI works well with gcloud-cli version 221.0.0 and later.
3.6Ensure That SSH Access Is Restricted From the Internet1
Attributes
- Profile
Level 2
- Section
3 Networking
- Description
GCP
Firewall Rulesare specific to aVPC Network. Each rule eitherallowsordeniestraffic when its conditions are met. Its conditions allow the user to specify the type of traffic, such as ports and protocols, and the source or destination of the traffic, including IP addresses, subnets, and instances.Firewall rules are defined at the VPC network level and are specific to the network in which they are defined. The rules themselves cannot be shared among networks. Firewall rules only support IPv4 traffic. When specifying a source for an ingress rule or a destination for an egress rule by address, only anIPv4address orIPv4 block in CIDRnotation can be used. Generic(0.0.0.0/0)incoming traffic from the internet to VPC or VM instance usingSSHonPort 22can be avoided.- Audit Procedure
From Google Cloud Console1. Go to
VPC network.2. Go to theFirewall Rules.3. Ensure thatPortis not equal to22andActionis not set toAllow.4. EnsureIP Rangesis not equal to0.0.0.0/0underSource filters.From Google Cloud CLI gcloud compute firewall-rules list --format=table'(name,direction,sourceRanges,allowed)'Ensure that there is no rule matching the below criteria:-SOURCE_RANGESis0.0.0.0/0- ANDDIRECTIONisINGRESS- AND IPProtocol istcporALL- ANDPORTSis set to22orrange containing 22orNull (not set)Note: - When ALL TCP ports are allowed in a rule, PORT does not have any value set (NULL)- When ALL Protocols are allowed in a rule, PORT does not have any value set (NULL)- Impact Statement
All Secure Shell (SSH) connections from outside of the network to the concerned VPC(s) will be blocked. There could be a business need where SSH access is required from outside of the network to access resources associated with the VPC. In that case, specific source IP(s) should be mentioned in firewall rules to white-list access to SSH port for the concerned VPC(s).
- Assessment Status
Automated
- Rationale Statement
GCP
Firewall Ruleswithin aVPC Networkapply to outgoing (egress) traffic from instances and incoming (ingress) traffic to instances in the network. Egress and ingress traffic flows are controlled even if the traffic stays within the network (for example, instance-to-instance communication).For an instance to have outgoing Internet access, the network must have a valid Internet gateway route or custom route whose destination IP is specified. This route simply defines the path to the Internet, to avoid the most general(0.0.0.0/0)destinationIP Rangespecified from the Internet throughSSHwith the defaultPort 22. Generic access from the Internet to a specific IP Range needs to be restricted.- Remediation Procedure
From Google Cloud Console1. Go to
VPC Network.2. Go to theFirewall Rules.3. Click theFirewall Ruleyou want to modify.4. ClickEdit.5. ModifySource IP rangesto specificIP.6. ClickSave.From Google Cloud CLI1.Update the Firewall rule with the newSOURCE_RANGEfrom the below command: gcloud compute firewall-rules update FirewallName --allow=[PROTOCOL[:PORT[-PORT]],...] --source-ranges=[CIDR_RANGE,...]- Additional Information
Currently, GCP VPC only supports IPV4; however, Google is already working on adding IPV6 support for VPC. In that case along with source IP range
0.0.0.0, the rule should be checked for IPv6 equivalent::/0as well.
3.7Ensure That RDP Access Is Restricted From the Internet1
Attributes
- Profile
Level 2
- Section
3 Networking
- Description
GCP
Firewall Rulesare specific to aVPC Network. Each rule eitherallowsordeniestraffic when its conditions are met. Its conditions allow users to specify the type of traffic, such as ports and protocols, and the source or destination of the traffic, including IP addresses, subnets, and instances.Firewall rules are defined at the VPC network level and are specific to the network in which they are defined. The rules themselves cannot be shared among networks. Firewall rules only support IPv4 traffic. When specifying a source for an ingress rule or a destination for an egress rule by address, anIPv4address orIPv4 block in CIDRnotation can be used. Generic(0.0.0.0/0)incoming traffic from the Internet to a VPC or VM instance usingRDPonPort 3389can be avoided.- Audit Procedure
From Google Cloud Console1. Go to
VPC network.2. Go to theFirewall Rules.3. EnsurePortis not equal to3389andActionis notAllow.4. EnsureIP Rangesis not equal to0.0.0.0/0underSource filters.From Google Cloud CLI gcloud compute firewall-rules list --format=table'(name,direction,sourceRanges,allowed.ports)'Ensure that there is no rule matching the below criteria:-SOURCE_RANGESis0.0.0.0/0- ANDDIRECTIONisINGRESS- AND IPProtocol isTCPorALL- ANDPORTSis set to3389orrange containing 3389orNull (not set)Note: - When ALL TCP ports are allowed in a rule, PORT does not have any value set (NULL)- When ALL Protocols are allowed in a rule, PORT does not have any value set (NULL)- Impact Statement
All Remote Desktop Protocol (RDP) connections from outside of the network to the concerned VPC(s) will be blocked. There could be a business need where secure shell access is required from outside of the network to access resources associated with the VPC. In that case, specific source IP(s) should be mentioned in firewall rules to white-list access to RDP port for the concerned VPC(s).
- Assessment Status
Automated
- Rationale Statement
GCP
Firewall Ruleswithin aVPC Network. These rules apply to outgoing (egress) traffic from instances and incoming (ingress) traffic to instances in the network. Egress and ingress traffic flows are controlled even if the traffic stays within the network (for example, instance-to-instance communication).For an instance to have outgoing Internet access, the network must have a valid Internet gateway route or custom route whose destination IP is specified. This route simply defines the path to the Internet, to avoid the most general(0.0.0.0/0)destinationIP Rangespecified from the Internet throughRDPwith the defaultPort 3389. Generic access from the Internet to a specific IP Range should be restricted.- Remediation Procedure
From Google Cloud Console1. Go to
VPC Network.2. Go to theFirewall Rules.3. Click theFirewall Ruleto be modified.4. ClickEdit.5. ModifySource IP rangesto specificIP.6. ClickSave.From Google Cloud CLI1.Update RDP Firewall rule with newSOURCE_RANGEfrom the below command: gcloud compute firewall-rules update FirewallName --allow=[PROTOCOL[:PORT[-PORT]],...] --source-ranges=[CIDR_RANGE,...]- Additional Information
Currently, GCP VPC only supports IPV4; however, Google is already working on adding IPV6 support for VPC. In that case along with source IP range
0.0.0.0, the rule should be checked for IPv6 equivalent::/0as well.
3.8Ensure that VPC Flow Logs is Enabled for Every Subnet in a VPC Network1
Attributes
- Profile
Level 2
- Section
3 Networking
- Description
Flow Logs is a feature that enables users to capture information about the IP traffic going to and from network interfaces in the organization's VPC Subnets. Once a flow log is created, the user can view and retrieve its data in Stackdriver Logging. It is recommended that Flow Logs be enabled for every business-critical VPC subnet.
- Default Value
By default, Flow Logs is set to Off when a new VPC network subnet is created.
- Audit Procedure
From Google Cloud Console1. Go to the VPC network GCP Console visiting
https://console.cloud.google.com/networking/networks/list2. From the list of network subnets, make sure for each subnet:-Flow Logsis set toOn-Aggregation Intervalis set to5 sec-Include metadatacheckbox is checked-Sample rateis set to100%Note: It is not possible to determine if a Log filter has been defined from the console.From Google Cloud CLIgcloud compute networks subnets list --format json | \ jq -r '(["Subnet","Purpose","Flow_Logs","Aggregation_Interval","Flow_Sampling","Metadata","Logs_Filtered"] | (., map(length*"-"))), (.[] | [ .name, .purpose, (if has("enableFlowLogs") and .enableFlowLogs == true then "Enabled" else "Disabled" end), (if has("logConfig") then .logConfig.aggregationInterval else "N/A" end), (if has("logConfig") then .logConfig.flowSampling else "N/A" end), (if has("logConfig") then .logConfig.metadata else "N/A" end), (if has("logConfig") then (.logConfig | has("filterExpr")) else "N/A" end) ] ) | @tsv' | \ column -tThe output of the above command will list:- each subnet- the subnet's purpose- aEnabledorDisabledvalue ifFlow Logsare enabled- the value forAggregation IntervalorN/Aif disabled, the value forFlow SamplingorN/Aif disabled- the value forMetadataorN/Aif disabled- 'true' or 'false' if a Logging Filter is configured or 'N/A' if disabled.If the subnet's purpose isPRIVATEthenFlow Logsshould beEnabled.IfFlow Logsis enabled then:-Aggregation_Intervalshould beINTERVAL_5_SEC-Flow_Samplingshould be 1-Metadatashould beINCLUDE_ALL_METADATA-Logs_Filteredshould befalse.- Impact Statement
Standard pricing for Stackdriver Logging, BigQuery, or Cloud Pub/Sub applies. VPC Flow Logs generation will be charged starting in GA as described in reference: https://cloud.google.com/vpc/
- Assessment Status
Automated
- Rationale Statement
VPC networks and subnetworks not reserved for internal HTTP(S) load balancing provide logically isolated and secure network partitions where GCP resources can be launched. When Flow Logs are enabled for a subnet, VMs within that subnet start reporting on all Transmission Control Protocol (TCP) and User Datagram Protocol (UDP) flows.Each VM samples the TCP and UDP flows it sees, inbound and outbound, whether the flow is to or from another VM, a host in the on-premises datacenter, a Google service, or a host on the Internet. If two GCP VMs are communicating, and both are in subnets that have VPC Flow Logs enabled, both VMs report the flows.Flow Logs supports the following use cases:- Network monitoring- Understanding network usage and optimizing network traffic expenses- Network forensics- Real-time security analysisFlow Logs provide visibility into network traffic for each VM inside the subnet and can be used to detect anomalous traffic or provide insight during security workflows.The Flow Logs must be configured such that all network traffic is logged, the interval of logging is granular to provide detailed information on the connections, no logs are filtered, and metadata to facilitate investigations are included.Note: Subnets reserved for use by internal HTTP(S) load balancers do not support VPC flow logs.
- Remediation Procedure
From Google Cloud Console1. Go to the VPC network GCP Console visiting
https://console.cloud.google.com/networking/networks/list2. Click the name of a subnet, TheSubnet detailspage displays.3. Click theEDITbutton.4. SetFlow LogstoOn.5. Expand theConfigure Logssection.6. SetAggregation Intervalto5 SEC.7. Check the box besideInclude metadata.8. SetSample rateto100.9. Click Save.Note: It is not possible to configure a Log filter from the console.From Google Cloud CLITo enable VPC Flow Logs for a network subnet, run the following command:gcloud compute networks subnets update [SUBNET_NAME] --region [REGION] --enable-flow-logs --logging-aggregation-interval=interval-5-sec --logging-flow-sampling=1 --logging-metadata=include-all
3.9Ensure No HTTPS or SSL Proxy Load Balancers Permit SSL Policies With Weak Cipher Suites0
Attributes
- Profile
Level 1
- Section
3 Networking
- Description
Secure Sockets Layer (SSL) policies determine what port Transport Layer Security (TLS) features clients are permitted to use when connecting to load balancers. To prevent usage of insecure features, SSL policies should use (a) at least TLS 1.2 with the MODERN profile; or (b) the RESTRICTED profile, because it effectively requires clients to use TLS 1.2 regardless of the chosen minimum TLS version; or (3) a CUSTOM profile that does not support any of the following features:
TLS_RSA_WITH_AES_128_GCM_SHA256TLS_RSA_WITH_AES_256_GCM_SHA384TLS_RSA_WITH_AES_128_CBC_SHATLS_RSA_WITH_AES_256_CBC_SHATLS_RSA_WITH_3DES_EDE_CBC_SHA- Default Value
The GCP default SSL policy is the least secure setting: Min TLS 1.0 and Compatible profile
- Audit Procedure
From Google Cloud Console1. See all load balancers by visiting https://console.cloud.google.com/net-services/loadbalancing/loadBalancers/list.2. For each load balancer for
SSL (Proxy)orHTTPS, click on its name to go theLoad balancer detailspage.3. Ensure that each target proxy entry in theFrontendtable has anSSL Policyconfigured. 4. Click on each SSL policy to go to itsSSL policy detailspage.5. Ensure that the SSL policy satisfies one of the following conditions: - has aMin TLSset toTLS 1.2andProfileset toModernprofile, or- hasProfileset toRestricted. Note that a Restricted profile effectively requires clients to use TLS 1.2 regardless of the chosen minimum TLS version, or- hasProfileset toCustomand the following features are all disabled:TLS_RSA_WITH_AES_128_GCM_SHA256TLS_RSA_WITH_AES_256_GCM_SHA384TLS_RSA_WITH_AES_128_CBC_SHATLS_RSA_WITH_AES_256_CBC_SHATLS_RSA_WITH_3DES_EDE_CBC_SHAFrom Google Cloud CLI1. List all TargetHttpsProxies and TargetSslProxies.gcloud compute target-https-proxies listgcloud compute target-ssl-proxies list2. For each target proxy, list its properties:gcloud compute target-https-proxies describe TARGET_HTTPS_PROXY_NAMEgcloud compute target-ssl-proxies describe TARGET_SSL_PROXY_NAME3. Ensure that thesslPolicyfield is present and identifies the name of the SSL policy:sslPolicy: https://www.googleapis.com/compute/v1/projects/PROJECT_ID/global/sslPolicies/SSL_POLICY_NAMEIf thesslPolicyfield is missing from the configuration, it means that the GCP default policy is used, which is insecure.4. Describe the SSL policy:gcloud compute ssl-policies describe SSL_POLICY_NAME5. Ensure that the policy satisfies one of the following conditions:- hasProfileset toModernandminTlsVersionset toTLS_1_2, or- hasProfileset toRestricted, or- hasProfileset toCustomandenabledFeaturesdoes not contain any of the following values:TLS_RSA_WITH_AES_128_GCM_SHA256TLS_RSA_WITH_AES_256_GCM_SHA384TLS_RSA_WITH_AES_128_CBC_SHATLS_RSA_WITH_AES_256_CBC_SHATLS_RSA_WITH_3DES_EDE_CBC_SHA- Impact Statement
Creating more secure SSL policies can prevent clients using older TLS versions from establishing a connection.
- Assessment Status
Manual
- Rationale Statement
Load balancers are used to efficiently distribute traffic across multiple servers. Both SSL proxy and HTTPS load balancers are external load balancers, meaning they distribute traffic from the Internet to a GCP network. GCP customers can configure load balancer SSL policies with a minimum TLS version (1.0, 1.1, or 1.2) that clients can use to establish a connection, along with a profile (Compatible, Modern, Restricted, or Custom) that specifies permissible cipher suites. To comply with users using outdated protocols, GCP load balancers can be configured to permit insecure cipher suites. In fact, the GCP default SSL policy uses a minimum TLS version of 1.0 and a Compatible profile, which allows the widest range of insecure cipher suites. As a result, it is easy for customers to configure a load balancer without even knowing that they are permitting outdated cipher suites.
- Remediation Procedure
From Google Cloud ConsoleIf the TargetSSLProxy or TargetHttpsProxy does not have an SSL policy configured, create a new SSL policy. Otherwise, modify the existing insecure policy. 1. Navigate to the
SSL Policiespage by visiting: https://console.cloud.google.com/net-security/sslpolicies2. Click on the name of the insecure policy to go to itsSSL policy detailspage.3. ClickEDIT.4. SetMinimum TLS versiontoTLS 1.2.5. SetProfiletoModernorRestricted. 6. Alternatively, if teh user selects the profileCustom, make sure that the following features are disabled:TLS_RSA_WITH_AES_128_GCM_SHA256TLS_RSA_WITH_AES_256_GCM_SHA384TLS_RSA_WITH_AES_128_CBC_SHATLS_RSA_WITH_AES_256_CBC_SHATLS_RSA_WITH_3DES_EDE_CBC_SHAFrom Google Cloud CLI1. For each insecure SSL policy, update it to use secure cyphers:gcloud compute ssl-policies update NAME [--profile COMPATIBLE|MODERN|RESTRICTED|CUSTOM] --min-tls-version 1.2 [--custom-features FEATURES]2. If the target proxy has a GCP default SSL policy, use the following command corresponding to the proxy type to update it.gcloud compute target-ssl-proxies update TARGET_SSL_PROXY_NAME --ssl-policy SSL_POLICY_NAMEgcloud compute target-https-proxies update TARGET_HTTPS_POLICY_NAME --ssl-policy SSL_POLICY_NAME
3.10Use Identity Aware Proxy (IAP) to Ensure Only Traffic From Google IP Addresses are 'Allowed'0
Attributes
- Profile
Level 2
- Section
3 Networking
- Description
IAP authenticates the user requests to your apps via a Google single sign in. You can then manage these users with permissions to control access. It is recommended to use both IAP permissions and firewalls to restrict this access to your apps with sensitive information.
- Default Value
By default all traffic is allowed.
- Audit Procedure
From Google Cloud Console1. For each of your apps that have IAP enabled go to the Cloud Console VPC network > Firewall rules.2. Verify that the only rules correspond to the following values: - Targets: All instances in the network - Source IP ranges: - IAP Proxy Addresses
35.235.240.0/20- Google Health Check130.211.0.0/22- Google Health Check35.191.0.0/16- Protocols and ports: - Specified protocols and ports required for access and management of your app. For example most health check connection protocols would be covered by; - tcp:80 (Default HTTP Health Check port) - tcp:443 (Default HTTPS Health Check port)Note: if you have custom ports used by your load balancers, you will need to list them here- Impact Statement
If firewall rules are not configured correctly, legitimate business services could be negatively impacted. It is recommended to make these changes during a time of low usage.
- Assessment Status
Manual
- Rationale Statement
IAP ensure that access to VMs is controlled by authenticating incoming requests. Access to your apps and the VMs should be restricted by firewall rules that allow only the proxy IAP IP addresses contained in the 35.235.240.0/20 subnet. Otherwise, unauthenticated requests can be made to your apps. To ensure that load balancing works correctly health checks should also be allowed.
- Remediation Procedure
From Google Cloud Console1. Go to the Cloud Console VPC network > Firewall rules.2. Select the checkbox next to the following rules: - default-allow-http - default-allow-https - default-allow-internal3. Click
Delete.4. ClickCreate firewall ruleand set the following values: - Name: allow-iap-traffic - Targets: All instances in the network - Source IP ranges (press Enter after you paste each value in the box, copy each full CIDR IP address): - IAP Proxy Addresses35.235.240.0/20- Google Health Check130.211.0.0/22- Google Health Check35.191.0.0/16- Protocols and ports: - Specified protocols and ports required for access and management of your app. For example most health check connection protocols would be covered by; - tcp:80 (Default HTTP Health Check port) - tcp:443 (Default HTTPS Health Check port)Note: if you have custom ports used by your load balancers, you will need to list them here5. When you're finished updating values, clickCreate.
4 Virtual Machines1210
4.1Ensure That Instances Are Not Configured To Use the Default Service Account1
Attributes
- Profile
Level 1
- Section
4 Virtual Machines
- Description
It is recommended to configure your instance to not use the default Compute Engine service account because it has the Editor role on the project.
- Default Value
By default, Compute instances are configured to use the default Compute Engine service account.
- Audit Procedure
From Google Cloud Console1. Go to the
VM instancespage by visiting: https://console.cloud.google.com/compute/instances.2. Click on each instance name to go to itsVM instance detailspage.3. Under the sectionAPI and identity management, ensure that the default Compute Engine service account is not used. This account is named[PROJECT_NUMBER]-compute@developer.gserviceaccount.com.From Google Cloud CLI1. List the instances in your project and get details on each instance:gcloud compute instances list --format=json | jq -r '. | "SA: \(.[].serviceAccounts[].email) Name: \(.[].name)"'2. Ensure that the service account section has an email that does not match the pattern[PROJECT_NUMBER]-compute@developer.gserviceaccount.com.**Exception:**VMs created by GKE should be excluded. These VMs have names that start withgke-and are labeledgoog-gke-node.- Assessment Status
Automated
- Rationale Statement
When a default Compute Engine service account is created, it is automatically granted the Editor role (roles/editor) on your project which allows read and write access to most Google Cloud Services. This role includes a very large number of permissions. To defend against privilege escalations if your VM is compromised and prevent an attacker from gaining access to all of your project, you should either revoke the Editor role from the default Compute Engine service account or create a new service account and assign only the permissions needed by your instance. To mitigate this at scale, we strongly recommend that you disable the automatic role grant by adding a constraint to your organization policy.The default Compute Engine service account is named
[PROJECT_NUMBER]-compute@developer.gserviceaccount.com.- Remediation Procedure
From Google Cloud Console1. Go to the
VM instancespage by visiting: https://console.cloud.google.com/compute/instances.2. Click on the instance name to go to itsVM instance detailspage.3. ClickSTOPand then clickEDIT.4. Under the sectionAPI and identity management, select a service account other than the default Compute Engine service account. You may first need to create a new service account.5. ClickSaveand then clickSTART.From Google Cloud CLI1. Stop the instance:gcloud compute instances stop <INSTANCE_NAME>2. Update the instance:gcloud compute instances set-service-account <INSTANCE_NAME> --service-account=<SERVICE_ACCOUNT>3. Restart the instance:gcloud compute instances start <INSTANCE_NAME>
4.2Ensure That Instances Are Not Configured To Use the Default Service Account With Full Access to All Cloud APIs1
Attributes
- Profile
Level 1
- Section
4 Virtual Machines
- Description
To support principle of least privileges and prevent potential privilege escalation it is recommended that instances are not assigned to default service account
Compute Engine default service accountwith ScopeAllow full access to all Cloud APIs.- Default Value
While creating an VM instance, default service account is used with scope
Allow default access.- Audit Procedure
From Google Cloud Console1. Go to the
VM instancespage by visiting: https://console.cloud.google.com/compute/instances.2. Click on each instance name to go to itsVM instance detailspage.3. Under theAPI and identity management, ensure thatCloud API access scopesis not set toAllow full access to all Cloud APIs.From Google Cloud CLI1. List the instances in your project and get details on each instance:gcloud compute instances list --format=json | jq -r '. | "SA Scopes: \(.[].serviceAccounts[].scopes) Name: \(.[].name) Email: \(.[].serviceAccounts[].email)"'2. Ensure that the service account section has an email that does not match the pattern[PROJECT_NUMBER]-compute@developer.gserviceaccount.com.**Exception:**VMs created by GKE should be excluded. These VMs have names that start withgke-and are labeled `goog-gke-node- Impact Statement
In order to change service account or scope for an instance, it needs to be stopped.
- Assessment Status
Automated
- Rationale Statement
Along with ability to optionally create, manage and use user managed custom service accounts, Google Compute Engine provides default service account
Compute Engine default service accountfor an instances to access necessary cloud services.Project Editorrole is assigned toCompute Engine default service accounthence, This service account has almost all capabilities over all cloud services except billing.However, whenCompute Engine default service accountassigned to an instance it can operate in 3 scopes.1. Allow default access: Allows only minimum access required to run an Instance (Least Privileges)2. Allow full access to all Cloud APIs: Allow full access to all the cloud APIs/Services (Too much access)3. Set access for each API: Allows Instance administrator to choose only those APIs that are needed to perform specific business functionality expected by instanceWhen an instance is configured withCompute Engine default service accountwith ScopeAllow full access to all Cloud APIs, based on IAM roles assigned to the user(s) accessing Instance, it may allow user to perform cloud operations/API calls that user is not supposed to perform leading to successful privilege escalation.- Remediation Procedure
From Google Cloud Console1. Go to the
VM instancespage by visiting: https://console.cloud.google.com/compute/instances.2. Click on the impacted VM instance.3. If the instance is not stopped, click theStopbutton. Wait for the instance to be stopped.4. Next, click theEditbutton.5. Scroll down to theService Accountsection.6. Select a different service account or ensure thatAllow full access to all Cloud APIsis not selected.7. Click theSavebutton to save your changes and then clickSTART.From Google Cloud CLI1. Stop the instance:gcloud compute instances stop <INSTANCE_NAME>2. Update the instance:gcloud compute instances set-service-account <INSTANCE_NAME> --service-account=<SERVICE_ACCOUNT> --scopes [SCOPE1, SCOPE2...]3. Restart the instance:gcloud compute instances start <INSTANCE_NAME>- Additional Information
'- User IAM roles will override service account scope but configuring minimal scope ensures defense in depth- Non-default service accounts do not offer selection of access scopes like default service account. IAM roles with non-default service accounts should be used to control VM access.
4.3Ensure “Block Project-Wide SSH Keys” Is Enabled for VM Instances1
Attributes
- Profile
Level 1
- Section
4 Virtual Machines
- Description
It is recommended to use Instance specific SSH key(s) instead of using common/shared project-wide SSH key(s) to access Instances.
- Default Value
By Default
Block Project-wide SSH keysis not enabled.- Audit Procedure
From Google Cloud Console1. Go to the
VM instancespage by visiting https://console.cloud.google.com/compute/instances. It will list all the instances in your project.2. For every instance, click on the name of the instance.3. UnderSSH Keys, ensureBlock project-wide SSH keysis selected.From Google Cloud CLI1. List the instances in your project and get details on each instance:gcloud compute instances list --format=json2. Ensurekey: block-project-ssh-keysis set tovalue: 'true'.- Impact Statement
Users already having Project-wide ssh key pairs and using third party SSH clients will lose access to the impacted Instances. For Project users using gcloud or GCP Console based SSH option, no manual key creation and distribution is required and will be handled by GCE (Google Compute Engine) itself. To access Instance using third party SSH clients Instance specific SSH key pairs need to be created and distributed to the required users.
- Assessment Status
Automated
- Rationale Statement
Project-wide SSH keys are stored in Compute/Project-meta-data. Project wide SSH keys can be used to login into all the instances within project. Using project-wide SSH keys eases the SSH key management but if compromised, poses the security risk which can impact all the instances within project.It is recommended to use Instance specific SSH keys which can limit the attack surface if the SSH keys are compromised.
- Remediation Procedure
From Google Cloud Console1. Go to the
VM instancespage by visiting: https://console.cloud.google.com/compute/instances. It will list all the instances in your project.2. Click on the name of the Impacted instance3. ClickEditin the toolbar4. Under SSH Keys, go to theBlock project-wide SSH keyscheckbox5. To block users with project-wide SSH keys from connecting to this instance, selectBlock project-wide SSH keys6. ClickSaveat the bottom of the page7. Repeat steps for every impacted InstanceFrom Google Cloud CLITo block project-wide public SSH keys, set the metadata value toTRUE:gcloud compute instances add-metadata <INSTANCE_NAME> --metadata block-project-ssh-keys=TRUE- Additional Information
If OS Login is enabled, SSH keys in instance metadata are ignored, and therefore blocking project-wide SSH keys is not necessary.
4.4Ensure Oslogin Is Enabled for a Project1
Attributes
- Profile
Level 1
- Section
4 Virtual Machines
- Description
Enabling OS login binds SSH certificates to IAM users and facilitates effective SSH certificate management.
- Default Value
By default, parameter
enable-osloginis not set, which is equivalent to setting it toFALSE.- Audit Procedure
From Google Cloud Console1. Go to the VM compute metadata page by visiting https://console.cloud.google.com/compute/metadata.2. Ensure that key
enable-osloginis present with value set toTRUE. 3. Because instances can override project settings, ensure that no instance has custom metadata with keyenable-osloginand valueFALSE.From Google Cloud CLI1. List the instances in your project and get details on each instance:gcloud compute instances list --format=json2. Verify that the sectioncommonInstanceMetadatahas a keyenable-osloginset to valueTRUE.**Exception:**VMs created by GKE should be excluded. These VMs have names that start withgke-and are labeledgoog-gke-node- Impact Statement
Enabling OS Login on project disables metadata-based SSH key configurations on all instances from a project. Disabling OS Login restores SSH keys that you have configured in project or instance meta-data.
- Assessment Status
Automated
- Rationale Statement
Enabling osLogin ensures that SSH keys used to connect to instances are mapped with IAM users. Revoking access to IAM user will revoke all the SSH keys associated with that particular user. It facilitates centralized and automated SSH key pair management which is useful in handling cases like response to compromised SSH key pairs and/or revocation of external/third-party/Vendor users.
- Remediation Procedure
From Google Cloud Console1. Go to the VM compute metadata page by visiting: https://console.cloud.google.com/compute/metadata.2. Click
Edit.3. Add a metadata entry where the key isenable-osloginand the value isTRUE.4. ClickSaveto apply the changes.5. For every instance that overrides the project setting, go to theVM Instancespage at https://console.cloud.google.com/compute/instances.6. Click the name of the instance on which you want to remove the metadata value.7. At the top of the instance details page, clickEditto edit the instance settings.8. UnderCustom metadata, remove any entry with keyenable-osloginand the value isFALSE9. At the bottom of the instance details page, clickSaveto apply your changes to the instance.From Google Cloud CLI1. Configure oslogin on the project:gcloud compute project-info add-metadata --metadata enable-oslogin=TRUE2. Remove instance metadata that overrides the project setting.gcloud compute instances remove-metadata <INSTANCE_NAME> --keys=enable-osloginOptionally, you can enable two factor authentication for OS login. For more information, see: https://cloud.google.com/compute/docs/oslogin/setup-two-factor-authentication.- Additional Information
- In order to use osLogin, instance using Custom Images must have the latest version of the Linux Guest Environment installed. The following image families do not yet support OS Login:
Project cos-cloud (Container-Optimized OS) image family cos-stable.All project coreos-cloud (CoreOS) image familiesProject suse-cloud (SLES) image family sles-11All Windows Server and SQL Server image families2. Project enable-oslogin can be over-ridden by setting enable-oslogin parameter to an instance metadata individually.
- In order to use osLogin, instance using Custom Images must have the latest version of the Linux Guest Environment installed. The following image families do not yet support OS Login:
4.5Ensure ‘Enable Connecting to Serial Ports’ Is Not Enabled for VM Instance1
Attributes
- Profile
Level 1
- Section
4 Virtual Machines
- Description
Interacting with a serial port is often referred to as the serial console, which is similar to using a terminal window, in that input and output is entirely in text mode and there is no graphical interface or mouse support.If you enable the interactive serial console on an instance, clients can attempt to connect to that instance from any IP address. Therefore interactive serial console support should be disabled.
- Default Value
By default, connecting to serial ports is not enabled.
- Audit Procedure
From Google Cloud CLI1. Login to Google Cloud console2. Go to Compute Engine3. Go to VM instances4. Click on the Specific VM5. Ensure the statement
Connecting to serial serial ports is disabledis displayed at the top of the details tab, just below theConnect to serial consoledrop-down.. From Google Cloud ConsoleEnsure the below command's output showsnull:gcloud compute instances describe <vmName> --zone=<region> --format="json(metadata.items[].key,metadata.items[].value)"orkeyandvalueproperties from below command's json response are equal toserial-port-enableand0orfalserespectively.{ "metadata": { "items": [ { "key": "serial-port-enable", "value": "0" } ] } }- Assessment Status
Automated
- Rationale Statement
A virtual machine instance has four virtual serial ports. Interacting with a serial port is similar to using a terminal window, in that input and output is entirely in text mode and there is no graphical interface or mouse support. The instance's operating system, BIOS, and other system-level entities often write output to the serial ports, and can accept input such as commands or answers to prompts. Typically, these system-level entities use the first serial port (port 1) and serial port 1 is often referred to as the serial console.The interactive serial console does not support IP-based access restrictions such as IP whitelists. If you enable the interactive serial console on an instance, clients can attempt to connect to that instance from any IP address. This allows anybody to connect to that instance if they know the correct SSH key, username, project ID, zone, and instance name.Therefore interactive serial console support should be disabled.
- Remediation Procedure
From Google Cloud CLI1. Login to Google Cloud console2. Go to Computer Engine3. Go to VM instances4. Click on the Specific VM5. Click
EDIT6. UnselectEnable connecting to serial portsbelowRemote accessblock.7. ClickSaveFrom Google Cloud ConsoleUse the below command to disablegcloud compute instances add-metadata <INSTANCE_NAME> --zone=<ZONE> --metadata=serial-port-enable=falseorgcloud compute instances add-metadata <INSTANCE_NAME> --zone=<ZONE> --metadata=serial-port-enable=0**Prevention:**You can prevent VMs from having serial port access enable byDisable VM serial port accessorganization policy: https://console.cloud.google.com/iam-admin/orgpolicies/compute-disableSerialPortAccess.
4.6Ensure That IP Forwarding Is Not Enabled on Instances1
Attributes
- Profile
Level 1
- Section
4 Virtual Machines
- Description
Compute Engine instance cannot forward a packet unless the source IP address of the packet matches the IP address of the instance. Similarly, GCP won't deliver a packet whose destination IP address is different than the IP address of the instance receiving the packet. However, both capabilities are required if you want to use instances to help route packets.Forwarding of data packets should be disabled to prevent data loss or information disclosure.
- Default Value
By default, instances are not configured to allow IP forwarding.
- Audit Procedure
From Google Cloud Console1. Go to the
VM Instancespage by visiting: https://console.cloud.google.com/compute/instances. 2. For every instance, click on its name to go to theVM instance detailspage.3. Under theNetwork interfacessection, ensure thatIP forwardingis set toOfffor every network interface.From Google Cloud CLI1. List all instances:gcloud compute instances list --format='table(name,canIpForward)'2. Ensure thatCAN_IP_FORWARDcolumn in the output of above command does not containTruefor any VM instance.**Exception:**Instances created by GKE should be excluded because they need to have IP forwarding enabled and cannot be changed. Instances created by GKE have names that start with "gke-".- Impact Statement
Deleting instance(s) acting as routers/packet forwarders may break the network connectivity.
- Assessment Status
Automated
- Rationale Statement
Compute Engine instance cannot forward a packet unless the source IP address of the packet matches the IP address of the instance. Similarly, GCP won't deliver a packet whose destination IP address is different than the IP address of the instance receiving the packet. However, both capabilities are required if you want to use instances to help route packets.To enable this source and destination IP check, disable the
canIpForwardfield, which allows an instance to send and receive packets with non-matching destination or source IPs.- Remediation Procedure
You only edit the
canIpForwardsetting at instance creation time. Therefore, you need to delete the instance and create a new one wherecanIpForwardis set tofalse.From Google Cloud Console1. Go to theVM Instancespage by visiting: https://console.cloud.google.com/compute/instances. 2. Select theVM Instanceyou want to remediate.3. Click theDeletebutton.4. On the 'VM Instances' page, clickCREATE INSTANCE'.5. Create a new instance with the desired configuration. By default, the instance is configured to not allow IP forwarding.**From Google Cloud CLI**1. Delete the instance:```gcloud compute instances delete INSTANCE_NAME```2. Create a new instance to replace it, withIP forwardingset toOff````gcloud compute instances create```- Additional Information
You can only set the
canIpForwardfield at instance creation time. After an instance is created, the field becomes read-only.
4.7Ensure VM Disks for Critical VMs Are Encrypted With Customer-Supplied Encryption Keys (CSEK)1
Attributes
- Profile
Level 2
- Section
4 Virtual Machines
- Description
Customer-Supplied Encryption Keys (CSEK) are a feature in Google Cloud Storage and Google Compute Engine. If you supply your own encryption keys, Google uses your key to protect the Google-generated keys used to encrypt and decrypt your data. By default, Google Compute Engine encrypts all data at rest. Compute Engine handles and manages this encryption for you without any additional actions on your part. However, if you wanted to control and manage this encryption yourself, you can provide your own encryption keys.
- Default Value
By default, VM disks are encrypted with Google-managed keys. They are not encrypted with Customer-Supplied Encryption Keys.
- Audit Procedure
From Google Cloud Console1. Go to Compute Engine
Disksby visiting: https://console.cloud.google.com/compute/disks.2. Click on the disk for your critical VMs to see its configuration details.4. Ensure thatEncryption typeis set toCustomer supplied.From Google Cloud CLIEnsurediskEncryptionKeyproperty in the below command's response is not null, and contains keysha256with corresponding valuegcloud compute disks describe <DISK_NAME> --zone <ZONE> --format="json(diskEncryptionKey,name)"- Impact Statement
If you lose your encryption key, you will not be able to recover the data.
- Assessment Status
Automated
- Rationale Statement
By default, Google Compute Engine encrypts all data at rest. Compute Engine handles and manages this encryption for you without any additional actions on your part. However, if you wanted to control and manage this encryption yourself, you can provide your own encryption keys.If you provide your own encryption keys, Compute Engine uses your key to protect the Google-generated keys used to encrypt and decrypt your data. Only users who can provide the correct key can use resources protected by a customer-supplied encryption key.Google does not store your keys on its servers and cannot access your protected data unless you provide the key. This also means that if you forget or lose your key, there is no way for Google to recover the key or to recover any data encrypted with the lost key.At least business critical VMs should have VM disks encrypted with CSEK.
- Remediation Procedure
Currently there is no way to update the encryption of an existing disk. Therefore you should create a new disk with
Encryptionset toCustomer supplied.From Google Cloud Console1. Go to Compute EngineDisksby visiting: https://console.cloud.google.com/compute/disks.2. ClickCREATE DISK.3. SetEncryption typetoCustomer supplied,4. Provide theKeyin the box.5. SelectWrapped key.6. ClickCreate.From Google Cloud CLIIn the gcloud compute tool, encrypt a disk using the --csek-key-file flag during instance creation. If you are using an RSA-wrapped key, use the gcloud beta component:gcloud compute instances create <INSTANCE_NAME> --csek-key-file <example-file.json>To encrypt a standalone persistent disk:gcloud compute disks create <DISK_NAME> --csek-key-file <example-file.json>- Additional Information
Note 1:When you delete a persistent disk, Google discards the cipher keys, rendering the data irretrievable. This process is irreversible.Note 2:It is up to you to generate and manage your key. You must provide a key that is a 256-bit string encoded in RFC 4648 standard base64 to Compute Engine.Note 3:An example key file looks like this. [ { "uri": "https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/disks/example-disk", "key": "acXTX3rxrKAFTF0tYVLvydU1riRZTvUNC4g5I11NY-c=", "key-type": "raw" }, { "uri": "https://www.googleapis.com/compute/v1/projects/myproject/global/snapshots/my-private-snapshot", "key": "ieCx/NcW06PcT7Ep1X6LUTc/hLvUDYyzSZPPVCVPTVEohpeHASqC8uw5TzyO9U+Fka9JFHz0mBibXUInrC/jEk014kCK/NPjYgEMOyssZ4ZINPKxlUh2zn1bV+MCaTICrdmuSBTWlUUiFoDD6PYznLwh8ZNdaheCeZ8ewEXgFQ8V+sDroLaN3Xs3MDTXQEMMoNUXMCZEIpg9Vtp9x2oeQ5lAbtt7bYAAHf5l+gJWw3sUfs0/Glw5fpdjT8Uggrr+RMZezGrltJEF293rvTIjWOEB3z5OHyHwQkvdrPDFcTqsLfh+8Hr8g+mf+7zVPEC8nEbqpdl3GPv3A7AwpFp7MA==" "key-type": "rsa-encrypted" } ]
4.8Ensure Compute Instances Are Launched With Shielded VM Enabled1
Attributes
- Profile
Level 2
- Section
4 Virtual Machines
- Description
To defend against advanced threats and ensure that the boot loader and firmware on your VMs are signed and untampered, it is recommended that Compute instances are launched with Shielded VM enabled.
- Default Value
By default, Compute Instances do not have Shielded VM enabled.
- Audit Procedure
From Google Cloud Console1. Go to the
VM instancespage by visiting: https://console.cloud.google.com/compute/instances.2. Click on the instance name to see itsVM instance detailspage.3. Under the sectionShielded VM, ensure thatvTPMandIntegrity Monitoringareon.From Google Cloud CLI1. For each instance in your project, get its metadata:gcloud compute instances list --format=json | jq -r '. | "vTPM: \(.[].shieldedInstanceConfig.enableVtpm) IntegrityMonitoring: \(.[].shieldedInstanceConfig.enableIntegrityMonitoring) Name: \(.[].name)"'2. Ensure that there is ashieldedInstanceConfigconfiguration and that configuration has theenableIntegrityMonitoringandenableVtpmset totrue. If the VM is not a Shield VM image, you will not see a shieldedInstanceConfig` in the output.- Assessment Status
Automated
- Rationale Statement
Shielded VMs are virtual machines (VMs) on Google Cloud Platform hardened by a set of security controls that help defend against rootkits and bootkits. Shielded VM offers verifiable integrity of your Compute Engine VM instances, so you can be confident your instances haven't been compromised by boot- or kernel-level malware or rootkits. Shielded VM's verifiable integrity is achieved through the use of Secure Boot, virtual trusted platform module (vTPM)-enabled Measured Boot, and integrity monitoring.Shielded VM instances run firmware which is signed and verified using Google's Certificate Authority, ensuring that the instance's firmware is unmodified and establishing the root of trust for Secure Boot.Integrity monitoring helps you understand and make decisions about the state of your VM instances and the Shielded VM vTPM enables Measured Boot by performing the measurements needed to create a known good boot baseline, called the integrity policy baseline. The integrity policy baseline is used for comparison with measurements from subsequent VM boots to determine if anything has changed.Secure Boot helps ensure that the system only runs authentic software by verifying the digital signature of all boot components, and halting the boot process if signature verification fails.
- Remediation Procedure
To be able turn on
Shielded VMon an instance, your instance must use an image with Shielded VM support. From Google Cloud Console1. Go to theVM instancespage by visiting: https://console.cloud.google.com/compute/instances.2. Click on the instance name to see itsVM instance detailspage.3. ClickSTOPto stop the instance.4. When the instance has stopped, clickEDIT.5. In the Shielded VM section, selectTurn on vTPMandTurn on Integrity Monitoring.6. Optionally, if you do not use any custom or unsigned drivers on the instance, also selectTurn on Secure Boot.7. Click theSavebutton to modify the instance and then clickSTARTto restart it.From Google Cloud CLIYou can only enable Shielded VM options on instances that have Shielded VM support. For a list of Shielded VM public images, run the gcloud compute images list command with the following flags:gcloud compute images list --project gce-uefi-images --no-standard-images1. Stop the instance:gcloud compute instances stop <INSTANCE_NAME>2. Update the instance:gcloud compute instances update <INSTANCE_NAME> --shielded-vtpm --shielded-vm-integrity-monitoring3. Optionally, if you do not use any custom or unsigned drivers on the instance, also turn on secure boot.gcloud compute instances update <INSTANCE_NAME> --shielded-vm-secure-boot4. Restart the instance:gcloud compute instances start <INSTANCE_NAME>**Prevention:**You can ensure that all new VMs will be created with Shielded VM enabled by setting up an Organization Policy to forShielded VMat https://console.cloud.google.com/iam-admin/orgpolicies/compute-requireShieldedVm. Learn more at: https://cloud.google.com/security/shielded-cloud/shielded-vm#organization-policy-constraint.- Additional Information
If you do use custom or unsigned drivers on the instance, enabling Secure Boot will cause the machine to no longer boot. Turn on Secure Boot only on instances that have been verified to not have any custom drivers installed.
4.9Ensure That Compute Instances Do Not Have Public IP Addresses1
Attributes
- Profile
Level 2
- Section
4 Virtual Machines
- Description
Compute instances should not be configured to have external IP addresses.
- Default Value
By default, Compute instances have a public IP address.
- Audit Procedure
From Google Cloud Console1. Go to the
VM instancespage by visiting: https://console.cloud.google.com/compute/instances.2. For every VM, ensure that there is noExternal IPconfigured.From Google Cloud CLIgcloud compute instances list --format=json1. The output should not contain anaccessConfigssection undernetworkInterfaces. Note that thenatIPvalue is present only for instances that are running or for instances that are stopped but have a static IP address. For instances that are stopped and are configured to have an ephemeral public IP address, thenatIPfield will not be present. Example output:networkInterfaces:- accessConfigs: - kind: compute#accessConfig name: External NAT networkTier: STANDARD type: ONE_TO_ONE_NAT**Exception:**Instances created by GKE should be excluded because some of them have external IP addresses and cannot be changed by editing the instance settings. Instances created by GKE should be excluded. These instances have names that start with "gke-" and are labeled "goog-gke-node".- Impact Statement
Removing the external IP address from your Compute instance may cause some applications to stop working.
- Assessment Status
Automated
- Rationale Statement
To reduce your attack surface, Compute instances should not have public IP addresses. Instead, instances should be configured behind load balancers, to minimize the instance's exposure to the internet.
- Remediation Procedure
From Google Cloud Console1. Go to the
VM instancespage by visiting: https://console.cloud.google.com/compute/instances.2. Click on the instance name to go the theInstance detail page.3. ClickEdit.4. For each Network interface, ensure thatExternal IPis set toNone.5. ClickDoneand then clickSave.From Google Cloud CLI1. Describe the instance properties:gcloud compute instances describe <INSTANCE_NAME> --zone=<ZONE>2. Identify the access config name that contains the external IP address. This access config appears in the following format:networkInterfaces:- accessConfigs: - kind: compute#accessConfig name: External NAT natIP: 130.211.181.55 type: ONE_TO_ONE_NAT3. Delete the access config.gcloud compute instances delete-access-config <INSTANCE_NAME> --zone=<ZONE> --access-config-name <ACCESS_CONFIG_NAME>In the above example, theACCESS_CONFIG_NAMEisExternal NAT. The name of your access config might be different.**Prevention:**You can configure theDefine allowed external IPs for VM instancesOrganization Policy to prevent VMs from being configured with public IP addresses. Learn more at: https://console.cloud.google.com/orgpolicies/compute-vmExternalIpAccess- Additional Information
You can connect to Linux VMs that do not have public IP addresses by using Identity-Aware Proxy for TCP forwarding. Learn more at https://cloud.google.com/compute/docs/instances/connecting-advanced#sshbetweeninstancesFor Windows VMs, see https://cloud.google.com/compute/docs/instances/connecting-to-instance.
4.10Ensure That App Engine Applications Enforce HTTPS Connections0
Attributes
- Profile
Level 2
- Section
4 Virtual Machines
- Description
In order to maintain the highest level of security all connections to an application should be secure by default.
- Default Value
By default both HTTP and HTTP are supported
- Audit Procedure
Verify that the app.yaml file controlling the application contains a line which enforces secure connections. For example
handlers:- url: /.* secure: always redirect_http_response_code: 301 script: autohttps://cloud.google.com/appengine/docs/standard/python3/config/appref- Impact Statement
All connections to appengine will automatically be redirected to the HTTPS endpoint ensuring that all connections are secured by TLS.
- Assessment Status
Manual
- Rationale Statement
Insecure HTTP connections maybe subject to eavesdropping which can expose sensitive data.
- Remediation Procedure
Add a line to the app.yaml file controlling the application which enforces secure connections. For example
handlers:- url: /.* **secure: always** redirect_http_response_code: 301 script: auto[https://cloud.google.com/appengine/docs/standard/python3/config/appref]
4.11Ensure That Compute Instances Have Confidential Computing Enabled1
Attributes
- Profile
Level 2
- Section
4 Virtual Machines
- Description
Google Cloud encrypts data at-rest and in-transit, but customer data must be decrypted for processing. Confidential Computing is a breakthrough technology which encrypts data in-use—while it is being processed. Confidential Computing environments keep data encrypted in memory and elsewhere outside the central processing unit (CPU). Confidential VMs leverage the Secure Encrypted Virtualization (SEV) feature of AMD EPYC™ CPUs. Customer data will stay encrypted while it is used, indexed, queried, or trained on. Encryption keys are generated in hardware, per VM, and not exportable. Thanks to built-in hardware optimizations of both performance and security, there is no significant performance penalty to Confidential Computing workloads.
- Default Value
By default, Confidential Computing is disabled for Compute instances.
- Audit Procedure
Note: Confidential Computing is currently only supported on N2D and C2D machines. To learn more about features supported by types of machines, visit https://cloud.google.com/compute/docs/machine-typesFrom Google Cloud Console1. Go to the
VM instancespage by visiting: https://console.cloud.google.com/compute/instances.2. Click on the instance name to see its VM instance details page.3. Ensure thatConfidential VM serviceisEnabled.From Google Cloud CLI1. List the instances in your project and get details on each instance:gcloud compute instances list --format=json2. Ensure thatenableConfidentialComputeis set totruefor all instances with machine type starting with "n2d-".confidentialInstanceConfig: enableConfidentialCompute: true- Impact Statement
'- Confidential Computing for Compute instances does not support live migration. Unlike regular Compute instances, Confidential VMs experience disruptions during maintenance events like a software or hardware update.- Additional charges may be incurred when enabling this security feature. See https://cloud.google.com/compute/confidential-vm/pricing for more info.
- Assessment Status
Automated
- Rationale Statement
Confidential Computing enables customers' sensitive code and other data encrypted in memory during processing. Google does not have access to the encryption keys. Confidential VM can help alleviate concerns about risk related to either dependency on Google infrastructure or Google insiders' access to customer data in the clear.
- Remediation Procedure
Confidential Computing can only be enabled when an instance is created. You must delete the current instance and create a new one.From Google Cloud Console1. Go to the VM instances page by visiting: https://console.cloud.google.com/compute/instances.2. Click
CREATE INSTANCE.3. Fill out the desired configuration for your instance.4. Under theConfidential VM servicesection, check the optionEnable the Confidential Computing service on this VM instance.5. ClickCreate.From Google Cloud CLICreate a new instance with Confidential Compute enabled.gcloud compute instances create <INSTANCE_NAME> --zone <ZONE> --confidential-compute --maintenance-policy=TERMINATE
4.12Ensure the Latest Operating System Updates Are Installed On Your Virtual Machines in All Projects0
Attributes
- Profile
Level 2
- Section
4 Virtual Machines
- Description
Google Cloud Virtual Machines have the ability via an OS Config agent API to periodically (about every 10 minutes) report OS inventory data. A patch compliance API periodically reads this data, and cross references metadata to determine if the latest updates are installed.This is not the only Patch Management solution available to your organization and you should weigh your needs before committing to using this method.
- Default Value
By default most operating systems and programs do not update themselves. The Google Cloud VM Manager which is a dependency of the OS Patch management feature is installed on Google Built OS images with a build date of v20200114 or later. The VM manager is not enabled in a project by default and will need to be setup.
- Audit Procedure
From Google Cloud Console****Determine if OS Config API is Enabled for the Project1. Navigate into a project. In the expanded navigation menu located at the top left of the screen hover over
APIs & Services. Then in the menu right of that selectAPI Libraries2. Search for "VM Manager (OS Config API) or scroll down in the left hand column and select the filter labeled "Compute" where it is the last listed. Open this API.3. Verify the blue button at the top is enabled.Determine if VM Instances have correct metadata tags for OSConfig parsing1. From the main Google Cloud console, open the hamburger menu in the top left. Mouse over Computer Engine to expand the menu next to it.1. Under the "Settings" heading, select "Metadata".1. In this view there will be a list of the project wide metadata tags for VMs. Determine if the tag "enable-osconfig" is set to "true".Determine if the Operating System of VM Instances have the local OS-Config Agent runningThere is no way to determine this from the Google Cloud console. The only way is to run operating specific commands locally inside the operating system via remote connection. For the sake of brevity of this recommendation please view the docs/troubleshooting/vm-manager/verify-setup reference at the bottom of the page. If you initialized your VM instance with a Google Supplied OS Image with a build date of later than v20200114 it will have the service installed. You should still determine its status for proper operation.Verify the service account you have setup for the project in Recommendation 4.1 is running1. Go to theVM instancespage by visiting: https://console.cloud.google.com/compute/instances.2. Click on each instance name to go to itsVM instance detailspage.3. Under the sectionService Account, take note of the service account4. Run the commands locally for your operating system that are located at the docs/troubleshooting/vm-manager/verify-setup#service-account-enabled reference located at the bottom of this page. They should return the name of your service account.Determine if Instances can connect to public update hostingEach type of operating system has its own update process. You will need to determine on each operating system that it can reach the update servers via its network connection. The VM Manager doesn't host the updates, it will only allow you to centrally issue a command to each VM to update.Determine if OS Config API is Enabled for the Project1. In each project you wish to enable run the following commandgcloud services list2. If osconfig.googleapis.com is in the left hand column it is enabled for this project.Determine if VM Manager is Enabled for the Project1. Within the project run the following command:gcloud compute instances os-inventory describe VM-NAME \ --zone=ZONEThe output will look likeINSTANCE_ID INSTANCE_NAME OS OSCONFIG_AGENT_VERSION UPDATE_TIME29255009728795105 centos7 CentOS Linux 7 (Core) 20210217.00-g1.el7 2021-04-12T22:19:36.559Z5138980234596718741 rhel-8 Red Hat Enterprise Linux 8.3 (Ootpa) 20210316.00-g1.el8 2021-09-16T17:19:24Z7127836223366142250 windows Microsoft Windows Server 2019 Datacenter 20210316.00.0+win@1 2021-09-16T17:13:18ZDetermine if VM Instances have correct metadata tags for OSConfig parsing1. Select the project you want to view tagging in.From Google Cloud Console1. From the main Google Cloud console, open the hamburger menu in the top left. Mouse over Computer Engine to expand the menu next to it.2. Under the "Settings" heading, select "Metadata".3. In this view there will be a list of the project wide metadata tags for Vms. Verify a tag of ‘enable-osconfig’ is in this list and it is set to ‘true’.From Command LineRun the following command to view instance datagcloud compute instances list --format="table(name,status,tags.list())"On each instance it should have a tag of ‘enable-osconfig’ set to ‘true’Determine if the Operating System of VM Instances have the local OS-Config Agent runningThere is no way to determine this from the Google Cloud CLI. The best way is to run the the commands inside the operating system located at 'Check OS-Config agent is installed and running' at the /docs/troubleshooting/vm-manager/verify-setup reference at the bottom of the page. If you initialized your VM instance with a Google Supplied OS Image with a build date of later than v20200114 it will have the service installed. You should still determine its status.Verify the service account you have setup for the project in Recommendation 4.1 is running1. Go to theVM instancespage by visiting: https://console.cloud.google.com/compute/instances.2. Click on each instance name to go to itsVM instance detailspage.3. Under the sectionService Account, take note of the service account4. View the compute/docs/troubleshooting/vm-manager/verify-setup#service-account-enabled resource at the bottom of the page for operating system specific commands to run locally.Determine if Instances can connect to public update hostingLinux Debian Based Operating Systemssudo apt updateThe output should have a numbered list of lines with Hit: URL of updates.Redhat Based Operating Systemsyum check-updateThe output should show a list of packages that have updates available.Windowsping http://windowsupdate.microsoft.com/The ping should successfully be delivered and received.- Impact Statement
Most Operating Systems require a restart or changing critical resources to apply the updates. Using the Google Cloud VM manager for its OS Patch management will incur additional costs for each VM managed by it. Please view the VM manager pricing reference for further information.
- Assessment Status
Manual
- Rationale Statement
Keeping virtual machine operating systems up to date is a security best practice. Using this service will simplify this process.
- Remediation Procedure
From Google Cloud ConsoleEnabling OS Patch Management on a Project by Project BasisInstall OS Config API for the Project1. Navigate into a project. In the expanded portal menu located at the top left of the screen hover over "APIs & Services". Then in the menu right of that select "API Libraries"2. Search for "VM Manager (OS Config API) or scroll down in the left hand column and select the filter labeled "Compute" where it is the last listed. Open this API.3. Click the blue 'Enable' button.Add MetaData Tags for OSConfig Parsing1. From the main Google Cloud console, open the portal menu in the top left. Mouse over Computer Engine to expand the menu next to it.2. Under the "Settings" heading, select "Metadata".3. In this view there will be a list of the project wide metadata tags for VMs. Click edit and 'add item' in the key column type 'enable-osconfig' and in the value column set it to 'true'.From Command Line1. For project wide tagging, run the following command
gcloud compute project-info add-metadata \ --project <PROJECT_ID>\ --metadata=enable-osconfig=TRUEPlease see the reference /compute/docs/troubleshooting/vm-manager/verify-setup#metadata-enabled at the bottom for more options like instance specific tagging.Note: Adding a new tag via commandline may overwrite existing tags. You will need to do this at a time of low usage for the least impact.Install and Start the Local OSConfig for Data ParsingThere is no way to centrally manage or start the Local OSConfig agent. Please view the reference of manage-os#agent-install to view specific operating system commands. Setup a project wide Service AccountPlease view Recommendation 4.1 to view how to setup a service account. Rerun the audit procedure to test if it has taken effect.Enable NAT or Configure Private Google Access to allow Access to Public Update HostingFor the sake of brevity, please see the attached resources to enable NAT or Private Google Access. Rerun the audit procedure to test if it has taken effect.From Command Line:Install OS Config API for the Project1. In each project you wish to audit rungcloud services enable osconfig.googleapis.comInstall and Start the Local OSConfig for Data ParsingPlease view the reference of manage-os#agent-install to view specific operating system commands.Setup a project wide Service AccountPlease view Recommendation 4.1 to view how to setup a service account. Rerun the audit procedure to test if it has taken effect.Enable NAT or Configure Private Google Access to allow Access to Public Update HostingFor the sake of brevity, please see the attached resources to enable NAT or Private Google Access. Rerun the audit procedure to test if it has taken effect.Determine if Instances can connect to public update hostingLinux Debian Based Operating Systemssudo apt updateThe output should have a numbered list of lines with Hit: URL of updates.Redhat Based Operating Systemsyum check-updateThe output should show a list of packages that have updates available.Windowsping http://windowsupdate.microsoft.com/The ping should successfully be delivered and received.- Additional Information
This is not your only solution to handle updates. This is a Google Cloud specific recommendation to leverage a resource to solve the need for comprehensive update procedures and policy. If you have a solution already in place you do not need to make the switch.There are also further resources that would be out of the scope of this recommendation. If you need to allow your VMs to access public hosted updates, please see the reference to setup NAT or Private Google Access.
5 Storage22
5.1Ensure That Cloud Storage Bucket Is Not Anonymously or Publicly Accessible1
Attributes
- Profile
Level 1
- Section
5 Storage
- Description
It is recommended that IAM policy on Cloud Storage bucket does not allows anonymous or public access.
- Default Value
By Default, Storage buckets are not publicly shared.
- Audit Procedure
From Google Cloud Console1. Go to
Storage browserby visiting https://console.cloud.google.com/storage/browser.2. Click on each bucket name to go to itsBucket detailspage.3. Click on thePermissionstab.4. Ensure thatallUsersandallAuthenticatedUsersare not in theMemberslist.From Google Cloud CLI1. List all buckets in a projectgsutil ls2. Check the IAM Policy for each bucket:gsutil iam get gs://BUCKET_NAMENo role should containallUsersand/orallAuthenticatedUsersas a member.Using Rest API1. List all buckets in a projectGet https://www.googleapis.com/storage/v1/b?project=<ProjectName>2. Check the IAM Policy for each bucketGET https://www.googleapis.com/storage/v1/b/<bucketName>/iamNo role should containallUsersand/orallAuthenticatedUsersas a member.- Impact Statement
No storage buckets would be publicly accessible. You would have to explicitly administer bucket access.
- Assessment Status
Automated
- Rationale Statement
Allowing anonymous or public access grants permissions to anyone to access bucket content. Such access might not be desired if you are storing any sensitive data. Hence, ensure that anonymous or public access to a bucket is not allowed.
- Remediation Procedure
From Google Cloud Console1. Go to
Storage browserby visiting https://console.cloud.google.com/storage/browser.2. Click on the bucket name to go to itsBucket detailspage.3. Click on thePermissionstab. 4. ClickDeletebutton in front ofallUsersandallAuthenticatedUsersto remove that particular role assignment.From Google Cloud CLIRemoveallUsersandallAuthenticatedUsersaccess.gsutil iam ch -d allUsers gs://BUCKET_NAMEgsutil iam ch -d allAuthenticatedUsers gs://BUCKET_NAME**Prevention:**You can prevent Storage buckets from becoming publicly accessible by setting up theDomain restricted sharingorganization policy at: https://console.cloud.google.com/iam-admin/orgpolicies/iam-allowedPolicyMemberDomains .- Additional Information
To implement Access restrictions on buckets, configuring Bucket IAM is preferred way than configuring Bucket ACL. On GCP console, "Edit Permissions" for bucket exposes IAM configurations only. Bucket ACLs are configured automatically as per need in order to implement/support User enforced Bucket IAM policy. In-case administrator changes bucket ACL using command-line(gsutils)/API bucket IAM also gets updated automatically.
5.2Ensure That Cloud Storage Buckets Have Uniform Bucket-Level Access Enabled1
Attributes
- Profile
Level 2
- Section
5 Storage
- Description
It is recommended that uniform bucket-level access is enabled on Cloud Storage buckets.
- Default Value
By default, Cloud Storage buckets do not have uniform bucket-level access enabled.
- Audit Procedure
From Google Cloud Console1. Open the Cloud Storage browser in the Google Cloud Console by visiting: https://console.cloud.google.com/storage/browser2. For each bucket, make sure that
Access controlcolumn has the valueUniform.From Google Cloud CLI1. List all buckets in a projectgsutil ls2. For each bucket, verify that uniform bucket-level access is enabled.gsutil uniformbucketlevelaccess get gs://BUCKET_NAME/If uniform bucket-level access is enabled, the response looks like:Uniform bucket-level access setting for gs://BUCKET_NAME/: Enabled: True LockedTime: LOCK_DATE- Impact Statement
If you enable uniform bucket-level access, you revoke access from users who gain their access solely through object ACLs.Certain Google Cloud services, such as Stackdriver, Cloud Audit Logs, and Datastore, cannot export to Cloud Storage buckets that have uniform bucket-level access enabled.
- Assessment Status
Automated
- Rationale Statement
It is recommended to use uniform bucket-level access to unify and simplify how you grant access to your Cloud Storage resources. Cloud Storage offers two systems for granting users permission to access your buckets and objects: Cloud Identity and Access Management (Cloud IAM) and Access Control Lists (ACLs). These systems act in parallel - in order for a user to access a Cloud Storage resource, only one of the systems needs to grant the user permission. Cloud IAM is used throughout Google Cloud and allows you to grant a variety of permissions at the bucket and project levels. ACLs are used only by Cloud Storage and have limited permission options, but they allow you to grant permissions on a per-object basis.In order to support a uniform permissioning system, Cloud Storage has uniform bucket-level access. Using this feature disables ACLs for all Cloud Storage resources: access to Cloud Storage resources then is granted exclusively through Cloud IAM. Enabling uniform bucket-level access guarantees that if a Storage bucket is not publicly accessible, no object in the bucket is publicly accessible either.
- Remediation Procedure
From Google Cloud Console1. Open the Cloud Storage browser in the Google Cloud Console by visiting: https://console.cloud.google.com/storage/browser2. In the list of buckets, click on the name of the desired bucket.3. Select the
Permissionstab near the top of the page.4. In the text box that starts withThis bucket uses fine-grained access control..., clickEdit.5. In the pop-up menu that appears, selectUniform.6. ClickSave.From Google Cloud CLIUse the on option in a uniformbucketlevelaccess set command:gsutil uniformbucketlevelaccess set on gs://BUCKET_NAME/PreventionYou can set up an Organization Policy to enforce that any new bucket has uniform bucket level access enabled. Learn more at:https://cloud.google.com/storage/docs/setting-org-policies#uniform-bucket- Additional Information
Uniform bucket-level access can no longer be disabled if it has been active on a bucket for 90 consecutive days.
6 Cloud SQL Database Services2221
6.1.1Ensure That a MySQL Database Instance Does Not Allow Anyone To Connect With Administrative Privileges0
Attributes
- Profile
Level 1
- Section
6 Cloud SQL Database Services
- Sub Section
6.1 MySQL Database
- Description
It is recommended to set a password for the administrative user (
rootby default) to prevent unauthorized access to the SQL database instances.This recommendation is applicable only for MySQL Instances. PostgreSQL does not offer any setting for No Password from the cloud console.- Default Value
From the Google Cloud Platform Console, the
Create Instanceworkflow enforces the rule to enter the root password unless the optionNo Passwordis selected explicitly.- Audit Procedure
From Google Cloud CLI1. List All SQL database instances of type MySQL:
gcloud sql instances list --filter='DATABASE_VERSION:MYSQL* --project <project_id> --format="(NAME,PRIMARY_ADDRESS)"'2. For every MySQL instance try to connect using thePRIMARY_ADDRESS, if available:mysql -u root -h <mysql_instance_ip_address>The command should return either an error message or a password prompt.Sample Error message:ERROR 1045 (28000): Access denied for user 'root'@'<Instance_IP>' (using password: NO)If a command produces themysql>prompt, the MySQL instance allows anyone to connect with administrative privileges without needing a password.Note: TheNo Passwordsetting is exposed only at the time of MySQL instance creation. Once the instance is created, the Google Cloud Platform Console does not expose the set to confirm whether a password for an administrative user is set to a MySQL instance.- Impact Statement
Connection strings for administrative clients need to be reconfigured to use a password.
- Assessment Status
Manual
- Rationale Statement
At the time of MySQL Instance creation, not providing an administrative password allows anyone to connect to the SQL database instance with administrative privileges. The root password should be set to ensure only authorized users have these privileges.
- Remediation Procedure
From Google Cloud Console1. Go to the Cloud SQL Instances page in the Google Cloud Platform Console using
https://console.cloud.google.com/sql/2. Select the instance to open its Overview page.3. SelectAccess Control > Users.4. Click theMore actions iconfor the user to be updated.5. SelectChange password, specify aNew password, and clickOK.From Google Cloud CLI1. Set a password to a MySql instance:gcloud sql users set-password root --host=<host> --instance=<instance_name> --prompt-for-password2. A prompt will appear, requiring the user to enter a password:Instance Password:3. With a successful password configured, the following message should be seen:Updating Cloud SQL user...done.
6.1.2Ensure ‘Skip_show_database’ Database Flag for Cloud SQL MySQL Instance Is Set to ‘On’1
Attributes
- Profile
Level 1
- Section
6 Cloud SQL Database Services
- Sub Section
6.1 MySQL Database
- Description
It is recommended to set
skip_show_databasedatabase flag for Cloud SQL Mysql instance toon- Audit Procedure
From Google Cloud Console1. Go to the Cloud SQL Instances page in the Google Cloud Console by visiting https://console.cloud.google.com/sql/instances.2. Select the instance to open its
Instance Overviewpage3. Ensure the database flagskip_show_databasethat has been set is listed under theDatabase flagssection.From Google Cloud CLI1. List all Cloud SQL database Instancesgcloud sql instances list2. Ensure the below command returnsonfor every Cloud SQL Mysql database instancegcloud sql instances describe <INSTANCE_NAME> --format=json | jq '.settings.databaseFlags[] | select(.name=="skip_show_database")|.value'- Assessment Status
Automated
- Rationale Statement
skip_show_databasedatabase flag prevents people from using the SHOW DATABASES statement if they do not have the SHOW DATABASES privilege. This can improve security if you have concerns about users being able to see databases belonging to other users. Its effect depends on the SHOW DATABASES privilege: If the variable value is ON, the SHOW DATABASES statement is permitted only to users who have the SHOW DATABASES privilege, and the statement displays all database names. If the value is OFF, SHOW DATABASES is permitted to all users, but displays the names of only those databases for which the user has the SHOW DATABASES or other privilege. This recommendation is applicable to Mysql database instances.- Remediation Procedure
From Google Cloud Console1. Go to the Cloud SQL Instances page in the Google Cloud Console by visiting https://console.cloud.google.com/sql/instances.2. Select the Mysql instance for which you want to enable to database flag.3. Click
Edit.4. Scroll down to theFlagssection.5. To set a flag that has not been set on the instance before, clickAdd a Database Flag, choose the flagskip_show_databasefrom the drop-down menu, and set its value toon.6. ClickSaveto save your changes.7. Confirm your changes underFlagson the Overview page.From Google Cloud CLI1. List all Cloud SQL database Instancesgcloud sql instances list2. Configure theskip_show_databasedatabase flag for every Cloud SQL Mysql database instance using the below command.gcloud sql instances patch <INSTANCE_NAME> --database-flags skip_show_database=onNote: This command will overwrite all database flags previously set. To keep those and add new ones, include the values for all flags you want set on the instance; any flag not specifically included is set to its default value. For flags that do not take a value, specify the flag name followed by an equals sign ("=").- Additional Information
WARNING: This patch modifies database flag values, which may require your instance to be restarted. Check the list of supported flags - https://cloud.google.com/sql/docs/mysql/flags - to see if your instance will be restarted when this patch is submitted.Note: some database flag settings can affect instance availability or stability, and remove the instance from the Cloud SQL SLA. For information about these flags, see Operational Guidelines."Note: Configuring the above flag restarts the Cloud SQL instance.
6.1.3Ensure That the ‘Local_infile’ Database Flag for a Cloud SQL MySQL Instance Is Set to ‘Off’1
Attributes
- Profile
Level 1
- Section
6 Cloud SQL Database Services
- Sub Section
6.1 MySQL Database
- Description
It is recommended to set the
local_infiledatabase flag for a Cloud SQL MySQL instance tooff.- Default Value
By default
local_infileison.- Audit Procedure
From Google Cloud Console1. Go to the Cloud SQL Instances page in the Google Cloud Console by visiting https://console.cloud.google.com/sql/instances.2. Select the instance to open its
Instance Overviewpage3. Ensure the database flaglocal_infilethat has been set is listed under theDatabase flagssection.From Google Cloud CLI1. List all Cloud SQL database instances:gcloud sql instances list2. Ensure the below command returnsofffor every Cloud SQL MySQL database instance.gcloud sql instances describe <INSTANCE_NAME> --format=json | jq '.settings.databaseFlags[] | select(.name=="local_infile")|.value'- Impact Statement
Disabling
local_infilemakes the server refuse local data loading by clients that have LOCAL enabled on the client side.- Assessment Status
Automated
- Rationale Statement
The
local_infileflag controls the server-side LOCAL capability for LOAD DATA statements. Depending on thelocal_infilesetting, the server refuses or permits local data loading by clients that have LOCAL enabled on the client side.To explicitly cause the server to refuse LOAD DATA LOCAL statements (regardless of how client programs and libraries are configured at build time or runtime), start mysqld with local_infile disabled. local_infile can also be set at runtime.Due to security issues associated with thelocal_infileflag, it is recommended to disable it. This recommendation is applicable to MySQL database instances.- Remediation Procedure
From Google Cloud Console1. Go to the Cloud SQL Instances page in the Google Cloud Console by visiting https://console.cloud.google.com/sql/instances.2. Select the MySQL instance where the database flag needs to be enabled.3. Click
Edit.4. Scroll down to theFlagssection.5. To set a flag that has not been set on the instance before, clickAdd a Database Flag, choose the flaglocal_infilefrom the drop-down menu, and set its value tooff.6. ClickSave.7. Confirm the changes underFlagson the Overview page.From Google Cloud CLI1. List all Cloud SQL database instances using the following command:gcloud sql instances list2. Configure thelocal_infiledatabase flag for every Cloud SQL Mysql database instance using the below command:gcloud sql instances patch <INSTANCE_NAME> --database-flags local_infile=offNote: This command will overwrite all database flags that were previously set. To keep those and add new ones, include the values for all flags to be set on the instance; any flag not specifically included is set to its default value. For flags that do not take a value, specify the flag name followed by an equals sign ("=").- Additional Information
WARNING: This patch modifies database flag values, which may require the instance to be restarted. Check the list of supported flags - https://cloud.google.com/sql/docs/mysql/flags - to see if your instance will be restarted when this patch is submitted.Note: some database flag settings can affect instance availability or stability, and remove the instance from the Cloud SQL SLA. For information about these flags, see Operational Guidelines."Note: Configuring the above flag restarts the Cloud SQL instance.
6.2.1Ensure ‘Log_error_verbosity’ Database Flag for Cloud SQL PostgreSQL Instance Is Set to ‘DEFAULT’ or Stricter1
Attributes
- Profile
Level 2
- Section
6 Cloud SQL Database Services
- Sub Section
6.2 PostgreSQL Database
- Description
The
log_error_verbosityflag controls the verbosity/details of messages logged. Valid values are:-TERSE-DEFAULT-VERBOSE``TERSEexcludes the logging ofDETAIL,HINT,QUERY, andCONTEXTerror information.VERBOSEoutput includes theSQLSTATEerror code, source code file name, function name, and line number that generated the error.Ensure an appropriate value is set to 'DEFAULT' or stricter.- Default Value
By default
log_error_verbosityisDEFAULT.- Audit Procedure
From Google Cloud Console1. Go to the Cloud SQL Instances page in the Google Cloud Console by visiting https://console.cloud.google.com/sql/instances.2. Select the instance to open its
Instance Overviewpage3. Go toConfigurationcard4. UnderDatabase flags, check the value oflog_error_verbosityflag is set to 'DEFAULT' or stricter.From Google Cloud CLI1. Use the below command for every Cloud SQL PostgreSQL database instance to verify the value of `log_error_verbosity````gcloud sql instances describe [INSTANCE_NAME] --format=json | jq '.settings.databaseFlags[] | select(.name=="log_error_verbosity")|.value'```In the output, database flags are listed under the settings as the collection databaseFlags.- Impact Statement
Turning on logging will increase the required storage over time. Mismanaged logs may cause your storage costs to increase. Setting custom flags via command line on certain instances will cause all omitted flags to be reset to defaults. This may cause you to lose custom flags and could result in unforeseen complications or instance restarts. Because of this, it is recommended you apply these flags changes during a period of low usage.
- Assessment Status
Automated
- Rationale Statement
Auditing helps in troubleshooting operational problems and also permits forensic analysis. If
log_error_verbosityis not set to the correct value, too many details or too few details may be logged. This flag should be configured with a value of 'DEFAULT' or stricter. This recommendation is applicable to PostgreSQL database instances.- Remediation Procedure
From Google Cloud Console1. Go to the Cloud SQL Instances page in the Google Cloud Console by visiting https://console.cloud.google.com/sql/instances.2. Select the PostgreSQL instance for which you want to enable the database flag.3. Click
Edit.4. Scroll down to theFlagssection.5. To set a flag that has not been set on the instance before, clickAdd a Database Flag, choose the flaglog_error_verbosityfrom the drop-down menu and set appropriate value.6. ClickSaveto save your changes.7. Confirm your changes underFlagson the Overview page.From Google Cloud CLI1. Configure the log_error_verbosity database flag for every Cloud SQL PosgreSQL database instance using the below command.gcloud sql instances patch INSTANCE_NAME --database-flags log_error_verbosity=<TERSE|DEFAULT|VERBOSE>Note: This command will overwrite all database flags previously set. To keep those and add new ones, include the values for all flags you want set on the instance; any flag not specifically included is set to its default value. For flags that do not take a value, specify the flag name followed by an equals sign ("=").- Additional Information
WARNING: This patch modifies database flag values, which may require your instance to be restarted. Check the list of supported flags - https://cloud.google.com/sql/docs/postgres/flags - to see if your instance will be restarted when this patch is submitted.Note: some database flag settings can affect instance availability or stability and remove the instance from the Cloud SQL SLA. For information about these flags, see Operational Guidelines.Note: Configuring the above flag does not require restarting the Cloud SQL instance.
6.2.2Ensure That the ‘Log_connections’ Database Flag for Cloud SQL PostgreSQL Instance Is Set to ‘On’1
Attributes
- Profile
Level 1
- Section
6 Cloud SQL Database Services
- Sub Section
6.2 PostgreSQL Database
- Description
Enabling the
log_connectionssetting causes each attempted connection to the server to be logged, along with successful completion of client authentication. This parameter cannot be changed after the session starts.- Default Value
By default
log_connectionsisoff.- Audit Procedure
From Google Cloud Console1. Go to the Cloud SQL Instances page in the Google Cloud Console by visiting https://console.cloud.google.com/sql/instances.2. Select the instance to open its
Instance Overviewpage.3. Go to theConfigurationcard.4. UnderDatabase flags, check the value oflog_connectionsflag to determine if it is configured as expected.From Google Cloud CLI1. Ensure the below command returnsonfor every Cloud SQL PostgreSQL database instance:gcloud sql instances describe [INSTANCE_NAME] --format=json | jq '.settings.databaseFlags[] | select(.name=="log_connections")|.value'In the output, database flags are listed under thesettingsas the collectiondatabaseFlags.- Impact Statement
Turning on logging will increase the required storage over time. Mismanaged logs may cause your storage costs to increase. Setting custom flags via command line on certain instances will cause all omitted flags to be reset to defaults. This may cause you to lose custom flags and could result in unforeseen complications or instance restarts. Because of this, it is recommended you apply these flags changes during a period of low usage.
- Assessment Status
Automated
- Rationale Statement
PostgreSQL does not log attempted connections by default. Enabling the
log_connectionssetting will create log entries for each attempted connection as well as successful completion of client authentication which can be useful in troubleshooting issues and to determine any unusual connection attempts to the server. This recommendation is applicable to PostgreSQL database instances.- Remediation Procedure
From Google Cloud Console1. Go to the Cloud SQL Instances page in the Google Cloud Console by visiting https://console.cloud.google.com/sql/instances.2. Select the PostgreSQL instance for which you want to enable the database flag.3. Click
Edit.4. Scroll down to theFlagssection.5. To set a flag that has not been set on the instance before, clickAdd a Database Flag, choose the flaglog_connectionsfrom the drop-down menu and set the value ason.6. ClickSave.7. Confirm the changes underFlagson the Overview page.From Google Cloud CLI1. Configure thelog_connectionsdatabase flag for every Cloud SQL PosgreSQL database instance using the below command.gcloud sql instances patch <INSTANCE_NAME> --database-flags "log_connections"=onNote: This command will overwrite all previously set database flags. To keep those and add new ones, include the values for all flags to be set on the instance; any flag not specifically included is set to its default value. For flags that do not take a value, specify the flag name followed by an equals sign ("=").- Additional Information
WARNING: This patch modifies database flag values, which may require your instance to be restarted. Check the list of supported flags - https://cloud.google.com/sql/docs/postgres/flags - to see if your instance will be restarted when this patch is submitted.Note: some database flag settings can affect instance availability or stability and remove the instance from the Cloud SQL SLA. For information about these flags, see the Operational Guidelines.Note: Configuring the above flag does not require restarting the Cloud SQL instance.
6.2.3Ensure That the ‘Log_disconnections’ Database Flag for Cloud SQL PostgreSQL Instance Is Set to ‘On’1
Attributes
- Profile
Level 1
- Section
6 Cloud SQL Database Services
- Sub Section
6.2 PostgreSQL Database
- Description
Enabling the
log_disconnectionssetting logs the end of each session, including the session duration.- Default Value
By default
log_disconnectionsis off.- Audit Procedure
From Google Cloud Console1. Go to the Cloud SQL Instances page in the Google Cloud Console by visiting https://console.cloud.google.com/sql/instances.2. Select the instance to open its
Instance Overviewpage3. Go to theConfigurationcard.4. UnderDatabase flags, check the value oflog_disconnectionsflag is configured as expected.From Google Cloud CLI1. Ensure the below command returnsonfor every Cloud SQL PostgreSQL database instance:gcloud sql instances list --format=json | jq '.[].settings.databaseFlags[] | select(.name=="log_disconnections")|.value'- Impact Statement
Turning on logging will increase the required storage over time. Mismanaged logs may cause your storage costs to increase. Setting custom flags via command line on certain instances will cause all omitted flags to be reset to defaults. This may cause you to lose custom flags and could result in unforeseen complications or instance restarts. Because of this, it is recommended you apply these flags changes during a period of low usage.
- Assessment Status
Automated
- Rationale Statement
PostgreSQL does not log session details such as duration and session end by default. Enabling the
log_disconnectionssetting will create log entries at the end of each session which can be useful in troubleshooting issues and determine any unusual activity across a time period.Thelog_disconnectionsandlog_connectionswork hand in hand and generally, the pair would be enabled/disabled together. This recommendation is applicable to PostgreSQL database instances.- Remediation Procedure
From Google Cloud Console1. Go to the Cloud SQL Instances page in the Google Cloud Console by visiting https://console.cloud.google.com/sql/instances.2. Select the PostgreSQL instance where the database flag needs to be enabled.3. Click
Edit.4. Scroll down to theFlagssection.5. To set a flag that has not been set on the instance before, clickAdd a Database Flag, choose the flaglog_disconnectionsfrom the drop-down menu and set the value ason.6. ClickSave.7. Confirm the changes underFlagson the Overview page.From Google Cloud CLI1. Configure thelog_disconnectionsdatabase flag for every Cloud SQL PosgreSQL database instance using the below command:gcloud sql instances patch <INSTANCE_NAME> --database-flags log_disconnections=onNote: This command will overwrite all previously set database flags. To keep those and add new ones, include the values for all flags to be set on the instance; any flag not specifically included is set to its default value. For flags that do not take a value, specify the flag name followed by an equals sign ("=").- Additional Information
WARNING: This patch modifies database flag values, which may require your instance to be restarted. Check the list of supported flags - https://cloud.google.com/sql/docs/postgres/flags - to see if your instance will be restarted when this patch is submitted.Note: some database flag settings can affect instance availability or stability and remove the instance from the Cloud SQL SLA. For information about these flags, see Operational Guidelines.Note: Configuring the above flag does not require restarting the Cloud SQL instance.
6.2.4Ensure ‘Log_statement’ Database Flag for Cloud SQL PostgreSQL Instance Is Set Appropriately1
Attributes
- Profile
Level 2
- Section
6 Cloud SQL Database Services
- Sub Section
6.2 PostgreSQL Database
- Description
The value of
log_statementflag determined the SQL statements that are logged. Valid values are:-none-ddl-mod-allThe valueddllogs all data definition statements.The valuemodlogs all ddl statements, plus data-modifying statements.The statements are logged after a basic parsing is done and statement type is determined, thus this does not logs statements with errors. When using extended query protocol, logging occurs after an Execute message is received and values of the Bind parameters are included.A value of 'ddl' is recommended unless otherwise directed by your organization's logging policy.- Audit Procedure
From Google Cloud Console1. Go to the Cloud SQL Instances page in the Google Cloud Console by visiting https://console.cloud.google.com/sql/instances.2. Select the instance to open its
Instance Overviewpage3. Go toConfigurationcard4. UnderDatabase flags, check the value oflog_statementflag is set to appropriately.From Google Cloud CLI1. Use the below command for every Cloud SQL PostgreSQL database instance to verify the value of `log_statement````gcloud sql instances list --format=json | jq '.[].settings.databaseFlags[] | select(.name=="log_statement")|.value'```- Impact Statement
Turning on logging will increase the required storage over time. Mismanaged logs may cause your storage costs to increase. Setting custom flags via command line on certain instances will cause all omitted flags to be reset to defaults. This may cause you to lose custom flags and could result in unforeseen complications or instance restarts. Because of this, it is recommended you apply these flags changes during a period of low usage.
- Assessment Status
Automated
- Rationale Statement
Auditing helps in forensic analysis. If
log_statementis not set to the correct value, too many statements may be logged leading to issues in finding the relevant information from the logs, or too few statements may be logged with relevant information missing from the logs. Setting log_statement to align with your organization's security and logging policies facilitates later auditing and review of database activities.This recommendation is applicable to PostgreSQL database instances.- Remediation Procedure
From Google Cloud Console1. Go to the Cloud SQL Instances page in the Google Cloud Console by visiting https://console.cloud.google.com/sql/instances.2. Select the PostgreSQL instance for which you want to enable the database flag.3. Click
Edit.4. Scroll down to theFlagssection.5. To set a flag that has not been set on the instance before, clickAdd a Database Flag, choose the flaglog_statementfrom the drop-down menu and set appropriate value.6. ClickSaveto save your changes.7. Confirm your changes underFlagson the Overview page.From Google Cloud CLI1. Configure thelog_statementdatabase flag for every Cloud SQL PosgreSQL database instance using the below command.gcloud sql instances patch <INSTANCE_NAME> --database-flags log_statement=<ddl|mod|all|none>Note: This command will overwrite all database flags previously set. To keep those and add new ones, include the values for all flags you want set on the instance; any flag not specifically included is set to its default value. For flags that do not take a value, specify the flag name followed by an equals sign ("=").- Additional Information
WARNING: This patch modifies database flag values, which may require your instance to be restarted. Check the list of supported flags - https://cloud.google.com/sql/docs/postgres/flags - to see if your instance will be restarted when this patch is submitted.Note: some database flag settings can affect instance availability or stability and remove the instance from the Cloud SQL SLA. For information about these flags, see Operational Guidelines.Note: Configuring the above flag does not require restarting the Cloud SQL instance.
6.2.5Ensure that the ‘Log_min_messages’ Flag for a Cloud SQL PostgreSQL Instance is set at minimum to 'Warning'1
Attributes
- Profile
Level 1
- Section
6 Cloud SQL Database Services
- Sub Section
6.2 PostgreSQL Database
- Description
The
log_min_messagesflag defines the minimum message severity level that is considered as an error statement. Messages for error statements are logged with the SQL statement. Valid values include (from lowest to highest severity)DEBUG5,DEBUG4,DEBUG3,DEBUG2,DEBUG1,INFO,NOTICE,WARNING,ERROR,LOG,FATAL, andPANIC.Each severity level includes the subsequent levels mentioned above. ERROR is considered the best practice setting. Changes should only be made in accordance with the organization's logging policy.- Default Value
By default
log_min_messagesisERROR.- Audit Procedure
From Google Cloud Console1. Go to the Cloud SQL Instances page in the Google Cloud Console by visiting https://console.cloud.google.com/sql/instances.2. Select the instance to open its
Instance Overviewpage.3. Go to theConfigurationcard.4. UnderDatabase flags, check the value oflog_min_messagesflag is in accordance with the organization's logging policy.From Google Cloud CLI1. Use the below command for every Cloud SQL PostgreSQL database instance to verify that the value oflog_min_messagesis in accordance with the organization's logging policy.gcloud sql instances describe [INSTANCE_NAME] --format=json | jq '.settings.databaseFlags[] | select(.name=="log_min_messages")|.value'- Impact Statement
Setting the threshold too low will might result in increased log storage size and length, making it difficult to find actual errors. Setting the threshold to 'Warning' will log messages for the most needed error messages. Higher severity levels may cause errors needed to troubleshoot to not be logged.Note: To effectively turn off logging failing statements, set this parameter to PANIC.
- Assessment Status
Automated
- Rationale Statement
Auditing helps in troubleshooting operational problems and also permits forensic analysis. If
log_min_messagesis not set to the correct value, messages may not be classified as error messages appropriately. An organization will need to decide their own threshold for logginglog_min_messagesflag.This recommendation is applicable to PostgreSQL database instances.- Remediation Procedure
From Google Cloud Console1. Go to the Cloud SQL Instances page in the Google Cloud Console by visiting https://console.cloud.google.com/sql/instances2. Select the PostgreSQL instance for which you want to enable the database flag.3. Click
Edit.4. Scroll down to theFlagssection.5. To set a flag that has not been set on the instance before, clickAdd a Database Flag, choose the flaglog_min_messagesfrom the drop-down menu and set appropriate value.6. ClickSaveto save the changes.7. Confirm the changes underFlagson the Overview page.From Google Cloud CLI1. Configure thelog_min_messagesdatabase flag for every Cloud SQL PosgreSQL database instance using the below command.gcloud sql instances patch <INSTANCE_NAME> --database-flags log_min_messages=<DEBUG5|DEBUG4|DEBUG3|DEBUG2|DEBUG1|INFO|NOTICE|WARNING|ERROR|LOG|FATAL|PANIC>Note: This command will overwrite all database flags previously set. To keep those and add new ones, include the values for all flags to be set on the instance; any flag not specifically included is set to its default value. For flags that do not take a value, specify the flag name followed by an equals sign ("=").- Additional Information
WARNING: This patch modifies database flag values, which may require your instance to be restarted. Check the list of supported flags - https://cloud.google.com/sql/docs/postgres/flags - to see if your instance will be restarted when this patch is submitted.Note: Some database flag settings can affect instance availability or stability and remove the instance from the Cloud SQL SLA. For information about these flags, see Operational Guidelines.Note: Configuring the above flag does not require restarting the Cloud SQL instance.
6.2.6Ensure ‘Log_min_error_statement’ Database Flag for Cloud SQL PostgreSQL Instance Is Set to ‘Error’ or Stricter1
Attributes
- Profile
Level 1
- Section
6 Cloud SQL Database Services
- Sub Section
6.2 PostgreSQL Database
- Description
The
log_min_error_statementflag defines the minimum message severity level that are considered as an error statement. Messages for error statements are logged with the SQL statement. Valid values include (from lowest to highest severity)DEBUG5,DEBUG4,DEBUG3,DEBUG2,DEBUG1,INFO,NOTICE,WARNING,ERROR,LOG,FATAL, andPANIC.Each severity level includes the subsequent levels mentioned above. Ensure a value ofERRORor stricter is set.- Default Value
By default
log_min_error_statementisERROR.- Audit Procedure
From Google Cloud Console1. Go to the Cloud SQL Instances page in the Google Cloud Console by visiting https://console.cloud.google.com/sql/instances.2. Select the instance to open its
Instance Overviewpage3. Go toConfigurationcard4. UnderDatabase flags, check the value oflog_min_error_statementflag is configured as toERRORor stricter.From Google Cloud CLI1. Use the below command for every Cloud SQL PostgreSQL database instance to verify the value oflog_min_error_statementis set toERRORor stricter.gcloud sql instances describe <INSTANCE_NAME> --format=json | jq '.[].settings.databaseFlags[] | select(.name=="log_min_error_statement")|.value'In the output, database flags are listed under thesettingsas the collectiondatabaseFlags.- Impact Statement
Turning on logging will increase the required storage over time. Mismanaged logs may cause your storage costs to increase. Setting custom flags via command line on certain instances will cause all omitted flags to be reset to defaults. This may cause you to lose custom flags and could result in unforeseen complications or instance restarts. Because of this, it is recommended you apply these flags changes during a period of low usage.
- Assessment Status
Automated
- Rationale Statement
Auditing helps in troubleshooting operational problems and also permits forensic analysis. If
log_min_error_statementis not set to the correct value, messages may not be classified as error messages appropriately. Considering general log messages as error messages would make is difficult to find actual errors and considering only stricter severity levels as error messages may skip actual errors to log their SQL statements.Thelog_min_error_statementflag should be set toERRORor stricter. This recommendation is applicable to PostgreSQL database instances.- Remediation Procedure
From Google Cloud Console1. Go to the Cloud SQL Instances page in the Google Cloud Console by visiting https://console.cloud.google.com/sql/instances.2. Select the PostgreSQL instance for which you want to enable the database flag.3. Click
Edit.4. Scroll down to theFlagssection.5. To set a flag that has not been set on the instance before, clickAdd item, choose the flaglog_min_error_statementfrom the drop-down menu and set appropriate value.6. ClickSaveto save your changes.7. Confirm your changes underFlagson the Overview page.From Google Cloud CLI1. Configure thelog_min_error_statementdatabase flag for every Cloud SQL PosgreSQL database instance using the below command.gcloud sql instances patch <INSTANCE_NAME> --database-flags log_min_error_statement=<DEBUG5|DEBUG4|DEBUG3|DEBUG2|DEBUG1|INFO|NOTICE|WARNING|ERROR>Note: This command will overwrite all database flags previously set. To keep those and add new ones, include the values for all flags you want set on the instance; any flag not specifically included is set to its default value. For flags that do not take a value, specify the flag name followed by an equals sign ("=").- Additional Information
WARNING: This patch modifies database flag values, which may require your instance to be restarted. Check the list of supported flags - https://cloud.google.com/sql/docs/postgres/flags - to see if your instance will be restarted when this patch is submitted.Note: some database flag settings can affect instance availability or stability and remove the instance from the Cloud SQL SLA. For information about these flags, see Operational Guidelines.Note: Configuring the above flag does not require restarting the Cloud SQL instance.
6.2.7Ensure That the ‘Log_min_duration_statement’ Database Flag for Cloud SQL PostgreSQL Instance Is Set to '-1' (Disabled)1
Attributes
- Profile
Level 1
- Section
6 Cloud SQL Database Services
- Sub Section
6.2 PostgreSQL Database
- Description
The
log_min_duration_statementflag defines the minimum amount of execution time of a statement in milliseconds where the total duration of the statement is logged. Ensure thatlog_min_duration_statementis disabled, i.e., a value of-1is set.- Default Value
By default
log_min_duration_statementis-1.- Audit Procedure
From Google Cloud Console1. Go to the Cloud SQL Instances page in the Google Cloud Console by visiting https://console.cloud.google.com/sql/instances.2. Select the instance to open its
Instance Overviewpage.3. Go to theConfigurationcard.4. UnderDatabase flags, check that the value oflog_min_duration_statementflag is set to-1.From Google Cloud CLI1. Use the below command for every Cloud SQL PostgreSQL database instance to verify the value oflog_min_duration_statementis set to-1.gcloud sql instances describe <INSTANCE_NAME> --format=json| jq '.settings.databaseFlags[] | select(.name=="log_min_duration_statement")|.value'In the output, database flags are listed under thesettingsas the collectiondatabaseFlags.- Impact Statement
Turning on logging will increase the required storage over time. Mismanaged logs may cause your storage costs to increase. Setting custom flags via command line on certain instances will cause all omitted flags to be reset to defaults. This may cause you to lose custom flags and could result in unforeseen complications or instance restarts. Because of this, it is recommended you apply these flags changes during a period of low usage.
- Assessment Status
Automated
- Rationale Statement
Logging SQL statements may include sensitive information that should not be recorded in logs. This recommendation is applicable to PostgreSQL database instances.
- Remediation Procedure
From Google Cloud Console1. Go to the Cloud SQL Instances page in the Google Cloud Console by visiting https://console.cloud.google.com/sql/instances.2. Select the PostgreSQL instance where the database flag needs to be enabled.3. Click
Edit.4. Scroll down to theFlagssection.5. To set a flag that has not been set on the instance before, clickAdd item, choose the flaglog_min_duration_statementfrom the drop-down menu and set a value of-1.6. ClickSave.7. Confirm the changes underFlagson the Overview page.From Google Cloud CLI1. List all Cloud SQL database instances using the following command:gcloud sql instances list2. Configure thelog_min_duration_statementflag for every Cloud SQL PosgreSQL database instance using the below command:gcloud sql instances patch <INSTANCE_NAME> --database-flags log_min_duration_statement=-1Note: This command will overwrite all database flags previously set. To keep those and add new ones, include the values for all flags to be set on the instance; any flag not specifically included is set to its default value. For flags that do not take a value, specify the flag name followed by an equals sign ("=").- Additional Information
WARNING: This patch modifies database flag values, which may require your instance to be restarted. Check the list of supported flags - https://cloud.google.com/sql/docs/postgres/flags - to see if your instance will be restarted when this patch is submitted.Note: Some database flag settings can affect instance availability or stability and remove the instance from the Cloud SQL SLA. For information about these flags, see Operational Guidelines.Note: Configuring the above flag does not require restarting the Cloud SQL instance.
6.2.8Ensure That 'cloudsql.enable_pgaudit' Database Flag for each Cloud Sql Postgresql Instance Is Set to 'on' For Centralized Logging1
Attributes
- Profile
Level 1
- Section
6 Cloud SQL Database Services
- Sub Section
6.2 PostgreSQL Database
- Description
Ensure
cloudsql.enable_pgauditdatabase flag for Cloud SQL PostgreSQL instance is set toonto allow for centralized logging.- Default Value
By default
cloudsql.enable_pgauditdatabase flag is set tooffand the extension is not enabled.- Audit Procedure
Determining if the pgAudit Flag is set to 'on'****From Google Cloud Console1. Go to https://console.cloud.google.com/sql/instances.2. Select the instance to open its
Overviewpage.3. ClickEdit.4. Scroll down and expandFlags.5. Ensure thatcloudsql.enable_pgauditflag is set toon.From Google Cloud CLIRun the command by providing<INSTANCE_NAME>. Ensure the value of the flag ison.gcloud sql instances describe <INSTANCE_NAME> --format="json" | jq '.settings|.|.databaseFlags[]|select(.name=="cloudsql.enable_pgaudit")|.value'Determine if the pgAudit extension is installed1. Connect to the the server running PostgreSQL or through a SQL client of your choice.2. Via command line open the PostgreSQL shell by typingpsql3. Run the following commandSELECT * FROM pg_extension;4. If pgAudit is in this list. If so, it is installed.Determine if Data Access Audit logs are enabled for your project and have sufficient privileges1. From the homepage open the hamburger menu in the top left.2. Scroll down toIAM & Adminand hover over it.3. In the menu that opens up, selectAudit Logs4. In the middle of the page, in the search box next tofiltersearch forCloud Composer API5. Select it, and ensure that both 'Admin Read' and 'Data Read' are checked.Determine if logs are being sent to Logs Explorer1. From the Google Console home page, open the hamburger menu in the top left.2. In the menu that pops open, scroll down to Logs Explorer under Operations.3. In the query box, paste the following and searchresource.type="cloudsql_database"logName="projects/<your-project-name>/logs/cloudaudit.googleapis.com%2Fdata_access"protoPayload.request.@type="type.googleapis.com/google.cloud.sql.audit.v1.PgAuditEntry"4. If it returns any log sources, they are correctly setup.- Impact Statement
Enabling the pgAudit extension can lead to increased data storage requirements and to ensure durability of pgAudit log records in the event of unexpected storage issues, it is recommended to enable the
Enable automatic storage increasessetting on the instance. Enabling flags via the command line will also overwrite all existing flags, so you should apply all needed flags in the CLI command. Also flags may require a restart of the server to be implemented or will break existing functionality so update your servers at a time of low usage.- Assessment Status
Automated
- Rationale Statement
As numerous other recommendations in this section consist of turning on flags for logging purposes, your organization will need a way to manage these logs. You may have a solution already in place. If you do not, consider installing and enabling the open source pgaudit extension within PostgreSQL and enabling its corresponding flag of
cloudsql.enable_pgaudit. This flag and installing the extension enables database auditing in PostgreSQL through the open-source pgAudit extension. This extension provides detailed session and object logging to comply with government, financial, & ISO standards and provides auditing capabilities to mitigate threats by monitoring security events on the instance. Enabling the flag and settings later in this recommendation will send these logs to Google Logs Explorer so that you can access them in a central location. to This recommendation is applicable only to PostgreSQL database instances.- Remediation Procedure
Initialize the pgAudit flag****From Google Cloud Console1. Go to https://console.cloud.google.com/sql/instances.2. Select the instance to open its
Overviewpage.3. ClickEdit.4. Scroll down and expandFlags.5. To set a flag that has not been set on the instance before, clickAdd item.6. Entercloudsql.enable_pgauditfor the flag name and set the flag toon.7. ClickDone.8. ClickSaveto update the configuration.9. Confirm your changes underFlagson theOverviewpage.From Google Cloud CLIRun the below command by providing<INSTANCE_NAME>to enablecloudsql.enable_pgauditflag.gcloud sql instances patch <INSTANCE_NAME> --database-flags cloudsql.enable_pgaudit=onNote:RESTARTis required to get this configuration in effect.Creating the extension1. Connect to the the server running PostgreSQL or through a SQL client of your choice.2. If SSHing to the server in the command line open the PostgreSQL shell by typingpsql3. Run the following command as a superuser.CREATE EXTENSION pgaudit;**Updating the previously created pgaudit.log flag for your Logging Needs****From Console:**Note: there are multiple options here. This command will enable logging for all databases on a server. Please see the customizing database audit logging reference for more flag options. 1. Go to https://console.cloud.google.com/sql/instances.2. Select the instance to open itsOverviewpage.3. ClickEdit.4. Scroll down and expandFlags.5. To set a flag that has not been set on the instance before, clickAdd item.6. Enterpgaudit.log=allfor the flag name and set the flag toon.7. ClickDone.8. ClickSaveto update the configuration.9. Confirm your changes underFlagson theOverviewpage.**From Command Line:**Run the commandgcloud sql instances patch <INSTANCE_NAME> --database-flags \ cloudsql.enable_pgaudit=on,pgaudit.log=allDetermine if logs are being sent to Logs Explorer1. From the Google Console home page, open the hamburger menu in the top left.2. In the menu that pops open, scroll down to Logs Explorer under Operations.3. In the query box, paste the following and searchresource.type="cloudsql_database"logName="projects/<your-project-name>/logs/cloudaudit.googleapis.com%2Fdata_access"protoPayload.request.@type="type.googleapis.com/google.cloud.sql.audit.v1.PgAuditEntry" If it returns any log sources, they are correctly setup.- Additional Information
WARNING: This patch modifies database flag values, which may require your instance to be restarted. Check the list of supported flags - https://cloud.google.com/sql/docs/postgres/flags - to see if your instance will be restarted when this patch is submitted.Note: Configuring the 'cloudsql.enable_pgaudit' database flag requires restarting the Cloud SQL PostgreSQL instance.
6.3.1Ensure 'external scripts enabled' database flag for Cloud SQL SQL Server instance is set to 'off'1
Attributes
- Profile
Level 1
- Section
6 Cloud SQL Database Services
- Sub Section
6.3 SQL Server
- Description
It is recommended to set
external scripts enableddatabase flag for Cloud SQL SQL Server instance tooff- Default Value
By default
external scripts enabledisoff- Audit Procedure
From Google Cloud Console1. Go to the Cloud SQL Instances page in the Google Cloud Console by visiting https://console.cloud.google.com/sql/instances.2. Select the instance to open its
Instance Overviewpage3. Ensure the database flagexternal scripts enabledthat has been set is listed under theDatabase flagssection.From Google Cloud CLI1. Ensure the below command returnsofffor every Cloud SQL SQL Server database instancegcloud sql instances describe <INSTANCE_NAME> --format=json | jq '.settings.databaseFlags[] | select(.name=="external scripts enabled")|.value'In the output, database flags are listed under thesettingsas the collectiondatabaseFlags.- Impact Statement
Setting custom flags via command line on certain instances will cause all omitted flags to be reset to defaults. This may cause you to lose custom flags and could result in unforeseen complications or instance restarts. Because of this, it is recommended you apply these flags changes during a period of low usage.
- Assessment Status
Automated
- Rationale Statement
external scripts enabledenable the execution of scripts with certain remote language extensions. This property is OFF by default. When Advanced Analytics Services is installed, setup can optionally set this property to true. As the External Scripts Enabled feature allows scripts external to SQL such as files located in an R library to be executed, which could adversely affect the security of the system, hence this should be disabled. This recommendation is applicable to SQL Server database instances.- Remediation Procedure
From Google Cloud Console1. Go to the Cloud SQL Instances page in the Google Cloud Console by visiting https://console.cloud.google.com/sql/instances.2. Select the SQL Server instance for which you want to enable to database flag.3. Click
Edit.4. Scroll down to theFlagssection.5. To set a flag that has not been set on the instance before, clickAdd item, choose the flagexternal scripts enabledfrom the drop-down menu, and set its value tooff.6. ClickSaveto save your changes.7. Confirm your changes underFlagson the Overview page.From Google Cloud CLI1. Configure theexternal scripts enableddatabase flag for every Cloud SQL SQL Server database instance using the below command.gcloud sql instances patch <INSTANCE_NAME> --database-flags "external scripts enabled"=offNote: This command will overwrite all database flags previously set. To keep those and add new ones, include the values for all flags you want set on the instance; any flag not specifically included is set to its default value. For flags that do not take a value, specify the flag name followed by an equals sign ("=").- Additional Information
WARNING: This patch modifies database flag values, which may require your instance to be restarted. Check the list of supported flags - https://cloud.google.com/sql/docs/sqlserver/flags - to see if your instance will be restarted when this patch is submitted.Note: some database flag settings can affect instance availability or stability, and remove the instance from the Cloud SQL SLA. For information about these flags, see Operational Guidelines."Note: Configuring the above flag restarts the Cloud SQL instance.
6.3.2Ensure that the 'cross db ownership chaining' database flag for Cloud SQL SQL Server instance is set to 'off'1
Attributes
- Profile
Level 1
- Section
6 Cloud SQL Database Services
- Sub Section
6.3 SQL Server
- Description
It is recommended to set
cross db ownership chainingdatabase flag for Cloud SQL SQL Server instance tooff.This flag is deprecated for all SQL Server versions in CGP. Going forward, you can't set its value to on. However, if you have this flag enabled, we strongly recommend that you either remove the flag from your database or set it to off. For cross-database access, use the Microsoft tutorial for signing stored procedures with a certificate.- Default Value
This flag is deprecated for all SQL Server versions. Going forward, you can't set its value to on.
- Audit Procedure
NOTE: This flag is deprecated for all SQL Server versions. Going forward, you can't set its value to on. However, if you have this flag enabled it should be removed from your database or set to off.From Google Cloud Console1. Go to the Cloud SQL Instances page in the Google Cloud Console.2. Select the instance to open its
Instance Overviewpage3. Ensure the database flagcross db ownership chainingthat has been set is listed under theDatabase flagssection.From Google Cloud CLI1. Ensure the below command returnsofffor every Cloud SQL SQL Server database instance:gcloud sql instances describe <INSTANCE_NAME> --format=json | jq '.settings.databaseFlags[] | select(.name=="cross db ownership chaining")|.value'In the output, database flags are listed under thesettingsas the collectiondatabaseFlags.- Impact Statement
Updating flags may cause the database to restart. This may cause it to unavailable for a short amount of time, so this is best done at a time of low usage. You should also determine if the tables in your databases reference another table without using credentials for that database, as turning off cross database ownership will break this relationship.
- Assessment Status
Automated
- Rationale Statement
Use the
cross db ownershipfor chaining option to configure cross-database ownership chaining for an instance of Microsoft SQL Server. This server option allows you to control cross-database ownership chaining at the database level or to allow cross-database ownership chaining for all databases. Enablingcross db ownershipis not recommended unless all of the databases hosted by the instance of SQL Server must participate in cross-database ownership chaining and you are aware of the security implications of this setting. This recommendation is applicable to SQL Server database instances.- Remediation Procedure
From Google Cloud Console1. Go to the Cloud SQL Instances page in the Google Cloud Console by visiting https://console.cloud.google.com/sql/instances.2. Select the SQL Server instance for which you want to enable to database flag.3. Click
Edit.4. Scroll down to theFlagssection.5. To set a flag that has not been set on the instance before, clickAdd item, choose the flagcross db ownership chainingfrom the drop-down menu, and set its value tooff.6. ClickSave.7. Confirm the changes underFlagson the Overview page.From Google Cloud CLI1. Configure thecross db ownership chainingdatabase flag for every Cloud SQL SQL Server database instance using the below command:gcloud sql instances patch <INSTANCE_NAME> --database-flags "cross db ownership chaining"=offNote: This command will overwrite all database flags previously set. To keep those and add new ones, include the values for all flags to be set on the instance; any flag not specifically included is set to its default value. For flags that do not take a value, specify the flag name followed by an equals sign ("=").- Additional Information
WARNING: This patch modifies database flag values, which may require your instance to be restarted. Check the list of supported flags - https://cloud.google.com/sql/docs/sqlserver/flags - to see if your instance will be restarted when this patch is submitted.Note: Some database flag settings can affect instance availability or stability, and remove the instance from the Cloud SQL SLA. For information about these flags, see Operational Guidelines.Note: Configuring the above flag does not restart the Cloud SQL instance.
6.3.3Ensure 'user Connections' Database Flag for Cloud Sql Sql Server Instance Is Set to a Non-limiting Value1
Attributes
- Profile
Level 1
- Section
6 Cloud SQL Database Services
- Sub Section
6.3 SQL Server
- Description
It is recommended to check the
user connectionsfor a Cloud SQL SQL Server instance to ensure that it is not artificially limiting connections.- Default Value
By default
user connectionsis set to '0' which does not limit the number of connections, giving the server free reign to facilitate a max of 32,767 connections.- Audit Procedure
From Google Cloud Console1. Go to the Cloud SQL Instances page in the Google Cloud Console by visiting https://console.cloud.google.com/sql/instances.2. Select the instance to open its
Instance Overviewpage3. Ensure the database flaguser connectionslisted under theDatabase flagssection is 0.From Google Cloud CLI1. Ensure the below command returns a value of 0, for every Cloud SQL SQL Server database instance.gcloud sql instances describe <INSTANCE_NAME> --format=json | jq '.settings.databaseFlags[] | select(.name=="user connections")|.value'- Impact Statement
Setting custom flags via command line on certain instances will cause all omitted flags to be reset to defaults. This may cause you to lose custom flags and could result in unforeseen complications or instance restarts. Because of this, it is recommended you apply these flags changes during a period of low usage.
- Assessment Status
Automated
- Rationale Statement
The
user connectionsoption specifies the maximum number of simultaneous user connections that are allowed on an instance of SQL Server. The actual number of user connections allowed also depends on the version of SQL Server that you are using, and also the limits of your application or applications and hardware. SQL Server allows a maximum of 32,767 user connections. Because user connections is by default a self-configuring value, with SQL Server adjusting the maximum number of user connections automatically as needed, up to the maximum value allowable. For example, if only 10 users are logged in, 10 user connection objects are allocated. In most cases, you do not have to change the value for this option. The default is 0, which means that the maximum (32,767) user connections are allowed. However if there is a number defined here that limits connections, SQL Server will not allow anymore above this limit. If the connections are at the limit, any new requests will be dropped, potentially causing lost data or outages for those using the database.- Remediation Procedure
From Google Cloud Console1. Go to the Cloud SQL Instances page in the Google Cloud Console by visiting https://console.cloud.google.com/sql/instances.2. Select the SQL Server instance for which you want to enable to database flag.3. Click
Edit.4. Scroll down to theFlagssection.5. To set a flag that has not been set on the instance before, clickAdd item, choose the flaguser connectionsfrom the drop-down menu, and set its value to your organization recommended value.6. ClickSaveto save your changes.7. Confirm your changes underFlagson the Overview page.From Google Cloud CLI1. Configure theuser connectionsdatabase flag for every Cloud SQL SQL Server database instance using the below command.gcloud sql instances patch <INSTANCE_NAME> --database-flags "user connections=[0-32,767]"Note: This command will overwrite all database flags previously set. To keep those and add new ones, include the values for all flags you want set on the instance; any flag not specifically included is set to its default value. For flags that do not take a value, specify the flag name followed by an equals sign ("=").- Additional Information
WARNING: This patch modifies database flag values, which may require your instance to be restarted. Check the list of supported flags - https://cloud.google.com/sql/docs/sqlserver/flags - to see if your instance will be restarted when this patch is submitted.Note: some database flag settings can affect instance availability or stability, and remove the instance from the Cloud SQL SLA. For information about these flags, see Operational Guidelines.Note: Configuring the above flag does not restart the Cloud SQL instance.
6.3.4Ensure 'user options' database flag for Cloud SQL SQL Server instance is not configured1
Attributes
- Profile
Level 1
- Section
6 Cloud SQL Database Services
- Sub Section
6.3 SQL Server
- Description
It is recommended that,
user optionsdatabase flag for Cloud SQL SQL Server instance should not be configured.- Default Value
By default 'user options' is not configured.
- Audit Procedure
From Google Cloud Console1. Go to the Cloud SQL Instances page in the Google Cloud Console by visiting https://console.cloud.google.com/sql/instances.2. Select the instance to open its
Instance Overviewpage3. Ensure the database flaguser optionsthat has been set is not listed under theDatabase flagssection.From Google Cloud CLI1. Ensure the below command returns empty result for every Cloud SQL SQL Server database instancegcloud sql instances describe <INSTANCE_NAME> --format=json | jq '.settings.databaseFlags[] | select(.name=="user options")|.value'In the output, database flags are listed under thesettingsas the collectiondatabaseFlags.- Impact Statement
Setting custom flags via command line on certain instances will cause all omitted flags to be reset to defaults. This may cause you to lose custom flags and could result in unforeseen complications or instance restarts. Because of this, it is recommended you apply these flags changes during a period of low usage.
- Assessment Status
Automated
- Rationale Statement
The
user optionsoption specifies global defaults for all users. A list of default query processing options is established for the duration of a user's work session. The user options option allows you to change the default values of the SET options (if the server's default settings are not appropriate).A user can override these defaults by using the SET statement. You can configure user options dynamically for new logins. After you change the setting of user options, new login sessions use the new setting; current login sessions are not affected. This recommendation is applicable to SQL Server database instances.- Remediation Procedure
From Google Cloud Console1. Go to the Cloud SQL Instances page in the Google Cloud Console by visiting https://console.cloud.google.com/sql/instances.2. Select the SQL Server instance for which you want to enable to database flag.3. Click
Edit.4. Scroll down to theFlagssection.5. Click the X nextuser optionsflag shown6. ClickSaveto save your changes.7. Confirm your changes underFlagson the Overview page.From Google Cloud CLI1. List all Cloud SQL database Instancesgcloud sql instances list2. Clear theuser optionsdatabase flag for every Cloud SQL SQL Server database instance using either of the below commands.Clearing all flags to their default valuegcloud sql instances patch <INSTANCE_NAME> --clear-database-flagsORTo clear onlyuser optionsdatabase flag, configure the database flag by overriding theuser options. Excludeuser optionsflag and its value, and keep all other flags you want to configure.gcloud sql instances patch <INSTANCE_NAME> --database-flags [FLAG1=VALUE1,FLAG2=VALUE2]Note: This command will overwrite all database flags previously set. To keep those and add new ones, include the values for all flags you want set on the instance; any flag not specifically included is set to its default value. For flags that do not take a value, specify the flag name followed by an equals sign ("=").- Additional Information
WARNING: This patch modifies database flag values, which may require your instance to be restarted. Check the list of supported flags - https://cloud.google.com/sql/docs/sqlserver/flags - to see if your instance will be restarted when this patch is submitted.Note: some database flag settings can affect instance availability or stability, and remove the instance from the Cloud SQL SLA. For information about these flags, see Operational Guidelines.Note: Configuring the above flag does not restart the Cloud SQL instance.
6.3.5Ensure 'remote access' database flag for Cloud SQL SQL Server instance is set to 'off'1
Attributes
- Profile
Level 1
- Section
6 Cloud SQL Database Services
- Sub Section
6.3 SQL Server
- Description
It is recommended to set
remote accessdatabase flag for Cloud SQL SQL Server instance tooff.- Default Value
By default 'remote access' is 'on'.
- Audit Procedure
From Google Cloud Console1. Go to the Cloud SQL Instances page in the Google Cloud Console by visiting https://console.cloud.google.com/sql/instances.2. Select the instance to open its
Instance Overviewpage3. Ensure the database flagremote accessthat has been set is listed under theDatabase flagssection.From Google Cloud CLI1. Ensure the below command returnsofffor every Cloud SQL SQL Server database instancegcloud sql instances describe <INSTANCE_NAME> --format=json | jq '.settings.databaseFlags[] | select(.name=="remote access")|.value'In the output, database flags are listed under thesettingsas the collectiondatabaseFlags.- Impact Statement
Setting custom flags via command line on certain instances will cause all omitted flags to be reset to defaults. This may cause you to lose custom flags and could result in unforeseen complications or instance restarts. Because of this, it is recommended you apply these flags changes during a period of low usage.
- Assessment Status
Automated
- Rationale Statement
The
remote accessoption controls the execution of stored procedures from local or remote servers on which instances of SQL Server are running. This default value for this option is 1. This grants permission to run local stored procedures from remote servers or remote stored procedures from the local server. To prevent local stored procedures from being run from a remote server or remote stored procedures from being run on the local server, this must be disabled. The Remote Access option controls the execution of local stored procedures on remote servers or remote stored procedures on local server. 'Remote access' functionality can be abused to launch a Denial-of-Service (DoS) attack on remote servers by off-loading query processing to a target, hence this should be disabled. This recommendation is applicable to SQL Server database instances.- Remediation Procedure
From Google Cloud Console1. Go to the Cloud SQL Instances page in the Google Cloud Console by visiting https://console.cloud.google.com/sql/instances.2. Select the SQL Server instance for which you want to enable to database flag.3. Click
Edit.4. Scroll down to theFlagssection.5. To set a flag that has not been set on the instance before, clickAdd item, choose the flagremote accessfrom the drop-down menu, and set its value tooff.6. ClickSaveto save your changes.7. Confirm your changes underFlagson the Overview page.From Google Cloud CLI1. Configure theremote accessdatabase flag for every Cloud SQL SQL Server database instance using the below commandgcloud sql instances patch <INSTANCE_NAME> --database-flags "remote access"=offNote: This command will overwrite all database flags previously set. To keep those and add new ones, include the values for all flags you want set on the instance; any flag not specifically included is set to its default value. For flags that do not take a value, specify the flag name followed by an equals sign ("=").- Additional Information
WARNING: This patch modifies database flag values, which may require your instance to be restarted. Check the list of supported flags - https://cloud.google.com/sql/docs/sqlserver/flags - to see if your instance will be restarted when this patch is submitted.Note: some database flag settings can affect instance availability or stability, and remove the instance from the Cloud SQL SLA. For information about these flags, see Operational Guidelines.Note: Configuring the above flag does not restart the Cloud SQL instance.
6.3.6Ensure '3625 (trace flag)' database flag for all Cloud SQL Server instances is set to 'on'1
Attributes
- Profile
Level 1
- Section
6 Cloud SQL Database Services
- Sub Section
6.3 SQL Server
- Description
It is recommended to set
3625 (trace flag)database flag for Cloud SQL SQL Server instance toon.- Default Value
MySQL implementations by default have trace flags turned off, as they are used for logging purposes.
- Audit Procedure
From Google Cloud Console1. Go to the Cloud SQL Instances page in the Google Cloud Console by visiting https://console.cloud.google.com/sql/instances.2. Select the instance to open its
Instance Overviewpage3. Ensure the database flag3625that has been set is listed under theDatabase flagssection.From Google Cloud CLI1. Ensure the below command returnsonfor every Cloud SQL SQL Server database instancegcloud sql instances describe <INSTANCE_NAME> --format=json | jq '.settings.databaseFlags[] | select(.name=="3625")|.value'- Impact Statement
Changing flags on a database may cause it to be restarted. The best time to do this is at a time where there is low usage.
- Assessment Status
Automated
- Rationale Statement
Microsoft SQL Trace Flags are frequently used to diagnose performance issues or to debug stored procedures or complex computer systems, but they may also be recommended by Microsoft Support to address behavior that is negatively impacting a specific workload. All documented trace flags and those recommended by Microsoft Support are fully supported in a production environment when used as directed.
3625(trace log)Limits the amount of information returned to users who are not members of the sysadmin fixed server role, by masking the parameters of some error messages using '******'. Setting this in a Google Cloud flag for the instance allows for security through obscurity and prevents the disclosure of sensitive information, hence this is recommended to set this flag globally to on to prevent the flag having been left off, or changed by bad actors. This recommendation is applicable to SQL Server database instances.- Remediation Procedure
From Google Cloud Console1. Go to the Cloud SQL Instances page in the Google Cloud Console by visiting https://console.cloud.google.com/sql/instances.2. Select the SQL Server instance for which you want to enable to database flag.3. Click
Edit.4. Scroll down to theFlagssection.5. To set a flag that has not been set on the instance before, clickAdd item, choose the flag3625from the drop-down menu, and set its value toon.6. ClickSaveto save your changes.7. Confirm your changes underFlagson the Overview page.From Google Cloud CLI1. Configure the3625database flag for every Cloud SQL SQL Server database instance using the below command.gcloud sql instances patch <INSTANCE_NAME> --database-flags "3625=on"Note: This command will overwrite all database flags previously set. To keep those and add new ones, include the values for all flags you want set on the instance; any flag not specifically included is set to its default value. For flags that do not take a value, specify the flag name followed by an equals sign ("=").- Additional Information
WARNING: This patch modifies database flag values, which may require your instance to be restarted. Check the list of supported flags - https://cloud.google.com/sql/docs/sqlserver/flags - to see if your instance will be restarted when this patch is submitted.Note: some database flag settings can affect instance availability or stability, and remove the instance from the Cloud SQL SLA. For information about these flags, see Operational Guidelines.Note: Configuring the above flag restarts the Cloud SQL instance.
6.3.7Ensure that the 'contained database authentication' database flag for Cloud SQL on the SQL Server instance is not set to 'on'1
Attributes
- Profile
Level 1
- Section
6 Cloud SQL Database Services
- Sub Section
6.3 SQL Server
- Description
It is recommended not to set
contained database authenticationdatabase flag for Cloud SQL on the SQL Server instance toon.- Audit Procedure
From Google Cloud Console1. Go to the Cloud SQL Instances page in the Google Cloud Console by visiting https://console.cloud.google.com/sql/instances.2. Select the instance to open its
Instance Overviewpage3. Under the 'Database flags' section, if the database flagcontained database authenticationis present, then ensure that it is not set to 'on'.From Google Cloud CLI1. Ensure the below command doesn't returnonfor any Cloud SQL for SQL Server database instance.gcloud sql instances describe <INSTANCE_NAME> --format=json | jq '.settings.databaseFlags[] | select(.name=="contained database authentication")|.value'- Impact Statement
When
contained database authenticationis off (0) for the instance, contained databases cannot be created, or attached to the Database Engine. Turning on logging will increase the required storage over time. Mismanaged logs may cause your storage costs to increase. Setting custom flags via command line on certain instances will cause all omitted flags to be reset to defaults. This may cause you to lose custom flags and could result in unforeseen complications or instance restarts. Because of this, it is recommended you apply these flags changes during a period of low usage.- Assessment Status
Automated
- Rationale Statement
A contained database includes all database settings and metadata required to define the database and has no configuration dependencies on the instance of the Database Engine where the database is installed. Users can connect to the database without authenticating a login at the Database Engine level. Isolating the database from the Database Engine makes it possible to easily move the database to another instance of SQL Server. Contained databases have some unique threats that should be understood and mitigated by SQL Server Database Engine administrators. Most of the threats are related to the USER WITH PASSWORD authentication process, which moves the authentication boundary from the Database Engine level to the database level, hence this is recommended not to enable this flag. This recommendation is applicable to SQL Server database instances.
- Remediation Procedure
From Google Cloud Console1. Go to the Cloud SQL Instances page in the Google Cloud Console by visiting https://console.cloud.google.com/sql/instances.2. Select the SQL Server instance for which you want to enable to database flag.3. Click
Edit.4. Scroll down to theFlagssection.5.If the flagcontained database authenticationis present and its value is set to 'on', then change it to 'off'.6. ClickSave.7. Confirm the changes underFlagson the Overview page.From Google Cloud CLI1. If any Cloud SQL for SQL Server instance has the database flagcontained database authenticationset to 'on', then change it to 'off' using the below command:gcloud sql instances patch <INSTANCE_NAME> --database-flags "contained database authentication=off"Note: This command will overwrite all database flags previously set. To keep those and add new ones, include the values for all flags to be set on the instance; any flag not specifically included is set to its default value. For flags that do not take a value, specify the flag name followed by an equals sign ("=").- Additional Information
WARNING: This patch modifies database flag values, which may require your instance to be restarted. Check the list of supported flags - https://cloud.google.com/sql/docs/sqlserver/flags - to see if your instance will be restarted when this patch is submitted.Note: Some database flag settings can affect instance availability or stability, and remove the instance from the Cloud SQL SLA. For information about these flags, see Operational Guidelines.Note: Configuring the above flag does not restart the Cloud SQL instance.
6.4Ensure That the Cloud SQL Database Instance Requires All Incoming Connections To Use SSL1
Attributes
- Profile
Level 1
- Section
6 Cloud SQL Database Services
- Description
It is recommended to enforce all incoming connections to SQL database instance to use SSL.
- Default Value
By default parameter
settings: ipConfiguration: sslModeis not set which is equivalent tosslMode:ALLOW_UNENCRYPTED_AND_ENCRYPTED.- Audit Procedure
From Google Cloud Console1. Go to https://console.cloud.google.com/sql/instances.2. Click on an instance name to see its configuration overview.3. In the left-side panel, select
Connections.3. In theSecuritysection, ensure thatAllow only SSL connectionsoption is selected.From Google Cloud CLI1. Get the detailed configuration for every SQL database instance using the following command:gcloud sql instances list --format=jsonEnsure that sectionsettings: ipConfigurationhas the parametersslModeset toENCRYPTED_ONLY.- Impact Statement
After enforcing SSL requirement for connections, existing client will not be able to communicate with Cloud SQL database instance unless they use SSL encrypted connections to communicate to Cloud SQL database instance.
- Assessment Status
Automated
- Rationale Statement
SQL database connections if successfully trapped (MITM); can reveal sensitive data like credentials, database queries, query outputs etc.For security, it is recommended to always use SSL encryption when connecting to your instance.This recommendation is applicable for Postgresql, MySql generation 1, MySql generation 2 and SQL Server 2017 instances.
- Remediation Procedure
From Google Cloud Console1. Go to https://console.cloud.google.com/sql/instances.2. Click on an instance name to see its configuration overview.3. In the left-side panel, select
Connections.3. In thesecuritysection, select SSL mode asAllow only SSL connections.4. UnderConfigure SSL server certificatesclickCreate new certificateand save the settingFrom Google Cloud CLITo enforce SSL encryption for an instance run the command:gcloud sql instances patch INSTANCE_NAME --ssl-mode= ENCRYPTED_ONLYNote:RESTARTis required for type MySQL Generation 1 Instances (backendType: FIRST_GEN) to get this configuration in effect.- Additional Information
By default
Settings: ipConfigurationhas noauthorizedNetworksset/configured. In that case even if by defaultsslModeis not set, which is equivalent tosslMode:ALLOW_UNENCRYPTED_AND_ENCRYPTEDthere is no risk as instance cannot be accessed outside of the network unlessauthorizedNetworksare configured. However, If default forsslModeis not updated toENCRYPTED_ONLYanyauthorizedNetworkscreated later on will not enforce SSL only connection.
6.5Ensure That Cloud SQL Database Instances Do Not Implicitly Whitelist All Public IP Addresses1
Attributes
- Profile
Level 1
- Section
6 Cloud SQL Database Services
- Description
Database Server should accept connections only from trusted Network(s)/IP(s) and restrict access from public IP addresses.
- Default Value
By default, authorized networks are not configured. Remote connection to Cloud SQL database instance is not possible unless authorized networks are configured.
- Audit Procedure
From Google Cloud Console1. Go to the Cloud SQL Instances page in the Google Cloud Console by visiting https://console.cloud.google.com/sql/instances.2. Click the instance name to open its
Instance detailspage.3. Under theConfigurationsection clickEdit configurations4. UnderConfiguration optionsexpand theConnectivitysection.5. Ensure that no authorized network is configured to allow0.0.0.0/0.From Google Cloud CLI1. Get detailed configuration for every Cloud SQL database instance.gcloud sql instances list --format=jsonEnsure that the sectionsettings: ipConfiguration : authorizedNetworksdoes not have any parametervaluecontaining0.0.0.0/0.- Impact Statement
The Cloud SQL database instance would not be available to public IP addresses.
- Assessment Status
Automated
- Rationale Statement
To minimize attack surface on a Database server instance, only trusted/known and required IP(s) should be white-listed to connect to it.An authorized network should not have IPs/networks configured to
0.0.0.0/0which will allow access to the instance from anywhere in the world. Note that authorized networks apply only to instances with public IPs.- Remediation Procedure
From Google Cloud Console1. Go to the Cloud SQL Instances page in the Google Cloud Console by visiting https://console.cloud.google.com/sql/instances.2. Click the instance name to open its
Instance detailspage.3. Under theConfigurationsection clickEdit configurations4. UnderConfiguration optionsexpand theConnectivitysection.5. Click thedeleteicon for the authorized network0.0.0.0/0.6. ClickSaveto update the instance.From Google Cloud CLIUpdate the authorized network list by dropping off any addresses.gcloud sql instances patch <INSTANCE_NAME> --authorized-networks=IP_ADDR1,IP_ADDR2...**Prevention:**To prevent new SQL instances from being configured to accept incoming connections from any IP addresses, set up aRestrict Authorized Networks on Cloud SQL instancesOrganization Policy at: https://console.cloud.google.com/iam-admin/orgpolicies/sql-restrictAuthorizedNetworks.- Additional Information
There is no IPv6 configuration found for Google cloud SQL server services.
6.6Ensure That Cloud SQL Database Instances Do Not Have Public IPs1
Attributes
- Profile
Level 2
- Section
6 Cloud SQL Database Services
- Description
It is recommended to configure Second Generation Sql instance to use private IPs instead of public IPs.
- Default Value
By default, Cloud Sql instances have a public IP.
- Audit Procedure
From Google Cloud Console1. Go to the Cloud SQL Instances page in the Google Cloud Console: https://console.cloud.google.com/sql/instances2. Ensure that every instance has a private IP address and no public IP address configured.From Google Cloud CLI1. List all Cloud SQL database instances using the following command:
gcloud sql instances list2. For every instance of typeinstanceType: CLOUD_SQL_INSTANCEwithbackendType: SECOND_GEN, get detailed configuration. Ignore instances of typeREAD_REPLICA_INSTANCEbecause these instances inherit their settings from the primary instance. Also, note that first generation instances cannot be configured to have a private IP address.gcloud sql instances describe <INSTANCE_NAME>3. Ensure that the settingipAddresseshas an IP address configured oftype: PRIVATEand has no IP address oftype: PRIMARY.PRIMARYIP addresses are public addresses. An instance can have both a private and public address at the same time. Note also that you cannot use private IP with First Generation instances.- Impact Statement
Removing the public IP address on SQL instances may break some applications that relied on it for database connectivity.
- Assessment Status
Automated
- Rationale Statement
To lower the organization's attack surface, Cloud SQL databases should not have public IPs. Private IPs provide improved network security and lower latency for your application.
- Remediation Procedure
From Google Cloud Console1. Go to the Cloud SQL Instances page in the Google Cloud Console: https://console.cloud.google.com/sql/instances2. Click the instance name to open its Instance details page.3. Select the
Connectionstab.4. Deselect thePublic IPcheckbox.5. ClickSaveto update the instance.From Google Cloud CLI1. For every instance remove its public IP and assign a private IP instead:gcloud sql instances patch <INSTANCE_NAME> --network=<VPC_NETWORK_NAME> --no-assign-ip2. Confirm the changes using the following command::gcloud sql instances describe <INSTANCE_NAME>**Prevention:**To prevent new SQL instances from getting configured with public IP addresses, set up aRestrict Public IP access on Cloud SQL instancesOrganization policy at: https://console.cloud.google.com/iam-admin/orgpolicies/sql-restrictPublicIp.- Additional Information
Replicas inherit their private IP status from their primary instance. You cannot configure a private IP directly on a replica.
6.7Ensure That Cloud SQL Database Instances Are Configured With Automated Backups1
Attributes
- Profile
Level 1
- Section
6 Cloud SQL Database Services
- Description
It is recommended to have all SQL database instances set to enable automated backups.
- Default Value
By default, automated backups are not configured for Cloud SQL instances. Data backup is not possible on any Cloud SQL instance unless Automated Backup is configured.
- Audit Procedure
From Google Cloud Console1. Go to the Cloud SQL Instances page in the Google Cloud Console by visiting https://console.cloud.google.com/sql/instances.2. Click the instance name to open its instance details page.3. Go to the
Backupsmenu.4. Ensure thatAutomated backupsis set toEnabledandBackup timeis mentioned.From Google Cloud CLI1. List all Cloud SQL database instances using the following command:gcloud sql instances list --format=json | jq '. | map(select(.instanceType != "READ_REPLICA_INSTANCE")) | .[].name'NOTE: gcloud command has been added with the filter to exclude read-replicas instances, as GCP do not provide Automated Backups for read-replica instances.2. Ensure that the below command returnsTruefor every Cloud SQL database instance.gcloud sql instances describe <INSTANCE_NAME> --format="value('Enabled':settings.backupConfiguration.enabled)"- Impact Statement
Automated Backups will increase required size of storage and costs associated with it.
- Assessment Status
Automated
- Rationale Statement
Backups provide a way to restore a Cloud SQL instance to recover lost data or recover from a problem with that instance. Automated backups need to be set for any instance that contains data that should be protected from loss or damage. This recommendation is applicable for SQL Server, PostgreSql, MySql generation 1 and MySql generation 2 instances.
- Remediation Procedure
From Google Cloud Console1. Go to the Cloud SQL Instances page in the Google Cloud Console by visiting https://console.cloud.google.com/sql/instances.2. Select the instance where the backups need to be configured.3. Click
Edit.4. In theBackupssection, checkEnable automated backups', and choose a backup window.5. ClickSave.**From Google Cloud CLI**1. List all Cloud SQL database instances using the following command:```gcloud sql instances list --format=json | jq '. | map(select(.instanceType != "READ_REPLICA_INSTANCE")) | .[].name' ```NOTE: gcloud command has been added with the filter to exclude read-replicas instances, as GCP do not provide Automated Backups for read-replica instances.2. EnableAutomated backupsfor every Cloud SQL database instance using the below command:```gcloud sql instances patch <INSTANCE_NAME> --backup-start-time <[HH:MM]>```Thebackup-start-time` parameter is specified in 24-hour time, in the UTC±00 time zone, and specifies the start of a 4-hour backup window. Backups can start any time during the backup window.
7 BigQuery43
7.1Ensure That BigQuery Datasets Are Not Anonymously or Publicly Accessible1
Attributes
- Profile
Level 1
- Section
7 BigQuery
- Description
It is recommended that the IAM policy on BigQuery datasets does not allow anonymous and/or public access.
- Default Value
By default, BigQuery datasets are not publicly accessible.
- Audit Procedure
From Google Cloud Console1. Go to
BigQueryby visiting: https://console.cloud.google.com/bigquery.2. Select a dataset fromResources.3. ClickSHARINGnear the right side of the window and selectPermissions.4. Validate that none of the attached roles containallUsersorallAuthenticatedUsers.From Google Cloud CLIList the name of all datasets.bq lsRetrieve each dataset details using the following command:bq show PROJECT_ID:DATASET_NAMEEnsure thatallUsersandallAuthenticatedUsershave not been granted access to the dataset.- Impact Statement
The dataset is not publicly accessible. Explicit modification of IAM privileges would be necessary to make them publicly accessible.
- Assessment Status
Automated
- Rationale Statement
Granting permissions to
allUsersorallAuthenticatedUsersallows anyone to access the dataset. Such access might not be desirable if sensitive data is being stored in the dataset. Therefore, ensure that anonymous and/or public access to a dataset is not allowed.- Remediation Procedure
From Google Cloud Console1. Go to
BigQueryby visiting: https://console.cloud.google.com/bigquery.2. Select the dataset from 'Resources'.3. ClickSHARINGnear the right side of the window and selectPermissions.4. Review each attached role.5. Click the delete icon for each memberallUsersorallAuthenticatedUsers. On the popup clickRemove.From Google Cloud CLIList the name of all datasets.bq lsRetrieve the data set details:bq show --format=prettyjson PROJECT_ID:DATASET_NAME > PATH_TO_FILEIn the access section of the JSON file, update the dataset information to remove all roles containingallUsersorallAuthenticatedUsers.Update the dataset:bq update --source PATH_TO_FILE PROJECT_ID:DATASET_NAME**Prevention:**You can prevent Bigquery dataset from becoming publicly accessible by setting up theDomain restricted sharingorganization policy at: https://console.cloud.google.com/iam-admin/orgpolicies/iam-allowedPolicyMemberDomains .
7.2Ensure That All BigQuery Tables Are Encrypted With Customer-Managed Encryption Key (CMEK)1
Attributes
- Profile
Level 2
- Section
7 BigQuery
- Description
BigQuery by default encrypts the data as rest by employing
Envelope Encryptionusing Google managed cryptographic keys. The data is encrypted using thedata encryption keysand data encryption keys themselves are further encrypted usingkey encryption keys. This is seamless and do not require any additional input from the user. However, if you want to have greater control, Customer-managed encryption keys (CMEK) can be used as encryption key management solution for BigQuery Data Sets. If CMEK is used, the CMEK is used to encrypt the data encryption keys instead of using google-managed encryption keys.- Default Value
Google Managed keys are used as
key encryption keys.- Audit Procedure
From Google Cloud Console1. Go to
Analytics2. Go toBigQuery3. UnderSQL Workspace, select the project4. Select Data Set, select the table5. Go toDetailstab6. UnderTable info, verifyCustomer-managed keyis present.7. Repeat for each table in all data sets for all projects.From Google Cloud CLIList all dataset namesbq lsUse the following command to view the table details. Verify thekmsKeyNameis present.bq show <table_object>- Impact Statement
Using Customer-managed encryption keys (CMEK) will incur additional labor-hour investment to create, protect, and manage the keys.
- Assessment Status
Automated
- Rationale Statement
BigQuery by default encrypts the data as rest by employing
Envelope Encryptionusing Google managed cryptographic keys. This is seamless and does not require any additional input from the user.For greater control over the encryption, customer-managed encryption keys (CMEK) can be used as encryption key management solution for BigQuery tables. The CMEK is used to encrypt the data encryption keys instead of using google-managed encryption keys. BigQuery stores the table and CMEK association and the encryption/decryption is done automatically.Applying the Default Customer-managed keys on BigQuery data sets ensures that all the new tables created in the future will be encrypted using CMEK but existing tables need to be updated to use CMEK individually.Note: Google does not store your keys on its servers and cannot access your protected data unless you provide the key. This also means that if you forget or lose your key, there is no way for Google to recover the key or to recover any data encrypted with the lost key.- Remediation Procedure
From Google Cloud CLIUse the following command to copy the data. The source and the destination needs to be same in case copying to the original table.
bq cp --destination_kms_key <customer_managed_key> source_dataset.source_table destination_dataset.destination_table
7.3Ensure That a Default Customer-Managed Encryption Key (CMEK) Is Specified for All BigQuery Data Sets1
Attributes
- Profile
Level 2
- Section
7 BigQuery
- Description
BigQuery by default encrypts the data as rest by employing
Envelope Encryptionusing Google managed cryptographic keys. The data is encrypted using thedata encryption keysand data encryption keys themselves are further encrypted usingkey encryption keys. This is seamless and do not require any additional input from the user. However, if you want to have greater control, Customer-managed encryption keys (CMEK) can be used as encryption key management solution for BigQuery Data Sets.- Default Value
Google Managed keys are used as
key encryption keys.- Audit Procedure
From Google Cloud Console1. Go to
Analytics2. Go toBigQuery3. UnderAnalysisclick onSQL Workspaces, select the project4. Select Data Set5. EnsureCustomer-managed keyis present underDataset infosection.6. Repeat for each data set in all projects.From Google Cloud CLIList all dataset namesbq lsUse the following command to view each dataset details.bq show <data_set_object>Verify thekmsKeyNameis present.- Impact Statement
Using Customer-managed encryption keys (CMEK) will incur additional labor-hour investment to create, protect, and manage the keys.
- Assessment Status
Automated
- Rationale Statement
BigQuery by default encrypts the data as rest by employing
Envelope Encryptionusing Google managed cryptographic keys. This is seamless and does not require any additional input from the user.For greater control over the encryption, customer-managed encryption keys (CMEK) can be used as encryption key management solution for BigQuery Data Sets. Setting a Default Customer-managed encryption key (CMEK) for a data set ensure any tables created in future will use the specified CMEK if none other is provided.Note: Google does not store your keys on its servers and cannot access your protected data unless you provide the key. This also means that if you forget or lose your key, there is no way for Google to recover the key or to recover any data encrypted with the lost key.- Remediation Procedure
From Google Cloud CLIThe default CMEK for existing data sets can be updated by specifying the default key in the
EncryptionConfiguration.kmsKeyNamefield when calling thedatasets.insertordatasets.patchmethods
7.4Ensure all data in BigQuery has been classified0
Attributes
- Profile
Level 2
- Section
7 BigQuery
- Description
BigQuery tables can contain sensitive data that for security purposes should be discovered, monitored, classified, and protected. Google Cloud's Sensitive Data Protection tools can automatically provide data classification of all BigQuery data across an organization.
- Audit Procedure
- Go to Cloud DLP by visiting https://console.cloud.google.com/dlp/landing/dataProfiles/configurations.2. Verify there is a discovery scan configuration either for the organization or project.
- Impact Statement
There is a cost associated with using Sensitive Data Protection. There is also typically a cost associated with 3rd party tools that perform similar processes and protection.
- Assessment Status
Manual
- Rationale Statement
Using a cloud service or 3rd party software to continuously monitor and automate the process of data discovery and classification for BigQuery tables is an important part of protecting the data.Sensitive Data Protection is a fully managed data protection and data privacy platform that uses machine learning and pattern matching to discover and classify sensitive data in Google Cloud.
- Remediation Procedure
**Enable profiling:**1. Go to Cloud DLP by visiting https://console.cloud.google.com/dlp/landing/dataProfiles/configurations1. Click "Create Configuration"1. For projects follow https://cloud.google.com/dlp/docs/profile-project. For organizations or folders follow https://cloud.google.com/dlp/docs/profile-org-folder Review findings:- Columns or tables with high data risk have evidence of sensitive information without additional protections. To lower the data risk score, consider doing the following:- For columns containing sensitive data, apply a BigQuery policy tag to restrict access to accounts with specific access rights.- De-identify the raw sensitive data using de-identification techniques like masking and tokenization.Incorporate findings into your security and governance operations:- Enable sending findings into your security and posture services. You can publish data profiles to Security Command Center and Chronicle.- Automate remediation or enable alerting of new or changed data risk with Pub/Sub.
8 Dataproc11
8.1Ensure that Dataproc Cluster is encrypted using Customer-Managed Encryption Key1
Attributes
- Profile
Level 2
- Section
8 Dataproc
- Description
When you use Dataproc, cluster and job data is stored on Persistent Disks (PDs) associated with the Compute Engine VMs in your cluster and in a Cloud Storage staging bucket. This PD and bucket data is encrypted using a Google-generated data encryption key (DEK) and key encryption key (KEK). The CMEK feature allows you to create, use, and revoke the key encryption key (KEK). Google still controls the data encryption key (DEK).
- Audit Procedure
From Google Cloud Console1. Login to the GCP Console and navigate to the Dataproc Cluster page by visiting https://console.cloud.google.com/dataproc/clusters.1. Select the project from the project dropdown list.1. On the
Dataproc Clusterspage, select the cluster and click on the Name attribute value that you want to examine.1. On thedetailspage, select theConfigurationstab.1. On theConfigurationstab, check theEncryption typeconfiguration attribute value. If the value is set toGoogle-managed key, then Dataproc Cluster is not encrypted with Customer managed encryption keys.Repeat step no. 3 - 5 for other Dataproc Clusters available in the selected project.6. Change the project from the project dropdown list and repeat the audit procedure for other projects.From Google Cloud CLI1. Run clusters list command to list all the Dataproc Clusters available in the region:gcloud dataproc clusters list --region='us-central1'2. Run clusters describe command to get the key details of the selected cluster:gcloud dataproc clusters describe <cluster_name> --region=us-central1 --flatten=config.encryptionConfig.gcePdKmsKeyName3. If the above command output return "null", then the selected cluster is not encrypted with Customer managed encryption keys.4. Repeat step no. 2 and 3 for other Dataproc Clusters available in the selected region. Change the region by updating --region and repeat step no. 2 for other clusters available in the project. Change the project by running the below command and repeat the audit procedure for other Dataproc clusters available in other projects:gcloud config set project <project_ID>"- Impact Statement
Using Customer Managed Keys involves additional overhead in maintenance by administrators.
- Assessment Status
Automated
- Rationale Statement
"Cloud services offer the ability to protect data related to those services using encryption keys managed by the customer within Cloud KMS. These encryption keys are called customer-managed encryption keys (CMEK). When you protect data in Google Cloud services with CMEK, the CMEK key is within your control.
- Remediation Procedure
From Google Cloud Console1. Login to the GCP Console and navigate to the Dataproc Cluster page by visiting https://console.cloud.google.com/dataproc/clusters.1. Select the project from the projects dropdown list.1. On the
Dataproc Clusterpage, click on theCreate Clusterto create a new cluster with Customer managed encryption keys.1. OnCreate a clusterpage, perform below steps: - InsideSet up clustersection perform below steps: -In theNametextbox, provide a name for your cluster. - FromLocationselect the location in which you want to deploy a cluster. - Configure other configurations as per your requirements. - InsideConfigure NodesandCustomize clustersection configure the settings as per your requirements. - InsideManage securitysection, perform below steps: - FromEncryption, selectCustomer-managed key. - Select a customer-managed key from dropdown list. - Ensure that the selected KMS Key have Cloud KMS CryptoKey Encrypter/Decrypter role assign to Dataproc Cluster service account ("serviceAccount:service-<project_number>@compute-system.iam.gserviceaccount.com"). - Click onCreateto create a cluster. - Once the cluster is created migrate all your workloads from the older cluster to the new cluster and delete the old cluster by performing the below steps: - On theClusterspage, select the old cluster and click onDelete cluster. - On theConfirm deletionwindow, click onConfirmto delete the cluster. - Repeat step above for other Dataproc clusters available in the selected project. - Change the project from the project dropdown list and repeat the remediation procedure for other Dataproc clusters available in other projects.From Google Cloud CLIBefore creating cluster ensure that the selected KMS Key have Cloud KMS CryptoKey Encrypter/Decrypter role assign to Dataproc Cluster service account ("serviceAccount:service-<project_number>@compute-system.iam.gserviceaccount.com").Run clusters create command to create new cluster with customer-managed key:gcloud dataproc clusters create <cluster_name> --region=us-central1 --gce-pd-kms-key=<key_resource_name>The above command will create a new cluster in the selected region.Once the cluster is created migrate all your workloads from the older cluster to the new cluster and Run clusters delete command to delete cluster:gcloud dataproc clusters delete <cluster_name> --region=us-central1Repeat step no. 1 to create a new Dataproc cluster.Change the project by running the below command and repeat the remediation procedure for other projects:gcloud config set project <project_ID>"