Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var CheckDiskEncryptionCustomerKey = rules.Register( rules.Rule{ AVDID: "AVD-GCP-0034", Provider: provider.GoogleProvider, Service: "compute", ShortCode: "disk-encryption-customer-key", Summary: "Disks should be encrypted with customer managed encryption keys", Impact: "Using unmanaged keys does not allow for proper key management.", Resolution: "Use managed keys to encrypt disks.", Explanation: `Using unmanaged keys makes rotation and general management difficult.`, Links: []string{}, Terraform: &rules.EngineMetadata{ GoodExamples: terraformDiskEncryptionCustomerKeyGoodExamples, BadExamples: terraformDiskEncryptionCustomerKeyBadExamples, Links: terraformDiskEncryptionCustomerKeyLinks, RemediationMarkdown: terraformDiskEncryptionCustomerKeyRemediationMarkdown, }, Severity: severity.Low, }, func(s *state.State) (results rules.Results) { for _, disk := range s.Google.Compute.Disks { if disk.Encryption.KMSKeyLink.IsEmpty() { results.Add( "Disk is not encrypted with a customer managed key.", disk.Encryption.KMSKeyLink, ) } } return }, )
View Source
var CheckDiskEncryptionRequired = rules.Register( rules.Rule{ AVDID: "AVD-GCP-0037", Provider: provider.GoogleProvider, Service: "compute", ShortCode: "disk-encryption-no-plaintext-key", Summary: "The encryption key used to encrypt a compute disk has been specified in plaintext.", Impact: "The encryption key should be considered compromised as it is not stored securely.", Resolution: "Reference a managed key rather than include the key in raw format.", Explanation: `Sensitive values such as raw encryption keys should not be included in your Terraform code, and should be stored securely by a secrets manager.`, Links: []string{ "https://cloud.google.com/compute/docs/disks/customer-supplied-encryption", }, Terraform: &rules.EngineMetadata{ GoodExamples: terraformDiskEncryptionNoPlaintextKeyGoodExamples, BadExamples: terraformDiskEncryptionNoPlaintextKeyBadExamples, Links: terraformDiskEncryptionNoPlaintextKeyLinks, RemediationMarkdown: terraformDiskEncryptionNoPlaintextKeyRemediationMarkdown, }, Severity: severity.Critical, }, func(s *state.State) (results rules.Results) { for _, disk := range s.Google.Compute.Disks { if disk.Encryption.RawKey.Len() > 0 { results.Add( "Disk encryption key is supplied in plaintext.", disk.Encryption.RawKey, ) } } return }, )
View Source
var CheckEnableShieldedVMIntegrityMonitoring = rules.Register( rules.Rule{ AVDID: "AVD-GCP-0045", Provider: provider.GoogleProvider, Service: "compute", ShortCode: "enable-shielded-vm-im", Summary: "Instances should have Shielded VM integrity monitoring enabled", Impact: "No visibility of VM instance boot state.", Resolution: "Enable Shielded VM Integrity Monitoring", Explanation: `Integrity monitoring helps you understand and make decisions about the state of your VM instances.`, Links: []string{ "https://cloud.google.com/security/shielded-cloud/shielded-vm#integrity-monitoring", }, Terraform: &rules.EngineMetadata{ GoodExamples: terraformEnableShieldedVmImGoodExamples, BadExamples: terraformEnableShieldedVmImBadExamples, Links: terraformEnableShieldedVmImLinks, RemediationMarkdown: terraformEnableShieldedVmImRemediationMarkdown, }, Severity: severity.Medium, }, func(s *state.State) (results rules.Results) { for _, instance := range s.Google.Compute.Instances { if instance.ShieldedVM.IntegrityMonitoringEnabled.IsFalse() { results.Add( "Instance does not have shielded VM integrity monitoring enabled.", instance.ShieldedVM.IntegrityMonitoringEnabled, ) } } return }, )
View Source
var CheckEnableShieldedVMVTPM = rules.Register( rules.Rule{ AVDID: "AVD-GCP-0041", Provider: provider.GoogleProvider, Service: "compute", ShortCode: "enable-shielded-vm-vtpm", Summary: "Instances should have Shielded VM VTPM enabled", Impact: "Unable to prevent unwanted system state modification", Resolution: "Enable Shielded VM VTPM", Explanation: `The virtual TPM provides numerous security measures to your VM.`, Links: []string{ "https://cloud.google.com/blog/products/identity-security/virtual-trusted-platform-module-for-shielded-vms-security-in-plaintext", }, Terraform: &rules.EngineMetadata{ GoodExamples: terraformEnableShieldedVmVtpmGoodExamples, BadExamples: terraformEnableShieldedVmVtpmBadExamples, Links: terraformEnableShieldedVmVtpmLinks, RemediationMarkdown: terraformEnableShieldedVmVtpmRemediationMarkdown, }, Severity: severity.Medium, }, func(s *state.State) (results rules.Results) { for _, instance := range s.Google.Compute.Instances { if instance.ShieldedVM.VTPMEnabled.IsFalse() { results.Add( "Instance does not have VTPM for shielded VMs enabled.", instance.ShieldedVM.VTPMEnabled, ) } } return }, )
View Source
var CheckEnableVPCFlowLogs = rules.Register( rules.Rule{ AVDID: "AVD-GCP-0029", Provider: provider.GoogleProvider, Service: "compute", ShortCode: "enable-vpc-flow-logs", Summary: "VPC flow logs should be enabled for all subnetworks", Impact: "Limited auditing capability and awareness", Resolution: "Enable VPC flow logs", Explanation: `VPC flow logs record information about all traffic, which is a vital tool in reviewing anomalous traffic.`, Links: []string{}, Terraform: &rules.EngineMetadata{ GoodExamples: terraformEnableVpcFlowLogsGoodExamples, BadExamples: terraformEnableVpcFlowLogsBadExamples, Links: terraformEnableVpcFlowLogsLinks, RemediationMarkdown: terraformEnableVpcFlowLogsRemediationMarkdown, }, Severity: severity.Low, }, func(s *state.State) (results rules.Results) { for _, network := range s.Google.Compute.Networks { for _, subnetwork := range network.Subnetworks { if subnetwork.EnableFlowLogs.IsFalse() { results.Add( "Subnetwork does not have VPC flow logs enabled.", subnetwork.EnableFlowLogs, ) } } } return }, )
View Source
var CheckInstancesDoNotHavePublicIPs = rules.Register( rules.Rule{ AVDID: "AVD-GCP-0031", Provider: provider.GoogleProvider, Service: service, ShortCode: "no-public-ip", Summary: "Instances should not have public IP addresses", Impact: "Direct exposure of an instance to the public internet", Resolution: "Remove public IP", Explanation: `Instances should not be publicly exposed to the internet`, Terraform: &rules.EngineMetadata{ GoodExamples: terraformNoPublicIpGoodExamples, BadExamples: terraformNoPublicIpBadExamples, Links: terraformNoPublicIpLinks, RemediationMarkdown: terraformNoPublicIpRemediationMarkdown, }, Severity: severity.High, Links: []string{ "https://cloud.google.com/compute/docs/ip-addresses#externaladdresses", }, }, func(s *state.State) (results rules.Results) { for _, instance := range s.Google.Compute.Instances { for _, networkInterface := range instance.NetworkInterfaces { if networkInterface.HasPublicIP.IsTrue() { results.Add( "Instance has a public IP allocated.", networkInterface.HasPublicIP, ) } } } return results }, )
View Source
var CheckNoDefaultServiceAccount = rules.Register( rules.Rule{ AVDID: "AVD-GCP-0044", Provider: provider.GoogleProvider, Service: "compute", ShortCode: "no-default-service-account", Summary: "Instances should not use the default service account", Impact: "Instance has full access to the project", Resolution: "Remove use of default service account", Explanation: `The default service account has full project access. Instances should instead be assigned the minimal access they need.`, Links: []string{}, Terraform: &rules.EngineMetadata{ GoodExamples: terraformNoDefaultServiceAccountGoodExamples, BadExamples: terraformNoDefaultServiceAccountBadExamples, Links: terraformNoDefaultServiceAccountLinks, RemediationMarkdown: terraformNoDefaultServiceAccountRemediationMarkdown, }, Severity: severity.Critical, }, func(s *state.State) (results rules.Results) { for _, instance := range s.Google.Compute.Instances { if instance.ServiceAccount.Email.IsEmpty() || instance.ServiceAccount.Email.EndsWith("-compute@developer.gserviceaccount.com") { results.Add( "Instance uses the default service account.", instance.ServiceAccount.Email, ) } } return }, )
View Source
var CheckNoIpForwarding = rules.Register( rules.Rule{ AVDID: "AVD-GCP-0043", Provider: provider.GoogleProvider, Service: "compute", ShortCode: "no-ip-forwarding", Summary: "Instances should not have IP forwarding enabled", Impact: "Instance can send/receive packets without the explicit instance address", Resolution: "Disable IP forwarding", Explanation: `Disabling IP forwarding ensures the instance can only receive packets addressed to the instance and can only send packets with a source address of the instance.`, Links: []string{}, Terraform: &rules.EngineMetadata{ GoodExamples: terraformNoIpForwardingGoodExamples, BadExamples: terraformNoIpForwardingBadExamples, Links: terraformNoIpForwardingLinks, RemediationMarkdown: terraformNoIpForwardingRemediationMarkdown, }, Severity: severity.High, }, func(s *state.State) (results rules.Results) { for _, instance := range s.Google.Compute.Instances { if instance.CanIPForward.IsTrue() { results.Add( "Instance has IP forwarding allowed.", instance.CanIPForward, ) } } return }, )
View Source
var CheckNoOsloginOverride = rules.Register( rules.Rule{ AVDID: "AVD-GCP-0036", Provider: provider.GoogleProvider, Service: "compute", ShortCode: "no-oslogin-override", Summary: "Instances should not override the project setting for OS Login", Impact: "Access via SSH key cannot be revoked automatically when an IAM user is removed.", Resolution: "Enable OS Login at project level and remove instance-level overrides", Explanation: `OS Login automatically revokes the relevant SSH keys when an IAM user has their access revoked.`, Links: []string{}, Terraform: &rules.EngineMetadata{ GoodExamples: terraformNoOsloginOverrideGoodExamples, BadExamples: terraformNoOsloginOverrideBadExamples, Links: terraformNoOsloginOverrideLinks, RemediationMarkdown: terraformNoOsloginOverrideRemediationMarkdown, }, Severity: severity.Medium, }, func(s *state.State) (results rules.Results) { for _, instance := range s.Google.Compute.Instances { if instance.OSLoginEnabled.IsFalse() { results.Add( "Instance has OS Login disabled.", instance.OSLoginEnabled, ) } } return }, )
View Source
var CheckNoPlaintextVmDiskKeys = rules.Register( rules.Rule{ AVDID: "AVD-GCP-0040", Provider: provider.GoogleProvider, Service: "compute", ShortCode: "no-plaintext-vm-disk-keys", Summary: "VM disk encryption keys should not be provided in plaintext", Impact: "Compromise of encryption keys", Resolution: "Use managed keys or provide the raw key via a secrets manager ", Explanation: `Providing your encryption key in plaintext format means anyone with access to the source code also has access to the key.`, Links: []string{}, Terraform: &rules.EngineMetadata{ GoodExamples: terraformNoPlaintextVmDiskKeysGoodExamples, BadExamples: terraformNoPlaintextVmDiskKeysBadExamples, Links: terraformNoPlaintextVmDiskKeysLinks, RemediationMarkdown: terraformNoPlaintextVmDiskKeysRemediationMarkdown, }, Severity: severity.High, }, func(s *state.State) (results rules.Results) { for _, instance := range s.Google.Compute.Instances { for _, disk := range append(instance.BootDisks, instance.AttachedDisks...) { if disk.Encryption.RawKey.Len() > 0 { results.Add( "Instance disk has encryption key provided in plaintext.", disk.Encryption.RawKey, ) } } } return }, )
View Source
var CheckNoProjectWideSshKeys = rules.Register( rules.Rule{ AVDID: "AVD-GCP-0030", Provider: provider.GoogleProvider, Service: "compute", ShortCode: "no-project-wide-ssh-keys", Summary: "Disable project-wide SSH keys for all instances", Impact: "Compromise of a single key pair compromises all instances", Resolution: "Disable project-wide SSH keys", Explanation: `Use of project-wide SSH keys means that a compromise of any one of these key pairs can result in all instances being compromised. It is recommended to use instance-level keys.`, Links: []string{}, Terraform: &rules.EngineMetadata{ GoodExamples: terraformNoProjectWideSshKeysGoodExamples, BadExamples: terraformNoProjectWideSshKeysBadExamples, Links: terraformNoProjectWideSshKeysLinks, RemediationMarkdown: terraformNoProjectWideSshKeysRemediationMarkdown, }, Severity: severity.Medium, }, func(s *state.State) (results rules.Results) { for _, instance := range s.Google.Compute.Instances { if instance.EnableProjectSSHKeyBlocking.IsFalse() { results.Add( "Instance allows use of project-level SSH keys.", instance.EnableProjectSSHKeyBlocking, ) } } return }, )
View Source
var CheckNoPublicEgress = rules.Register( rules.Rule{ AVDID: "AVD-GCP-0035", Provider: provider.GoogleProvider, Service: "compute", ShortCode: "no-public-egress", Summary: "An outbound firewall rule allows traffic to /0.", Impact: "The port is exposed for egress to the internet", Resolution: "Set a more restrictive cidr range", Explanation: `Network security rules should not use very broad subnets. Where possible, segments should be broken into smaller subnets and avoid using the <code>/0</code> subnet.`, Links: []string{ "https://cloud.google.com/vpc/docs/using-firewalls", }, Terraform: &rules.EngineMetadata{ GoodExamples: terraformNoPublicEgressGoodExamples, BadExamples: terraformNoPublicEgressBadExamples, Links: terraformNoPublicEgressLinks, RemediationMarkdown: terraformNoPublicEgressRemediationMarkdown, }, Severity: severity.Critical, }, func(s *state.State) (results rules.Results) { for _, network := range s.Google.Compute.Networks { if network.Firewall == nil { continue } for _, rule := range network.Firewall.EgressRules { if !rule.IsAllow.IsTrue() { continue } if rule.Enforced.IsFalse() { continue } for _, destination := range rule.DestinationRanges { if cidr.IsPublic(destination.Value()) { results.Add( "Firewall rule allows egress traffic to a destination on the public internet.", destination, ) } } } } return }, )
View Source
var CheckNoPublicIngress = rules.Register( rules.Rule{ AVDID: "AVD-GCP-0027", Provider: provider.GoogleProvider, Service: "compute", ShortCode: "no-public-ingress", Summary: "An inbound firewall rule allows traffic from /0.", Impact: "The port is exposed for ingress from the internet", Resolution: "Set a more restrictive cidr range", Explanation: `Network security rules should not use very broad subnets. Where possible, segments should be broken into smaller subnets and avoid using the <code>/0</code> subnet.`, Links: []string{ "https://cloud.google.com/vpc/docs/using-firewalls", }, Terraform: &rules.EngineMetadata{ GoodExamples: terraformNoPublicIngressGoodExamples, BadExamples: terraformNoPublicIngressBadExamples, Links: terraformNoPublicIngressLinks, RemediationMarkdown: terraformNoPublicIngressRemediationMarkdown, }, Severity: severity.Critical, }, func(s *state.State) (results rules.Results) { for _, network := range s.Google.Compute.Networks { if network.Firewall == nil { continue } for _, rule := range network.Firewall.IngressRules { if !rule.IsAllow.IsTrue() { continue } if rule.Enforced.IsFalse() { continue } for _, source := range rule.SourceRanges { if cidr.IsPublic(source.Value()) { results.Add( "Firewall rule allows ingress traffic from a source on the public internet.", source, ) } } } } return }, )
View Source
var CheckNoSerialPort = rules.Register( rules.Rule{ AVDID: "AVD-GCP-0032", Provider: provider.GoogleProvider, Service: "compute", ShortCode: "no-serial-port", Summary: "Disable serial port connectivity for all instances", Impact: "Unrestricted network access to the serial console of the instance", Resolution: "Disable serial port access", Explanation: `When serial port access is enabled, the access is not governed by network security rules meaning the port can be exposed publicly.`, Links: []string{}, Terraform: &rules.EngineMetadata{ GoodExamples: terraformNoSerialPortGoodExamples, BadExamples: terraformNoSerialPortBadExamples, Links: terraformNoSerialPortLinks, RemediationMarkdown: terraformNoSerialPortRemediationMarkdown, }, Severity: severity.Medium, }, func(s *state.State) (results rules.Results) { for _, instance := range s.Google.Compute.Instances { if instance.EnableSerialPort.IsTrue() { results.Add( "Instance has serial port enabled.", instance.EnableSerialPort, ) } } return }, )
View Source
var CheckProjectLevelOslogin = rules.Register( rules.Rule{ AVDID: "AVD-GCP-0042", Provider: provider.GoogleProvider, Service: "compute", ShortCode: "project-level-oslogin", Summary: "OS Login should be enabled at project level", Impact: "Access via SSH key cannot be revoked automatically when an IAM user is removed.", Resolution: "Enable OS Login at project level", Explanation: `OS Login automatically revokes the relevant SSH keys when an IAM user has their access revoked.`, Links: []string{}, Terraform: &rules.EngineMetadata{ GoodExamples: terraformProjectLevelOsloginGoodExamples, BadExamples: terraformProjectLevelOsloginBadExamples, Links: terraformProjectLevelOsloginLinks, RemediationMarkdown: terraformProjectLevelOsloginRemediationMarkdown, }, Severity: severity.Medium, }, func(s *state.State) (results rules.Results) { if s.Google.Compute.ProjectMetadata.EnableOSLogin.IsFalse() { results.Add( "OS Login is disabled at project level.", s.Google.Compute.ProjectMetadata.EnableOSLogin, ) } return }, )
View Source
var CheckUseSecureTlsPolicy = rules.Register( rules.Rule{ AVDID: "AVD-GCP-0039", Provider: provider.GoogleProvider, Service: "compute", ShortCode: "use-secure-tls-policy", Summary: "SSL policies should enforce secure versions of TLS", Impact: "Data in transit is not sufficiently secured", Resolution: "Enforce a minimum TLS version of 1.2", Explanation: `TLS versions prior to 1.2 are outdated and insecure. You should use 1.2 as aminimum version.`, Links: []string{}, Terraform: &rules.EngineMetadata{ GoodExamples: terraformUseSecureTlsPolicyGoodExamples, BadExamples: terraformUseSecureTlsPolicyBadExamples, Links: terraformUseSecureTlsPolicyLinks, RemediationMarkdown: terraformUseSecureTlsPolicyRemediationMarkdown, }, Severity: severity.Critical, }, func(s *state.State) (results rules.Results) { for _, policy := range s.Google.Compute.SSLPolicies { if policy.MinimumTLSVersion.NotEqualTo("TLS_1_2") { results.Add( "TLS policy does not specify a minimum of TLS 1.2", policy.MinimumTLSVersion, ) } } return }, )
View Source
var CheckVmDiskEncryptionCustomerKey = rules.Register( rules.Rule{ AVDID: "AVD-GCP-0033", Provider: provider.GoogleProvider, Service: "compute", ShortCode: "vm-disk-encryption-customer-key", Summary: "VM disks should be encrypted with Customer Supplied Encryption Keys", Impact: "Using unmanaged keys does not allow for proper management", Resolution: "Use managed keys ", Explanation: `Using unmanaged keys makes rotation and general management difficult.`, Links: []string{}, Terraform: &rules.EngineMetadata{ GoodExamples: terraformVmDiskEncryptionCustomerKeyGoodExamples, BadExamples: terraformVmDiskEncryptionCustomerKeyBadExamples, Links: terraformVmDiskEncryptionCustomerKeyLinks, RemediationMarkdown: terraformVmDiskEncryptionCustomerKeyRemediationMarkdown, }, Severity: severity.Low, }, func(s *state.State) (results rules.Results) { for _, instance := range s.Google.Compute.Instances { for _, disk := range append(instance.BootDisks, instance.AttachedDisks...) { if disk.Encryption.KMSKeyLink.IsEmpty() { results.Add( "Instance disk encryption does not use a customer managed key.", disk.Encryption.KMSKeyLink, ) } } } return }, )
Functions ¶
This section is empty.
Types ¶
This section is empty.
Source Files ¶
- disk_encryption_customer_key.go
- disk_encryption_customer_key.tf.go
- disk_encryption_no_plaintext_key.go
- disk_encryption_no_plaintext_key.tf.go
- enable_shielded_vm_im.go
- enable_shielded_vm_im.tf.go
- enable_shielded_vm_vtpm.go
- enable_shielded_vm_vtpm.tf.go
- enable_vpc_flow_logs.go
- enable_vpc_flow_logs.tf.go
- no_default_service_account.go
- no_default_service_account.tf.go
- no_ip_forwarding.go
- no_ip_forwarding.tf.go
- no_oslogin_override.go
- no_oslogin_override.tf.go
- no_plaintext_vm_disk_keys.go
- no_plaintext_vm_disk_keys.tf.go
- no_project_wide_ssh_keys.go
- no_project_wide_ssh_keys.tf.go
- no_public_egress.go
- no_public_egress.tf.go
- no_public_ingress.go
- no_public_ingress.tf.go
- no_public_ip.go
- no_public_ip.tf.go
- no_serial_port.go
- no_serial_port.tf.go
- project_level_oslogin.go
- project_level_oslogin.tf.go
- service.go
- use_secure_tls_policy.go
- use_secure_tls_policy.tf.go
- vm_disk_encryption_customer_key.go
- vm_disk_encryption_customer_key.tf.go
Click to show internal directories.
Click to hide internal directories.