You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Trivy will check the following folders:
terraform/environments/contract-work-administration
Running Trivy in terraform/environments/contract-work-administration
2024-10-25T12:43:02Z INFO [vulndb] Need to update DB
2024-10-25T12:43:02Z INFO [vulndb] Downloading vulnerability DB...
2024-10-25T12:43:02Z INFO [vulndb] Downloading artifact... repo="public.ecr.aws/aquasecurity/trivy-db:2"
2024-10-25T12:43:04Z INFO [vulndb] Artifact successfully downloaded repo="public.ecr.aws/aquasecurity/trivy-db:2"
2024-10-25T12:43:04Z INFO [vuln] Vulnerability scanning is enabled
2024-10-25T12:43:04Z INFO [misconfig] Misconfiguration scanning is enabled
2024-10-25T12:43:04Z INFO [misconfig] Need to update the built-in checks
2024-10-25T12:43:04Z INFO [misconfig] Downloading the built-in checks...
2024-10-25T12:43:04Z ERROR [misconfig] Falling back to embedded checks err="failed to download built-in policies: download error: oci download error: failed to fetch the layer: GET https://ghcr.io/v2/aquasecurity/trivy-checks/blobs/sha256:16957b935ef82529bc26f3ceeeb60d798c90ef142d25e3715ab4478b204ed1bb: TOOMANYREQUESTS: retry-after: 584.155µs, allowed: 44000/minute"
2024-10-25T12:43:04Z INFO [secret] Secret scanning is enabled
2024-10-25T12:43:04Z INFO [secret] If your scanning is slow, please try '--scanners vuln' to disable secret scanning
2024-10-25T12:43:04Z INFO [secret] Please see also https://aquasecurity.github.io/trivy/v0.56/docs/scanner/secret#recommendation for faster secret detection
2024-10-25T12:43:05Z INFO [terraform scanner] Scanning root module file_path="."
2024-10-25T12:43:05Z WARN [terraform parser] Variable values was not found in the environment or variable files. Evaluating may not work correctly. module="root" variables="networking"
2024-10-25T12:43:06Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.aws_s3_object.user_public_keys" value="cty.NilVal"
2024-10-25T12:43:06Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.data.aws_subnet.local_account" value="cty.NilVal"
2024-10-25T12:43:06Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.dynamic.tag" value="cty.NilVal"
2024-10-25T12:43:06Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.dynamic.tag" value="cty.NilVal"
2024-10-25T12:43:07Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.expiration" value="cty.NilVal"
2024-10-25T12:43:07Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.transition" value="cty.NilVal"
2024-10-25T12:43:07Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.noncurrent_version_expiration" value="cty.NilVal"
2024-10-25T12:43:07Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.noncurrent_version_transition" value="cty.NilVal"
2024-10-25T12:43:07Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.principals" value="cty.NilVal"
2024-10-25T12:43:07Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.condition" value="cty.NilVal"
2024-10-25T12:43:07Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.expiration" value="cty.NilVal"
2024-10-25T12:43:07Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.transition" value="cty.NilVal"
2024-10-25T12:43:07Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.noncurrent_version_expiration" value="cty.NilVal"
2024-10-25T12:43:07Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.noncurrent_version_transition" value="cty.NilVal"
2024-10-25T12:43:07Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.principals" value="cty.NilVal"
2024-10-25T12:43:07Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.condition" value="cty.NilVal"
2024-10-25T12:43:08Z INFO [terraform executor] Ignore finding rule="aws-s3-encryption-customer-key" range="github.com/ministryofjustice/modernisation-platform-terraform-bastion-linux?ref=v4.2.0/github.com/ministryofjustice/modernisation-platform-terraform-s3-bucket?ref=568694e50e03630d99cb569eafa06a0b879a1239/main.tf:171-179"
2024-10-25T12:43:09Z INFO Number of language-specific files num=0
2024-10-25T12:43:09Z INFO Detected config files num=9
HIGH: Application load balancer is not set to drop invalid headers.
════════════════════════════════════════
Passing unknown or invalid headers through to the target poses a potential risk of compromise.
By setting drop_invalid_header_fields to true, anything that does not conform to well known, defined headers will be removed by the load balancer.
HIGH: Load balancer is exposed publicly.
════════════════════════════════════════
There are many scenarios in which you would want to expose a load balancer to the wider internet, but this check exists as a warning to prevent accidental exposure of internal assets. You should ensure that this resource should be exposed publicly.
HIGH: Instance does not require IMDS access to require a token.
════════════════════════════════════════
IMDS v2 (Instance Metadata Service) introduced session authentication tokens which improve security when talking to IMDS.
By default aws_instance resource sets IMDS session auth tokens to be optional.
To fully protect IMDS you need to enable session tokens by using metadata_options block and its http_tokens variable set to required.
See https://avd.aquasec.com/misconfig/avd-aws-0028
────────────────────────────────────────
app_servers.tf:191
via app_servers.tf:190-192 (metadata_options)
via app_servers.tf:179-211 (aws_instance.app1)
────────────────────────────────────────
179 resource "aws_instance" "app1" {
...
191 [ http_tokens = "optional"
...
211 }
────────────────────────────────────────
HIGH: Instance does not require IMDS access to require a token.
════════════════════════════════════════
IMDS v2 (Instance Metadata Service) introduced session authentication tokens which improve security when talking to IMDS.
By default aws_instance resource sets IMDS session auth tokens to be optional.
To fully protect IMDS you need to enable session tokens by using metadata_options block and its http_tokens variable set to required.
HIGH: Root block device is not encrypted.
════════════════════════════════════════
Block devices should be encrypted to ensure sensitive data is held securely at rest.
HIGH: Root block device is not encrypted.
════════════════════════════════════════
Block devices should be encrypted to ensure sensitive data is held securely at rest.
HIGH: Bucket does not have encryption enabled
════════════════════════════════════════
S3 Buckets should be encrypted to protect the data that is stored within them if access is compromised.
HIGH: Bucket does not encrypt data with a customer managed key.
════════════════════════════════════════
Encryption using AWS keys provides protection for your S3 buckets. To increase control of the encryption and manage factors like rotation use customer managed keys.
HIGH: Instance does not require IMDS access to require a token.
════════════════════════════════════════
IMDS v2 (Instance Metadata Service) introduced session authentication tokens which improve security when talking to IMDS.
By default aws_instance resource sets IMDS session auth tokens to be optional.
To fully protect IMDS you need to enable session tokens by using metadata_options block and its http_tokens variable set to required.
See https://avd.aquasec.com/misconfig/avd-aws-0028
────────────────────────────────────────
concurrent_manager.tf:170
via concurrent_manager.tf:169-171 (metadata_options)
via concurrent_manager.tf:158-190 (aws_instance.concurrent_manager)
────────────────────────────────────────
158 resource "aws_instance" "concurrent_manager" {
...
170 [ http_tokens = "optional"
...
190 }
────────────────────────────────────────
HIGH: Root block device is not encrypted.
════════════════════════════════════════
Block devices should be encrypted to ensure sensitive data is held securely at rest.
HIGH: Instance does not require IMDS access to require a token.
════════════════════════════════════════
IMDS v2 (Instance Metadata Service) introduced session authentication tokens which improve security when talking to IMDS.
By default aws_instance resource sets IMDS session auth tokens to be optional.
To fully protect IMDS you need to enable session tokens by using metadata_options block and its http_tokens variable set to required.
See https://avd.aquasec.com/misconfig/avd-aws-0028
────────────────────────────────────────
database.tf:196
via database.tf:195-197 (metadata_options)
via database.tf:184-213 (aws_instance.database)
────────────────────────────────────────
184 resource "aws_instance" "database" {
...
196 [ http_tokens = "optional"
...
213 }
────────────────────────────────────────
HIGH: Root block device is not encrypted.
════════════════════════════════════════
Block devices should be encrypted to ensure sensitive data is held securely at rest.
*****************************
Setting default tflint config...
Running tflint --init...
Installing "terraform" plugin...
Installed "terraform" (source: github.com/terraform-linters/tflint-ruleset-terraform, version:0.9.1)
tflint will check the following folders:
terraform/environments/contract-work-administration
*****************************
Running tflint in terraform/environments/contract-work-administration
Excluding the following checks: terraform_unused_declarations
4issue(s) found:
Warning: Missing version constraint for provider "time" in `required_providers` (terraform_required_providers)
on terraform/environments/contract-work-administration/backup_lambda.tf line 119:119:resource"time_sleep""wait_for_provision_files" {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_required_providers.md
Warning: Missing version constraint for provider "archive" in `required_providers` (terraform_required_providers)
on terraform/environments/contract-work-administration/backup_lambda.tf line 173:173:data"archive_file""connect_db" {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_required_providers.md
Warning: Missing version constraint for provider "template" in `required_providers` (terraform_required_providers)
on terraform/environments/contract-work-administration/cloudwatch.tf line 1126:1126:data"template_file""dashboard_no_ha" {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_required_providers.md
Warning: Missing version constraint for provider "local" in `required_providers` (terraform_required_providers)
on terraform/environments/contract-work-administration/data.tf line 11:11:data"local_file""cm_custom_metrics" {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_required_providers.mdtflint_exitcode=2
Trivy Scan Failed
Show Output
*****************************
Trivy will check the following folders:
terraform/environments/contract-work-administration
*****************************
Running Trivy in terraform/environments/contract-work-administration
2024-10-25T12:43:02Z INFO [vulndb] Need to update DB
2024-10-25T12:43:02Z INFO [vulndb] Downloading vulnerability DB...2024-10-25T12:43:02Z INFO [vulndb] Downloading artifact...repo="public.ecr.aws/aquasecurity/trivy-db:2"2024-10-25T12:43:04Z INFO [vulndb] Artifact successfully downloaded repo="public.ecr.aws/aquasecurity/trivy-db:2"2024-10-25T12:43:04Z INFO [vuln] Vulnerability scanning is enabled
2024-10-25T12:43:04Z INFO [misconfig] Misconfiguration scanning is enabled
2024-10-25T12:43:04Z INFO [misconfig] Need to update the built-in checks
2024-10-25T12:43:04Z INFO [misconfig] Downloading the built-in checks...2024-10-25T12:43:04Z ERROR [misconfig] Falling back to embedded checks err="failed to download built-in policies: download error: oci download error: failed to fetch the layer: GET https://ghcr.io/v2/aquasecurity/trivy-checks/blobs/sha256:16957b935ef82529bc26f3ceeeb60d798c90ef142d25e3715ab4478b204ed1bb: TOOMANYREQUESTS: retry-after: 584.155µs, allowed: 44000/minute"2024-10-25T12:43:04Z INFO [secret] Secret scanning is enabled
2024-10-25T12:43:04Z INFO [secret] If your scanning is slow, please try '--scanners vuln' to disable secret scanning
2024-10-25T12:43:04Z INFO [secret] Please see also https://aquasecurity.github.io/trivy/v0.56/docs/scanner/secret#recommendation for faster secret detection2024-10-25T12:43:05Z INFO [terraformscanner] Scanning root module file_path="."2024-10-25T12:43:05Z WARN [terraformparser] Variable values was not found in the environment or variable files. Evaluating may not work correctly.module="root"variables="networking"2024-10-25T12:43:06Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.aws_s3_object.user_public_keys"value="cty.NilVal"2024-10-25T12:43:06Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.data.aws_subnet.local_account"value="cty.NilVal"2024-10-25T12:43:06Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.dynamic.tag"value="cty.NilVal"2024-10-25T12:43:06Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.dynamic.tag"value="cty.NilVal"2024-10-25T12:43:07Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.expiration"value="cty.NilVal"2024-10-25T12:43:07Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.transition"value="cty.NilVal"2024-10-25T12:43:07Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.noncurrent_version_expiration"value="cty.NilVal"2024-10-25T12:43:07Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.noncurrent_version_transition"value="cty.NilVal"2024-10-25T12:43:07Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.principals"value="cty.NilVal"2024-10-25T12:43:07Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.condition"value="cty.NilVal"2024-10-25T12:43:07Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.expiration"value="cty.NilVal"2024-10-25T12:43:07Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.transition"value="cty.NilVal"2024-10-25T12:43:07Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.noncurrent_version_expiration"value="cty.NilVal"2024-10-25T12:43:07Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.noncurrent_version_transition"value="cty.NilVal"2024-10-25T12:43:07Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.principals"value="cty.NilVal"2024-10-25T12:43:07Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.condition"value="cty.NilVal"2024-10-25T12:43:08Z INFO [terraformexecutor] Ignore finding rule="aws-s3-encryption-customer-key"range="github.com/ministryofjustice/modernisation-platform-terraform-bastion-linux?ref=v4.2.0/github.com/ministryofjustice/modernisation-platform-terraform-s3-bucket?ref=568694e50e03630d99cb569eafa06a0b879a1239/main.tf:171-179"2024-10-25T12:43:09Z INFO Number of language-specific files num=02024-10-25T12:43:09Z INFO Detected config files num=9
alb.tf (terraform)
==================
Tests:3 (SUCCESSES:0, FAILURES:2, EXCEPTIONS:1)
Failures:2 (HIGH:2, CRITICAL:0)
HIGH: Application load balancer is not set to drop invalid headers.
════════════════════════════════════════
Passing unknown or invalid headers through to the target poses a potential risk of compromise.
By setting drop_invalid_header_fields to true, anything that does not conform to well known, defined headers will be removed by the load balancer.
See https://avd.aquasec.com/misconfig/avd-aws-0052
────────────────────────────────────────
alb.tf:130-153
────────────────────────────────────────
130 ┌ resource"aws_lb""external" {
131 │ name="${upper(local.application_name_short)}-LoadBalancer"132 │ internal=false133 │ load_balancer_type="application"134 │ security_groups=[aws_security_group.external_lb.id]
135 │ subnets=[data.aws_subnet.public_subnets_a.id, data.aws_subnet.public_subnets_b.id, data.aws_subnet.public_subnets_c.id]
136 │ enable_deletion_protection=local.lb_enable_deletion_protection137 │ idle_timeout=local.external_lb_idle_timeout138 └ enable_http2=false...
────────────────────────────────────────
HIGH: Load balancer is exposed publicly.
════════════════════════════════════════
There are many scenarios in which you would want to expose a load balancer to the wider internet, but this check exists as a warning to prevent accidental exposure of internal assets. You should ensure that this resource should be exposed publicly.
See https://avd.aquasec.com/misconfig/avd-aws-0053
────────────────────────────────────────
alb.tf:132
via alb.tf:130-153 (aws_lb.external)
────────────────────────────────────────
130resource"aws_lb""external" {
...132 [ internal = false...153 }
────────────────────────────────────────
app_servers.tf (terraform)
==========================Tests:5 (SUCCESSES:0, FAILURES:4, EXCEPTIONS:1)
Failures:4 (HIGH:4, CRITICAL:0)
HIGH:InstancedoesnotrequireIMDSaccesstorequireatoken.
════════════════════════════════════════
IMDSv2 (Instance Metadata Service) introducedsessionauthenticationtokenswhichimprovesecuritywhentalkingtoIMDS.Bydefault<code>aws_instance</code>resourcesetsIMDSsessionauthtokenstobeoptional.TofullyprotectIMDSyouneedtoenablesessiontokensbyusing<code>metadata_options</code>blockandits<code>http_tokens</code>variablesetto<code>required</code>.Seehttps://avd.aquasec.com/misconfig/avd-aws-0028
────────────────────────────────────────
app_servers.tf:191viaapp_servers.tf:190-192 (metadata_options)
viaapp_servers.tf:179-211 (aws_instance.app1)
────────────────────────────────────────
179resource"aws_instance""app1" {
...191 [ http_tokens ="optional"...211 }
────────────────────────────────────────
HIGH:InstancedoesnotrequireIMDSaccesstorequireatoken.
════════════════════════════════════════
IMDSv2 (Instance Metadata Service) introducedsessionauthenticationtokenswhichimprovesecuritywhentalkingtoIMDS.Bydefault<code>aws_instance</code>resourcesetsIMDSsessionauthtokenstobeoptional.TofullyprotectIMDSyouneedtoenablesessiontokensbyusing<code>metadata_options</code>blockandits<code>http_tokens</code>variablesetto<code>required</code>.Seehttps://avd.aquasec.com/misconfig/avd-aws-0028
────────────────────────────────────────
app_servers.tf:213-243
────────────────────────────────────────
213 ┌ resource"aws_instance""app2" {
214 │ count =contains(["development", "testing"], local.environment) ?0:1215 │ ami = local.application_data.accounts[local.environment].app_ami_id
216 │ availability_zone ="eu-west-2a"217 │ instance_type = local.application_data.accounts[local.environment].app_instance_type
218 │ monitoring =true219 │ vpc_security_group_ids = [aws_security_group.app.id]
220 │ subnet_id = data.aws_subnet.data_subnets_a.id
221 └ iam_instance_profile = aws_iam_instance_profile.cwa.id
...
────────────────────────────────────────
HIGH: Root block device is not encrypted.
════════════════════════════════════════
Block devices should be encrypted to ensure sensitive data is held securely at rest.
See https://avd.aquasec.com/misconfig/avd-aws-0131
────────────────────────────────────────
app_servers.tf:179-211
────────────────────────────────────────
179 ┌ resource "aws_instance""app1" {
180 │ ami = local.application_data.accounts[local.environment].app_ami_id
181 │ availability_zone ="eu-west-2a"182 │ instance_type = local.application_data.accounts[local.environment].app_instance_type
183 │ monitoring =true184 │ vpc_security_group_ids = [aws_security_group.app.id]
185 │ subnet_id = data.aws_subnet.private_subnets_a.id
186 │ iam_instance_profile = aws_iam_instance_profile.cwa.id
187 └ key_name = aws_key_pair.cwa.key_name
...
────────────────────────────────────────
HIGH: Root block device is not encrypted.
════════════════════════════════════════
Block devices should be encrypted to ensure sensitive data is held securely at rest.
See https://avd.aquasec.com/misconfig/avd-aws-0131
────────────────────────────────────────
app_servers.tf:213-243
────────────────────────────────────────
213 ┌ resource "aws_instance""app2" {
214 │ count =contains(["development", "testing"], local.environment) ?0:1215 │ ami = local.application_data.accounts[local.environment].app_ami_id
216 │ availability_zone ="eu-west-2a"217 │ instance_type = local.application_data.accounts[local.environment].app_instance_type
218 │ monitoring =true219 │ vpc_security_group_ids = [aws_security_group.app.id]
220 │ subnet_id = data.aws_subnet.data_subnets_a.id
221 └ iam_instance_profile = aws_iam_instance_profile.cwa.id
...
────────────────────────────────────────
backup_lambda.tf (terraform)
============================
Tests:3 (SUCCESSES:0, FAILURES:2, EXCEPTIONS:1)
Failures:2 (HIGH:2, CRITICAL:0)
HIGH: Bucket does not have encryption enabled
════════════════════════════════════════
S3 Buckets should be encrypted to protect the data that is stored within them ifaccessiscompromised.
See https://avd.aquasec.com/misconfig/avd-aws-0088
────────────────────────────────────────
backup_lambda.tf:101-107
────────────────────────────────────────
101 ┌ resource "aws_s3_bucket""scripts" {
102 │ bucket ="${local.application_name_short}-${local.environment}-scripts"103 │ tags =merge(
104 │ local.tags,
105 │ { Name ="${local.application_name_short}-${local.environment}-scripts" }
106 │ )
107 └ }
────────────────────────────────────────
HIGH: Bucket does not encrypt data with a customer managed key.
════════════════════════════════════════
Encryption using AWS keys provides protection foryourS3buckets.Toincreasecontroloftheencryptionandmanagefactorslikerotationusecustomermanagedkeys.
See https://avd.aquasec.com/misconfig/avd-aws-0132
────────────────────────────────────────
backup_lambda.tf:101-107
────────────────────────────────────────
101 ┌ resource "aws_s3_bucket""scripts" {
102 │ bucket ="${local.application_name_short}-${local.environment}-scripts"103 │ tags =merge(
104 │ local.tags,
105 │ { Name ="${local.application_name_short}-${local.environment}-scripts" }
106 │ )
107 └ }
────────────────────────────────────────
concurrent_manager.tf (terraform)
=================================
Tests:3 (SUCCESSES:0, FAILURES:2, EXCEPTIONS:1)
Failures:2 (HIGH:2, CRITICAL:0)
HIGH: Instance does not require IMDS access to require a token.
════════════════════════════════════════
IMDS v2 (Instance Metadata Service) introduced session authentication tokens which improve security when talking to IMDS.
By default <code>aws_instance</code> resource sets IMDS session auth tokens to be optional.
To fully protect IMDS you need to enable session tokens by using <code>metadata_options</code> block and its <code>http_tokens</code> variable set to <code>required</code>.
See https://avd.aquasec.com/misconfig/avd-aws-0028
────────────────────────────────────────
concurrent_manager.tf:170
via concurrent_manager.tf:169-171 (metadata_options)
via concurrent_manager.tf:158-190 (aws_instance.concurrent_manager)
────────────────────────────────────────
158 resource "aws_instance""concurrent_manager" {
...170 [ http_tokens ="optional"...190 }
────────────────────────────────────────
HIGH: Root block device is not encrypted.
════════════════════════════════════════
Block devices should be encrypted to ensure sensitive data is held securely at rest.
See https://avd.aquasec.com/misconfig/avd-aws-0131
────────────────────────────────────────
concurrent_manager.tf:158-190
────────────────────────────────────────
158 ┌ resource "aws_instance""concurrent_manager" {
159 │ ami = local.application_data.accounts[local.environment].cm_ami_id
160 │ availability_zone ="eu-west-2a"161 │ instance_type = local.application_data.accounts[local.environment].cm_instance_type
162 │ monitoring =true163 │ vpc_security_group_ids = [aws_security_group.concurrent_manager.id]
164 │ subnet_id = data.aws_subnet.private_subnets_a.id
165 │ iam_instance_profile = aws_iam_instance_profile.cwa.id
166 └ key_name = aws_key_pair.cwa.key_name
...
────────────────────────────────────────
database.tf (terraform)
=======================
Tests:3 (SUCCESSES:0, FAILURES:2, EXCEPTIONS:1)
Failures:2 (HIGH:2, CRITICAL:0)
HIGH: Instance does not require IMDS access to require a token.
════════════════════════════════════════
IMDS v2 (Instance Metadata Service) introduced session authentication tokens which improve security when talking to IMDS.
By default <code>aws_instance</code> resource sets IMDS session auth tokens to be optional.
To fully protect IMDS you need to enable session tokens by using <code>metadata_options</code> block and its <code>http_tokens</code> variable set to <code>required</code>.
See https://avd.aquasec.com/misconfig/avd-aws-0028
────────────────────────────────────────
database.tf:196
via database.tf:195-197 (metadata_options)
via database.tf:184-213 (aws_instance.database)
────────────────────────────────────────
184 resource "aws_instance""database" {
...196 [ http_tokens ="optional"...213 }
────────────────────────────────────────
HIGH: Root block device is not encrypted.
════════════════════════════════════════
Block devices should be encrypted to ensure sensitive data is held securely at rest.
See https://avd.aquasec.com/misconfig/avd-aws-0131
────────────────────────────────────────
database.tf:184-213
────────────────────────────────────────
184 ┌ resource "aws_instance""database" {
185 │ ami = local.application_data.accounts[local.environment].db_ami_id
186 │ availability_zone ="eu-west-2a"187 │ instance_type = local.application_data.accounts[local.environment].db_instance_type
188 │ monitoring =true189 │ vpc_security_group_ids = [aws_security_group.database.id]
190 │ subnet_id = data.aws_subnet.data_subnets_a.id
191 │ iam_instance_profile = aws_iam_instance_profile.cwa.id
192 └ key_name = aws_key_pair.cwa.key_name
...
────────────────────────────────────────
trivy_exitcode=1
Trivy will check the following folders:
terraform/environments/contract-work-administration
Running Trivy in terraform/environments/contract-work-administration
2024-10-29T12:40:38Z INFO [vulndb] Need to update DB
2024-10-29T12:40:38Z INFO [vulndb] Downloading vulnerability DB...
2024-10-29T12:40:38Z INFO [vulndb] Downloading artifact... repo="public.ecr.aws/aquasecurity/trivy-db:2"
2024-10-29T12:40:40Z INFO [vulndb] Artifact successfully downloaded repo="public.ecr.aws/aquasecurity/trivy-db:2"
2024-10-29T12:40:40Z INFO [vuln] Vulnerability scanning is enabled
2024-10-29T12:40:40Z INFO [misconfig] Misconfiguration scanning is enabled
2024-10-29T12:40:40Z INFO [misconfig] Need to update the built-in checks
2024-10-29T12:40:40Z INFO [misconfig] Downloading the built-in checks...
156.02 KiB / 156.02 KiB [---------------------------------------------------------] 100.00% ? p/s 0s2024-10-29T12:40:40Z INFO [secret] Secret scanning is enabled
2024-10-29T12:40:40Z INFO [secret] If your scanning is slow, please try '--scanners vuln' to disable secret scanning
2024-10-29T12:40:40Z INFO [secret] Please see also https://aquasecurity.github.io/trivy/v0.56/docs/scanner/secret#recommendation for faster secret detection
2024-10-29T12:40:41Z INFO [terraform scanner] Scanning root module file_path="."
2024-10-29T12:40:41Z WARN [terraform parser] Variable values was not found in the environment or variable files. Evaluating may not work correctly. module="root" variables="networking"
2024-10-29T12:40:43Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.aws_s3_object.user_public_keys" value="cty.NilVal"
2024-10-29T12:40:43Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.data.aws_subnet.local_account" value="cty.NilVal"
2024-10-29T12:40:43Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.dynamic.tag" value="cty.NilVal"
2024-10-29T12:40:43Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.dynamic.tag" value="cty.NilVal"
2024-10-29T12:40:43Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.expiration" value="cty.NilVal"
2024-10-29T12:40:43Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.transition" value="cty.NilVal"
2024-10-29T12:40:43Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.noncurrent_version_expiration" value="cty.NilVal"
2024-10-29T12:40:43Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.noncurrent_version_transition" value="cty.NilVal"
2024-10-29T12:40:43Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.principals" value="cty.NilVal"
2024-10-29T12:40:43Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.condition" value="cty.NilVal"
2024-10-29T12:40:43Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.expiration" value="cty.NilVal"
2024-10-29T12:40:43Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.transition" value="cty.NilVal"
2024-10-29T12:40:43Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.noncurrent_version_expiration" value="cty.NilVal"
2024-10-29T12:40:43Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.noncurrent_version_transition" value="cty.NilVal"
2024-10-29T12:40:43Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.principals" value="cty.NilVal"
2024-10-29T12:40:43Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.condition" value="cty.NilVal"
2024-10-29T12:40:45Z INFO [terraform executor] Ignore finding rule="aws-s3-encryption-customer-key" range="github.com/ministryofjustice/modernisation-platform-terraform-bastion-linux?ref=v4.2.0/github.com/ministryofjustice/modernisation-platform-terraform-s3-bucket?ref=568694e50e03630d99cb569eafa06a0b879a1239/main.tf:171-179"
2024-10-29T12:40:45Z INFO Number of language-specific files num=0
2024-10-29T12:40:45Z INFO Detected config files num=9
HIGH: Application load balancer is not set to drop invalid headers.
════════════════════════════════════════
Passing unknown or invalid headers through to the target poses a potential risk of compromise.
By setting drop_invalid_header_fields to true, anything that does not conform to well known, defined headers will be removed by the load balancer.
HIGH: Load balancer is exposed publicly.
════════════════════════════════════════
There are many scenarios in which you would want to expose a load balancer to the wider internet, but this check exists as a warning to prevent accidental exposure of internal assets. You should ensure that this resource should be exposed publicly.
HIGH: Instance does not require IMDS access to require a token.
════════════════════════════════════════
IMDS v2 (Instance Metadata Service) introduced session authentication tokens which improve security when talking to IMDS.
By default aws_instance resource sets IMDS session auth tokens to be optional.
To fully protect IMDS you need to enable session tokens by using metadata_options block and its http_tokens variable set to required.
See https://avd.aquasec.com/misconfig/avd-aws-0028
────────────────────────────────────────
app_servers.tf:192
via app_servers.tf:191-193 (metadata_options)
via app_servers.tf:180-212 (aws_instance.app1)
────────────────────────────────────────
180 resource "aws_instance" "app1" {
...
192 [ http_tokens = "optional"
...
212 }
────────────────────────────────────────
HIGH: Instance does not require IMDS access to require a token.
════════════════════════════════════════
IMDS v2 (Instance Metadata Service) introduced session authentication tokens which improve security when talking to IMDS.
By default aws_instance resource sets IMDS session auth tokens to be optional.
To fully protect IMDS you need to enable session tokens by using metadata_options block and its http_tokens variable set to required.
HIGH: Root block device is not encrypted.
════════════════════════════════════════
Block devices should be encrypted to ensure sensitive data is held securely at rest.
HIGH: Root block device is not encrypted.
════════════════════════════════════════
Block devices should be encrypted to ensure sensitive data is held securely at rest.
HIGH: Bucket does not have encryption enabled
════════════════════════════════════════
S3 Buckets should be encrypted to protect the data that is stored within them if access is compromised.
HIGH: Bucket does not encrypt data with a customer managed key.
════════════════════════════════════════
Encryption using AWS keys provides protection for your S3 buckets. To increase control of the encryption and manage factors like rotation use customer managed keys.
HIGH: Instance does not require IMDS access to require a token.
════════════════════════════════════════
IMDS v2 (Instance Metadata Service) introduced session authentication tokens which improve security when talking to IMDS.
By default aws_instance resource sets IMDS session auth tokens to be optional.
To fully protect IMDS you need to enable session tokens by using metadata_options block and its http_tokens variable set to required.
See https://avd.aquasec.com/misconfig/avd-aws-0028
────────────────────────────────────────
concurrent_manager.tf:170
via concurrent_manager.tf:169-171 (metadata_options)
via concurrent_manager.tf:158-190 (aws_instance.concurrent_manager)
────────────────────────────────────────
158 resource "aws_instance" "concurrent_manager" {
...
170 [ http_tokens = "optional"
...
190 }
────────────────────────────────────────
HIGH: Root block device is not encrypted.
════════════════════════════════════════
Block devices should be encrypted to ensure sensitive data is held securely at rest.
HIGH: Instance does not require IMDS access to require a token.
════════════════════════════════════════
IMDS v2 (Instance Metadata Service) introduced session authentication tokens which improve security when talking to IMDS.
By default aws_instance resource sets IMDS session auth tokens to be optional.
To fully protect IMDS you need to enable session tokens by using metadata_options block and its http_tokens variable set to required.
See https://avd.aquasec.com/misconfig/avd-aws-0028
────────────────────────────────────────
database.tf:196
via database.tf:195-197 (metadata_options)
via database.tf:184-213 (aws_instance.database)
────────────────────────────────────────
184 resource "aws_instance" "database" {
...
196 [ http_tokens = "optional"
...
213 }
────────────────────────────────────────
HIGH: Root block device is not encrypted.
════════════════════════════════════════
Block devices should be encrypted to ensure sensitive data is held securely at rest.
*****************************
Setting default tflint config...
Running tflint --init...
Installing "terraform" plugin...
Installed "terraform" (source: github.com/terraform-linters/tflint-ruleset-terraform, version:0.9.1)
tflint will check the following folders:
terraform/environments/contract-work-administration
*****************************
Running tflint in terraform/environments/contract-work-administration
Excluding the following checks: terraform_unused_declarations
4issue(s) found:
Warning: Missing version constraint for provider "archive" in `required_providers` (terraform_required_providers)
on terraform/environments/contract-work-administration/backup_lambda.tf line 173:173:data"archive_file""connect_db" {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_required_providers.md
Warning: Missing version constraint for provider "template" in `required_providers` (terraform_required_providers)
on terraform/environments/contract-work-administration/cloudwatch.tf line 1126:1126:data"template_file""dashboard_no_ha" {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_required_providers.md
Warning: Missing version constraint for provider "time" in `required_providers` (terraform_required_providers)
on terraform/environments/contract-work-administration/concurrent_manager.tf line 149:149:resource"time_sleep""wait_cm_custom_script" {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_required_providers.md
Warning: Missing version constraint for provider "local" in `required_providers` (terraform_required_providers)
on terraform/environments/contract-work-administration/data.tf line 11:11:data"local_file""cm_custom_metrics" {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_required_providers.mdtflint_exitcode=2
Trivy Scan Failed
Show Output
*****************************
Trivy will check the following folders:
terraform/environments/contract-work-administration
*****************************
Running Trivy in terraform/environments/contract-work-administration
2024-10-29T12:40:38Z INFO [vulndb] Need to update DB
2024-10-29T12:40:38Z INFO [vulndb] Downloading vulnerability DB...2024-10-29T12:40:38Z INFO [vulndb] Downloading artifact...repo="public.ecr.aws/aquasecurity/trivy-db:2"2024-10-29T12:40:40Z INFO [vulndb] Artifact successfully downloaded repo="public.ecr.aws/aquasecurity/trivy-db:2"2024-10-29T12:40:40Z INFO [vuln] Vulnerability scanning is enabled
2024-10-29T12:40:40Z INFO [misconfig] Misconfiguration scanning is enabled
2024-10-29T12:40:40Z INFO [misconfig] Need to update the built-in checks
2024-10-29T12:40:40Z INFO [misconfig] Downloading the built-in checks...156.02 KiB /156.02 KiB [---------------------------------------------------------] 100.00%? p/s 0s2024-10-29T12:40:40Z INFO [secret] Secret scanning is enabled
2024-10-29T12:40:40Z INFO [secret] If your scanning is slow, please try '--scanners vuln' to disable secret scanning
2024-10-29T12:40:40Z INFO [secret] Please see also https://aquasecurity.github.io/trivy/v0.56/docs/scanner/secret#recommendation for faster secret detection2024-10-29T12:40:41Z INFO [terraformscanner] Scanning root module file_path="."2024-10-29T12:40:41Z WARN [terraformparser] Variable values was not found in the environment or variable files. Evaluating may not work correctly.module="root"variables="networking"2024-10-29T12:40:43Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.aws_s3_object.user_public_keys"value="cty.NilVal"2024-10-29T12:40:43Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.data.aws_subnet.local_account"value="cty.NilVal"2024-10-29T12:40:43Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.dynamic.tag"value="cty.NilVal"2024-10-29T12:40:43Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.dynamic.tag"value="cty.NilVal"2024-10-29T12:40:43Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.expiration"value="cty.NilVal"2024-10-29T12:40:43Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.transition"value="cty.NilVal"2024-10-29T12:40:43Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.noncurrent_version_expiration"value="cty.NilVal"2024-10-29T12:40:43Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.noncurrent_version_transition"value="cty.NilVal"2024-10-29T12:40:43Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.principals"value="cty.NilVal"2024-10-29T12:40:43Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.condition"value="cty.NilVal"2024-10-29T12:40:43Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.expiration"value="cty.NilVal"2024-10-29T12:40:43Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.transition"value="cty.NilVal"2024-10-29T12:40:43Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.noncurrent_version_expiration"value="cty.NilVal"2024-10-29T12:40:43Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.noncurrent_version_transition"value="cty.NilVal"2024-10-29T12:40:43Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.principals"value="cty.NilVal"2024-10-29T12:40:43Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.condition"value="cty.NilVal"2024-10-29T12:40:45Z INFO [terraformexecutor] Ignore finding rule="aws-s3-encryption-customer-key"range="github.com/ministryofjustice/modernisation-platform-terraform-bastion-linux?ref=v4.2.0/github.com/ministryofjustice/modernisation-platform-terraform-s3-bucket?ref=568694e50e03630d99cb569eafa06a0b879a1239/main.tf:171-179"2024-10-29T12:40:45Z INFO Number of language-specific files num=02024-10-29T12:40:45Z INFO Detected config files num=9
alb.tf (terraform)
==================
Tests:3 (SUCCESSES:0, FAILURES:2, EXCEPTIONS:1)
Failures:2 (HIGH:2, CRITICAL:0)
HIGH: Application load balancer is not set to drop invalid headers.
════════════════════════════════════════
Passing unknown or invalid headers through to the target poses a potential risk of compromise.
By setting drop_invalid_header_fields to true, anything that does not conform to well known, defined headers will be removed by the load balancer.
See https://avd.aquasec.com/misconfig/avd-aws-0052
────────────────────────────────────────
alb.tf:130-153
────────────────────────────────────────
130 ┌ resource"aws_lb""external" {
131 │ name="${upper(local.application_name_short)}-LoadBalancer"132 │ internal=false133 │ load_balancer_type="application"134 │ security_groups=[aws_security_group.external_lb.id]
135 │ subnets=[data.aws_subnet.public_subnets_a.id, data.aws_subnet.public_subnets_b.id, data.aws_subnet.public_subnets_c.id]
136 │ enable_deletion_protection=local.lb_enable_deletion_protection137 │ idle_timeout=local.external_lb_idle_timeout138 └ enable_http2=false...
────────────────────────────────────────
HIGH: Load balancer is exposed publicly.
════════════════════════════════════════
There are many scenarios in which you would want to expose a load balancer to the wider internet, but this check exists as a warning to prevent accidental exposure of internal assets. You should ensure that this resource should be exposed publicly.
See https://avd.aquasec.com/misconfig/avd-aws-0053
────────────────────────────────────────
alb.tf:132
via alb.tf:130-153 (aws_lb.external)
────────────────────────────────────────
130resource"aws_lb""external" {
...132 [ internal = false...153 }
────────────────────────────────────────
app_servers.tf (terraform)
==========================Tests:5 (SUCCESSES:0, FAILURES:4, EXCEPTIONS:1)
Failures:4 (HIGH:4, CRITICAL:0)
HIGH:InstancedoesnotrequireIMDSaccesstorequireatoken.
════════════════════════════════════════
IMDSv2 (Instance Metadata Service) introducedsessionauthenticationtokenswhichimprovesecuritywhentalkingtoIMDS.Bydefault<code>aws_instance</code>resourcesetsIMDSsessionauthtokenstobeoptional.TofullyprotectIMDSyouneedtoenablesessiontokensbyusing<code>metadata_options</code>blockandits<code>http_tokens</code>variablesetto<code>required</code>.Seehttps://avd.aquasec.com/misconfig/avd-aws-0028
────────────────────────────────────────
app_servers.tf:192viaapp_servers.tf:191-193 (metadata_options)
viaapp_servers.tf:180-212 (aws_instance.app1)
────────────────────────────────────────
180resource"aws_instance""app1" {
...192 [ http_tokens ="optional"...212 }
────────────────────────────────────────
HIGH:InstancedoesnotrequireIMDSaccesstorequireatoken.
════════════════════════════════════════
IMDSv2 (Instance Metadata Service) introducedsessionauthenticationtokenswhichimprovesecuritywhentalkingtoIMDS.Bydefault<code>aws_instance</code>resourcesetsIMDSsessionauthtokenstobeoptional.TofullyprotectIMDSyouneedtoenablesessiontokensbyusing<code>metadata_options</code>blockandits<code>http_tokens</code>variablesetto<code>required</code>.Seehttps://avd.aquasec.com/misconfig/avd-aws-0028
────────────────────────────────────────
app_servers.tf:214-244
────────────────────────────────────────
214 ┌ resource"aws_instance""app2" {
215 │ count =contains(["development", "testing"], local.environment) ?0:1216 │ ami = local.application_data.accounts[local.environment].app_ami_id
217 │ availability_zone ="eu-west-2a"218 │ instance_type = local.application_data.accounts[local.environment].app_instance_type
219 │ monitoring =true220 │ vpc_security_group_ids = [aws_security_group.app.id]
221 │ subnet_id = data.aws_subnet.data_subnets_a.id
222 └ iam_instance_profile = aws_iam_instance_profile.cwa.id
...
────────────────────────────────────────
HIGH: Root block device is not encrypted.
════════════════════════════════════════
Block devices should be encrypted to ensure sensitive data is held securely at rest.
See https://avd.aquasec.com/misconfig/avd-aws-0131
────────────────────────────────────────
app_servers.tf:180-212
────────────────────────────────────────
180 ┌ resource "aws_instance""app1" {
181 │ ami = local.application_data.accounts[local.environment].app_ami_id
182 │ availability_zone ="eu-west-2a"183 │ instance_type = local.application_data.accounts[local.environment].app_instance_type
184 │ monitoring =true185 │ vpc_security_group_ids = [aws_security_group.app.id]
186 │ subnet_id = data.aws_subnet.private_subnets_a.id
187 │ iam_instance_profile = aws_iam_instance_profile.cwa.id
188 └ key_name = aws_key_pair.cwa.key_name
...
────────────────────────────────────────
HIGH: Root block device is not encrypted.
════════════════════════════════════════
Block devices should be encrypted to ensure sensitive data is held securely at rest.
See https://avd.aquasec.com/misconfig/avd-aws-0131
────────────────────────────────────────
app_servers.tf:214-244
────────────────────────────────────────
214 ┌ resource "aws_instance""app2" {
215 │ count =contains(["development", "testing"], local.environment) ?0:1216 │ ami = local.application_data.accounts[local.environment].app_ami_id
217 │ availability_zone ="eu-west-2a"218 │ instance_type = local.application_data.accounts[local.environment].app_instance_type
219 │ monitoring =true220 │ vpc_security_group_ids = [aws_security_group.app.id]
221 │ subnet_id = data.aws_subnet.data_subnets_a.id
222 └ iam_instance_profile = aws_iam_instance_profile.cwa.id
...
────────────────────────────────────────
backup_lambda.tf (terraform)
============================
Tests:3 (SUCCESSES:0, FAILURES:2, EXCEPTIONS:1)
Failures:2 (HIGH:2, CRITICAL:0)
HIGH: Bucket does not have encryption enabled
════════════════════════════════════════
S3 Buckets should be encrypted to protect the data that is stored within them ifaccessiscompromised.
See https://avd.aquasec.com/misconfig/avd-aws-0088
────────────────────────────────────────
backup_lambda.tf:101-107
────────────────────────────────────────
101 ┌ resource "aws_s3_bucket""scripts" {
102 │ bucket ="${local.application_name_short}-${local.environment}-scripts"103 │ tags =merge(
104 │ local.tags,
105 │ { Name ="${local.application_name_short}-${local.environment}-scripts" }
106 │ )
107 └ }
────────────────────────────────────────
HIGH: Bucket does not encrypt data with a customer managed key.
════════════════════════════════════════
Encryption using AWS keys provides protection foryourS3buckets.Toincreasecontroloftheencryptionandmanagefactorslikerotationusecustomermanagedkeys.
See https://avd.aquasec.com/misconfig/avd-aws-0132
────────────────────────────────────────
backup_lambda.tf:101-107
────────────────────────────────────────
101 ┌ resource "aws_s3_bucket""scripts" {
102 │ bucket ="${local.application_name_short}-${local.environment}-scripts"103 │ tags =merge(
104 │ local.tags,
105 │ { Name ="${local.application_name_short}-${local.environment}-scripts" }
106 │ )
107 └ }
────────────────────────────────────────
concurrent_manager.tf (terraform)
=================================
Tests:3 (SUCCESSES:0, FAILURES:2, EXCEPTIONS:1)
Failures:2 (HIGH:2, CRITICAL:0)
HIGH: Instance does not require IMDS access to require a token.
════════════════════════════════════════
IMDS v2 (Instance Metadata Service) introduced session authentication tokens which improve security when talking to IMDS.
By default <code>aws_instance</code> resource sets IMDS session auth tokens to be optional.
To fully protect IMDS you need to enable session tokens by using <code>metadata_options</code> block and its <code>http_tokens</code> variable set to <code>required</code>.
See https://avd.aquasec.com/misconfig/avd-aws-0028
────────────────────────────────────────
concurrent_manager.tf:170
via concurrent_manager.tf:169-171 (metadata_options)
via concurrent_manager.tf:158-190 (aws_instance.concurrent_manager)
────────────────────────────────────────
158 resource "aws_instance""concurrent_manager" {
...170 [ http_tokens ="optional"...190 }
────────────────────────────────────────
HIGH: Root block device is not encrypted.
════════════════════════════════════════
Block devices should be encrypted to ensure sensitive data is held securely at rest.
See https://avd.aquasec.com/misconfig/avd-aws-0131
────────────────────────────────────────
concurrent_manager.tf:158-190
────────────────────────────────────────
158 ┌ resource "aws_instance""concurrent_manager" {
159 │ ami = local.application_data.accounts[local.environment].cm_ami_id
160 │ availability_zone ="eu-west-2a"161 │ instance_type = local.application_data.accounts[local.environment].cm_instance_type
162 │ monitoring =true163 │ vpc_security_group_ids = [aws_security_group.concurrent_manager.id]
164 │ subnet_id = data.aws_subnet.private_subnets_a.id
165 │ iam_instance_profile = aws_iam_instance_profile.cwa.id
166 └ key_name = aws_key_pair.cwa.key_name
...
────────────────────────────────────────
database.tf (terraform)
=======================
Tests:3 (SUCCESSES:0, FAILURES:2, EXCEPTIONS:1)
Failures:2 (HIGH:2, CRITICAL:0)
HIGH: Instance does not require IMDS access to require a token.
════════════════════════════════════════
IMDS v2 (Instance Metadata Service) introduced session authentication tokens which improve security when talking to IMDS.
By default <code>aws_instance</code> resource sets IMDS session auth tokens to be optional.
To fully protect IMDS you need to enable session tokens by using <code>metadata_options</code> block and its <code>http_tokens</code> variable set to <code>required</code>.
See https://avd.aquasec.com/misconfig/avd-aws-0028
────────────────────────────────────────
database.tf:196
via database.tf:195-197 (metadata_options)
via database.tf:184-213 (aws_instance.database)
────────────────────────────────────────
184 resource "aws_instance""database" {
...196 [ http_tokens ="optional"...213 }
────────────────────────────────────────
HIGH: Root block device is not encrypted.
════════════════════════════════════════
Block devices should be encrypted to ensure sensitive data is held securely at rest.
See https://avd.aquasec.com/misconfig/avd-aws-0131
────────────────────────────────────────
database.tf:184-213
────────────────────────────────────────
184 ┌ resource "aws_instance""database" {
185 │ ami = local.application_data.accounts[local.environment].db_ami_id
186 │ availability_zone ="eu-west-2a"187 │ instance_type = local.application_data.accounts[local.environment].db_instance_type
188 │ monitoring =true189 │ vpc_security_group_ids = [aws_security_group.database.id]
190 │ subnet_id = data.aws_subnet.data_subnets_a.id
191 │ iam_instance_profile = aws_iam_instance_profile.cwa.id
192 └ key_name = aws_key_pair.cwa.key_name
...
────────────────────────────────────────
trivy_exitcode=1
Trivy will check the following folders:
terraform/environments/contract-work-administration
Running Trivy in terraform/environments/contract-work-administration
2024-10-30T10:35:19Z INFO [vulndb] Need to update DB
2024-10-30T10:35:19Z INFO [vulndb] Downloading vulnerability DB...
2024-10-30T10:35:19Z INFO [vulndb] Downloading artifact... repo="public.ecr.aws/aquasecurity/trivy-db:2"
2024-10-30T10:35:22Z INFO [vulndb] Artifact successfully downloaded repo="public.ecr.aws/aquasecurity/trivy-db:2"
2024-10-30T10:35:22Z INFO [vuln] Vulnerability scanning is enabled
2024-10-30T10:35:22Z INFO [misconfig] Misconfiguration scanning is enabled
2024-10-30T10:35:22Z INFO [misconfig] Need to update the built-in checks
2024-10-30T10:35:22Z INFO [misconfig] Downloading the built-in checks...
160.60 KiB / 160.60 KiB [---------------------------------------------------------] 100.00% ? p/s 0s2024-10-30T10:35:22Z INFO [secret] Secret scanning is enabled
2024-10-30T10:35:22Z INFO [secret] If your scanning is slow, please try '--scanners vuln' to disable secret scanning
2024-10-30T10:35:22Z INFO [secret] Please see also https://aquasecurity.github.io/trivy/v0.56/docs/scanner/secret#recommendation for faster secret detection
2024-10-30T10:35:23Z INFO [terraform scanner] Scanning root module file_path="."
2024-10-30T10:35:23Z WARN [terraform parser] Variable values was not found in the environment or variable files. Evaluating may not work correctly. module="root" variables="networking"
2024-10-30T10:35:24Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.aws_s3_object.user_public_keys" value="cty.NilVal"
2024-10-30T10:35:24Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.data.aws_subnet.local_account" value="cty.NilVal"
2024-10-30T10:35:24Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.dynamic.tag" value="cty.NilVal"
2024-10-30T10:35:24Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.dynamic.tag" value="cty.NilVal"
2024-10-30T10:35:25Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.expiration" value="cty.NilVal"
2024-10-30T10:35:25Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.transition" value="cty.NilVal"
2024-10-30T10:35:25Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.noncurrent_version_expiration" value="cty.NilVal"
2024-10-30T10:35:25Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.noncurrent_version_transition" value="cty.NilVal"
2024-10-30T10:35:25Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.principals" value="cty.NilVal"
2024-10-30T10:35:25Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.condition" value="cty.NilVal"
2024-10-30T10:35:25Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.expiration" value="cty.NilVal"
2024-10-30T10:35:25Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.transition" value="cty.NilVal"
2024-10-30T10:35:25Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.noncurrent_version_expiration" value="cty.NilVal"
2024-10-30T10:35:25Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.noncurrent_version_transition" value="cty.NilVal"
2024-10-30T10:35:25Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.principals" value="cty.NilVal"
2024-10-30T10:35:25Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.condition" value="cty.NilVal"
2024-10-30T10:35:26Z INFO [terraform executor] Ignore finding rule="aws-s3-encryption-customer-key" range="github.com/ministryofjustice/modernisation-platform-terraform-bastion-linux?ref=v4.2.0/github.com/ministryofjustice/modernisation-platform-terraform-s3-bucket?ref=568694e50e03630d99cb569eafa06a0b879a1239/main.tf:171-179"
2024-10-30T10:35:26Z INFO Number of language-specific files num=0
2024-10-30T10:35:26Z INFO Detected config files num=9
HIGH: Application load balancer is not set to drop invalid headers.
════════════════════════════════════════
Passing unknown or invalid headers through to the target poses a potential risk of compromise.
By setting drop_invalid_header_fields to true, anything that does not conform to well known, defined headers will be removed by the load balancer.
HIGH: Load balancer is exposed publicly.
════════════════════════════════════════
There are many scenarios in which you would want to expose a load balancer to the wider internet, but this check exists as a warning to prevent accidental exposure of internal assets. You should ensure that this resource should be exposed publicly.
HIGH: Instance does not require IMDS access to require a token.
════════════════════════════════════════
IMDS v2 (Instance Metadata Service) introduced session authentication tokens which improve security when talking to IMDS.
By default aws_instance resource sets IMDS session auth tokens to be optional.
To fully protect IMDS you need to enable session tokens by using metadata_options block and its http_tokens variable set to required.
HIGH: Instance does not require IMDS access to require a token.
════════════════════════════════════════
IMDS v2 (Instance Metadata Service) introduced session authentication tokens which improve security when talking to IMDS.
By default aws_instance resource sets IMDS session auth tokens to be optional.
To fully protect IMDS you need to enable session tokens by using metadata_options block and its http_tokens variable set to required.
HIGH: Root block device is not encrypted.
════════════════════════════════════════
Block devices should be encrypted to ensure sensitive data is held securely at rest.
HIGH: Root block device is not encrypted.
════════════════════════════════════════
Block devices should be encrypted to ensure sensitive data is held securely at rest.
HIGH: Bucket does not have encryption enabled
════════════════════════════════════════
S3 Buckets should be encrypted to protect the data that is stored within them if access is compromised.
HIGH: Bucket does not encrypt data with a customer managed key.
════════════════════════════════════════
Encryption using AWS keys provides protection for your S3 buckets. To increase control of the encryption and manage factors like rotation use customer managed keys.
HIGH: Instance does not require IMDS access to require a token.
════════════════════════════════════════
IMDS v2 (Instance Metadata Service) introduced session authentication tokens which improve security when talking to IMDS.
By default aws_instance resource sets IMDS session auth tokens to be optional.
To fully protect IMDS you need to enable session tokens by using metadata_options block and its http_tokens variable set to required.
HIGH: Root block device is not encrypted.
════════════════════════════════════════
Block devices should be encrypted to ensure sensitive data is held securely at rest.
HIGH: Instance does not require IMDS access to require a token.
════════════════════════════════════════
IMDS v2 (Instance Metadata Service) introduced session authentication tokens which improve security when talking to IMDS.
By default aws_instance resource sets IMDS session auth tokens to be optional.
To fully protect IMDS you need to enable session tokens by using metadata_options block and its http_tokens variable set to required.
HIGH: Root block device is not encrypted.
════════════════════════════════════════
Block devices should be encrypted to ensure sensitive data is held securely at rest.
*****************************
Setting default tflint config...
Running tflint --init...
Installing "terraform" plugin...
Installed "terraform" (source: github.com/terraform-linters/tflint-ruleset-terraform, version:0.9.1)
tflint will check the following folders:
terraform/environments/contract-work-administration
*****************************
Running tflint in terraform/environments/contract-work-administration
Excluding the following checks: terraform_unused_declarations
4issue(s) found:
Warning: Missing version constraint for provider "time" in `required_providers` (terraform_required_providers)
on terraform/environments/contract-work-administration/app_servers.tf line 170:170:resource"time_sleep""wait_app_userdata_scripts" {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_required_providers.md
Warning: Missing version constraint for provider "archive" in `required_providers` (terraform_required_providers)
on terraform/environments/contract-work-administration/backup_lambda.tf line 173:173:data"archive_file""connect_db" {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_required_providers.md
Warning: Missing version constraint for provider "template" in `required_providers` (terraform_required_providers)
on terraform/environments/contract-work-administration/cloudwatch.tf line 1126:1126:data"template_file""dashboard_no_ha" {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_required_providers.md
Warning: Missing version constraint for provider "local" in `required_providers` (terraform_required_providers)
on terraform/environments/contract-work-administration/data.tf line 11:11:data"local_file""cm_custom_metrics" {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_required_providers.mdtflint_exitcode=2
Trivy Scan Failed
Show Output
*****************************
Trivy will check the following folders:
terraform/environments/contract-work-administration
*****************************
Running Trivy in terraform/environments/contract-work-administration
2024-10-30T10:35:19Z INFO [vulndb] Need to update DB
2024-10-30T10:35:19Z INFO [vulndb] Downloading vulnerability DB...2024-10-30T10:35:19Z INFO [vulndb] Downloading artifact...repo="public.ecr.aws/aquasecurity/trivy-db:2"2024-10-30T10:35:22Z INFO [vulndb] Artifact successfully downloaded repo="public.ecr.aws/aquasecurity/trivy-db:2"2024-10-30T10:35:22Z INFO [vuln] Vulnerability scanning is enabled
2024-10-30T10:35:22Z INFO [misconfig] Misconfiguration scanning is enabled
2024-10-30T10:35:22Z INFO [misconfig] Need to update the built-in checks
2024-10-30T10:35:22Z INFO [misconfig] Downloading the built-in checks...160.60 KiB /160.60 KiB [---------------------------------------------------------] 100.00%? p/s 0s2024-10-30T10:35:22Z INFO [secret] Secret scanning is enabled
2024-10-30T10:35:22Z INFO [secret] If your scanning is slow, please try '--scanners vuln' to disable secret scanning
2024-10-30T10:35:22Z INFO [secret] Please see also https://aquasecurity.github.io/trivy/v0.56/docs/scanner/secret#recommendation for faster secret detection2024-10-30T10:35:23Z INFO [terraformscanner] Scanning root module file_path="."2024-10-30T10:35:23Z WARN [terraformparser] Variable values was not found in the environment or variable files. Evaluating may not work correctly.module="root"variables="networking"2024-10-30T10:35:24Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.aws_s3_object.user_public_keys"value="cty.NilVal"2024-10-30T10:35:24Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.data.aws_subnet.local_account"value="cty.NilVal"2024-10-30T10:35:24Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.dynamic.tag"value="cty.NilVal"2024-10-30T10:35:24Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.dynamic.tag"value="cty.NilVal"2024-10-30T10:35:25Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.expiration"value="cty.NilVal"2024-10-30T10:35:25Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.transition"value="cty.NilVal"2024-10-30T10:35:25Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.noncurrent_version_expiration"value="cty.NilVal"2024-10-30T10:35:25Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.noncurrent_version_transition"value="cty.NilVal"2024-10-30T10:35:25Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.principals"value="cty.NilVal"2024-10-30T10:35:25Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.condition"value="cty.NilVal"2024-10-30T10:35:25Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.expiration"value="cty.NilVal"2024-10-30T10:35:25Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.transition"value="cty.NilVal"2024-10-30T10:35:25Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.noncurrent_version_expiration"value="cty.NilVal"2024-10-30T10:35:25Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.noncurrent_version_transition"value="cty.NilVal"2024-10-30T10:35:25Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.principals"value="cty.NilVal"2024-10-30T10:35:25Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.condition"value="cty.NilVal"2024-10-30T10:35:26Z INFO [terraformexecutor] Ignore finding rule="aws-s3-encryption-customer-key"range="github.com/ministryofjustice/modernisation-platform-terraform-bastion-linux?ref=v4.2.0/github.com/ministryofjustice/modernisation-platform-terraform-s3-bucket?ref=568694e50e03630d99cb569eafa06a0b879a1239/main.tf:171-179"2024-10-30T10:35:26Z INFO Number of language-specific files num=02024-10-30T10:35:26Z INFO Detected config files num=9
alb.tf (terraform)
==================
Tests:3 (SUCCESSES:0, FAILURES:2, EXCEPTIONS:1)
Failures:2 (HIGH:2, CRITICAL:0)
HIGH: Application load balancer is not set to drop invalid headers.
════════════════════════════════════════
Passing unknown or invalid headers through to the target poses a potential risk of compromise.
By setting drop_invalid_header_fields to true, anything that does not conform to well known, defined headers will be removed by the load balancer.
See https://avd.aquasec.com/misconfig/avd-aws-0052
────────────────────────────────────────
alb.tf:130-153
────────────────────────────────────────
130 ┌ resource"aws_lb""external" {
131 │ name="${upper(local.application_name_short)}-LoadBalancer"132 │ internal=false133 │ load_balancer_type="application"134 │ security_groups=[aws_security_group.external_lb.id]
135 │ subnets=[data.aws_subnet.public_subnets_a.id, data.aws_subnet.public_subnets_b.id, data.aws_subnet.public_subnets_c.id]
136 │ enable_deletion_protection=local.lb_enable_deletion_protection137 │ idle_timeout=local.external_lb_idle_timeout138 └ enable_http2=false...
────────────────────────────────────────
HIGH: Load balancer is exposed publicly.
════════════════════════════════════════
There are many scenarios in which you would want to expose a load balancer to the wider internet, but this check exists as a warning to prevent accidental exposure of internal assets. You should ensure that this resource should be exposed publicly.
See https://avd.aquasec.com/misconfig/avd-aws-0053
────────────────────────────────────────
alb.tf:130-153
────────────────────────────────────────
130 ┌ resource"aws_lb""external" {
131 │ name="${upper(local.application_name_short)}-LoadBalancer"132 │ internal=false133 │ load_balancer_type="application"134 │ security_groups=[aws_security_group.external_lb.id]
135 │ subnets=[data.aws_subnet.public_subnets_a.id, data.aws_subnet.public_subnets_b.id, data.aws_subnet.public_subnets_c.id]
136 │ enable_deletion_protection=local.lb_enable_deletion_protection137 │ idle_timeout=local.external_lb_idle_timeout138 └ enable_http2=false...
────────────────────────────────────────
app_servers.tf (terraform)
==========================
Tests:5 (SUCCESSES:0, FAILURES:4, EXCEPTIONS:1)
Failures:4 (HIGH:4, CRITICAL:0)
HIGH: Instance does not require IMDS access to require a token.
════════════════════════════════════════
IMDS v2 (Instance Metadata Service) introduced session authentication tokens which improve security when talking to IMDS.
By default <code>aws_instance</code> resource sets IMDS session auth tokens to be optional.
To fully protect IMDS you need to enable session tokens by using <code>metadata_options</code> block and its <code>http_tokens</code> variable set to <code>required</code>.
See https://avd.aquasec.com/misconfig/avd-aws-0028
────────────────────────────────────────
app_servers.tf:191-193
via app_servers.tf:180-212 (aws_instance.app1)
────────────────────────────────────────
180resource"aws_instance""app1" {
...191 ┌ metadata_options {
192 │ http_tokens="optional"193 └ }
...212 }
────────────────────────────────────────
HIGH: Instance does not require IMDS access to require a token.
════════════════════════════════════════
IMDS v2 (Instance Metadata Service) introduced session authentication tokens which improve security when talking to IMDS.
By default <code>aws_instance</code> resource sets IMDS session auth tokens to be optional.
To fully protect IMDS you need to enable session tokens by using <code>metadata_options</code> block and its <code>http_tokens</code> variable set to <code>required</code>.
See https://avd.aquasec.com/misconfig/avd-aws-0028
────────────────────────────────────────
app_servers.tf:214-244
────────────────────────────────────────
214 ┌ resource"aws_instance""app2" {
215 │ count=contains(["development2", "testing"], local.environment) ?0:1216 │ ami=local.application_data.accounts[local.environment].app_ami_id217 │ availability_zone="eu-west-2a"218 │ instance_type=local.application_data.accounts[local.environment].app_instance_type219 │ monitoring=true220 │ vpc_security_group_ids=[aws_security_group.app.id]
221 │ subnet_id=data.aws_subnet.data_subnets_a.id222 └ iam_instance_profile=aws_iam_instance_profile.cwa.id...
────────────────────────────────────────
HIGH: Root block device is not encrypted.
════════════════════════════════════════
Block devices should be encrypted to ensure sensitive data is held securely at rest.
See https://avd.aquasec.com/misconfig/avd-aws-0131
────────────────────────────────────────
app_servers.tf:195-201
via app_servers.tf:180-212 (aws_instance.app1)
────────────────────────────────────────
180resource"aws_instance""app1" {
...195 ┌ root_block_device {
196 │ tags=merge(
197 │ { "instance-scheduling" = "skip-scheduling" },
198 │ local.tags,
199 │ { "Name" = "${local.application_name_short}-app1-root" }
200 │ )
201 └ }
...
────────────────────────────────────────
HIGH: Root block device is not encrypted.
════════════════════════════════════════
Block devices should be encrypted to ensure sensitive data is held securely at rest.
See https://avd.aquasec.com/misconfig/avd-aws-0131
────────────────────────────────────────
app_servers.tf:227-233
via app_servers.tf:214-244 (aws_instance.app2[0])
────────────────────────────────────────
214resource"aws_instance""app2" {
...227 ┌ root_block_device {
228 │ tags=merge(
229 │ { "instance-scheduling" = "skip-scheduling" },
230 │ local.tags,
231 │ { "Name" = "${local.application_name_short}-app2-root" }
232 │ )
233 └ }
...
────────────────────────────────────────
backup_lambda.tf (terraform)
============================
Tests:3 (SUCCESSES:0, FAILURES:2, EXCEPTIONS:1)
Failures:2 (HIGH:2, CRITICAL:0)
HIGH: Bucket does not have encryption enabled
════════════════════════════════════════
S3 Buckets should be encrypted to protect the data that is stored within them if access is compromised.
See https://avd.aquasec.com/misconfig/avd-aws-0088
────────────────────────────────────────
backup_lambda.tf:101-107
────────────────────────────────────────
101 ┌ resource"aws_s3_bucket""scripts" {
102 │ bucket="${local.application_name_short}-${local.environment}-scripts"103 │ tags=merge(
104 │ local.tags,
105 │ { Name ="${local.application_name_short}-${local.environment}-scripts" }
106 │ )
107 └ }
────────────────────────────────────────
HIGH: Bucket does not encrypt data with a customer managed key.
════════════════════════════════════════
Encryption using AWS keys provides protection for your S3 buckets. To increase control of the encryption and manage factors like rotation use customer managed keys.
See https://avd.aquasec.com/misconfig/avd-aws-0132
────────────────────────────────────────
backup_lambda.tf:101-107
────────────────────────────────────────
101 ┌ resource"aws_s3_bucket""scripts" {
102 │ bucket="${local.application_name_short}-${local.environment}-scripts"103 │ tags=merge(
104 │ local.tags,
105 │ { Name ="${local.application_name_short}-${local.environment}-scripts" }
106 │ )
107 └ }
────────────────────────────────────────
concurrent_manager.tf (terraform)
=================================
Tests:3 (SUCCESSES:0, FAILURES:2, EXCEPTIONS:1)
Failures:2 (HIGH:2, CRITICAL:0)
HIGH: Instance does not require IMDS access to require a token.
════════════════════════════════════════
IMDS v2 (Instance Metadata Service) introduced session authentication tokens which improve security when talking to IMDS.
By default <code>aws_instance</code> resource sets IMDS session auth tokens to be optional.
To fully protect IMDS you need to enable session tokens by using <code>metadata_options</code> block and its <code>http_tokens</code> variable set to <code>required</code>.
See https://avd.aquasec.com/misconfig/avd-aws-0028
────────────────────────────────────────
concurrent_manager.tf:169-171
via concurrent_manager.tf:158-190 (aws_instance.concurrent_manager)
────────────────────────────────────────
158resource"aws_instance""concurrent_manager" {
...169 ┌ metadata_options {
170 │ http_tokens="optional"171 └ }
...190 }
────────────────────────────────────────
HIGH: Root block device is not encrypted.
════════════════════════════════════════
Block devices should be encrypted to ensure sensitive data is held securely at rest.
See https://avd.aquasec.com/misconfig/avd-aws-0131
────────────────────────────────────────
concurrent_manager.tf:173-179
via concurrent_manager.tf:158-190 (aws_instance.concurrent_manager)
────────────────────────────────────────
158resource"aws_instance""concurrent_manager" {
...173 ┌ root_block_device {
174 │ tags=merge(
175 │ { "instance-scheduling" = "skip-scheduling" },
176 │ local.tags,
177 │ { "Name" = "${local.application_name_short}-concurrent-manager-root" }
178 │ )
179 └ }
...
────────────────────────────────────────
database.tf (terraform)
=======================
Tests:3 (SUCCESSES:0, FAILURES:2, EXCEPTIONS:1)
Failures:2 (HIGH:2, CRITICAL:0)
HIGH: Instance does not require IMDS access to require a token.
════════════════════════════════════════
IMDS v2 (Instance Metadata Service) introduced session authentication tokens which improve security when talking to IMDS.
By default <code>aws_instance</code> resource sets IMDS session auth tokens to be optional.
To fully protect IMDS you need to enable session tokens by using <code>metadata_options</code> block and its <code>http_tokens</code> variable set to <code>required</code>.
See https://avd.aquasec.com/misconfig/avd-aws-0028
────────────────────────────────────────
database.tf:195-197
via database.tf:184-213 (aws_instance.database)
────────────────────────────────────────
184resource"aws_instance""database" {
...195 ┌ metadata_options {
196 │ http_tokens="optional"197 └ }
...213 }
────────────────────────────────────────
HIGH: Root block device is not encrypted.
════════════════════════════════════════
Block devices should be encrypted to ensure sensitive data is held securely at rest.
See https://avd.aquasec.com/misconfig/avd-aws-0131
────────────────────────────────────────
database.tf:199-205
via database.tf:184-213 (aws_instance.database)
────────────────────────────────────────
184resource"aws_instance""database" {
...199 ┌ root_block_device {
200 │ tags=merge(
201 │ { "instance-scheduling" = "skip-scheduling" },
202 │ local.tags,
203 │ { "Name" = "${local.application_name_short}-database-root" }
204 │ )
205 └ }
...
────────────────────────────────────────
trivy_exitcode=1
Trivy will check the following folders:
terraform/environments/contract-work-administration
Running Trivy in terraform/environments/contract-work-administration
2024-10-30T11:06:14Z INFO [vulndb] Need to update DB
2024-10-30T11:06:14Z INFO [vulndb] Downloading vulnerability DB...
2024-10-30T11:06:14Z INFO [vulndb] Downloading artifact... repo="public.ecr.aws/aquasecurity/trivy-db:2"
2024-10-30T11:06:16Z INFO [vulndb] Artifact successfully downloaded repo="public.ecr.aws/aquasecurity/trivy-db:2"
2024-10-30T11:06:16Z INFO [vuln] Vulnerability scanning is enabled
2024-10-30T11:06:16Z INFO [misconfig] Misconfiguration scanning is enabled
2024-10-30T11:06:16Z INFO [misconfig] Need to update the built-in checks
2024-10-30T11:06:16Z INFO [misconfig] Downloading the built-in checks...
160.60 KiB / 160.60 KiB [---------------------------------------------------------] 100.00% ? p/s 0s2024-10-30T11:06:17Z INFO [secret] Secret scanning is enabled
2024-10-30T11:06:17Z INFO [secret] If your scanning is slow, please try '--scanners vuln' to disable secret scanning
2024-10-30T11:06:17Z INFO [secret] Please see also https://aquasecurity.github.io/trivy/v0.56/docs/scanner/secret#recommendation for faster secret detection
2024-10-30T11:06:18Z INFO [terraform scanner] Scanning root module file_path="."
2024-10-30T11:06:18Z WARN [terraform parser] Variable values was not found in the environment or variable files. Evaluating may not work correctly. module="root" variables="networking"
2024-10-30T11:06:19Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.aws_s3_object.user_public_keys" value="cty.NilVal"
2024-10-30T11:06:19Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.data.aws_subnet.local_account" value="cty.NilVal"
2024-10-30T11:06:19Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.dynamic.tag" value="cty.NilVal"
2024-10-30T11:06:19Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.dynamic.tag" value="cty.NilVal"
2024-10-30T11:06:20Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.expiration" value="cty.NilVal"
2024-10-30T11:06:20Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.transition" value="cty.NilVal"
2024-10-30T11:06:20Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.noncurrent_version_expiration" value="cty.NilVal"
2024-10-30T11:06:20Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.noncurrent_version_transition" value="cty.NilVal"
2024-10-30T11:06:20Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.principals" value="cty.NilVal"
2024-10-30T11:06:20Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.condition" value="cty.NilVal"
2024-10-30T11:06:20Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.expiration" value="cty.NilVal"
2024-10-30T11:06:20Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.transition" value="cty.NilVal"
2024-10-30T11:06:20Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.noncurrent_version_expiration" value="cty.NilVal"
2024-10-30T11:06:20Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.noncurrent_version_transition" value="cty.NilVal"
2024-10-30T11:06:20Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.principals" value="cty.NilVal"
2024-10-30T11:06:20Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.condition" value="cty.NilVal"
2024-10-30T11:06:21Z INFO [terraform executor] Ignore finding rule="aws-s3-encryption-customer-key" range="github.com/ministryofjustice/modernisation-platform-terraform-bastion-linux?ref=v4.2.0/github.com/ministryofjustice/modernisation-platform-terraform-s3-bucket?ref=568694e50e03630d99cb569eafa06a0b879a1239/main.tf:171-179"
2024-10-30T11:06:22Z INFO Number of language-specific files num=0
2024-10-30T11:06:22Z INFO Detected config files num=9
HIGH: Application load balancer is not set to drop invalid headers.
════════════════════════════════════════
Passing unknown or invalid headers through to the target poses a potential risk of compromise.
By setting drop_invalid_header_fields to true, anything that does not conform to well known, defined headers will be removed by the load balancer.
HIGH: Load balancer is exposed publicly.
════════════════════════════════════════
There are many scenarios in which you would want to expose a load balancer to the wider internet, but this check exists as a warning to prevent accidental exposure of internal assets. You should ensure that this resource should be exposed publicly.
HIGH: Instance does not require IMDS access to require a token.
════════════════════════════════════════
IMDS v2 (Instance Metadata Service) introduced session authentication tokens which improve security when talking to IMDS.
By default aws_instance resource sets IMDS session auth tokens to be optional.
To fully protect IMDS you need to enable session tokens by using metadata_options block and its http_tokens variable set to required.
HIGH: Instance does not require IMDS access to require a token.
════════════════════════════════════════
IMDS v2 (Instance Metadata Service) introduced session authentication tokens which improve security when talking to IMDS.
By default aws_instance resource sets IMDS session auth tokens to be optional.
To fully protect IMDS you need to enable session tokens by using metadata_options block and its http_tokens variable set to required.
HIGH: Root block device is not encrypted.
════════════════════════════════════════
Block devices should be encrypted to ensure sensitive data is held securely at rest.
HIGH: Root block device is not encrypted.
════════════════════════════════════════
Block devices should be encrypted to ensure sensitive data is held securely at rest.
HIGH: Bucket does not have encryption enabled
════════════════════════════════════════
S3 Buckets should be encrypted to protect the data that is stored within them if access is compromised.
HIGH: Bucket does not encrypt data with a customer managed key.
════════════════════════════════════════
Encryption using AWS keys provides protection for your S3 buckets. To increase control of the encryption and manage factors like rotation use customer managed keys.
HIGH: Instance does not require IMDS access to require a token.
════════════════════════════════════════
IMDS v2 (Instance Metadata Service) introduced session authentication tokens which improve security when talking to IMDS.
By default aws_instance resource sets IMDS session auth tokens to be optional.
To fully protect IMDS you need to enable session tokens by using metadata_options block and its http_tokens variable set to required.
HIGH: Root block device is not encrypted.
════════════════════════════════════════
Block devices should be encrypted to ensure sensitive data is held securely at rest.
HIGH: Instance does not require IMDS access to require a token.
════════════════════════════════════════
IMDS v2 (Instance Metadata Service) introduced session authentication tokens which improve security when talking to IMDS.
By default aws_instance resource sets IMDS session auth tokens to be optional.
To fully protect IMDS you need to enable session tokens by using metadata_options block and its http_tokens variable set to required.
HIGH: Root block device is not encrypted.
════════════════════════════════════════
Block devices should be encrypted to ensure sensitive data is held securely at rest.
*****************************
Setting default tflint config...
Running tflint --init...
Installing "terraform" plugin...
Installed "terraform" (source: github.com/terraform-linters/tflint-ruleset-terraform, version:0.9.1)
tflint will check the following folders:
terraform/environments/contract-work-administration
*****************************
Running tflint in terraform/environments/contract-work-administration
Excluding the following checks: terraform_unused_declarations
4issue(s) found:
Warning: Missing version constraint for provider "archive" in `required_providers` (terraform_required_providers)
on terraform/environments/contract-work-administration/backup_lambda.tf line 173:173:data"archive_file""connect_db" {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_required_providers.md
Warning: Missing version constraint for provider "template" in `required_providers` (terraform_required_providers)
on terraform/environments/contract-work-administration/cloudwatch.tf line 1126:1126:data"template_file""dashboard_no_ha" {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_required_providers.md
Warning: Missing version constraint for provider "time" in `required_providers` (terraform_required_providers)
on terraform/environments/contract-work-administration/concurrent_manager.tf line 149:149:resource"time_sleep""wait_cm_custom_script" {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_required_providers.md
Warning: Missing version constraint for provider "local" in `required_providers` (terraform_required_providers)
on terraform/environments/contract-work-administration/data.tf line 11:11:data"local_file""cm_custom_metrics" {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_required_providers.mdtflint_exitcode=2
Trivy Scan Failed
Show Output
*****************************
Trivy will check the following folders:
terraform/environments/contract-work-administration
*****************************
Running Trivy in terraform/environments/contract-work-administration
2024-10-30T11:06:14Z INFO [vulndb] Need to update DB
2024-10-30T11:06:14Z INFO [vulndb] Downloading vulnerability DB...2024-10-30T11:06:14Z INFO [vulndb] Downloading artifact...repo="public.ecr.aws/aquasecurity/trivy-db:2"2024-10-30T11:06:16Z INFO [vulndb] Artifact successfully downloaded repo="public.ecr.aws/aquasecurity/trivy-db:2"2024-10-30T11:06:16Z INFO [vuln] Vulnerability scanning is enabled
2024-10-30T11:06:16Z INFO [misconfig] Misconfiguration scanning is enabled
2024-10-30T11:06:16Z INFO [misconfig] Need to update the built-in checks
2024-10-30T11:06:16Z INFO [misconfig] Downloading the built-in checks...160.60 KiB /160.60 KiB [---------------------------------------------------------] 100.00%? p/s 0s2024-10-30T11:06:17Z INFO [secret] Secret scanning is enabled
2024-10-30T11:06:17Z INFO [secret] If your scanning is slow, please try '--scanners vuln' to disable secret scanning
2024-10-30T11:06:17Z INFO [secret] Please see also https://aquasecurity.github.io/trivy/v0.56/docs/scanner/secret#recommendation for faster secret detection2024-10-30T11:06:18Z INFO [terraformscanner] Scanning root module file_path="."2024-10-30T11:06:18Z WARN [terraformparser] Variable values was not found in the environment or variable files. Evaluating may not work correctly.module="root"variables="networking"2024-10-30T11:06:19Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.aws_s3_object.user_public_keys"value="cty.NilVal"2024-10-30T11:06:19Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.data.aws_subnet.local_account"value="cty.NilVal"2024-10-30T11:06:19Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.dynamic.tag"value="cty.NilVal"2024-10-30T11:06:19Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.dynamic.tag"value="cty.NilVal"2024-10-30T11:06:20Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.expiration"value="cty.NilVal"2024-10-30T11:06:20Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.transition"value="cty.NilVal"2024-10-30T11:06:20Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.noncurrent_version_expiration"value="cty.NilVal"2024-10-30T11:06:20Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.noncurrent_version_transition"value="cty.NilVal"2024-10-30T11:06:20Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.principals"value="cty.NilVal"2024-10-30T11:06:20Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.condition"value="cty.NilVal"2024-10-30T11:06:20Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.expiration"value="cty.NilVal"2024-10-30T11:06:20Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.transition"value="cty.NilVal"2024-10-30T11:06:20Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.noncurrent_version_expiration"value="cty.NilVal"2024-10-30T11:06:20Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.noncurrent_version_transition"value="cty.NilVal"2024-10-30T11:06:20Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.principals"value="cty.NilVal"2024-10-30T11:06:20Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.condition"value="cty.NilVal"2024-10-30T11:06:21Z INFO [terraformexecutor] Ignore finding rule="aws-s3-encryption-customer-key"range="github.com/ministryofjustice/modernisation-platform-terraform-bastion-linux?ref=v4.2.0/github.com/ministryofjustice/modernisation-platform-terraform-s3-bucket?ref=568694e50e03630d99cb569eafa06a0b879a1239/main.tf:171-179"2024-10-30T11:06:22Z INFO Number of language-specific files num=02024-10-30T11:06:22Z INFO Detected config files num=9
alb.tf (terraform)
==================
Tests:3 (SUCCESSES:0, FAILURES:2, EXCEPTIONS:1)
Failures:2 (HIGH:2, CRITICAL:0)
HIGH: Application load balancer is not set to drop invalid headers.
════════════════════════════════════════
Passing unknown or invalid headers through to the target poses a potential risk of compromise.
By setting drop_invalid_header_fields to true, anything that does not conform to well known, defined headers will be removed by the load balancer.
See https://avd.aquasec.com/misconfig/avd-aws-0052
────────────────────────────────────────
alb.tf:130-153
────────────────────────────────────────
130 ┌ resource"aws_lb""external" {
131 │ name="${upper(local.application_name_short)}-LoadBalancer"132 │ internal=false133 │ load_balancer_type="application"134 │ security_groups=[aws_security_group.external_lb.id]
135 │ subnets=[data.aws_subnet.public_subnets_a.id, data.aws_subnet.public_subnets_b.id, data.aws_subnet.public_subnets_c.id]
136 │ enable_deletion_protection=local.lb_enable_deletion_protection137 │ idle_timeout=local.external_lb_idle_timeout138 └ enable_http2=false...
────────────────────────────────────────
HIGH: Load balancer is exposed publicly.
════════════════════════════════════════
There are many scenarios in which you would want to expose a load balancer to the wider internet, but this check exists as a warning to prevent accidental exposure of internal assets. You should ensure that this resource should be exposed publicly.
See https://avd.aquasec.com/misconfig/avd-aws-0053
────────────────────────────────────────
alb.tf:130-153
────────────────────────────────────────
130 ┌ resource"aws_lb""external" {
131 │ name="${upper(local.application_name_short)}-LoadBalancer"132 │ internal=false133 │ load_balancer_type="application"134 │ security_groups=[aws_security_group.external_lb.id]
135 │ subnets=[data.aws_subnet.public_subnets_a.id, data.aws_subnet.public_subnets_b.id, data.aws_subnet.public_subnets_c.id]
136 │ enable_deletion_protection=local.lb_enable_deletion_protection137 │ idle_timeout=local.external_lb_idle_timeout138 └ enable_http2=false...
────────────────────────────────────────
app_servers.tf (terraform)
==========================
Tests:5 (SUCCESSES:0, FAILURES:4, EXCEPTIONS:1)
Failures:4 (HIGH:4, CRITICAL:0)
HIGH: Instance does not require IMDS access to require a token.
════════════════════════════════════════
IMDS v2 (Instance Metadata Service) introduced session authentication tokens which improve security when talking to IMDS.
By default <code>aws_instance</code> resource sets IMDS session auth tokens to be optional.
To fully protect IMDS you need to enable session tokens by using <code>metadata_options</code> block and its <code>http_tokens</code> variable set to <code>required</code>.
See https://avd.aquasec.com/misconfig/avd-aws-0028
────────────────────────────────────────
app_servers.tf:191-193
via app_servers.tf:180-212 (aws_instance.app1)
────────────────────────────────────────
180resource"aws_instance""app1" {
...191 ┌ metadata_options {
192 │ http_tokens="optional"193 └ }
...212 }
────────────────────────────────────────
HIGH: Instance does not require IMDS access to require a token.
════════════════════════════════════════
IMDS v2 (Instance Metadata Service) introduced session authentication tokens which improve security when talking to IMDS.
By default <code>aws_instance</code> resource sets IMDS session auth tokens to be optional.
To fully protect IMDS you need to enable session tokens by using <code>metadata_options</code> block and its <code>http_tokens</code> variable set to <code>required</code>.
See https://avd.aquasec.com/misconfig/avd-aws-0028
────────────────────────────────────────
app_servers.tf:226-228
via app_servers.tf:214-247 (aws_instance.app2[0])
────────────────────────────────────────
214resource"aws_instance""app2" {
...226 ┌ metadata_options {
227 │ http_tokens="optional"228 └ }
...247 }
────────────────────────────────────────
HIGH: Root block device is not encrypted.
════════════════════════════════════════
Block devices should be encrypted to ensure sensitive data is held securely at rest.
See https://avd.aquasec.com/misconfig/avd-aws-0131
────────────────────────────────────────
app_servers.tf:195-201
via app_servers.tf:180-212 (aws_instance.app1)
────────────────────────────────────────
180resource"aws_instance""app1" {
...195 ┌ root_block_device {
196 │ tags=merge(
197 │ { "instance-scheduling" = "skip-scheduling" },
198 │ local.tags,
199 │ { "Name" = "${local.application_name_short}-app1-root" }
200 │ )
201 └ }
...
────────────────────────────────────────
HIGH: Root block device is not encrypted.
════════════════════════════════════════
Block devices should be encrypted to ensure sensitive data is held securely at rest.
See https://avd.aquasec.com/misconfig/avd-aws-0131
────────────────────────────────────────
app_servers.tf:230-236
via app_servers.tf:214-247 (aws_instance.app2[0])
────────────────────────────────────────
214resource"aws_instance""app2" {
...230 ┌ root_block_device {
231 │ tags=merge(
232 │ { "instance-scheduling" = "skip-scheduling" },
233 │ local.tags,
234 │ { "Name" = "${local.application_name_short}-app2-root" }
235 │ )
236 └ }
...
────────────────────────────────────────
backup_lambda.tf (terraform)
============================
Tests:3 (SUCCESSES:0, FAILURES:2, EXCEPTIONS:1)
Failures:2 (HIGH:2, CRITICAL:0)
HIGH: Bucket does not have encryption enabled
════════════════════════════════════════
S3 Buckets should be encrypted to protect the data that is stored within them if access is compromised.
See https://avd.aquasec.com/misconfig/avd-aws-0088
────────────────────────────────────────
backup_lambda.tf:101-107
────────────────────────────────────────
101 ┌ resource"aws_s3_bucket""scripts" {
102 │ bucket="${local.application_name_short}-${local.environment}-scripts"103 │ tags=merge(
104 │ local.tags,
105 │ { Name ="${local.application_name_short}-${local.environment}-scripts" }
106 │ )
107 └ }
────────────────────────────────────────
HIGH: Bucket does not encrypt data with a customer managed key.
════════════════════════════════════════
Encryption using AWS keys provides protection for your S3 buckets. To increase control of the encryption and manage factors like rotation use customer managed keys.
See https://avd.aquasec.com/misconfig/avd-aws-0132
────────────────────────────────────────
backup_lambda.tf:101-107
────────────────────────────────────────
101 ┌ resource"aws_s3_bucket""scripts" {
102 │ bucket="${local.application_name_short}-${local.environment}-scripts"103 │ tags=merge(
104 │ local.tags,
105 │ { Name ="${local.application_name_short}-${local.environment}-scripts" }
106 │ )
107 └ }
────────────────────────────────────────
concurrent_manager.tf (terraform)
=================================
Tests:3 (SUCCESSES:0, FAILURES:2, EXCEPTIONS:1)
Failures:2 (HIGH:2, CRITICAL:0)
HIGH: Instance does not require IMDS access to require a token.
════════════════════════════════════════
IMDS v2 (Instance Metadata Service) introduced session authentication tokens which improve security when talking to IMDS.
By default <code>aws_instance</code> resource sets IMDS session auth tokens to be optional.
To fully protect IMDS you need to enable session tokens by using <code>metadata_options</code> block and its <code>http_tokens</code> variable set to <code>required</code>.
See https://avd.aquasec.com/misconfig/avd-aws-0028
────────────────────────────────────────
concurrent_manager.tf:169-171
via concurrent_manager.tf:158-190 (aws_instance.concurrent_manager)
────────────────────────────────────────
158resource"aws_instance""concurrent_manager" {
...169 ┌ metadata_options {
170 │ http_tokens="optional"171 └ }
...190 }
────────────────────────────────────────
HIGH: Root block device is not encrypted.
════════════════════════════════════════
Block devices should be encrypted to ensure sensitive data is held securely at rest.
See https://avd.aquasec.com/misconfig/avd-aws-0131
────────────────────────────────────────
concurrent_manager.tf:173-179
via concurrent_manager.tf:158-190 (aws_instance.concurrent_manager)
────────────────────────────────────────
158resource"aws_instance""concurrent_manager" {
...173 ┌ root_block_device {
174 │ tags=merge(
175 │ { "instance-scheduling" = "skip-scheduling" },
176 │ local.tags,
177 │ { "Name" = "${local.application_name_short}-concurrent-manager-root" }
178 │ )
179 └ }
...
────────────────────────────────────────
database.tf (terraform)
=======================
Tests:3 (SUCCESSES:0, FAILURES:2, EXCEPTIONS:1)
Failures:2 (HIGH:2, CRITICAL:0)
HIGH: Instance does not require IMDS access to require a token.
════════════════════════════════════════
IMDS v2 (Instance Metadata Service) introduced session authentication tokens which improve security when talking to IMDS.
By default <code>aws_instance</code> resource sets IMDS session auth tokens to be optional.
To fully protect IMDS you need to enable session tokens by using <code>metadata_options</code> block and its <code>http_tokens</code> variable set to <code>required</code>.
See https://avd.aquasec.com/misconfig/avd-aws-0028
────────────────────────────────────────
database.tf:195-197
via database.tf:184-213 (aws_instance.database)
────────────────────────────────────────
184resource"aws_instance""database" {
...195 ┌ metadata_options {
196 │ http_tokens="optional"197 └ }
...213 }
────────────────────────────────────────
HIGH: Root block device is not encrypted.
════════════════════════════════════════
Block devices should be encrypted to ensure sensitive data is held securely at rest.
See https://avd.aquasec.com/misconfig/avd-aws-0131
────────────────────────────────────────
database.tf:199-205
via database.tf:184-213 (aws_instance.database)
────────────────────────────────────────
184resource"aws_instance""database" {
...199 ┌ root_block_device {
200 │ tags=merge(
201 │ { "instance-scheduling" = "skip-scheduling" },
202 │ local.tags,
203 │ { "Name" = "${local.application_name_short}-database-root" }
204 │ )
205 └ }
...
────────────────────────────────────────
trivy_exitcode=1
Trivy will check the following folders:
terraform/environments/contract-work-administration
Running Trivy in terraform/environments/contract-work-administration
2024-10-30T13:59:37Z INFO [vulndb] Need to update DB
2024-10-30T13:59:37Z INFO [vulndb] Downloading vulnerability DB...
2024-10-30T13:59:37Z INFO [vulndb] Downloading artifact... repo="public.ecr.aws/aquasecurity/trivy-db:2"
2024-10-30T13:59:39Z INFO [vulndb] Artifact successfully downloaded repo="public.ecr.aws/aquasecurity/trivy-db:2"
2024-10-30T13:59:39Z INFO [vuln] Vulnerability scanning is enabled
2024-10-30T13:59:39Z INFO [misconfig] Misconfiguration scanning is enabled
2024-10-30T13:59:39Z INFO [misconfig] Need to update the built-in checks
2024-10-30T13:59:39Z INFO [misconfig] Downloading the built-in checks...
160.60 KiB / 160.60 KiB [------------------------------------------------------] 100.00% ? p/s 100ms2024-10-30T13:59:39Z INFO [secret] Secret scanning is enabled
2024-10-30T13:59:39Z INFO [secret] If your scanning is slow, please try '--scanners vuln' to disable secret scanning
2024-10-30T13:59:39Z INFO [secret] Please see also https://aquasecurity.github.io/trivy/v0.56/docs/scanner/secret#recommendation for faster secret detection
2024-10-30T13:59:41Z INFO [terraform scanner] Scanning root module file_path="."
2024-10-30T13:59:41Z WARN [terraform parser] Variable values was not found in the environment or variable files. Evaluating may not work correctly. module="root" variables="networking"
2024-10-30T13:59:43Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.aws_s3_object.user_public_keys" value="cty.NilVal"
2024-10-30T13:59:43Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.data.aws_subnet.local_account" value="cty.NilVal"
2024-10-30T13:59:43Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.dynamic.tag" value="cty.NilVal"
2024-10-30T13:59:43Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.dynamic.tag" value="cty.NilVal"
2024-10-30T13:59:43Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.expiration" value="cty.NilVal"
2024-10-30T13:59:43Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.transition" value="cty.NilVal"
2024-10-30T13:59:43Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.noncurrent_version_expiration" value="cty.NilVal"
2024-10-30T13:59:43Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.noncurrent_version_transition" value="cty.NilVal"
2024-10-30T13:59:43Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.principals" value="cty.NilVal"
2024-10-30T13:59:43Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.condition" value="cty.NilVal"
2024-10-30T13:59:43Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.expiration" value="cty.NilVal"
2024-10-30T13:59:43Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.transition" value="cty.NilVal"
2024-10-30T13:59:43Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.noncurrent_version_expiration" value="cty.NilVal"
2024-10-30T13:59:43Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.noncurrent_version_transition" value="cty.NilVal"
2024-10-30T13:59:43Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.principals" value="cty.NilVal"
2024-10-30T13:59:43Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.condition" value="cty.NilVal"
2024-10-30T13:59:44Z INFO [terraform executor] Ignore finding rule="aws-s3-encryption-customer-key" range="github.com/ministryofjustice/modernisation-platform-terraform-bastion-linux?ref=v4.2.0/github.com/ministryofjustice/modernisation-platform-terraform-s3-bucket?ref=568694e50e03630d99cb569eafa06a0b879a1239/main.tf:171-179"
2024-10-30T13:59:45Z INFO Number of language-specific files num=0
2024-10-30T13:59:45Z INFO Detected config files num=9
HIGH: Application load balancer is not set to drop invalid headers.
════════════════════════════════════════
Passing unknown or invalid headers through to the target poses a potential risk of compromise.
By setting drop_invalid_header_fields to true, anything that does not conform to well known, defined headers will be removed by the load balancer.
HIGH: Load balancer is exposed publicly.
════════════════════════════════════════
There are many scenarios in which you would want to expose a load balancer to the wider internet, but this check exists as a warning to prevent accidental exposure of internal assets. You should ensure that this resource should be exposed publicly.
HIGH: Instance does not require IMDS access to require a token.
════════════════════════════════════════
IMDS v2 (Instance Metadata Service) introduced session authentication tokens which improve security when talking to IMDS.
By default aws_instance resource sets IMDS session auth tokens to be optional.
To fully protect IMDS you need to enable session tokens by using metadata_options block and its http_tokens variable set to required.
HIGH: Instance does not require IMDS access to require a token.
════════════════════════════════════════
IMDS v2 (Instance Metadata Service) introduced session authentication tokens which improve security when talking to IMDS.
By default aws_instance resource sets IMDS session auth tokens to be optional.
To fully protect IMDS you need to enable session tokens by using metadata_options block and its http_tokens variable set to required.
HIGH: Root block device is not encrypted.
════════════════════════════════════════
Block devices should be encrypted to ensure sensitive data is held securely at rest.
HIGH: Root block device is not encrypted.
════════════════════════════════════════
Block devices should be encrypted to ensure sensitive data is held securely at rest.
HIGH: Bucket does not have encryption enabled
════════════════════════════════════════
S3 Buckets should be encrypted to protect the data that is stored within them if access is compromised.
HIGH: Bucket does not encrypt data with a customer managed key.
════════════════════════════════════════
Encryption using AWS keys provides protection for your S3 buckets. To increase control of the encryption and manage factors like rotation use customer managed keys.
HIGH: Instance does not require IMDS access to require a token.
════════════════════════════════════════
IMDS v2 (Instance Metadata Service) introduced session authentication tokens which improve security when talking to IMDS.
By default aws_instance resource sets IMDS session auth tokens to be optional.
To fully protect IMDS you need to enable session tokens by using metadata_options block and its http_tokens variable set to required.
HIGH: Root block device is not encrypted.
════════════════════════════════════════
Block devices should be encrypted to ensure sensitive data is held securely at rest.
HIGH: Instance does not require IMDS access to require a token.
════════════════════════════════════════
IMDS v2 (Instance Metadata Service) introduced session authentication tokens which improve security when talking to IMDS.
By default aws_instance resource sets IMDS session auth tokens to be optional.
To fully protect IMDS you need to enable session tokens by using metadata_options block and its http_tokens variable set to required.
HIGH: Root block device is not encrypted.
════════════════════════════════════════
Block devices should be encrypted to ensure sensitive data is held securely at rest.
*****************************
Setting default tflint config...
Running tflint --init...
Installing "terraform" plugin...
Installed "terraform" (source: github.com/terraform-linters/tflint-ruleset-terraform, version:0.9.1)
tflint will check the following folders:
terraform/environments/contract-work-administration
*****************************
Running tflint in terraform/environments/contract-work-administration
Excluding the following checks: terraform_unused_declarations
4issue(s) found:
Warning: Missing version constraint for provider "time" in `required_providers` (terraform_required_providers)
on terraform/environments/contract-work-administration/backup_lambda.tf line 119:119:resource"time_sleep""wait_for_provision_files" {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_required_providers.md
Warning: Missing version constraint for provider "archive" in `required_providers` (terraform_required_providers)
on terraform/environments/contract-work-administration/backup_lambda.tf line 173:173:data"archive_file""connect_db" {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_required_providers.md
Warning: Missing version constraint for provider "template" in `required_providers` (terraform_required_providers)
on terraform/environments/contract-work-administration/cloudwatch.tf line 1126:1126:data"template_file""dashboard_no_ha" {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_required_providers.md
Warning: Missing version constraint for provider "local" in `required_providers` (terraform_required_providers)
on terraform/environments/contract-work-administration/data.tf line 11:11:data"local_file""cm_custom_metrics" {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_required_providers.mdtflint_exitcode=2
Trivy Scan Failed
Show Output
*****************************
Trivy will check the following folders:
terraform/environments/contract-work-administration
*****************************
Running Trivy in terraform/environments/contract-work-administration
2024-10-30T13:59:37Z INFO [vulndb] Need to update DB
2024-10-30T13:59:37Z INFO [vulndb] Downloading vulnerability DB...2024-10-30T13:59:37Z INFO [vulndb] Downloading artifact...repo="public.ecr.aws/aquasecurity/trivy-db:2"2024-10-30T13:59:39Z INFO [vulndb] Artifact successfully downloaded repo="public.ecr.aws/aquasecurity/trivy-db:2"2024-10-30T13:59:39Z INFO [vuln] Vulnerability scanning is enabled
2024-10-30T13:59:39Z INFO [misconfig] Misconfiguration scanning is enabled
2024-10-30T13:59:39Z INFO [misconfig] Need to update the built-in checks
2024-10-30T13:59:39Z INFO [misconfig] Downloading the built-in checks...160.60 KiB /160.60 KiB [------------------------------------------------------] 100.00%? p/s 100ms2024-10-30T13:59:39Z INFO [secret] Secret scanning is enabled
2024-10-30T13:59:39Z INFO [secret] If your scanning is slow, please try '--scanners vuln' to disable secret scanning
2024-10-30T13:59:39Z INFO [secret] Please see also https://aquasecurity.github.io/trivy/v0.56/docs/scanner/secret#recommendation for faster secret detection2024-10-30T13:59:41Z INFO [terraformscanner] Scanning root module file_path="."2024-10-30T13:59:41Z WARN [terraformparser] Variable values was not found in the environment or variable files. Evaluating may not work correctly.module="root"variables="networking"2024-10-30T13:59:43Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.aws_s3_object.user_public_keys"value="cty.NilVal"2024-10-30T13:59:43Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.data.aws_subnet.local_account"value="cty.NilVal"2024-10-30T13:59:43Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.dynamic.tag"value="cty.NilVal"2024-10-30T13:59:43Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.dynamic.tag"value="cty.NilVal"2024-10-30T13:59:43Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.expiration"value="cty.NilVal"2024-10-30T13:59:43Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.transition"value="cty.NilVal"2024-10-30T13:59:43Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.noncurrent_version_expiration"value="cty.NilVal"2024-10-30T13:59:43Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.noncurrent_version_transition"value="cty.NilVal"2024-10-30T13:59:43Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.principals"value="cty.NilVal"2024-10-30T13:59:43Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.condition"value="cty.NilVal"2024-10-30T13:59:43Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.expiration"value="cty.NilVal"2024-10-30T13:59:43Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.transition"value="cty.NilVal"2024-10-30T13:59:43Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.noncurrent_version_expiration"value="cty.NilVal"2024-10-30T13:59:43Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.noncurrent_version_transition"value="cty.NilVal"2024-10-30T13:59:43Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.principals"value="cty.NilVal"2024-10-30T13:59:43Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.condition"value="cty.NilVal"2024-10-30T13:59:44Z INFO [terraformexecutor] Ignore finding rule="aws-s3-encryption-customer-key"range="github.com/ministryofjustice/modernisation-platform-terraform-bastion-linux?ref=v4.2.0/github.com/ministryofjustice/modernisation-platform-terraform-s3-bucket?ref=568694e50e03630d99cb569eafa06a0b879a1239/main.tf:171-179"2024-10-30T13:59:45Z INFO Number of language-specific files num=02024-10-30T13:59:45Z INFO Detected config files num=9
alb.tf (terraform)
==================
Tests:3 (SUCCESSES:0, FAILURES:2, EXCEPTIONS:1)
Failures:2 (HIGH:2, CRITICAL:0)
HIGH: Application load balancer is not set to drop invalid headers.
════════════════════════════════════════
Passing unknown or invalid headers through to the target poses a potential risk of compromise.
By setting drop_invalid_header_fields to true, anything that does not conform to well known, defined headers will be removed by the load balancer.
See https://avd.aquasec.com/misconfig/avd-aws-0052
────────────────────────────────────────
alb.tf:130-153
────────────────────────────────────────
130 ┌ resource"aws_lb""external" {
131 │ name="${upper(local.application_name_short)}-LoadBalancer"132 │ internal=false133 │ load_balancer_type="application"134 │ security_groups=[aws_security_group.external_lb.id]
135 │ subnets=[data.aws_subnet.public_subnets_a.id, data.aws_subnet.public_subnets_b.id, data.aws_subnet.public_subnets_c.id]
136 │ enable_deletion_protection=local.lb_enable_deletion_protection137 │ idle_timeout=local.external_lb_idle_timeout138 └ enable_http2=false...
────────────────────────────────────────
HIGH: Load balancer is exposed publicly.
════════════════════════════════════════
There are many scenarios in which you would want to expose a load balancer to the wider internet, but this check exists as a warning to prevent accidental exposure of internal assets. You should ensure that this resource should be exposed publicly.
See https://avd.aquasec.com/misconfig/avd-aws-0053
────────────────────────────────────────
alb.tf:130-153
────────────────────────────────────────
130 ┌ resource"aws_lb""external" {
131 │ name="${upper(local.application_name_short)}-LoadBalancer"132 │ internal=false133 │ load_balancer_type="application"134 │ security_groups=[aws_security_group.external_lb.id]
135 │ subnets=[data.aws_subnet.public_subnets_a.id, data.aws_subnet.public_subnets_b.id, data.aws_subnet.public_subnets_c.id]
136 │ enable_deletion_protection=local.lb_enable_deletion_protection137 │ idle_timeout=local.external_lb_idle_timeout138 └ enable_http2=false...
────────────────────────────────────────
app_servers.tf (terraform)
==========================
Tests:5 (SUCCESSES:0, FAILURES:4, EXCEPTIONS:1)
Failures:4 (HIGH:4, CRITICAL:0)
HIGH: Instance does not require IMDS access to require a token.
════════════════════════════════════════
IMDS v2 (Instance Metadata Service) introduced session authentication tokens which improve security when talking to IMDS.
By default <code>aws_instance</code> resource sets IMDS session auth tokens to be optional.
To fully protect IMDS you need to enable session tokens by using <code>metadata_options</code> block and its <code>http_tokens</code> variable set to <code>required</code>.
See https://avd.aquasec.com/misconfig/avd-aws-0028
────────────────────────────────────────
app_servers.tf:191-193
via app_servers.tf:180-212 (aws_instance.app1)
────────────────────────────────────────
180resource"aws_instance""app1" {
...191 ┌ metadata_options {
192 │ http_tokens="optional"193 └ }
...212 }
────────────────────────────────────────
HIGH: Instance does not require IMDS access to require a token.
════════════════════════════════════════
IMDS v2 (Instance Metadata Service) introduced session authentication tokens which improve security when talking to IMDS.
By default <code>aws_instance</code> resource sets IMDS session auth tokens to be optional.
To fully protect IMDS you need to enable session tokens by using <code>metadata_options</code> block and its <code>http_tokens</code> variable set to <code>required</code>.
See https://avd.aquasec.com/misconfig/avd-aws-0028
────────────────────────────────────────
app_servers.tf:226-228
via app_servers.tf:214-247 (aws_instance.app2[0])
────────────────────────────────────────
214resource"aws_instance""app2" {
...226 ┌ metadata_options {
227 │ http_tokens="optional"228 └ }
...247 }
────────────────────────────────────────
HIGH: Root block device is not encrypted.
════════════════════════════════════════
Block devices should be encrypted to ensure sensitive data is held securely at rest.
See https://avd.aquasec.com/misconfig/avd-aws-0131
────────────────────────────────────────
app_servers.tf:195-201
via app_servers.tf:180-212 (aws_instance.app1)
────────────────────────────────────────
180resource"aws_instance""app1" {
...195 ┌ root_block_device {
196 │ tags=merge(
197 │ { "instance-scheduling" = "skip-scheduling" },
198 │ local.tags,
199 │ { "Name" = "${local.application_name_short}-app1-root" }
200 │ )
201 └ }
...
────────────────────────────────────────
HIGH: Root block device is not encrypted.
════════════════════════════════════════
Block devices should be encrypted to ensure sensitive data is held securely at rest.
See https://avd.aquasec.com/misconfig/avd-aws-0131
────────────────────────────────────────
app_servers.tf:230-236
via app_servers.tf:214-247 (aws_instance.app2[0])
────────────────────────────────────────
214resource"aws_instance""app2" {
...230 ┌ root_block_device {
231 │ tags=merge(
232 │ { "instance-scheduling" = "skip-scheduling" },
233 │ local.tags,
234 │ { "Name" = "${local.application_name_short}-app2-root" }
235 │ )
236 └ }
...
────────────────────────────────────────
backup_lambda.tf (terraform)
============================
Tests:3 (SUCCESSES:0, FAILURES:2, EXCEPTIONS:1)
Failures:2 (HIGH:2, CRITICAL:0)
HIGH: Bucket does not have encryption enabled
════════════════════════════════════════
S3 Buckets should be encrypted to protect the data that is stored within them if access is compromised.
See https://avd.aquasec.com/misconfig/avd-aws-0088
────────────────────────────────────────
backup_lambda.tf:101-107
────────────────────────────────────────
101 ┌ resource"aws_s3_bucket""scripts" {
102 │ bucket="${local.application_name_short}-${local.environment}-scripts"103 │ tags=merge(
104 │ local.tags,
105 │ { Name ="${local.application_name_short}-${local.environment}-scripts" }
106 │ )
107 └ }
────────────────────────────────────────
HIGH: Bucket does not encrypt data with a customer managed key.
════════════════════════════════════════
Encryption using AWS keys provides protection for your S3 buckets. To increase control of the encryption and manage factors like rotation use customer managed keys.
See https://avd.aquasec.com/misconfig/avd-aws-0132
────────────────────────────────────────
backup_lambda.tf:101-107
────────────────────────────────────────
101 ┌ resource"aws_s3_bucket""scripts" {
102 │ bucket="${local.application_name_short}-${local.environment}-scripts"103 │ tags=merge(
104 │ local.tags,
105 │ { Name ="${local.application_name_short}-${local.environment}-scripts" }
106 │ )
107 └ }
────────────────────────────────────────
concurrent_manager.tf (terraform)
=================================
Tests:3 (SUCCESSES:0, FAILURES:2, EXCEPTIONS:1)
Failures:2 (HIGH:2, CRITICAL:0)
HIGH: Instance does not require IMDS access to require a token.
════════════════════════════════════════
IMDS v2 (Instance Metadata Service) introduced session authentication tokens which improve security when talking to IMDS.
By default <code>aws_instance</code> resource sets IMDS session auth tokens to be optional.
To fully protect IMDS you need to enable session tokens by using <code>metadata_options</code> block and its <code>http_tokens</code> variable set to <code>required</code>.
See https://avd.aquasec.com/misconfig/avd-aws-0028
────────────────────────────────────────
concurrent_manager.tf:169-171
via concurrent_manager.tf:158-190 (aws_instance.concurrent_manager)
────────────────────────────────────────
158resource"aws_instance""concurrent_manager" {
...169 ┌ metadata_options {
170 │ http_tokens="optional"171 └ }
...190 }
────────────────────────────────────────
HIGH: Root block device is not encrypted.
════════════════════════════════════════
Block devices should be encrypted to ensure sensitive data is held securely at rest.
See https://avd.aquasec.com/misconfig/avd-aws-0131
────────────────────────────────────────
concurrent_manager.tf:173-179
via concurrent_manager.tf:158-190 (aws_instance.concurrent_manager)
────────────────────────────────────────
158resource"aws_instance""concurrent_manager" {
...173 ┌ root_block_device {
174 │ tags=merge(
175 │ { "instance-scheduling" = "skip-scheduling" },
176 │ local.tags,
177 │ { "Name" = "${local.application_name_short}-concurrent-manager-root" }
178 │ )
179 └ }
...
────────────────────────────────────────
database.tf (terraform)
=======================
Tests:3 (SUCCESSES:0, FAILURES:2, EXCEPTIONS:1)
Failures:2 (HIGH:2, CRITICAL:0)
HIGH: Instance does not require IMDS access to require a token.
════════════════════════════════════════
IMDS v2 (Instance Metadata Service) introduced session authentication tokens which improve security when talking to IMDS.
By default <code>aws_instance</code> resource sets IMDS session auth tokens to be optional.
To fully protect IMDS you need to enable session tokens by using <code>metadata_options</code> block and its <code>http_tokens</code> variable set to <code>required</code>.
See https://avd.aquasec.com/misconfig/avd-aws-0028
────────────────────────────────────────
database.tf:195-197
via database.tf:184-213 (aws_instance.database)
────────────────────────────────────────
184resource"aws_instance""database" {
...195 ┌ metadata_options {
196 │ http_tokens="optional"197 └ }
...213 }
────────────────────────────────────────
HIGH: Root block device is not encrypted.
════════════════════════════════════════
Block devices should be encrypted to ensure sensitive data is held securely at rest.
See https://avd.aquasec.com/misconfig/avd-aws-0131
────────────────────────────────────────
database.tf:199-205
via database.tf:184-213 (aws_instance.database)
────────────────────────────────────────
184resource"aws_instance""database" {
...199 ┌ root_block_device {
200 │ tags=merge(
201 │ { "instance-scheduling" = "skip-scheduling" },
202 │ local.tags,
203 │ { "Name" = "${local.application_name_short}-database-root" }
204 │ )
205 └ }
...
────────────────────────────────────────
trivy_exitcode=1
Trivy will check the following folders:
terraform/environments/contract-work-administration
Running Trivy in terraform/environments/contract-work-administration
2024-10-30T15:17:06Z INFO [vulndb] Need to update DB
2024-10-30T15:17:06Z INFO [vulndb] Downloading vulnerability DB...
2024-10-30T15:17:06Z INFO [vulndb] Downloading artifact... repo="public.ecr.aws/aquasecurity/trivy-db:2"
2024-10-30T15:17:08Z INFO [vulndb] Artifact successfully downloaded repo="public.ecr.aws/aquasecurity/trivy-db:2"
2024-10-30T15:17:08Z INFO [vuln] Vulnerability scanning is enabled
2024-10-30T15:17:08Z INFO [misconfig] Misconfiguration scanning is enabled
2024-10-30T15:17:08Z INFO [misconfig] Need to update the built-in checks
2024-10-30T15:17:08Z INFO [misconfig] Downloading the built-in checks...
160.60 KiB / 160.60 KiB [---------------------------------------------------------] 100.00% ? p/s 0s2024-10-30T15:17:08Z INFO [secret] Secret scanning is enabled
2024-10-30T15:17:08Z INFO [secret] If your scanning is slow, please try '--scanners vuln' to disable secret scanning
2024-10-30T15:17:08Z INFO [secret] Please see also https://aquasecurity.github.io/trivy/v0.56/docs/scanner/secret#recommendation for faster secret detection
2024-10-30T15:17:09Z INFO [terraform scanner] Scanning root module file_path="."
2024-10-30T15:17:09Z WARN [terraform parser] Variable values was not found in the environment or variable files. Evaluating may not work correctly. module="root" variables="networking"
2024-10-30T15:17:11Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.aws_s3_object.user_public_keys" value="cty.NilVal"
2024-10-30T15:17:11Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.data.aws_subnet.local_account" value="cty.NilVal"
2024-10-30T15:17:11Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.dynamic.tag" value="cty.NilVal"
2024-10-30T15:17:11Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.dynamic.tag" value="cty.NilVal"
2024-10-30T15:17:11Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.expiration" value="cty.NilVal"
2024-10-30T15:17:11Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.transition" value="cty.NilVal"
2024-10-30T15:17:11Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.noncurrent_version_expiration" value="cty.NilVal"
2024-10-30T15:17:11Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.noncurrent_version_transition" value="cty.NilVal"
2024-10-30T15:17:11Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.principals" value="cty.NilVal"
2024-10-30T15:17:11Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.condition" value="cty.NilVal"
2024-10-30T15:17:11Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.expiration" value="cty.NilVal"
2024-10-30T15:17:11Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.transition" value="cty.NilVal"
2024-10-30T15:17:11Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.noncurrent_version_expiration" value="cty.NilVal"
2024-10-30T15:17:11Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.noncurrent_version_transition" value="cty.NilVal"
2024-10-30T15:17:11Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.principals" value="cty.NilVal"
2024-10-30T15:17:11Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.condition" value="cty.NilVal"
2024-10-30T15:17:12Z INFO [terraform executor] Ignore finding rule="aws-s3-encryption-customer-key" range="github.com/ministryofjustice/modernisation-platform-terraform-bastion-linux?ref=v4.2.0/github.com/ministryofjustice/modernisation-platform-terraform-s3-bucket?ref=568694e50e03630d99cb569eafa06a0b879a1239/main.tf:171-179"
2024-10-30T15:17:13Z INFO Number of language-specific files num=0
2024-10-30T15:17:13Z INFO Detected config files num=9
HIGH: Application load balancer is not set to drop invalid headers.
════════════════════════════════════════
Passing unknown or invalid headers through to the target poses a potential risk of compromise.
By setting drop_invalid_header_fields to true, anything that does not conform to well known, defined headers will be removed by the load balancer.
HIGH: Load balancer is exposed publicly.
════════════════════════════════════════
There are many scenarios in which you would want to expose a load balancer to the wider internet, but this check exists as a warning to prevent accidental exposure of internal assets. You should ensure that this resource should be exposed publicly.
HIGH: Instance does not require IMDS access to require a token.
════════════════════════════════════════
IMDS v2 (Instance Metadata Service) introduced session authentication tokens which improve security when talking to IMDS.
By default aws_instance resource sets IMDS session auth tokens to be optional.
To fully protect IMDS you need to enable session tokens by using metadata_options block and its http_tokens variable set to required.
HIGH: Instance does not require IMDS access to require a token.
════════════════════════════════════════
IMDS v2 (Instance Metadata Service) introduced session authentication tokens which improve security when talking to IMDS.
By default aws_instance resource sets IMDS session auth tokens to be optional.
To fully protect IMDS you need to enable session tokens by using metadata_options block and its http_tokens variable set to required.
HIGH: Root block device is not encrypted.
════════════════════════════════════════
Block devices should be encrypted to ensure sensitive data is held securely at rest.
HIGH: Root block device is not encrypted.
════════════════════════════════════════
Block devices should be encrypted to ensure sensitive data is held securely at rest.
HIGH: Bucket does not have encryption enabled
════════════════════════════════════════
S3 Buckets should be encrypted to protect the data that is stored within them if access is compromised.
HIGH: Bucket does not encrypt data with a customer managed key.
════════════════════════════════════════
Encryption using AWS keys provides protection for your S3 buckets. To increase control of the encryption and manage factors like rotation use customer managed keys.
HIGH: Instance does not require IMDS access to require a token.
════════════════════════════════════════
IMDS v2 (Instance Metadata Service) introduced session authentication tokens which improve security when talking to IMDS.
By default aws_instance resource sets IMDS session auth tokens to be optional.
To fully protect IMDS you need to enable session tokens by using metadata_options block and its http_tokens variable set to required.
HIGH: Root block device is not encrypted.
════════════════════════════════════════
Block devices should be encrypted to ensure sensitive data is held securely at rest.
HIGH: Instance does not require IMDS access to require a token.
════════════════════════════════════════
IMDS v2 (Instance Metadata Service) introduced session authentication tokens which improve security when talking to IMDS.
By default aws_instance resource sets IMDS session auth tokens to be optional.
To fully protect IMDS you need to enable session tokens by using metadata_options block and its http_tokens variable set to required.
HIGH: Root block device is not encrypted.
════════════════════════════════════════
Block devices should be encrypted to ensure sensitive data is held securely at rest.
*****************************
Setting default tflint config...
Running tflint --init...
Installing "terraform" plugin...
Installed "terraform" (source: github.com/terraform-linters/tflint-ruleset-terraform, version:0.9.1)
tflint will check the following folders:
terraform/environments/contract-work-administration
*****************************
Running tflint in terraform/environments/contract-work-administration
Excluding the following checks: terraform_unused_declarations
4issue(s) found:
Warning: Missing version constraint for provider "archive" in `required_providers` (terraform_required_providers)
on terraform/environments/contract-work-administration/backup_lambda.tf line 173:173:data"archive_file""connect_db" {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_required_providers.md
Warning: Missing version constraint for provider "template" in `required_providers` (terraform_required_providers)
on terraform/environments/contract-work-administration/cloudwatch.tf line 1126:1126:data"template_file""dashboard_no_ha" {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_required_providers.md
Warning: Missing version constraint for provider "local" in `required_providers` (terraform_required_providers)
on terraform/environments/contract-work-administration/data.tf line 11:11:data"local_file""cm_custom_metrics" {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_required_providers.md
Warning: Missing version constraint for provider "time" in `required_providers` (terraform_required_providers)
on terraform/environments/contract-work-administration/database.tf line 175:175:resource"time_sleep""wait_db_userdata_scripts" {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_required_providers.mdtflint_exitcode=2
Trivy Scan Failed
Show Output
*****************************
Trivy will check the following folders:
terraform/environments/contract-work-administration
*****************************
Running Trivy in terraform/environments/contract-work-administration
2024-10-30T15:17:06Z INFO [vulndb] Need to update DB
2024-10-30T15:17:06Z INFO [vulndb] Downloading vulnerability DB...2024-10-30T15:17:06Z INFO [vulndb] Downloading artifact...repo="public.ecr.aws/aquasecurity/trivy-db:2"2024-10-30T15:17:08Z INFO [vulndb] Artifact successfully downloaded repo="public.ecr.aws/aquasecurity/trivy-db:2"2024-10-30T15:17:08Z INFO [vuln] Vulnerability scanning is enabled
2024-10-30T15:17:08Z INFO [misconfig] Misconfiguration scanning is enabled
2024-10-30T15:17:08Z INFO [misconfig] Need to update the built-in checks
2024-10-30T15:17:08Z INFO [misconfig] Downloading the built-in checks...160.60 KiB /160.60 KiB [---------------------------------------------------------] 100.00%? p/s 0s2024-10-30T15:17:08Z INFO [secret] Secret scanning is enabled
2024-10-30T15:17:08Z INFO [secret] If your scanning is slow, please try '--scanners vuln' to disable secret scanning
2024-10-30T15:17:08Z INFO [secret] Please see also https://aquasecurity.github.io/trivy/v0.56/docs/scanner/secret#recommendation for faster secret detection2024-10-30T15:17:09Z INFO [terraformscanner] Scanning root module file_path="."2024-10-30T15:17:09Z WARN [terraformparser] Variable values was not found in the environment or variable files. Evaluating may not work correctly.module="root"variables="networking"2024-10-30T15:17:11Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.aws_s3_object.user_public_keys"value="cty.NilVal"2024-10-30T15:17:11Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.data.aws_subnet.local_account"value="cty.NilVal"2024-10-30T15:17:11Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.dynamic.tag"value="cty.NilVal"2024-10-30T15:17:11Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.dynamic.tag"value="cty.NilVal"2024-10-30T15:17:11Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.expiration"value="cty.NilVal"2024-10-30T15:17:11Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.transition"value="cty.NilVal"2024-10-30T15:17:11Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.noncurrent_version_expiration"value="cty.NilVal"2024-10-30T15:17:11Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.noncurrent_version_transition"value="cty.NilVal"2024-10-30T15:17:11Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.principals"value="cty.NilVal"2024-10-30T15:17:11Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.condition"value="cty.NilVal"2024-10-30T15:17:11Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.expiration"value="cty.NilVal"2024-10-30T15:17:11Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.transition"value="cty.NilVal"2024-10-30T15:17:11Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.noncurrent_version_expiration"value="cty.NilVal"2024-10-30T15:17:11Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.noncurrent_version_transition"value="cty.NilVal"2024-10-30T15:17:11Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.principals"value="cty.NilVal"2024-10-30T15:17:11Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.condition"value="cty.NilVal"2024-10-30T15:17:12Z INFO [terraformexecutor] Ignore finding rule="aws-s3-encryption-customer-key"range="github.com/ministryofjustice/modernisation-platform-terraform-bastion-linux?ref=v4.2.0/github.com/ministryofjustice/modernisation-platform-terraform-s3-bucket?ref=568694e50e03630d99cb569eafa06a0b879a1239/main.tf:171-179"2024-10-30T15:17:13Z INFO Number of language-specific files num=02024-10-30T15:17:13Z INFO Detected config files num=9
alb.tf (terraform)
==================
Tests:3 (SUCCESSES:0, FAILURES:2, EXCEPTIONS:1)
Failures:2 (HIGH:2, CRITICAL:0)
HIGH: Application load balancer is not set to drop invalid headers.
════════════════════════════════════════
Passing unknown or invalid headers through to the target poses a potential risk of compromise.
By setting drop_invalid_header_fields to true, anything that does not conform to well known, defined headers will be removed by the load balancer.
See https://avd.aquasec.com/misconfig/avd-aws-0052
────────────────────────────────────────
alb.tf:130-153
────────────────────────────────────────
130 ┌ resource"aws_lb""external" {
131 │ name="${upper(local.application_name_short)}-LoadBalancer"132 │ internal=false133 │ load_balancer_type="application"134 │ security_groups=[aws_security_group.external_lb.id]
135 │ subnets=[data.aws_subnet.public_subnets_a.id, data.aws_subnet.public_subnets_b.id, data.aws_subnet.public_subnets_c.id]
136 │ enable_deletion_protection=local.lb_enable_deletion_protection137 │ idle_timeout=local.external_lb_idle_timeout138 └ enable_http2=false...
────────────────────────────────────────
HIGH: Load balancer is exposed publicly.
════════════════════════════════════════
There are many scenarios in which you would want to expose a load balancer to the wider internet, but this check exists as a warning to prevent accidental exposure of internal assets. You should ensure that this resource should be exposed publicly.
See https://avd.aquasec.com/misconfig/avd-aws-0053
────────────────────────────────────────
alb.tf:130-153
────────────────────────────────────────
130 ┌ resource"aws_lb""external" {
131 │ name="${upper(local.application_name_short)}-LoadBalancer"132 │ internal=false133 │ load_balancer_type="application"134 │ security_groups=[aws_security_group.external_lb.id]
135 │ subnets=[data.aws_subnet.public_subnets_a.id, data.aws_subnet.public_subnets_b.id, data.aws_subnet.public_subnets_c.id]
136 │ enable_deletion_protection=local.lb_enable_deletion_protection137 │ idle_timeout=local.external_lb_idle_timeout138 └ enable_http2=false...
────────────────────────────────────────
app_servers.tf (terraform)
==========================
Tests:5 (SUCCESSES:0, FAILURES:4, EXCEPTIONS:1)
Failures:4 (HIGH:4, CRITICAL:0)
HIGH: Instance does not require IMDS access to require a token.
════════════════════════════════════════
IMDS v2 (Instance Metadata Service) introduced session authentication tokens which improve security when talking to IMDS.
By default <code>aws_instance</code> resource sets IMDS session auth tokens to be optional.
To fully protect IMDS you need to enable session tokens by using <code>metadata_options</code> block and its <code>http_tokens</code> variable set to <code>required</code>.
See https://avd.aquasec.com/misconfig/avd-aws-0028
────────────────────────────────────────
app_servers.tf:191-193
via app_servers.tf:180-212 (aws_instance.app1)
────────────────────────────────────────
180resource"aws_instance""app1" {
...191 ┌ metadata_options {
192 │ http_tokens="optional"193 └ }
...212 }
────────────────────────────────────────
HIGH: Instance does not require IMDS access to require a token.
════════════════════════════════════════
IMDS v2 (Instance Metadata Service) introduced session authentication tokens which improve security when talking to IMDS.
By default <code>aws_instance</code> resource sets IMDS session auth tokens to be optional.
To fully protect IMDS you need to enable session tokens by using <code>metadata_options</code> block and its <code>http_tokens</code> variable set to <code>required</code>.
See https://avd.aquasec.com/misconfig/avd-aws-0028
────────────────────────────────────────
app_servers.tf:226-228
via app_servers.tf:214-247 (aws_instance.app2[0])
────────────────────────────────────────
214resource"aws_instance""app2" {
...226 ┌ metadata_options {
227 │ http_tokens="optional"228 └ }
...247 }
────────────────────────────────────────
HIGH: Root block device is not encrypted.
════════════════════════════════════════
Block devices should be encrypted to ensure sensitive data is held securely at rest.
See https://avd.aquasec.com/misconfig/avd-aws-0131
────────────────────────────────────────
app_servers.tf:195-201
via app_servers.tf:180-212 (aws_instance.app1)
────────────────────────────────────────
180resource"aws_instance""app1" {
...195 ┌ root_block_device {
196 │ tags=merge(
197 │ { "instance-scheduling" = "skip-scheduling" },
198 │ local.tags,
199 │ { "Name" = "${local.application_name_short}-app1-root" }
200 │ )
201 └ }
...
────────────────────────────────────────
HIGH: Root block device is not encrypted.
════════════════════════════════════════
Block devices should be encrypted to ensure sensitive data is held securely at rest.
See https://avd.aquasec.com/misconfig/avd-aws-0131
────────────────────────────────────────
app_servers.tf:230-236
via app_servers.tf:214-247 (aws_instance.app2[0])
────────────────────────────────────────
214resource"aws_instance""app2" {
...230 ┌ root_block_device {
231 │ tags=merge(
232 │ { "instance-scheduling" = "skip-scheduling" },
233 │ local.tags,
234 │ { "Name" = "${local.application_name_short}-app2-root" }
235 │ )
236 └ }
...
────────────────────────────────────────
backup_lambda.tf (terraform)
============================
Tests:3 (SUCCESSES:0, FAILURES:2, EXCEPTIONS:1)
Failures:2 (HIGH:2, CRITICAL:0)
HIGH: Bucket does not have encryption enabled
════════════════════════════════════════
S3 Buckets should be encrypted to protect the data that is stored within them if access is compromised.
See https://avd.aquasec.com/misconfig/avd-aws-0088
────────────────────────────────────────
backup_lambda.tf:101-107
────────────────────────────────────────
101 ┌ resource"aws_s3_bucket""scripts" {
102 │ bucket="${local.application_name_short}-${local.environment}-scripts"103 │ tags=merge(
104 │ local.tags,
105 │ { Name ="${local.application_name_short}-${local.environment}-scripts" }
106 │ )
107 └ }
────────────────────────────────────────
HIGH: Bucket does not encrypt data with a customer managed key.
════════════════════════════════════════
Encryption using AWS keys provides protection for your S3 buckets. To increase control of the encryption and manage factors like rotation use customer managed keys.
See https://avd.aquasec.com/misconfig/avd-aws-0132
────────────────────────────────────────
backup_lambda.tf:101-107
────────────────────────────────────────
101 ┌ resource"aws_s3_bucket""scripts" {
102 │ bucket="${local.application_name_short}-${local.environment}-scripts"103 │ tags=merge(
104 │ local.tags,
105 │ { Name ="${local.application_name_short}-${local.environment}-scripts" }
106 │ )
107 └ }
────────────────────────────────────────
concurrent_manager.tf (terraform)
=================================
Tests:3 (SUCCESSES:0, FAILURES:2, EXCEPTIONS:1)
Failures:2 (HIGH:2, CRITICAL:0)
HIGH: Instance does not require IMDS access to require a token.
════════════════════════════════════════
IMDS v2 (Instance Metadata Service) introduced session authentication tokens which improve security when talking to IMDS.
By default <code>aws_instance</code> resource sets IMDS session auth tokens to be optional.
To fully protect IMDS you need to enable session tokens by using <code>metadata_options</code> block and its <code>http_tokens</code> variable set to <code>required</code>.
See https://avd.aquasec.com/misconfig/avd-aws-0028
────────────────────────────────────────
concurrent_manager.tf:169-171
via concurrent_manager.tf:158-190 (aws_instance.concurrent_manager)
────────────────────────────────────────
158resource"aws_instance""concurrent_manager" {
...169 ┌ metadata_options {
170 │ http_tokens="optional"171 └ }
...190 }
────────────────────────────────────────
HIGH: Root block device is not encrypted.
════════════════════════════════════════
Block devices should be encrypted to ensure sensitive data is held securely at rest.
See https://avd.aquasec.com/misconfig/avd-aws-0131
────────────────────────────────────────
concurrent_manager.tf:173-179
via concurrent_manager.tf:158-190 (aws_instance.concurrent_manager)
────────────────────────────────────────
158resource"aws_instance""concurrent_manager" {
...173 ┌ root_block_device {
174 │ tags=merge(
175 │ { "instance-scheduling" = "skip-scheduling" },
176 │ local.tags,
177 │ { "Name" = "${local.application_name_short}-concurrent-manager-root" }
178 │ )
179 └ }
...
────────────────────────────────────────
database.tf (terraform)
=======================
Tests:3 (SUCCESSES:0, FAILURES:2, EXCEPTIONS:1)
Failures:2 (HIGH:2, CRITICAL:0)
HIGH: Instance does not require IMDS access to require a token.
════════════════════════════════════════
IMDS v2 (Instance Metadata Service) introduced session authentication tokens which improve security when talking to IMDS.
By default <code>aws_instance</code> resource sets IMDS session auth tokens to be optional.
To fully protect IMDS you need to enable session tokens by using <code>metadata_options</code> block and its <code>http_tokens</code> variable set to <code>required</code>.
See https://avd.aquasec.com/misconfig/avd-aws-0028
────────────────────────────────────────
database.tf:195-197
via database.tf:184-213 (aws_instance.database)
────────────────────────────────────────
184resource"aws_instance""database" {
...195 ┌ metadata_options {
196 │ http_tokens="optional"197 └ }
...213 }
────────────────────────────────────────
HIGH: Root block device is not encrypted.
════════════════════════════════════════
Block devices should be encrypted to ensure sensitive data is held securely at rest.
See https://avd.aquasec.com/misconfig/avd-aws-0131
────────────────────────────────────────
database.tf:199-205
via database.tf:184-213 (aws_instance.database)
────────────────────────────────────────
184resource"aws_instance""database" {
...199 ┌ root_block_device {
200 │ tags=merge(
201 │ { "instance-scheduling" = "skip-scheduling" },
202 │ local.tags,
203 │ { "Name" = "${local.application_name_short}-database-root" }
204 │ )
205 └ }
...
────────────────────────────────────────
trivy_exitcode=1
Trivy will check the following folders:
terraform/environments/contract-work-administration
Running Trivy in terraform/environments/contract-work-administration
2024-10-30T15:28:27Z INFO [vulndb] Need to update DB
2024-10-30T15:28:27Z INFO [vulndb] Downloading vulnerability DB...
2024-10-30T15:28:27Z INFO [vulndb] Downloading artifact... repo="public.ecr.aws/aquasecurity/trivy-db:2"
2024-10-30T15:28:29Z INFO [vulndb] Artifact successfully downloaded repo="public.ecr.aws/aquasecurity/trivy-db:2"
2024-10-30T15:28:29Z INFO [vuln] Vulnerability scanning is enabled
2024-10-30T15:28:29Z INFO [misconfig] Misconfiguration scanning is enabled
2024-10-30T15:28:29Z INFO [misconfig] Need to update the built-in checks
2024-10-30T15:28:29Z INFO [misconfig] Downloading the built-in checks...
2024-10-30T15:28:29Z ERROR [misconfig] Falling back to embedded checks err="failed to download built-in policies: download error: OCI repository error: 1 error occurred:\n\t* GET https://ghcr.io/v2/aquasecurity/trivy-checks/manifests/1: TOOMANYREQUESTS: retry-after: 81.241µs, allowed: 44000/minute\n\n"
2024-10-30T15:28:29Z INFO [secret] Secret scanning is enabled
2024-10-30T15:28:29Z INFO [secret] If your scanning is slow, please try '--scanners vuln' to disable secret scanning
2024-10-30T15:28:29Z INFO [secret] Please see also https://aquasecurity.github.io/trivy/v0.56/docs/scanner/secret#recommendation for faster secret detection
2024-10-30T15:28:30Z INFO [terraform scanner] Scanning root module file_path="."
2024-10-30T15:28:30Z WARN [terraform parser] Variable values was not found in the environment or variable files. Evaluating may not work correctly. module="root" variables="networking"
2024-10-30T15:28:31Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.aws_s3_object.user_public_keys" value="cty.NilVal"
2024-10-30T15:28:31Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.data.aws_subnet.local_account" value="cty.NilVal"
2024-10-30T15:28:31Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.dynamic.tag" value="cty.NilVal"
2024-10-30T15:28:31Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.dynamic.tag" value="cty.NilVal"
2024-10-30T15:28:31Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.expiration" value="cty.NilVal"
2024-10-30T15:28:31Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.transition" value="cty.NilVal"
2024-10-30T15:28:31Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.noncurrent_version_expiration" value="cty.NilVal"
2024-10-30T15:28:31Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.noncurrent_version_transition" value="cty.NilVal"
2024-10-30T15:28:31Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.principals" value="cty.NilVal"
2024-10-30T15:28:31Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.condition" value="cty.NilVal"
2024-10-30T15:28:31Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.expiration" value="cty.NilVal"
2024-10-30T15:28:31Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.transition" value="cty.NilVal"
2024-10-30T15:28:31Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.noncurrent_version_expiration" value="cty.NilVal"
2024-10-30T15:28:31Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.noncurrent_version_transition" value="cty.NilVal"
2024-10-30T15:28:31Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.principals" value="cty.NilVal"
2024-10-30T15:28:31Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.condition" value="cty.NilVal"
2024-10-30T15:28:32Z INFO [terraform executor] Ignore finding rule="aws-s3-encryption-customer-key" range="github.com/ministryofjustice/modernisation-platform-terraform-bastion-linux?ref=v4.2.0/github.com/ministryofjustice/modernisation-platform-terraform-s3-bucket?ref=568694e50e03630d99cb569eafa06a0b879a1239/main.tf:171-179"
2024-10-30T15:28:33Z INFO Number of language-specific files num=0
2024-10-30T15:28:33Z INFO Detected config files num=9
HIGH: Application load balancer is not set to drop invalid headers.
════════════════════════════════════════
Passing unknown or invalid headers through to the target poses a potential risk of compromise.
By setting drop_invalid_header_fields to true, anything that does not conform to well known, defined headers will be removed by the load balancer.
HIGH: Load balancer is exposed publicly.
════════════════════════════════════════
There are many scenarios in which you would want to expose a load balancer to the wider internet, but this check exists as a warning to prevent accidental exposure of internal assets. You should ensure that this resource should be exposed publicly.
HIGH: Instance does not require IMDS access to require a token.
════════════════════════════════════════
IMDS v2 (Instance Metadata Service) introduced session authentication tokens which improve security when talking to IMDS.
By default aws_instance resource sets IMDS session auth tokens to be optional.
To fully protect IMDS you need to enable session tokens by using metadata_options block and its http_tokens variable set to required.
See https://avd.aquasec.com/misconfig/avd-aws-0028
────────────────────────────────────────
app_servers.tf:192
via app_servers.tf:191-193 (metadata_options)
via app_servers.tf:180-212 (aws_instance.app1)
────────────────────────────────────────
180 resource "aws_instance" "app1" {
...
192 [ http_tokens = "optional"
...
212 }
────────────────────────────────────────
HIGH: Instance does not require IMDS access to require a token.
════════════════════════════════════════
IMDS v2 (Instance Metadata Service) introduced session authentication tokens which improve security when talking to IMDS.
By default aws_instance resource sets IMDS session auth tokens to be optional.
To fully protect IMDS you need to enable session tokens by using metadata_options block and its http_tokens variable set to required.
See https://avd.aquasec.com/misconfig/avd-aws-0028
────────────────────────────────────────
app_servers.tf:227
via app_servers.tf:226-228 (metadata_options)
via app_servers.tf:214-247 (aws_instance.app2[0])
────────────────────────────────────────
214 resource "aws_instance" "app2" {
...
227 [ http_tokens = "optional"
...
247 }
────────────────────────────────────────
HIGH: Root block device is not encrypted.
════════════════════════════════════════
Block devices should be encrypted to ensure sensitive data is held securely at rest.
HIGH: Root block device is not encrypted.
════════════════════════════════════════
Block devices should be encrypted to ensure sensitive data is held securely at rest.
HIGH: Bucket does not have encryption enabled
════════════════════════════════════════
S3 Buckets should be encrypted to protect the data that is stored within them if access is compromised.
HIGH: Bucket does not encrypt data with a customer managed key.
════════════════════════════════════════
Encryption using AWS keys provides protection for your S3 buckets. To increase control of the encryption and manage factors like rotation use customer managed keys.
HIGH: Instance does not require IMDS access to require a token.
════════════════════════════════════════
IMDS v2 (Instance Metadata Service) introduced session authentication tokens which improve security when talking to IMDS.
By default aws_instance resource sets IMDS session auth tokens to be optional.
To fully protect IMDS you need to enable session tokens by using metadata_options block and its http_tokens variable set to required.
See https://avd.aquasec.com/misconfig/avd-aws-0028
────────────────────────────────────────
concurrent_manager.tf:170
via concurrent_manager.tf:169-171 (metadata_options)
via concurrent_manager.tf:158-190 (aws_instance.concurrent_manager)
────────────────────────────────────────
158 resource "aws_instance" "concurrent_manager" {
...
170 [ http_tokens = "optional"
...
190 }
────────────────────────────────────────
HIGH: Root block device is not encrypted.
════════════════════════════════════════
Block devices should be encrypted to ensure sensitive data is held securely at rest.
HIGH: Instance does not require IMDS access to require a token.
════════════════════════════════════════
IMDS v2 (Instance Metadata Service) introduced session authentication tokens which improve security when talking to IMDS.
By default aws_instance resource sets IMDS session auth tokens to be optional.
To fully protect IMDS you need to enable session tokens by using metadata_options block and its http_tokens variable set to required.
See https://avd.aquasec.com/misconfig/avd-aws-0028
────────────────────────────────────────
database.tf:196
via database.tf:195-197 (metadata_options)
via database.tf:184-213 (aws_instance.database)
────────────────────────────────────────
184 resource "aws_instance" "database" {
...
196 [ http_tokens = "optional"
...
213 }
────────────────────────────────────────
HIGH: Root block device is not encrypted.
════════════════════════════════════════
Block devices should be encrypted to ensure sensitive data is held securely at rest.
*****************************
Setting default tflint config...
Running tflint --init...
Installing "terraform" plugin...
Installed "terraform" (source: github.com/terraform-linters/tflint-ruleset-terraform, version:0.9.1)
tflint will check the following folders:
terraform/environments/contract-work-administration
*****************************
Running tflint in terraform/environments/contract-work-administration
Excluding the following checks: terraform_unused_declarations
4issue(s) found:
Warning: Missing version constraint for provider "time" in `required_providers` (terraform_required_providers)
on terraform/environments/contract-work-administration/app_servers.tf line 170:170:resource"time_sleep""wait_app_userdata_scripts" {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_required_providers.md
Warning: Missing version constraint for provider "archive" in `required_providers` (terraform_required_providers)
on terraform/environments/contract-work-administration/backup_lambda.tf line 173:173:data"archive_file""connect_db" {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_required_providers.md
Warning: Missing version constraint for provider "template" in `required_providers` (terraform_required_providers)
on terraform/environments/contract-work-administration/cloudwatch.tf line 1126:1126:data"template_file""dashboard_no_ha" {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_required_providers.md
Warning: Missing version constraint for provider "local" in `required_providers` (terraform_required_providers)
on terraform/environments/contract-work-administration/data.tf line 11:11:data"local_file""cm_custom_metrics" {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_required_providers.mdtflint_exitcode=2
Trivy Scan Failed
Show Output
*****************************
Trivy will check the following folders:
terraform/environments/contract-work-administration
*****************************
Running Trivy in terraform/environments/contract-work-administration
2024-10-30T15:28:27Z INFO [vulndb] Need to update DB
2024-10-30T15:28:27Z INFO [vulndb] Downloading vulnerability DB...2024-10-30T15:28:27Z INFO [vulndb] Downloading artifact...repo="public.ecr.aws/aquasecurity/trivy-db:2"2024-10-30T15:28:29Z INFO [vulndb] Artifact successfully downloaded repo="public.ecr.aws/aquasecurity/trivy-db:2"2024-10-30T15:28:29Z INFO [vuln] Vulnerability scanning is enabled
2024-10-30T15:28:29Z INFO [misconfig] Misconfiguration scanning is enabled
2024-10-30T15:28:29Z INFO [misconfig] Need to update the built-in checks
2024-10-30T15:28:29Z INFO [misconfig] Downloading the built-in checks...2024-10-30T15:28:29Z ERROR [misconfig] Falling back to embedded checks err="failed to download built-in policies: download error: OCI repository error: 1 error occurred:\n\t* GET https://ghcr.io/v2/aquasecurity/trivy-checks/manifests/1: TOOMANYREQUESTS: retry-after: 81.241µs, allowed: 44000/minute\n\n"2024-10-30T15:28:29Z INFO [secret] Secret scanning is enabled
2024-10-30T15:28:29Z INFO [secret] If your scanning is slow, please try '--scanners vuln' to disable secret scanning
2024-10-30T15:28:29Z INFO [secret] Please see also https://aquasecurity.github.io/trivy/v0.56/docs/scanner/secret#recommendation for faster secret detection2024-10-30T15:28:30Z INFO [terraformscanner] Scanning root module file_path="."2024-10-30T15:28:30Z WARN [terraformparser] Variable values was not found in the environment or variable files. Evaluating may not work correctly.module="root"variables="networking"2024-10-30T15:28:31Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.aws_s3_object.user_public_keys"value="cty.NilVal"2024-10-30T15:28:31Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.data.aws_subnet.local_account"value="cty.NilVal"2024-10-30T15:28:31Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.dynamic.tag"value="cty.NilVal"2024-10-30T15:28:31Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.dynamic.tag"value="cty.NilVal"2024-10-30T15:28:31Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.expiration"value="cty.NilVal"2024-10-30T15:28:31Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.transition"value="cty.NilVal"2024-10-30T15:28:31Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.noncurrent_version_expiration"value="cty.NilVal"2024-10-30T15:28:31Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.noncurrent_version_transition"value="cty.NilVal"2024-10-30T15:28:31Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.principals"value="cty.NilVal"2024-10-30T15:28:31Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.condition"value="cty.NilVal"2024-10-30T15:28:31Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.expiration"value="cty.NilVal"2024-10-30T15:28:31Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.transition"value="cty.NilVal"2024-10-30T15:28:31Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.noncurrent_version_expiration"value="cty.NilVal"2024-10-30T15:28:31Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.noncurrent_version_transition"value="cty.NilVal"2024-10-30T15:28:31Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.principals"value="cty.NilVal"2024-10-30T15:28:31Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.condition"value="cty.NilVal"2024-10-30T15:28:32Z INFO [terraformexecutor] Ignore finding rule="aws-s3-encryption-customer-key"range="github.com/ministryofjustice/modernisation-platform-terraform-bastion-linux?ref=v4.2.0/github.com/ministryofjustice/modernisation-platform-terraform-s3-bucket?ref=568694e50e03630d99cb569eafa06a0b879a1239/main.tf:171-179"2024-10-30T15:28:33Z INFO Number of language-specific files num=02024-10-30T15:28:33Z INFO Detected config files num=9
alb.tf (terraform)
==================
Tests:3 (SUCCESSES:0, FAILURES:2, EXCEPTIONS:1)
Failures:2 (HIGH:2, CRITICAL:0)
HIGH: Application load balancer is not set to drop invalid headers.
════════════════════════════════════════
Passing unknown or invalid headers through to the target poses a potential risk of compromise.
By setting drop_invalid_header_fields to true, anything that does not conform to well known, defined headers will be removed by the load balancer.
See https://avd.aquasec.com/misconfig/avd-aws-0052
────────────────────────────────────────
alb.tf:130-153
────────────────────────────────────────
130 ┌ resource"aws_lb""external" {
131 │ name="${upper(local.application_name_short)}-LoadBalancer"132 │ internal=false133 │ load_balancer_type="application"134 │ security_groups=[aws_security_group.external_lb.id]
135 │ subnets=[data.aws_subnet.public_subnets_a.id, data.aws_subnet.public_subnets_b.id, data.aws_subnet.public_subnets_c.id]
136 │ enable_deletion_protection=local.lb_enable_deletion_protection137 │ idle_timeout=local.external_lb_idle_timeout138 └ enable_http2=false...
────────────────────────────────────────
HIGH: Load balancer is exposed publicly.
════════════════════════════════════════
There are many scenarios in which you would want to expose a load balancer to the wider internet, but this check exists as a warning to prevent accidental exposure of internal assets. You should ensure that this resource should be exposed publicly.
See https://avd.aquasec.com/misconfig/avd-aws-0053
────────────────────────────────────────
alb.tf:132
via alb.tf:130-153 (aws_lb.external)
────────────────────────────────────────
130resource"aws_lb""external" {
...132 [ internal = false...153 }
────────────────────────────────────────
app_servers.tf (terraform)
==========================Tests:5 (SUCCESSES:0, FAILURES:4, EXCEPTIONS:1)
Failures:4 (HIGH:4, CRITICAL:0)
HIGH:InstancedoesnotrequireIMDSaccesstorequireatoken.
════════════════════════════════════════
IMDSv2 (Instance Metadata Service) introducedsessionauthenticationtokenswhichimprovesecuritywhentalkingtoIMDS.Bydefault<code>aws_instance</code>resourcesetsIMDSsessionauthtokenstobeoptional.TofullyprotectIMDSyouneedtoenablesessiontokensbyusing<code>metadata_options</code>blockandits<code>http_tokens</code>variablesetto<code>required</code>.Seehttps://avd.aquasec.com/misconfig/avd-aws-0028
────────────────────────────────────────
app_servers.tf:192viaapp_servers.tf:191-193 (metadata_options)
viaapp_servers.tf:180-212 (aws_instance.app1)
────────────────────────────────────────
180resource"aws_instance""app1" {
...192 [ http_tokens ="optional"...212 }
────────────────────────────────────────
HIGH:InstancedoesnotrequireIMDSaccesstorequireatoken.
════════════════════════════════════════
IMDSv2 (Instance Metadata Service) introducedsessionauthenticationtokenswhichimprovesecuritywhentalkingtoIMDS.Bydefault<code>aws_instance</code>resourcesetsIMDSsessionauthtokenstobeoptional.TofullyprotectIMDSyouneedtoenablesessiontokensbyusing<code>metadata_options</code>blockandits<code>http_tokens</code>variablesetto<code>required</code>.Seehttps://avd.aquasec.com/misconfig/avd-aws-0028
────────────────────────────────────────
app_servers.tf:227viaapp_servers.tf:226-228 (metadata_options)
viaapp_servers.tf:214-247 (aws_instance.app2[0])
────────────────────────────────────────
214resource"aws_instance""app2" {
...227 [ http_tokens ="optional"...247 }
────────────────────────────────────────
HIGH:Rootblockdeviceisnotencrypted.
════════════════════════════════════════
Blockdevicesshouldbeencryptedtoensuresensitivedataisheldsecurelyatrest.Seehttps://avd.aquasec.com/misconfig/avd-aws-0131
────────────────────────────────────────
app_servers.tf:180-212
────────────────────────────────────────
180 ┌ resource"aws_instance""app1" {
181 │ ami = local.application_data.accounts[local.environment].app_ami_id
182 │ availability_zone ="eu-west-2a"183 │ instance_type = local.application_data.accounts[local.environment].app_instance_type
184 │ monitoring =true185 │ vpc_security_group_ids = [aws_security_group.app.id]
186 │ subnet_id = data.aws_subnet.private_subnets_a.id
187 │ iam_instance_profile = aws_iam_instance_profile.cwa.id
188 └ key_name = aws_key_pair.cwa.key_name
...
────────────────────────────────────────
HIGH: Root block device is not encrypted.
════════════════════════════════════════
Block devices should be encrypted to ensure sensitive data is held securely at rest.
See https://avd.aquasec.com/misconfig/avd-aws-0131
────────────────────────────────────────
app_servers.tf:214-247
────────────────────────────────────────
214 ┌ resource "aws_instance""app2" {
215 │ count =contains(["development2", "testing"], local.environment) ?0:1216 │ ami = local.application_data.accounts[local.environment].app_ami_id
217 │ availability_zone ="eu-west-2b"218 │ instance_type = local.application_data.accounts[local.environment].app_instance_type
219 │ monitoring =true220 │ vpc_security_group_ids = [aws_security_group.app.id]
221 │ subnet_id = data.aws_subnet.private_subnets_b.id
222 └ iam_instance_profile = aws_iam_instance_profile.cwa.id
...
────────────────────────────────────────
backup_lambda.tf (terraform)
============================
Tests:3 (SUCCESSES:0, FAILURES:2, EXCEPTIONS:1)
Failures:2 (HIGH:2, CRITICAL:0)
HIGH: Bucket does not have encryption enabled
════════════════════════════════════════
S3 Buckets should be encrypted to protect the data that is stored within them ifaccessiscompromised.
See https://avd.aquasec.com/misconfig/avd-aws-0088
────────────────────────────────────────
backup_lambda.tf:101-107
────────────────────────────────────────
101 ┌ resource "aws_s3_bucket""scripts" {
102 │ bucket ="${local.application_name_short}-${local.environment}-scripts"103 │ tags =merge(
104 │ local.tags,
105 │ { Name ="${local.application_name_short}-${local.environment}-scripts" }
106 │ )
107 └ }
────────────────────────────────────────
HIGH: Bucket does not encrypt data with a customer managed key.
════════════════════════════════════════
Encryption using AWS keys provides protection foryourS3buckets.Toincreasecontroloftheencryptionandmanagefactorslikerotationusecustomermanagedkeys.
See https://avd.aquasec.com/misconfig/avd-aws-0132
────────────────────────────────────────
backup_lambda.tf:101-107
────────────────────────────────────────
101 ┌ resource "aws_s3_bucket""scripts" {
102 │ bucket ="${local.application_name_short}-${local.environment}-scripts"103 │ tags =merge(
104 │ local.tags,
105 │ { Name ="${local.application_name_short}-${local.environment}-scripts" }
106 │ )
107 └ }
────────────────────────────────────────
concurrent_manager.tf (terraform)
=================================
Tests:3 (SUCCESSES:0, FAILURES:2, EXCEPTIONS:1)
Failures:2 (HIGH:2, CRITICAL:0)
HIGH: Instance does not require IMDS access to require a token.
════════════════════════════════════════
IMDS v2 (Instance Metadata Service) introduced session authentication tokens which improve security when talking to IMDS.
By default <code>aws_instance</code> resource sets IMDS session auth tokens to be optional.
To fully protect IMDS you need to enable session tokens by using <code>metadata_options</code> block and its <code>http_tokens</code> variable set to <code>required</code>.
See https://avd.aquasec.com/misconfig/avd-aws-0028
────────────────────────────────────────
concurrent_manager.tf:170
via concurrent_manager.tf:169-171 (metadata_options)
via concurrent_manager.tf:158-190 (aws_instance.concurrent_manager)
────────────────────────────────────────
158 resource "aws_instance""concurrent_manager" {
...170 [ http_tokens ="optional"...190 }
────────────────────────────────────────
HIGH: Root block device is not encrypted.
════════════════════════════════════════
Block devices should be encrypted to ensure sensitive data is held securely at rest.
See https://avd.aquasec.com/misconfig/avd-aws-0131
────────────────────────────────────────
concurrent_manager.tf:158-190
────────────────────────────────────────
158 ┌ resource "aws_instance""concurrent_manager" {
159 │ ami = local.application_data.accounts[local.environment].cm_ami_id
160 │ availability_zone ="eu-west-2a"161 │ instance_type = local.application_data.accounts[local.environment].cm_instance_type
162 │ monitoring =true163 │ vpc_security_group_ids = [aws_security_group.concurrent_manager.id]
164 │ subnet_id = data.aws_subnet.private_subnets_a.id
165 │ iam_instance_profile = aws_iam_instance_profile.cwa.id
166 └ key_name = aws_key_pair.cwa.key_name
...
────────────────────────────────────────
database.tf (terraform)
=======================
Tests:3 (SUCCESSES:0, FAILURES:2, EXCEPTIONS:1)
Failures:2 (HIGH:2, CRITICAL:0)
HIGH: Instance does not require IMDS access to require a token.
════════════════════════════════════════
IMDS v2 (Instance Metadata Service) introduced session authentication tokens which improve security when talking to IMDS.
By default <code>aws_instance</code> resource sets IMDS session auth tokens to be optional.
To fully protect IMDS you need to enable session tokens by using <code>metadata_options</code> block and its <code>http_tokens</code> variable set to <code>required</code>.
See https://avd.aquasec.com/misconfig/avd-aws-0028
────────────────────────────────────────
database.tf:196
via database.tf:195-197 (metadata_options)
via database.tf:184-213 (aws_instance.database)
────────────────────────────────────────
184 resource "aws_instance""database" {
...196 [ http_tokens ="optional"...213 }
────────────────────────────────────────
HIGH: Root block device is not encrypted.
════════════════════════════════════════
Block devices should be encrypted to ensure sensitive data is held securely at rest.
See https://avd.aquasec.com/misconfig/avd-aws-0131
────────────────────────────────────────
database.tf:184-213
────────────────────────────────────────
184 ┌ resource "aws_instance""database" {
185 │ ami = local.application_data.accounts[local.environment].db_ami_id
186 │ availability_zone ="eu-west-2a"187 │ instance_type = local.application_data.accounts[local.environment].db_instance_type
188 │ monitoring =true189 │ vpc_security_group_ids = [aws_security_group.database.id]
190 │ subnet_id = data.aws_subnet.data_subnets_a.id
191 │ iam_instance_profile = aws_iam_instance_profile.cwa.id
192 └ key_name = aws_key_pair.cwa.key_name
...
────────────────────────────────────────
trivy_exitcode=1
Trivy will check the following folders:
terraform/environments/contract-work-administration
Running Trivy in terraform/environments/contract-work-administration
2024-10-30T17:10:03Z INFO [vulndb] Need to update DB
2024-10-30T17:10:03Z INFO [vulndb] Downloading vulnerability DB...
2024-10-30T17:10:03Z INFO [vulndb] Downloading artifact... repo="public.ecr.aws/aquasecurity/trivy-db:2"
2024-10-30T17:10:06Z INFO [vulndb] Artifact successfully downloaded repo="public.ecr.aws/aquasecurity/trivy-db:2"
2024-10-30T17:10:06Z INFO [vuln] Vulnerability scanning is enabled
2024-10-30T17:10:06Z INFO [misconfig] Misconfiguration scanning is enabled
2024-10-30T17:10:06Z INFO [misconfig] Need to update the built-in checks
2024-10-30T17:10:06Z INFO [misconfig] Downloading the built-in checks...
2024-10-30T17:10:06Z ERROR [misconfig] Falling back to embedded checks err="failed to download built-in policies: download error: oci download error: failed to fetch the layer: GET https://ghcr.io/v2/aquasecurity/trivy-checks/blobs/sha256:6305306961f35e5295f110df324ec41b25d1b48376b3cb97ea91b3edbbf3c463: TOOMANYREQUESTS: retry-after: 71.972µs, allowed: 44000/minute"
2024-10-30T17:10:06Z INFO [secret] Secret scanning is enabled
2024-10-30T17:10:06Z INFO [secret] If your scanning is slow, please try '--scanners vuln' to disable secret scanning
2024-10-30T17:10:06Z INFO [secret] Please see also https://aquasecurity.github.io/trivy/v0.56/docs/scanner/secret#recommendation for faster secret detection
2024-10-30T17:10:07Z INFO [terraform scanner] Scanning root module file_path="."
2024-10-30T17:10:07Z WARN [terraform parser] Variable values was not found in the environment or variable files. Evaluating may not work correctly. module="root" variables="networking"
2024-10-30T17:10:08Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.aws_s3_object.user_public_keys" value="cty.NilVal"
2024-10-30T17:10:08Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.data.aws_subnet.local_account" value="cty.NilVal"
2024-10-30T17:10:08Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.dynamic.tag" value="cty.NilVal"
2024-10-30T17:10:08Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.dynamic.tag" value="cty.NilVal"
2024-10-30T17:10:09Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.expiration" value="cty.NilVal"
2024-10-30T17:10:09Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.transition" value="cty.NilVal"
2024-10-30T17:10:09Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.noncurrent_version_expiration" value="cty.NilVal"
2024-10-30T17:10:09Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.noncurrent_version_transition" value="cty.NilVal"
2024-10-30T17:10:09Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.principals" value="cty.NilVal"
2024-10-30T17:10:09Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.condition" value="cty.NilVal"
2024-10-30T17:10:09Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.expiration" value="cty.NilVal"
2024-10-30T17:10:09Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.transition" value="cty.NilVal"
2024-10-30T17:10:09Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.noncurrent_version_expiration" value="cty.NilVal"
2024-10-30T17:10:09Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.noncurrent_version_transition" value="cty.NilVal"
2024-10-30T17:10:09Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.principals" value="cty.NilVal"
2024-10-30T17:10:09Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.condition" value="cty.NilVal"
2024-10-30T17:10:10Z INFO [terraform executor] Ignore finding rule="aws-s3-encryption-customer-key" range="github.com/ministryofjustice/modernisation-platform-terraform-bastion-linux?ref=v4.2.0/github.com/ministryofjustice/modernisation-platform-terraform-s3-bucket?ref=568694e50e03630d99cb569eafa06a0b879a1239/main.tf:171-179"
2024-10-30T17:10:11Z INFO Number of language-specific files num=0
2024-10-30T17:10:11Z INFO Detected config files num=9
HIGH: Application load balancer is not set to drop invalid headers.
════════════════════════════════════════
Passing unknown or invalid headers through to the target poses a potential risk of compromise.
By setting drop_invalid_header_fields to true, anything that does not conform to well known, defined headers will be removed by the load balancer.
HIGH: Load balancer is exposed publicly.
════════════════════════════════════════
There are many scenarios in which you would want to expose a load balancer to the wider internet, but this check exists as a warning to prevent accidental exposure of internal assets. You should ensure that this resource should be exposed publicly.
HIGH: Instance does not require IMDS access to require a token.
════════════════════════════════════════
IMDS v2 (Instance Metadata Service) introduced session authentication tokens which improve security when talking to IMDS.
By default aws_instance resource sets IMDS session auth tokens to be optional.
To fully protect IMDS you need to enable session tokens by using metadata_options block and its http_tokens variable set to required.
See https://avd.aquasec.com/misconfig/avd-aws-0028
────────────────────────────────────────
app_servers.tf:192
via app_servers.tf:191-193 (metadata_options)
via app_servers.tf:180-212 (aws_instance.app1)
────────────────────────────────────────
180 resource "aws_instance" "app1" {
...
192 [ http_tokens = "optional"
...
212 }
────────────────────────────────────────
HIGH: Instance does not require IMDS access to require a token.
════════════════════════════════════════
IMDS v2 (Instance Metadata Service) introduced session authentication tokens which improve security when talking to IMDS.
By default aws_instance resource sets IMDS session auth tokens to be optional.
To fully protect IMDS you need to enable session tokens by using metadata_options block and its http_tokens variable set to required.
See https://avd.aquasec.com/misconfig/avd-aws-0028
────────────────────────────────────────
app_servers.tf:227
via app_servers.tf:226-228 (metadata_options)
via app_servers.tf:214-247 (aws_instance.app2[0])
────────────────────────────────────────
214 resource "aws_instance" "app2" {
...
227 [ http_tokens = "optional"
...
247 }
────────────────────────────────────────
HIGH: Root block device is not encrypted.
════════════════════════════════════════
Block devices should be encrypted to ensure sensitive data is held securely at rest.
HIGH: Root block device is not encrypted.
════════════════════════════════════════
Block devices should be encrypted to ensure sensitive data is held securely at rest.
HIGH: Bucket does not have encryption enabled
════════════════════════════════════════
S3 Buckets should be encrypted to protect the data that is stored within them if access is compromised.
HIGH: Bucket does not encrypt data with a customer managed key.
════════════════════════════════════════
Encryption using AWS keys provides protection for your S3 buckets. To increase control of the encryption and manage factors like rotation use customer managed keys.
HIGH: Instance does not require IMDS access to require a token.
════════════════════════════════════════
IMDS v2 (Instance Metadata Service) introduced session authentication tokens which improve security when talking to IMDS.
By default aws_instance resource sets IMDS session auth tokens to be optional.
To fully protect IMDS you need to enable session tokens by using metadata_options block and its http_tokens variable set to required.
See https://avd.aquasec.com/misconfig/avd-aws-0028
────────────────────────────────────────
concurrent_manager.tf:170
via concurrent_manager.tf:169-171 (metadata_options)
via concurrent_manager.tf:158-190 (aws_instance.concurrent_manager)
────────────────────────────────────────
158 resource "aws_instance" "concurrent_manager" {
...
170 [ http_tokens = "optional"
...
190 }
────────────────────────────────────────
HIGH: Root block device is not encrypted.
════════════════════════════════════════
Block devices should be encrypted to ensure sensitive data is held securely at rest.
HIGH: Instance does not require IMDS access to require a token.
════════════════════════════════════════
IMDS v2 (Instance Metadata Service) introduced session authentication tokens which improve security when talking to IMDS.
By default aws_instance resource sets IMDS session auth tokens to be optional.
To fully protect IMDS you need to enable session tokens by using metadata_options block and its http_tokens variable set to required.
See https://avd.aquasec.com/misconfig/avd-aws-0028
────────────────────────────────────────
database.tf:196
via database.tf:195-197 (metadata_options)
via database.tf:184-213 (aws_instance.database)
────────────────────────────────────────
184 resource "aws_instance" "database" {
...
196 [ http_tokens = "optional"
...
213 }
────────────────────────────────────────
HIGH: Root block device is not encrypted.
════════════════════════════════════════
Block devices should be encrypted to ensure sensitive data is held securely at rest.
*****************************
Setting default tflint config...
Running tflint --init...
Installing "terraform" plugin...
Installed "terraform" (source: github.com/terraform-linters/tflint-ruleset-terraform, version:0.9.1)
tflint will check the following folders:
terraform/environments/contract-work-administration
*****************************
Running tflint in terraform/environments/contract-work-administration
Excluding the following checks: terraform_unused_declarations
4issue(s) found:
Warning: Missing version constraint for provider "time" in `required_providers` (terraform_required_providers)
on terraform/environments/contract-work-administration/app_servers.tf line 170:170:resource"time_sleep""wait_app_userdata_scripts" {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_required_providers.md
Warning: Missing version constraint for provider "archive" in `required_providers` (terraform_required_providers)
on terraform/environments/contract-work-administration/backup_lambda.tf line 173:173:data"archive_file""connect_db" {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_required_providers.md
Warning: Missing version constraint for provider "template" in `required_providers` (terraform_required_providers)
on terraform/environments/contract-work-administration/cloudwatch.tf line 1126:1126:data"template_file""dashboard_no_ha" {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_required_providers.md
Warning: Missing version constraint for provider "local" in `required_providers` (terraform_required_providers)
on terraform/environments/contract-work-administration/data.tf line 11:11:data"local_file""cm_custom_metrics" {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_required_providers.mdtflint_exitcode=2
Trivy Scan Failed
Show Output
*****************************
Trivy will check the following folders:
terraform/environments/contract-work-administration
*****************************
Running Trivy in terraform/environments/contract-work-administration
2024-10-30T17:10:03Z INFO [vulndb] Need to update DB
2024-10-30T17:10:03Z INFO [vulndb] Downloading vulnerability DB...2024-10-30T17:10:03Z INFO [vulndb] Downloading artifact...repo="public.ecr.aws/aquasecurity/trivy-db:2"2024-10-30T17:10:06Z INFO [vulndb] Artifact successfully downloaded repo="public.ecr.aws/aquasecurity/trivy-db:2"2024-10-30T17:10:06Z INFO [vuln] Vulnerability scanning is enabled
2024-10-30T17:10:06Z INFO [misconfig] Misconfiguration scanning is enabled
2024-10-30T17:10:06Z INFO [misconfig] Need to update the built-in checks
2024-10-30T17:10:06Z INFO [misconfig] Downloading the built-in checks...2024-10-30T17:10:06Z ERROR [misconfig] Falling back to embedded checks err="failed to download built-in policies: download error: oci download error: failed to fetch the layer: GET https://ghcr.io/v2/aquasecurity/trivy-checks/blobs/sha256:6305306961f35e5295f110df324ec41b25d1b48376b3cb97ea91b3edbbf3c463: TOOMANYREQUESTS: retry-after: 71.972µs, allowed: 44000/minute"2024-10-30T17:10:06Z INFO [secret] Secret scanning is enabled
2024-10-30T17:10:06Z INFO [secret] If your scanning is slow, please try '--scanners vuln' to disable secret scanning
2024-10-30T17:10:06Z INFO [secret] Please see also https://aquasecurity.github.io/trivy/v0.56/docs/scanner/secret#recommendation for faster secret detection2024-10-30T17:10:07Z INFO [terraformscanner] Scanning root module file_path="."2024-10-30T17:10:07Z WARN [terraformparser] Variable values was not found in the environment or variable files. Evaluating may not work correctly.module="root"variables="networking"2024-10-30T17:10:08Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.aws_s3_object.user_public_keys"value="cty.NilVal"2024-10-30T17:10:08Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.data.aws_subnet.local_account"value="cty.NilVal"2024-10-30T17:10:08Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.dynamic.tag"value="cty.NilVal"2024-10-30T17:10:08Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.dynamic.tag"value="cty.NilVal"2024-10-30T17:10:09Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.expiration"value="cty.NilVal"2024-10-30T17:10:09Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.transition"value="cty.NilVal"2024-10-30T17:10:09Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.noncurrent_version_expiration"value="cty.NilVal"2024-10-30T17:10:09Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.noncurrent_version_transition"value="cty.NilVal"2024-10-30T17:10:09Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.principals"value="cty.NilVal"2024-10-30T17:10:09Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.condition"value="cty.NilVal"2024-10-30T17:10:09Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.expiration"value="cty.NilVal"2024-10-30T17:10:09Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.transition"value="cty.NilVal"2024-10-30T17:10:09Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.noncurrent_version_expiration"value="cty.NilVal"2024-10-30T17:10:09Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.noncurrent_version_transition"value="cty.NilVal"2024-10-30T17:10:09Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.principals"value="cty.NilVal"2024-10-30T17:10:09Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.condition"value="cty.NilVal"2024-10-30T17:10:10Z INFO [terraformexecutor] Ignore finding rule="aws-s3-encryption-customer-key"range="github.com/ministryofjustice/modernisation-platform-terraform-bastion-linux?ref=v4.2.0/github.com/ministryofjustice/modernisation-platform-terraform-s3-bucket?ref=568694e50e03630d99cb569eafa06a0b879a1239/main.tf:171-179"2024-10-30T17:10:11Z INFO Number of language-specific files num=02024-10-30T17:10:11Z INFO Detected config files num=9
alb.tf (terraform)
==================
Tests:3 (SUCCESSES:0, FAILURES:2, EXCEPTIONS:1)
Failures:2 (HIGH:2, CRITICAL:0)
HIGH: Application load balancer is not set to drop invalid headers.
════════════════════════════════════════
Passing unknown or invalid headers through to the target poses a potential risk of compromise.
By setting drop_invalid_header_fields to true, anything that does not conform to well known, defined headers will be removed by the load balancer.
See https://avd.aquasec.com/misconfig/avd-aws-0052
────────────────────────────────────────
alb.tf:130-153
────────────────────────────────────────
130 ┌ resource"aws_lb""external" {
131 │ name="${upper(local.application_name_short)}-LoadBalancer"132 │ internal=false133 │ load_balancer_type="application"134 │ security_groups=[aws_security_group.external_lb.id]
135 │ subnets=[data.aws_subnet.public_subnets_a.id, data.aws_subnet.public_subnets_b.id, data.aws_subnet.public_subnets_c.id]
136 │ enable_deletion_protection=local.lb_enable_deletion_protection137 │ idle_timeout=local.external_lb_idle_timeout138 └ enable_http2=false...
────────────────────────────────────────
HIGH: Load balancer is exposed publicly.
════════════════════════════════════════
There are many scenarios in which you would want to expose a load balancer to the wider internet, but this check exists as a warning to prevent accidental exposure of internal assets. You should ensure that this resource should be exposed publicly.
See https://avd.aquasec.com/misconfig/avd-aws-0053
────────────────────────────────────────
alb.tf:132
via alb.tf:130-153 (aws_lb.external)
────────────────────────────────────────
130resource"aws_lb""external" {
...132 [ internal = false...153 }
────────────────────────────────────────
app_servers.tf (terraform)
==========================Tests:5 (SUCCESSES:0, FAILURES:4, EXCEPTIONS:1)
Failures:4 (HIGH:4, CRITICAL:0)
HIGH:InstancedoesnotrequireIMDSaccesstorequireatoken.
════════════════════════════════════════
IMDSv2 (Instance Metadata Service) introducedsessionauthenticationtokenswhichimprovesecuritywhentalkingtoIMDS.Bydefault<code>aws_instance</code>resourcesetsIMDSsessionauthtokenstobeoptional.TofullyprotectIMDSyouneedtoenablesessiontokensbyusing<code>metadata_options</code>blockandits<code>http_tokens</code>variablesetto<code>required</code>.Seehttps://avd.aquasec.com/misconfig/avd-aws-0028
────────────────────────────────────────
app_servers.tf:192viaapp_servers.tf:191-193 (metadata_options)
viaapp_servers.tf:180-212 (aws_instance.app1)
────────────────────────────────────────
180resource"aws_instance""app1" {
...192 [ http_tokens ="optional"...212 }
────────────────────────────────────────
HIGH:InstancedoesnotrequireIMDSaccesstorequireatoken.
════════════════════════════════════════
IMDSv2 (Instance Metadata Service) introducedsessionauthenticationtokenswhichimprovesecuritywhentalkingtoIMDS.Bydefault<code>aws_instance</code>resourcesetsIMDSsessionauthtokenstobeoptional.TofullyprotectIMDSyouneedtoenablesessiontokensbyusing<code>metadata_options</code>blockandits<code>http_tokens</code>variablesetto<code>required</code>.Seehttps://avd.aquasec.com/misconfig/avd-aws-0028
────────────────────────────────────────
app_servers.tf:227viaapp_servers.tf:226-228 (metadata_options)
viaapp_servers.tf:214-247 (aws_instance.app2[0])
────────────────────────────────────────
214resource"aws_instance""app2" {
...227 [ http_tokens ="optional"...247 }
────────────────────────────────────────
HIGH:Rootblockdeviceisnotencrypted.
════════════════════════════════════════
Blockdevicesshouldbeencryptedtoensuresensitivedataisheldsecurelyatrest.Seehttps://avd.aquasec.com/misconfig/avd-aws-0131
────────────────────────────────────────
app_servers.tf:180-212
────────────────────────────────────────
180 ┌ resource"aws_instance""app1" {
181 │ ami = local.application_data.accounts[local.environment].app_ami_id
182 │ availability_zone ="eu-west-2a"183 │ instance_type = local.application_data.accounts[local.environment].app_instance_type
184 │ monitoring =true185 │ vpc_security_group_ids = [aws_security_group.app.id]
186 │ subnet_id = data.aws_subnet.private_subnets_a.id
187 │ iam_instance_profile = aws_iam_instance_profile.cwa.id
188 └ key_name = aws_key_pair.cwa.key_name
...
────────────────────────────────────────
HIGH: Root block device is not encrypted.
════════════════════════════════════════
Block devices should be encrypted to ensure sensitive data is held securely at rest.
See https://avd.aquasec.com/misconfig/avd-aws-0131
────────────────────────────────────────
app_servers.tf:214-247
────────────────────────────────────────
214 ┌ resource "aws_instance""app2" {
215 │ count =contains(["development2", "testing"], local.environment) ?0:1216 │ ami = local.application_data.accounts[local.environment].app_ami_id
217 │ availability_zone ="eu-west-2a"218 │ instance_type = local.application_data.accounts[local.environment].app_instance_type
219 │ monitoring =true220 │ vpc_security_group_ids = [aws_security_group.app.id]
221 │ subnet_id = data.aws_subnet.private_subnets_a.id
222 └ iam_instance_profile = aws_iam_instance_profile.cwa.id
...
────────────────────────────────────────
backup_lambda.tf (terraform)
============================
Tests:3 (SUCCESSES:0, FAILURES:2, EXCEPTIONS:1)
Failures:2 (HIGH:2, CRITICAL:0)
HIGH: Bucket does not have encryption enabled
════════════════════════════════════════
S3 Buckets should be encrypted to protect the data that is stored within them ifaccessiscompromised.
See https://avd.aquasec.com/misconfig/avd-aws-0088
────────────────────────────────────────
backup_lambda.tf:101-107
────────────────────────────────────────
101 ┌ resource "aws_s3_bucket""scripts" {
102 │ bucket ="${local.application_name_short}-${local.environment}-scripts"103 │ tags =merge(
104 │ local.tags,
105 │ { Name ="${local.application_name_short}-${local.environment}-scripts" }
106 │ )
107 └ }
────────────────────────────────────────
HIGH: Bucket does not encrypt data with a customer managed key.
════════════════════════════════════════
Encryption using AWS keys provides protection foryourS3buckets.Toincreasecontroloftheencryptionandmanagefactorslikerotationusecustomermanagedkeys.
See https://avd.aquasec.com/misconfig/avd-aws-0132
────────────────────────────────────────
backup_lambda.tf:101-107
────────────────────────────────────────
101 ┌ resource "aws_s3_bucket""scripts" {
102 │ bucket ="${local.application_name_short}-${local.environment}-scripts"103 │ tags =merge(
104 │ local.tags,
105 │ { Name ="${local.application_name_short}-${local.environment}-scripts" }
106 │ )
107 └ }
────────────────────────────────────────
concurrent_manager.tf (terraform)
=================================
Tests:3 (SUCCESSES:0, FAILURES:2, EXCEPTIONS:1)
Failures:2 (HIGH:2, CRITICAL:0)
HIGH: Instance does not require IMDS access to require a token.
════════════════════════════════════════
IMDS v2 (Instance Metadata Service) introduced session authentication tokens which improve security when talking to IMDS.
By default <code>aws_instance</code> resource sets IMDS session auth tokens to be optional.
To fully protect IMDS you need to enable session tokens by using <code>metadata_options</code> block and its <code>http_tokens</code> variable set to <code>required</code>.
See https://avd.aquasec.com/misconfig/avd-aws-0028
────────────────────────────────────────
concurrent_manager.tf:170
via concurrent_manager.tf:169-171 (metadata_options)
via concurrent_manager.tf:158-190 (aws_instance.concurrent_manager)
────────────────────────────────────────
158 resource "aws_instance""concurrent_manager" {
...170 [ http_tokens ="optional"...190 }
────────────────────────────────────────
HIGH: Root block device is not encrypted.
════════════════════════════════════════
Block devices should be encrypted to ensure sensitive data is held securely at rest.
See https://avd.aquasec.com/misconfig/avd-aws-0131
────────────────────────────────────────
concurrent_manager.tf:158-190
────────────────────────────────────────
158 ┌ resource "aws_instance""concurrent_manager" {
159 │ ami = local.application_data.accounts[local.environment].cm_ami_id
160 │ availability_zone ="eu-west-2a"161 │ instance_type = local.application_data.accounts[local.environment].cm_instance_type
162 │ monitoring =true163 │ vpc_security_group_ids = [aws_security_group.concurrent_manager.id]
164 │ subnet_id = data.aws_subnet.private_subnets_a.id
165 │ iam_instance_profile = aws_iam_instance_profile.cwa.id
166 └ key_name = aws_key_pair.cwa.key_name
...
────────────────────────────────────────
database.tf (terraform)
=======================
Tests:3 (SUCCESSES:0, FAILURES:2, EXCEPTIONS:1)
Failures:2 (HIGH:2, CRITICAL:0)
HIGH: Instance does not require IMDS access to require a token.
════════════════════════════════════════
IMDS v2 (Instance Metadata Service) introduced session authentication tokens which improve security when talking to IMDS.
By default <code>aws_instance</code> resource sets IMDS session auth tokens to be optional.
To fully protect IMDS you need to enable session tokens by using <code>metadata_options</code> block and its <code>http_tokens</code> variable set to <code>required</code>.
See https://avd.aquasec.com/misconfig/avd-aws-0028
────────────────────────────────────────
database.tf:196
via database.tf:195-197 (metadata_options)
via database.tf:184-213 (aws_instance.database)
────────────────────────────────────────
184 resource "aws_instance""database" {
...196 [ http_tokens ="optional"...213 }
────────────────────────────────────────
HIGH: Root block device is not encrypted.
════════════════════════════════════════
Block devices should be encrypted to ensure sensitive data is held securely at rest.
See https://avd.aquasec.com/misconfig/avd-aws-0131
────────────────────────────────────────
database.tf:184-213
────────────────────────────────────────
184 ┌ resource "aws_instance""database" {
185 │ ami = local.application_data.accounts[local.environment].db_ami_id
186 │ availability_zone ="eu-west-2a"187 │ instance_type = local.application_data.accounts[local.environment].db_instance_type
188 │ monitoring =true189 │ vpc_security_group_ids = [aws_security_group.database.id]
190 │ subnet_id = data.aws_subnet.data_subnets_a.id
191 │ iam_instance_profile = aws_iam_instance_profile.cwa.id
192 └ key_name = aws_key_pair.cwa.key_name
...
────────────────────────────────────────
trivy_exitcode=1
Trivy will check the following folders:
terraform/environments/contract-work-administration
Running Trivy in terraform/environments/contract-work-administration
2024-10-31T10:10:54Z INFO [vulndb] Need to update DB
2024-10-31T10:10:54Z INFO [vulndb] Downloading vulnerability DB...
2024-10-31T10:10:54Z INFO [vulndb] Downloading artifact... repo="public.ecr.aws/aquasecurity/trivy-db:2"
2024-10-31T10:10:56Z INFO [vulndb] Artifact successfully downloaded repo="public.ecr.aws/aquasecurity/trivy-db:2"
2024-10-31T10:10:56Z INFO [vuln] Vulnerability scanning is enabled
2024-10-31T10:10:56Z INFO [misconfig] Misconfiguration scanning is enabled
2024-10-31T10:10:56Z INFO [misconfig] Need to update the built-in checks
2024-10-31T10:10:56Z INFO [misconfig] Downloading the built-in checks...
160.60 KiB / 160.60 KiB [---------------------------------------------------------] 100.00% ? p/s 0s2024-10-31T10:10:56Z INFO [secret] Secret scanning is enabled
2024-10-31T10:10:56Z INFO [secret] If your scanning is slow, please try '--scanners vuln' to disable secret scanning
2024-10-31T10:10:56Z INFO [secret] Please see also https://aquasecurity.github.io/trivy/v0.56/docs/scanner/secret#recommendation for faster secret detection
2024-10-31T10:10:58Z INFO [terraform scanner] Scanning root module file_path="."
2024-10-31T10:10:58Z WARN [terraform parser] Variable values was not found in the environment or variable files. Evaluating may not work correctly. module="root" variables="networking"
2024-10-31T10:10:59Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.aws_s3_object.user_public_keys" value="cty.NilVal"
2024-10-31T10:10:59Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.data.aws_subnet.local_account" value="cty.NilVal"
2024-10-31T10:10:59Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.dynamic.tag" value="cty.NilVal"
2024-10-31T10:10:59Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.dynamic.tag" value="cty.NilVal"
2024-10-31T10:11:00Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.expiration" value="cty.NilVal"
2024-10-31T10:11:00Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.transition" value="cty.NilVal"
2024-10-31T10:11:00Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.noncurrent_version_expiration" value="cty.NilVal"
2024-10-31T10:11:00Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.noncurrent_version_transition" value="cty.NilVal"
2024-10-31T10:11:00Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.principals" value="cty.NilVal"
2024-10-31T10:11:00Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.condition" value="cty.NilVal"
2024-10-31T10:11:00Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.expiration" value="cty.NilVal"
2024-10-31T10:11:00Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.transition" value="cty.NilVal"
2024-10-31T10:11:00Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.noncurrent_version_expiration" value="cty.NilVal"
2024-10-31T10:11:00Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.noncurrent_version_transition" value="cty.NilVal"
2024-10-31T10:11:00Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.principals" value="cty.NilVal"
2024-10-31T10:11:00Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.condition" value="cty.NilVal"
2024-10-31T10:11:01Z INFO [terraform executor] Ignore finding rule="aws-s3-encryption-customer-key" range="github.com/ministryofjustice/modernisation-platform-terraform-bastion-linux?ref=v4.2.0/github.com/ministryofjustice/modernisation-platform-terraform-s3-bucket?ref=568694e50e03630d99cb569eafa06a0b879a1239/main.tf:171-179"
2024-10-31T10:11:01Z INFO Number of language-specific files num=0
2024-10-31T10:11:01Z INFO Detected config files num=9
HIGH: Application load balancer is not set to drop invalid headers.
════════════════════════════════════════
Passing unknown or invalid headers through to the target poses a potential risk of compromise.
By setting drop_invalid_header_fields to true, anything that does not conform to well known, defined headers will be removed by the load balancer.
HIGH: Load balancer is exposed publicly.
════════════════════════════════════════
There are many scenarios in which you would want to expose a load balancer to the wider internet, but this check exists as a warning to prevent accidental exposure of internal assets. You should ensure that this resource should be exposed publicly.
HIGH: Instance does not require IMDS access to require a token.
════════════════════════════════════════
IMDS v2 (Instance Metadata Service) introduced session authentication tokens which improve security when talking to IMDS.
By default aws_instance resource sets IMDS session auth tokens to be optional.
To fully protect IMDS you need to enable session tokens by using metadata_options block and its http_tokens variable set to required.
HIGH: Instance does not require IMDS access to require a token.
════════════════════════════════════════
IMDS v2 (Instance Metadata Service) introduced session authentication tokens which improve security when talking to IMDS.
By default aws_instance resource sets IMDS session auth tokens to be optional.
To fully protect IMDS you need to enable session tokens by using metadata_options block and its http_tokens variable set to required.
HIGH: Root block device is not encrypted.
════════════════════════════════════════
Block devices should be encrypted to ensure sensitive data is held securely at rest.
HIGH: Root block device is not encrypted.
════════════════════════════════════════
Block devices should be encrypted to ensure sensitive data is held securely at rest.
HIGH: Bucket does not have encryption enabled
════════════════════════════════════════
S3 Buckets should be encrypted to protect the data that is stored within them if access is compromised.
HIGH: Bucket does not encrypt data with a customer managed key.
════════════════════════════════════════
Encryption using AWS keys provides protection for your S3 buckets. To increase control of the encryption and manage factors like rotation use customer managed keys.
HIGH: Instance does not require IMDS access to require a token.
════════════════════════════════════════
IMDS v2 (Instance Metadata Service) introduced session authentication tokens which improve security when talking to IMDS.
By default aws_instance resource sets IMDS session auth tokens to be optional.
To fully protect IMDS you need to enable session tokens by using metadata_options block and its http_tokens variable set to required.
HIGH: Root block device is not encrypted.
════════════════════════════════════════
Block devices should be encrypted to ensure sensitive data is held securely at rest.
HIGH: Instance does not require IMDS access to require a token.
════════════════════════════════════════
IMDS v2 (Instance Metadata Service) introduced session authentication tokens which improve security when talking to IMDS.
By default aws_instance resource sets IMDS session auth tokens to be optional.
To fully protect IMDS you need to enable session tokens by using metadata_options block and its http_tokens variable set to required.
HIGH: Root block device is not encrypted.
════════════════════════════════════════
Block devices should be encrypted to ensure sensitive data is held securely at rest.
*****************************
Setting default tflint config...
Running tflint --init...
Installing "terraform" plugin...
Installed "terraform" (source: github.com/terraform-linters/tflint-ruleset-terraform, version:0.9.1)
tflint will check the following folders:
terraform/environments/contract-work-administration
*****************************
Running tflint in terraform/environments/contract-work-administration
Excluding the following checks: terraform_unused_declarations
4issue(s) found:
Warning: Missing version constraint for provider "archive" in `required_providers` (terraform_required_providers)
on terraform/environments/contract-work-administration/backup_lambda.tf line 173:173:data"archive_file""connect_db" {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_required_providers.md
Warning: Missing version constraint for provider "template" in `required_providers` (terraform_required_providers)
on terraform/environments/contract-work-administration/cloudwatch.tf line 1126:1126:data"template_file""dashboard_no_ha" {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_required_providers.md
Warning: Missing version constraint for provider "local" in `required_providers` (terraform_required_providers)
on terraform/environments/contract-work-administration/data.tf line 11:11:data"local_file""cm_custom_metrics" {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_required_providers.md
Warning: Missing version constraint for provider "time" in `required_providers` (terraform_required_providers)
on terraform/environments/contract-work-administration/database.tf line 174:174:resource"time_sleep""wait_db_userdata_scripts" {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_required_providers.mdtflint_exitcode=2
Trivy Scan Failed
Show Output
*****************************
Trivy will check the following folders:
terraform/environments/contract-work-administration
*****************************
Running Trivy in terraform/environments/contract-work-administration
2024-10-31T10:10:54Z INFO [vulndb] Need to update DB
2024-10-31T10:10:54Z INFO [vulndb] Downloading vulnerability DB...2024-10-31T10:10:54Z INFO [vulndb] Downloading artifact...repo="public.ecr.aws/aquasecurity/trivy-db:2"2024-10-31T10:10:56Z INFO [vulndb] Artifact successfully downloaded repo="public.ecr.aws/aquasecurity/trivy-db:2"2024-10-31T10:10:56Z INFO [vuln] Vulnerability scanning is enabled
2024-10-31T10:10:56Z INFO [misconfig] Misconfiguration scanning is enabled
2024-10-31T10:10:56Z INFO [misconfig] Need to update the built-in checks
2024-10-31T10:10:56Z INFO [misconfig] Downloading the built-in checks...160.60 KiB /160.60 KiB [---------------------------------------------------------] 100.00%? p/s 0s2024-10-31T10:10:56Z INFO [secret] Secret scanning is enabled
2024-10-31T10:10:56Z INFO [secret] If your scanning is slow, please try '--scanners vuln' to disable secret scanning
2024-10-31T10:10:56Z INFO [secret] Please see also https://aquasecurity.github.io/trivy/v0.56/docs/scanner/secret#recommendation for faster secret detection2024-10-31T10:10:58Z INFO [terraformscanner] Scanning root module file_path="."2024-10-31T10:10:58Z WARN [terraformparser] Variable values was not found in the environment or variable files. Evaluating may not work correctly.module="root"variables="networking"2024-10-31T10:10:59Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.aws_s3_object.user_public_keys"value="cty.NilVal"2024-10-31T10:10:59Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.data.aws_subnet.local_account"value="cty.NilVal"2024-10-31T10:10:59Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.dynamic.tag"value="cty.NilVal"2024-10-31T10:10:59Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.dynamic.tag"value="cty.NilVal"2024-10-31T10:11:00Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.expiration"value="cty.NilVal"2024-10-31T10:11:00Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.transition"value="cty.NilVal"2024-10-31T10:11:00Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.noncurrent_version_expiration"value="cty.NilVal"2024-10-31T10:11:00Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.noncurrent_version_transition"value="cty.NilVal"2024-10-31T10:11:00Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.principals"value="cty.NilVal"2024-10-31T10:11:00Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.condition"value="cty.NilVal"2024-10-31T10:11:00Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.expiration"value="cty.NilVal"2024-10-31T10:11:00Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.transition"value="cty.NilVal"2024-10-31T10:11:00Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.noncurrent_version_expiration"value="cty.NilVal"2024-10-31T10:11:00Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.noncurrent_version_transition"value="cty.NilVal"2024-10-31T10:11:00Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.principals"value="cty.NilVal"2024-10-31T10:11:00Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.condition"value="cty.NilVal"2024-10-31T10:11:01Z INFO [terraformexecutor] Ignore finding rule="aws-s3-encryption-customer-key"range="github.com/ministryofjustice/modernisation-platform-terraform-bastion-linux?ref=v4.2.0/github.com/ministryofjustice/modernisation-platform-terraform-s3-bucket?ref=568694e50e03630d99cb569eafa06a0b879a1239/main.tf:171-179"2024-10-31T10:11:01Z INFO Number of language-specific files num=02024-10-31T10:11:01Z INFO Detected config files num=9
alb.tf (terraform)
==================
Tests:3 (SUCCESSES:0, FAILURES:2, EXCEPTIONS:1)
Failures:2 (HIGH:2, CRITICAL:0)
HIGH: Application load balancer is not set to drop invalid headers.
════════════════════════════════════════
Passing unknown or invalid headers through to the target poses a potential risk of compromise.
By setting drop_invalid_header_fields to true, anything that does not conform to well known, defined headers will be removed by the load balancer.
See https://avd.aquasec.com/misconfig/avd-aws-0052
────────────────────────────────────────
alb.tf:130-153
────────────────────────────────────────
130 ┌ resource"aws_lb""external" {
131 │ name="${upper(local.application_name_short)}-LoadBalancer"132 │ internal=false133 │ load_balancer_type="application"134 │ security_groups=[aws_security_group.external_lb.id]
135 │ subnets=[data.aws_subnet.public_subnets_a.id, data.aws_subnet.public_subnets_b.id, data.aws_subnet.public_subnets_c.id]
136 │ enable_deletion_protection=local.lb_enable_deletion_protection137 │ idle_timeout=local.external_lb_idle_timeout138 └ enable_http2=false...
────────────────────────────────────────
HIGH: Load balancer is exposed publicly.
════════════════════════════════════════
There are many scenarios in which you would want to expose a load balancer to the wider internet, but this check exists as a warning to prevent accidental exposure of internal assets. You should ensure that this resource should be exposed publicly.
See https://avd.aquasec.com/misconfig/avd-aws-0053
────────────────────────────────────────
alb.tf:130-153
────────────────────────────────────────
130 ┌ resource"aws_lb""external" {
131 │ name="${upper(local.application_name_short)}-LoadBalancer"132 │ internal=false133 │ load_balancer_type="application"134 │ security_groups=[aws_security_group.external_lb.id]
135 │ subnets=[data.aws_subnet.public_subnets_a.id, data.aws_subnet.public_subnets_b.id, data.aws_subnet.public_subnets_c.id]
136 │ enable_deletion_protection=local.lb_enable_deletion_protection137 │ idle_timeout=local.external_lb_idle_timeout138 └ enable_http2=false...
────────────────────────────────────────
app_servers.tf (terraform)
==========================
Tests:5 (SUCCESSES:0, FAILURES:4, EXCEPTIONS:1)
Failures:4 (HIGH:4, CRITICAL:0)
HIGH: Instance does not require IMDS access to require a token.
════════════════════════════════════════
IMDS v2 (Instance Metadata Service) introduced session authentication tokens which improve security when talking to IMDS.
By default <code>aws_instance</code> resource sets IMDS session auth tokens to be optional.
To fully protect IMDS you need to enable session tokens by using <code>metadata_options</code> block and its <code>http_tokens</code> variable set to <code>required</code>.
See https://avd.aquasec.com/misconfig/avd-aws-0028
────────────────────────────────────────
app_servers.tf:192-194
via app_servers.tf:181-213 (aws_instance.app1)
────────────────────────────────────────
181resource"aws_instance""app1" {
...192 ┌ metadata_options {
193 │ http_tokens="optional"194 └ }
...213 }
────────────────────────────────────────
HIGH: Instance does not require IMDS access to require a token.
════════════════════════════════════════
IMDS v2 (Instance Metadata Service) introduced session authentication tokens which improve security when talking to IMDS.
By default <code>aws_instance</code> resource sets IMDS session auth tokens to be optional.
To fully protect IMDS you need to enable session tokens by using <code>metadata_options</code> block and its <code>http_tokens</code> variable set to <code>required</code>.
See https://avd.aquasec.com/misconfig/avd-aws-0028
────────────────────────────────────────
app_servers.tf:227-229
via app_servers.tf:215-248 (aws_instance.app2[0])
────────────────────────────────────────
215resource"aws_instance""app2" {
...227 ┌ metadata_options {
228 │ http_tokens="optional"229 └ }
...248 }
────────────────────────────────────────
HIGH: Root block device is not encrypted.
════════════════════════════════════════
Block devices should be encrypted to ensure sensitive data is held securely at rest.
See https://avd.aquasec.com/misconfig/avd-aws-0131
────────────────────────────────────────
app_servers.tf:196-202
via app_servers.tf:181-213 (aws_instance.app1)
────────────────────────────────────────
181resource"aws_instance""app1" {
...196 ┌ root_block_device {
197 │ tags=merge(
198 │ { "instance-scheduling" = "skip-scheduling" },
199 │ local.tags,
200 │ { "Name" = "${local.application_name_short}-app1-root" }
201 │ )
202 └ }
...
────────────────────────────────────────
HIGH: Root block device is not encrypted.
════════════════════════════════════════
Block devices should be encrypted to ensure sensitive data is held securely at rest.
See https://avd.aquasec.com/misconfig/avd-aws-0131
────────────────────────────────────────
app_servers.tf:231-237
via app_servers.tf:215-248 (aws_instance.app2[0])
────────────────────────────────────────
215resource"aws_instance""app2" {
...231 ┌ root_block_device {
232 │ tags=merge(
233 │ { "instance-scheduling" = "skip-scheduling" },
234 │ local.tags,
235 │ { "Name" = "${local.application_name_short}-app2-root" }
236 │ )
237 └ }
...
────────────────────────────────────────
backup_lambda.tf (terraform)
============================
Tests:3 (SUCCESSES:0, FAILURES:2, EXCEPTIONS:1)
Failures:2 (HIGH:2, CRITICAL:0)
HIGH: Bucket does not have encryption enabled
════════════════════════════════════════
S3 Buckets should be encrypted to protect the data that is stored within them if access is compromised.
See https://avd.aquasec.com/misconfig/avd-aws-0088
────────────────────────────────────────
backup_lambda.tf:101-107
────────────────────────────────────────
101 ┌ resource"aws_s3_bucket""scripts" {
102 │ bucket="${local.application_name_short}-${local.environment}-scripts"103 │ tags=merge(
104 │ local.tags,
105 │ { Name ="${local.application_name_short}-${local.environment}-scripts" }
106 │ )
107 └ }
────────────────────────────────────────
HIGH: Bucket does not encrypt data with a customer managed key.
════════════════════════════════════════
Encryption using AWS keys provides protection for your S3 buckets. To increase control of the encryption and manage factors like rotation use customer managed keys.
See https://avd.aquasec.com/misconfig/avd-aws-0132
────────────────────────────────────────
backup_lambda.tf:101-107
────────────────────────────────────────
101 ┌ resource"aws_s3_bucket""scripts" {
102 │ bucket="${local.application_name_short}-${local.environment}-scripts"103 │ tags=merge(
104 │ local.tags,
105 │ { Name ="${local.application_name_short}-${local.environment}-scripts" }
106 │ )
107 └ }
────────────────────────────────────────
concurrent_manager.tf (terraform)
=================================
Tests:3 (SUCCESSES:0, FAILURES:2, EXCEPTIONS:1)
Failures:2 (HIGH:2, CRITICAL:0)
HIGH: Instance does not require IMDS access to require a token.
════════════════════════════════════════
IMDS v2 (Instance Metadata Service) introduced session authentication tokens which improve security when talking to IMDS.
By default <code>aws_instance</code> resource sets IMDS session auth tokens to be optional.
To fully protect IMDS you need to enable session tokens by using <code>metadata_options</code> block and its <code>http_tokens</code> variable set to <code>required</code>.
See https://avd.aquasec.com/misconfig/avd-aws-0028
────────────────────────────────────────
concurrent_manager.tf:170-172
via concurrent_manager.tf:159-191 (aws_instance.concurrent_manager)
────────────────────────────────────────
159resource"aws_instance""concurrent_manager" {
...170 ┌ metadata_options {
171 │ http_tokens="optional"172 └ }
...191 }
────────────────────────────────────────
HIGH: Root block device is not encrypted.
════════════════════════════════════════
Block devices should be encrypted to ensure sensitive data is held securely at rest.
See https://avd.aquasec.com/misconfig/avd-aws-0131
────────────────────────────────────────
concurrent_manager.tf:174-180
via concurrent_manager.tf:159-191 (aws_instance.concurrent_manager)
────────────────────────────────────────
159resource"aws_instance""concurrent_manager" {
...174 ┌ root_block_device {
175 │ tags=merge(
176 │ { "instance-scheduling" = "skip-scheduling" },
177 │ local.tags,
178 │ { "Name" = "${local.application_name_short}-concurrent-manager-root" }
179 │ )
180 └ }
...
────────────────────────────────────────
database.tf (terraform)
=======================
Tests:3 (SUCCESSES:0, FAILURES:2, EXCEPTIONS:1)
Failures:2 (HIGH:2, CRITICAL:0)
HIGH: Instance does not require IMDS access to require a token.
════════════════════════════════════════
IMDS v2 (Instance Metadata Service) introduced session authentication tokens which improve security when talking to IMDS.
By default <code>aws_instance</code> resource sets IMDS session auth tokens to be optional.
To fully protect IMDS you need to enable session tokens by using <code>metadata_options</code> block and its <code>http_tokens</code> variable set to <code>required</code>.
See https://avd.aquasec.com/misconfig/avd-aws-0028
────────────────────────────────────────
database.tf:194-196
via database.tf:183-212 (aws_instance.database)
────────────────────────────────────────
183resource"aws_instance""database" {
...194 ┌ metadata_options {
195 │ http_tokens="optional"196 └ }
...212 }
────────────────────────────────────────
HIGH: Root block device is not encrypted.
════════════════════════════════════════
Block devices should be encrypted to ensure sensitive data is held securely at rest.
See https://avd.aquasec.com/misconfig/avd-aws-0131
────────────────────────────────────────
database.tf:198-204
via database.tf:183-212 (aws_instance.database)
────────────────────────────────────────
183resource"aws_instance""database" {
...198 ┌ root_block_device {
199 │ tags=merge(
200 │ { "instance-scheduling" = "skip-scheduling" },
201 │ local.tags,
202 │ { "Name" = "${local.application_name_short}-database-root" }
203 │ )
204 └ }
...
────────────────────────────────────────
trivy_exitcode=1
Trivy will check the following folders:
terraform/environments/contract-work-administration
Running Trivy in terraform/environments/contract-work-administration
2024-10-31T11:00:21Z INFO [vulndb] Need to update DB
2024-10-31T11:00:21Z INFO [vulndb] Downloading vulnerability DB...
2024-10-31T11:00:21Z INFO [vulndb] Downloading artifact... repo="public.ecr.aws/aquasecurity/trivy-db:2"
2024-10-31T11:00:23Z INFO [vulndb] Artifact successfully downloaded repo="public.ecr.aws/aquasecurity/trivy-db:2"
2024-10-31T11:00:23Z INFO [vuln] Vulnerability scanning is enabled
2024-10-31T11:00:23Z INFO [misconfig] Misconfiguration scanning is enabled
2024-10-31T11:00:23Z INFO [misconfig] Need to update the built-in checks
2024-10-31T11:00:23Z INFO [misconfig] Downloading the built-in checks...
160.60 KiB / 160.60 KiB [------------------------------------------------------] 100.00% ? p/s 100ms2024-10-31T11:00:24Z INFO [secret] Secret scanning is enabled
2024-10-31T11:00:24Z INFO [secret] If your scanning is slow, please try '--scanners vuln' to disable secret scanning
2024-10-31T11:00:24Z INFO [secret] Please see also https://aquasecurity.github.io/trivy/v0.56/docs/scanner/secret#recommendation for faster secret detection
2024-10-31T11:00:25Z INFO [terraform scanner] Scanning root module file_path="."
2024-10-31T11:00:25Z WARN [terraform parser] Variable values was not found in the environment or variable files. Evaluating may not work correctly. module="root" variables="networking"
2024-10-31T11:00:25Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.aws_s3_object.user_public_keys" value="cty.NilVal"
2024-10-31T11:00:25Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.data.aws_subnet.local_account" value="cty.NilVal"
2024-10-31T11:00:25Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.dynamic.tag" value="cty.NilVal"
2024-10-31T11:00:25Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.dynamic.tag" value="cty.NilVal"
2024-10-31T11:00:26Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.expiration" value="cty.NilVal"
2024-10-31T11:00:26Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.transition" value="cty.NilVal"
2024-10-31T11:00:26Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.noncurrent_version_expiration" value="cty.NilVal"
2024-10-31T11:00:26Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.noncurrent_version_transition" value="cty.NilVal"
2024-10-31T11:00:26Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.principals" value="cty.NilVal"
2024-10-31T11:00:26Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.condition" value="cty.NilVal"
2024-10-31T11:00:26Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.expiration" value="cty.NilVal"
2024-10-31T11:00:26Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.transition" value="cty.NilVal"
2024-10-31T11:00:26Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.noncurrent_version_expiration" value="cty.NilVal"
2024-10-31T11:00:26Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.noncurrent_version_transition" value="cty.NilVal"
2024-10-31T11:00:26Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.principals" value="cty.NilVal"
2024-10-31T11:00:26Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.condition" value="cty.NilVal"
2024-10-31T11:00:27Z INFO [terraform executor] Ignore finding rule="aws-s3-encryption-customer-key" range="github.com/ministryofjustice/modernisation-platform-terraform-bastion-linux?ref=v4.2.0/github.com/ministryofjustice/modernisation-platform-terraform-s3-bucket?ref=568694e50e03630d99cb569eafa06a0b879a1239/main.tf:171-179"
2024-10-31T11:00:27Z INFO Number of language-specific files num=0
2024-10-31T11:00:27Z INFO Detected config files num=9
HIGH: Application load balancer is not set to drop invalid headers.
════════════════════════════════════════
Passing unknown or invalid headers through to the target poses a potential risk of compromise.
By setting drop_invalid_header_fields to true, anything that does not conform to well known, defined headers will be removed by the load balancer.
HIGH: Load balancer is exposed publicly.
════════════════════════════════════════
There are many scenarios in which you would want to expose a load balancer to the wider internet, but this check exists as a warning to prevent accidental exposure of internal assets. You should ensure that this resource should be exposed publicly.
HIGH: Instance does not require IMDS access to require a token.
════════════════════════════════════════
IMDS v2 (Instance Metadata Service) introduced session authentication tokens which improve security when talking to IMDS.
By default aws_instance resource sets IMDS session auth tokens to be optional.
To fully protect IMDS you need to enable session tokens by using metadata_options block and its http_tokens variable set to required.
HIGH: Instance does not require IMDS access to require a token.
════════════════════════════════════════
IMDS v2 (Instance Metadata Service) introduced session authentication tokens which improve security when talking to IMDS.
By default aws_instance resource sets IMDS session auth tokens to be optional.
To fully protect IMDS you need to enable session tokens by using metadata_options block and its http_tokens variable set to required.
HIGH: Root block device is not encrypted.
════════════════════════════════════════
Block devices should be encrypted to ensure sensitive data is held securely at rest.
HIGH: Root block device is not encrypted.
════════════════════════════════════════
Block devices should be encrypted to ensure sensitive data is held securely at rest.
HIGH: Bucket does not have encryption enabled
════════════════════════════════════════
S3 Buckets should be encrypted to protect the data that is stored within them if access is compromised.
HIGH: Bucket does not encrypt data with a customer managed key.
════════════════════════════════════════
Encryption using AWS keys provides protection for your S3 buckets. To increase control of the encryption and manage factors like rotation use customer managed keys.
HIGH: Instance does not require IMDS access to require a token.
════════════════════════════════════════
IMDS v2 (Instance Metadata Service) introduced session authentication tokens which improve security when talking to IMDS.
By default aws_instance resource sets IMDS session auth tokens to be optional.
To fully protect IMDS you need to enable session tokens by using metadata_options block and its http_tokens variable set to required.
HIGH: Root block device is not encrypted.
════════════════════════════════════════
Block devices should be encrypted to ensure sensitive data is held securely at rest.
HIGH: Instance does not require IMDS access to require a token.
════════════════════════════════════════
IMDS v2 (Instance Metadata Service) introduced session authentication tokens which improve security when talking to IMDS.
By default aws_instance resource sets IMDS session auth tokens to be optional.
To fully protect IMDS you need to enable session tokens by using metadata_options block and its http_tokens variable set to required.
HIGH: Root block device is not encrypted.
════════════════════════════════════════
Block devices should be encrypted to ensure sensitive data is held securely at rest.
*****************************
Setting default tflint config...
Running tflint --init...
Installing "terraform" plugin...
Installed "terraform" (source: github.com/terraform-linters/tflint-ruleset-terraform, version:0.9.1)
tflint will check the following folders:
terraform/environments/contract-work-administration
*****************************
Running tflint in terraform/environments/contract-work-administration
Excluding the following checks: terraform_unused_declarations
4issue(s) found:
Warning: Missing version constraint for provider "archive" in `required_providers` (terraform_required_providers)
on terraform/environments/contract-work-administration/backup_lambda.tf line 173:173:data"archive_file""connect_db" {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_required_providers.md
Warning: Missing version constraint for provider "template" in `required_providers` (terraform_required_providers)
on terraform/environments/contract-work-administration/cloudwatch.tf line 1126:1126:data"template_file""dashboard_no_ha" {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_required_providers.md
Warning: Missing version constraint for provider "local" in `required_providers` (terraform_required_providers)
on terraform/environments/contract-work-administration/data.tf line 11:11:data"local_file""cm_custom_metrics" {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_required_providers.md
Warning: Missing version constraint for provider "time" in `required_providers` (terraform_required_providers)
on terraform/environments/contract-work-administration/database.tf line 174:174:resource"time_sleep""wait_db_userdata_scripts" {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_required_providers.mdtflint_exitcode=2
Trivy Scan Failed
Show Output
*****************************
Trivy will check the following folders:
terraform/environments/contract-work-administration
*****************************
Running Trivy in terraform/environments/contract-work-administration
2024-10-31T11:00:21Z INFO [vulndb] Need to update DB
2024-10-31T11:00:21Z INFO [vulndb] Downloading vulnerability DB...2024-10-31T11:00:21Z INFO [vulndb] Downloading artifact...repo="public.ecr.aws/aquasecurity/trivy-db:2"2024-10-31T11:00:23Z INFO [vulndb] Artifact successfully downloaded repo="public.ecr.aws/aquasecurity/trivy-db:2"2024-10-31T11:00:23Z INFO [vuln] Vulnerability scanning is enabled
2024-10-31T11:00:23Z INFO [misconfig] Misconfiguration scanning is enabled
2024-10-31T11:00:23Z INFO [misconfig] Need to update the built-in checks
2024-10-31T11:00:23Z INFO [misconfig] Downloading the built-in checks...160.60 KiB /160.60 KiB [------------------------------------------------------] 100.00%? p/s 100ms2024-10-31T11:00:24Z INFO [secret] Secret scanning is enabled
2024-10-31T11:00:24Z INFO [secret] If your scanning is slow, please try '--scanners vuln' to disable secret scanning
2024-10-31T11:00:24Z INFO [secret] Please see also https://aquasecurity.github.io/trivy/v0.56/docs/scanner/secret#recommendation for faster secret detection2024-10-31T11:00:25Z INFO [terraformscanner] Scanning root module file_path="."2024-10-31T11:00:25Z WARN [terraformparser] Variable values was not found in the environment or variable files. Evaluating may not work correctly.module="root"variables="networking"2024-10-31T11:00:25Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.aws_s3_object.user_public_keys"value="cty.NilVal"2024-10-31T11:00:25Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.data.aws_subnet.local_account"value="cty.NilVal"2024-10-31T11:00:25Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.dynamic.tag"value="cty.NilVal"2024-10-31T11:00:25Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.dynamic.tag"value="cty.NilVal"2024-10-31T11:00:26Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.expiration"value="cty.NilVal"2024-10-31T11:00:26Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.transition"value="cty.NilVal"2024-10-31T11:00:26Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.noncurrent_version_expiration"value="cty.NilVal"2024-10-31T11:00:26Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.noncurrent_version_transition"value="cty.NilVal"2024-10-31T11:00:26Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.principals"value="cty.NilVal"2024-10-31T11:00:26Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.condition"value="cty.NilVal"2024-10-31T11:00:26Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.expiration"value="cty.NilVal"2024-10-31T11:00:26Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.transition"value="cty.NilVal"2024-10-31T11:00:26Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.noncurrent_version_expiration"value="cty.NilVal"2024-10-31T11:00:26Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.noncurrent_version_transition"value="cty.NilVal"2024-10-31T11:00:26Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.principals"value="cty.NilVal"2024-10-31T11:00:26Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.condition"value="cty.NilVal"2024-10-31T11:00:27Z INFO [terraformexecutor] Ignore finding rule="aws-s3-encryption-customer-key"range="github.com/ministryofjustice/modernisation-platform-terraform-bastion-linux?ref=v4.2.0/github.com/ministryofjustice/modernisation-platform-terraform-s3-bucket?ref=568694e50e03630d99cb569eafa06a0b879a1239/main.tf:171-179"2024-10-31T11:00:27Z INFO Number of language-specific files num=02024-10-31T11:00:27Z INFO Detected config files num=9
alb.tf (terraform)
==================
Tests:3 (SUCCESSES:0, FAILURES:2, EXCEPTIONS:1)
Failures:2 (HIGH:2, CRITICAL:0)
HIGH: Application load balancer is not set to drop invalid headers.
════════════════════════════════════════
Passing unknown or invalid headers through to the target poses a potential risk of compromise.
By setting drop_invalid_header_fields to true, anything that does not conform to well known, defined headers will be removed by the load balancer.
See https://avd.aquasec.com/misconfig/avd-aws-0052
────────────────────────────────────────
alb.tf:130-153
────────────────────────────────────────
130 ┌ resource"aws_lb""external" {
131 │ name="${upper(local.application_name_short)}-LoadBalancer"132 │ internal=false133 │ load_balancer_type="application"134 │ security_groups=[aws_security_group.external_lb.id]
135 │ subnets=[data.aws_subnet.public_subnets_a.id, data.aws_subnet.public_subnets_b.id, data.aws_subnet.public_subnets_c.id]
136 │ enable_deletion_protection=local.lb_enable_deletion_protection137 │ idle_timeout=local.external_lb_idle_timeout138 └ enable_http2=false...
────────────────────────────────────────
HIGH: Load balancer is exposed publicly.
════════════════════════════════════════
There are many scenarios in which you would want to expose a load balancer to the wider internet, but this check exists as a warning to prevent accidental exposure of internal assets. You should ensure that this resource should be exposed publicly.
See https://avd.aquasec.com/misconfig/avd-aws-0053
────────────────────────────────────────
alb.tf:130-153
────────────────────────────────────────
130 ┌ resource"aws_lb""external" {
131 │ name="${upper(local.application_name_short)}-LoadBalancer"132 │ internal=false133 │ load_balancer_type="application"134 │ security_groups=[aws_security_group.external_lb.id]
135 │ subnets=[data.aws_subnet.public_subnets_a.id, data.aws_subnet.public_subnets_b.id, data.aws_subnet.public_subnets_c.id]
136 │ enable_deletion_protection=local.lb_enable_deletion_protection137 │ idle_timeout=local.external_lb_idle_timeout138 └ enable_http2=false...
────────────────────────────────────────
app_servers.tf (terraform)
==========================
Tests:5 (SUCCESSES:0, FAILURES:4, EXCEPTIONS:1)
Failures:4 (HIGH:4, CRITICAL:0)
HIGH: Instance does not require IMDS access to require a token.
════════════════════════════════════════
IMDS v2 (Instance Metadata Service) introduced session authentication tokens which improve security when talking to IMDS.
By default <code>aws_instance</code> resource sets IMDS session auth tokens to be optional.
To fully protect IMDS you need to enable session tokens by using <code>metadata_options</code> block and its <code>http_tokens</code> variable set to <code>required</code>.
See https://avd.aquasec.com/misconfig/avd-aws-0028
────────────────────────────────────────
app_servers.tf:193-195
via app_servers.tf:182-214 (aws_instance.app1)
────────────────────────────────────────
182resource"aws_instance""app1" {
...193 ┌ metadata_options {
194 │ http_tokens="optional"195 └ }
...214 }
────────────────────────────────────────
HIGH: Instance does not require IMDS access to require a token.
════════════════════════════════════════
IMDS v2 (Instance Metadata Service) introduced session authentication tokens which improve security when talking to IMDS.
By default <code>aws_instance</code> resource sets IMDS session auth tokens to be optional.
To fully protect IMDS you need to enable session tokens by using <code>metadata_options</code> block and its <code>http_tokens</code> variable set to <code>required</code>.
See https://avd.aquasec.com/misconfig/avd-aws-0028
────────────────────────────────────────
app_servers.tf:228-230
via app_servers.tf:216-249 (aws_instance.app2[0])
────────────────────────────────────────
216resource"aws_instance""app2" {
...228 ┌ metadata_options {
229 │ http_tokens="optional"230 └ }
...249 }
────────────────────────────────────────
HIGH: Root block device is not encrypted.
════════════════════════════════════════
Block devices should be encrypted to ensure sensitive data is held securely at rest.
See https://avd.aquasec.com/misconfig/avd-aws-0131
────────────────────────────────────────
app_servers.tf:197-203
via app_servers.tf:182-214 (aws_instance.app1)
────────────────────────────────────────
182resource"aws_instance""app1" {
...197 ┌ root_block_device {
198 │ tags=merge(
199 │ { "instance-scheduling" = "skip-scheduling" },
200 │ local.tags,
201 │ { "Name" = "${local.application_name_short}-app1-root" }
202 │ )
203 └ }
...
────────────────────────────────────────
HIGH: Root block device is not encrypted.
════════════════════════════════════════
Block devices should be encrypted to ensure sensitive data is held securely at rest.
See https://avd.aquasec.com/misconfig/avd-aws-0131
────────────────────────────────────────
app_servers.tf:232-238
via app_servers.tf:216-249 (aws_instance.app2[0])
────────────────────────────────────────
216resource"aws_instance""app2" {
...232 ┌ root_block_device {
233 │ tags=merge(
234 │ { "instance-scheduling" = "skip-scheduling" },
235 │ local.tags,
236 │ { "Name" = "${local.application_name_short}-app2-root" }
237 │ )
238 └ }
...
────────────────────────────────────────
backup_lambda.tf (terraform)
============================
Tests:3 (SUCCESSES:0, FAILURES:2, EXCEPTIONS:1)
Failures:2 (HIGH:2, CRITICAL:0)
HIGH: Bucket does not have encryption enabled
════════════════════════════════════════
S3 Buckets should be encrypted to protect the data that is stored within them if access is compromised.
See https://avd.aquasec.com/misconfig/avd-aws-0088
────────────────────────────────────────
backup_lambda.tf:101-107
────────────────────────────────────────
101 ┌ resource"aws_s3_bucket""scripts" {
102 │ bucket="${local.application_name_short}-${local.environment}-scripts"103 │ tags=merge(
104 │ local.tags,
105 │ { Name ="${local.application_name_short}-${local.environment}-scripts" }
106 │ )
107 └ }
────────────────────────────────────────
HIGH: Bucket does not encrypt data with a customer managed key.
════════════════════════════════════════
Encryption using AWS keys provides protection for your S3 buckets. To increase control of the encryption and manage factors like rotation use customer managed keys.
See https://avd.aquasec.com/misconfig/avd-aws-0132
────────────────────────────────────────
backup_lambda.tf:101-107
────────────────────────────────────────
101 ┌ resource"aws_s3_bucket""scripts" {
102 │ bucket="${local.application_name_short}-${local.environment}-scripts"103 │ tags=merge(
104 │ local.tags,
105 │ { Name ="${local.application_name_short}-${local.environment}-scripts" }
106 │ )
107 └ }
────────────────────────────────────────
concurrent_manager.tf (terraform)
=================================
Tests:3 (SUCCESSES:0, FAILURES:2, EXCEPTIONS:1)
Failures:2 (HIGH:2, CRITICAL:0)
HIGH: Instance does not require IMDS access to require a token.
════════════════════════════════════════
IMDS v2 (Instance Metadata Service) introduced session authentication tokens which improve security when talking to IMDS.
By default <code>aws_instance</code> resource sets IMDS session auth tokens to be optional.
To fully protect IMDS you need to enable session tokens by using <code>metadata_options</code> block and its <code>http_tokens</code> variable set to <code>required</code>.
See https://avd.aquasec.com/misconfig/avd-aws-0028
────────────────────────────────────────
concurrent_manager.tf:171-173
via concurrent_manager.tf:160-192 (aws_instance.concurrent_manager)
────────────────────────────────────────
160resource"aws_instance""concurrent_manager" {
...171 ┌ metadata_options {
172 │ http_tokens="optional"173 └ }
...192 }
────────────────────────────────────────
HIGH: Root block device is not encrypted.
════════════════════════════════════════
Block devices should be encrypted to ensure sensitive data is held securely at rest.
See https://avd.aquasec.com/misconfig/avd-aws-0131
────────────────────────────────────────
concurrent_manager.tf:175-181
via concurrent_manager.tf:160-192 (aws_instance.concurrent_manager)
────────────────────────────────────────
160resource"aws_instance""concurrent_manager" {
...175 ┌ root_block_device {
176 │ tags=merge(
177 │ { "instance-scheduling" = "skip-scheduling" },
178 │ local.tags,
179 │ { "Name" = "${local.application_name_short}-concurrent-manager-root" }
180 │ )
181 └ }
...
────────────────────────────────────────
database.tf (terraform)
=======================
Tests:3 (SUCCESSES:0, FAILURES:2, EXCEPTIONS:1)
Failures:2 (HIGH:2, CRITICAL:0)
HIGH: Instance does not require IMDS access to require a token.
════════════════════════════════════════
IMDS v2 (Instance Metadata Service) introduced session authentication tokens which improve security when talking to IMDS.
By default <code>aws_instance</code> resource sets IMDS session auth tokens to be optional.
To fully protect IMDS you need to enable session tokens by using <code>metadata_options</code> block and its <code>http_tokens</code> variable set to <code>required</code>.
See https://avd.aquasec.com/misconfig/avd-aws-0028
────────────────────────────────────────
database.tf:194-196
via database.tf:183-212 (aws_instance.database)
────────────────────────────────────────
183resource"aws_instance""database" {
...194 ┌ metadata_options {
195 │ http_tokens="optional"196 └ }
...212 }
────────────────────────────────────────
HIGH: Root block device is not encrypted.
════════════════════════════════════════
Block devices should be encrypted to ensure sensitive data is held securely at rest.
See https://avd.aquasec.com/misconfig/avd-aws-0131
────────────────────────────────────────
database.tf:198-204
via database.tf:183-212 (aws_instance.database)
────────────────────────────────────────
183resource"aws_instance""database" {
...198 ┌ root_block_device {
199 │ tags=merge(
200 │ { "instance-scheduling" = "skip-scheduling" },
201 │ local.tags,
202 │ { "Name" = "${local.application_name_short}-database-root" }
203 │ )
204 └ }
...
────────────────────────────────────────
trivy_exitcode=1
Trivy will check the following folders:
terraform/environments/contract-work-administration
Running Trivy in terraform/environments/contract-work-administration
2024-10-31T11:30:49Z INFO [vulndb] Need to update DB
2024-10-31T11:30:49Z INFO [vulndb] Downloading vulnerability DB...
2024-10-31T11:30:49Z INFO [vulndb] Downloading artifact... repo="public.ecr.aws/aquasecurity/trivy-db:2"
2024-10-31T11:30:51Z INFO [vulndb] Artifact successfully downloaded repo="public.ecr.aws/aquasecurity/trivy-db:2"
2024-10-31T11:30:51Z INFO [vuln] Vulnerability scanning is enabled
2024-10-31T11:30:51Z INFO [misconfig] Misconfiguration scanning is enabled
2024-10-31T11:30:51Z INFO [misconfig] Need to update the built-in checks
2024-10-31T11:30:51Z INFO [misconfig] Downloading the built-in checks...
160.60 KiB / 160.60 KiB [------------------------------------------------------] 100.00% ? p/s 100ms2024-10-31T11:30:51Z INFO [secret] Secret scanning is enabled
2024-10-31T11:30:51Z INFO [secret] If your scanning is slow, please try '--scanners vuln' to disable secret scanning
2024-10-31T11:30:51Z INFO [secret] Please see also https://aquasecurity.github.io/trivy/v0.56/docs/scanner/secret#recommendation for faster secret detection
2024-10-31T11:30:53Z INFO [terraform scanner] Scanning root module file_path="."
2024-10-31T11:30:53Z WARN [terraform parser] Variable values was not found in the environment or variable files. Evaluating may not work correctly. module="root" variables="networking"
2024-10-31T11:30:54Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.aws_s3_object.user_public_keys" value="cty.NilVal"
2024-10-31T11:30:54Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.data.aws_subnet.local_account" value="cty.NilVal"
2024-10-31T11:30:54Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.dynamic.tag" value="cty.NilVal"
2024-10-31T11:30:54Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.dynamic.tag" value="cty.NilVal"
2024-10-31T11:30:54Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.expiration" value="cty.NilVal"
2024-10-31T11:30:54Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.transition" value="cty.NilVal"
2024-10-31T11:30:54Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.noncurrent_version_expiration" value="cty.NilVal"
2024-10-31T11:30:54Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.noncurrent_version_transition" value="cty.NilVal"
2024-10-31T11:30:54Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.principals" value="cty.NilVal"
2024-10-31T11:30:54Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.condition" value="cty.NilVal"
2024-10-31T11:30:54Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.expiration" value="cty.NilVal"
2024-10-31T11:30:54Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.transition" value="cty.NilVal"
2024-10-31T11:30:54Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.noncurrent_version_expiration" value="cty.NilVal"
2024-10-31T11:30:54Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.noncurrent_version_transition" value="cty.NilVal"
2024-10-31T11:30:54Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.principals" value="cty.NilVal"
2024-10-31T11:30:54Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.condition" value="cty.NilVal"
2024-10-31T11:30:55Z INFO [terraform executor] Ignore finding rule="aws-s3-encryption-customer-key" range="github.com/ministryofjustice/modernisation-platform-terraform-bastion-linux?ref=v4.2.0/github.com/ministryofjustice/modernisation-platform-terraform-s3-bucket?ref=568694e50e03630d99cb569eafa06a0b879a1239/main.tf:171-179"
2024-10-31T11:30:55Z INFO Number of language-specific files num=0
2024-10-31T11:30:55Z INFO Detected config files num=9
HIGH: Application load balancer is not set to drop invalid headers.
════════════════════════════════════════
Passing unknown or invalid headers through to the target poses a potential risk of compromise.
By setting drop_invalid_header_fields to true, anything that does not conform to well known, defined headers will be removed by the load balancer.
HIGH: Load balancer is exposed publicly.
════════════════════════════════════════
There are many scenarios in which you would want to expose a load balancer to the wider internet, but this check exists as a warning to prevent accidental exposure of internal assets. You should ensure that this resource should be exposed publicly.
HIGH: Instance does not require IMDS access to require a token.
════════════════════════════════════════
IMDS v2 (Instance Metadata Service) introduced session authentication tokens which improve security when talking to IMDS.
By default aws_instance resource sets IMDS session auth tokens to be optional.
To fully protect IMDS you need to enable session tokens by using metadata_options block and its http_tokens variable set to required.
HIGH: Instance does not require IMDS access to require a token.
════════════════════════════════════════
IMDS v2 (Instance Metadata Service) introduced session authentication tokens which improve security when talking to IMDS.
By default aws_instance resource sets IMDS session auth tokens to be optional.
To fully protect IMDS you need to enable session tokens by using metadata_options block and its http_tokens variable set to required.
HIGH: Root block device is not encrypted.
════════════════════════════════════════
Block devices should be encrypted to ensure sensitive data is held securely at rest.
HIGH: Root block device is not encrypted.
════════════════════════════════════════
Block devices should be encrypted to ensure sensitive data is held securely at rest.
HIGH: Bucket does not have encryption enabled
════════════════════════════════════════
S3 Buckets should be encrypted to protect the data that is stored within them if access is compromised.
HIGH: Bucket does not encrypt data with a customer managed key.
════════════════════════════════════════
Encryption using AWS keys provides protection for your S3 buckets. To increase control of the encryption and manage factors like rotation use customer managed keys.
HIGH: Instance does not require IMDS access to require a token.
════════════════════════════════════════
IMDS v2 (Instance Metadata Service) introduced session authentication tokens which improve security when talking to IMDS.
By default aws_instance resource sets IMDS session auth tokens to be optional.
To fully protect IMDS you need to enable session tokens by using metadata_options block and its http_tokens variable set to required.
HIGH: Root block device is not encrypted.
════════════════════════════════════════
Block devices should be encrypted to ensure sensitive data is held securely at rest.
HIGH: Instance does not require IMDS access to require a token.
════════════════════════════════════════
IMDS v2 (Instance Metadata Service) introduced session authentication tokens which improve security when talking to IMDS.
By default aws_instance resource sets IMDS session auth tokens to be optional.
To fully protect IMDS you need to enable session tokens by using metadata_options block and its http_tokens variable set to required.
HIGH: Root block device is not encrypted.
════════════════════════════════════════
Block devices should be encrypted to ensure sensitive data is held securely at rest.
*****************************
Setting default tflint config...
Running tflint --init...
Installing "terraform" plugin...
Installed "terraform" (source: github.com/terraform-linters/tflint-ruleset-terraform, version:0.9.1)
tflint will check the following folders:
terraform/environments/contract-work-administration
*****************************
Running tflint in terraform/environments/contract-work-administration
Excluding the following checks: terraform_unused_declarations
4issue(s) found:
Warning: Missing version constraint for provider "archive" in `required_providers` (terraform_required_providers)
on terraform/environments/contract-work-administration/backup_lambda.tf line 173:173:data"archive_file""connect_db" {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_required_providers.md
Warning: Missing version constraint for provider "template" in `required_providers` (terraform_required_providers)
on terraform/environments/contract-work-administration/cloudwatch.tf line 1126:1126:data"template_file""dashboard_no_ha" {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_required_providers.md
Warning: Missing version constraint for provider "local" in `required_providers` (terraform_required_providers)
on terraform/environments/contract-work-administration/data.tf line 11:11:data"local_file""cm_custom_metrics" {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_required_providers.md
Warning: Missing version constraint for provider "time" in `required_providers` (terraform_required_providers)
on terraform/environments/contract-work-administration/database.tf line 174:174:resource"time_sleep""wait_db_userdata_scripts" {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_required_providers.mdtflint_exitcode=2
Trivy Scan Failed
Show Output
*****************************
Trivy will check the following folders:
terraform/environments/contract-work-administration
*****************************
Running Trivy in terraform/environments/contract-work-administration
2024-10-31T11:30:49Z INFO [vulndb] Need to update DB
2024-10-31T11:30:49Z INFO [vulndb] Downloading vulnerability DB...2024-10-31T11:30:49Z INFO [vulndb] Downloading artifact...repo="public.ecr.aws/aquasecurity/trivy-db:2"2024-10-31T11:30:51Z INFO [vulndb] Artifact successfully downloaded repo="public.ecr.aws/aquasecurity/trivy-db:2"2024-10-31T11:30:51Z INFO [vuln] Vulnerability scanning is enabled
2024-10-31T11:30:51Z INFO [misconfig] Misconfiguration scanning is enabled
2024-10-31T11:30:51Z INFO [misconfig] Need to update the built-in checks
2024-10-31T11:30:51Z INFO [misconfig] Downloading the built-in checks...160.60 KiB /160.60 KiB [------------------------------------------------------] 100.00%? p/s 100ms2024-10-31T11:30:51Z INFO [secret] Secret scanning is enabled
2024-10-31T11:30:51Z INFO [secret] If your scanning is slow, please try '--scanners vuln' to disable secret scanning
2024-10-31T11:30:51Z INFO [secret] Please see also https://aquasecurity.github.io/trivy/v0.56/docs/scanner/secret#recommendation for faster secret detection2024-10-31T11:30:53Z INFO [terraformscanner] Scanning root module file_path="."2024-10-31T11:30:53Z WARN [terraformparser] Variable values was not found in the environment or variable files. Evaluating may not work correctly.module="root"variables="networking"2024-10-31T11:30:54Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.aws_s3_object.user_public_keys"value="cty.NilVal"2024-10-31T11:30:54Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.data.aws_subnet.local_account"value="cty.NilVal"2024-10-31T11:30:54Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.dynamic.tag"value="cty.NilVal"2024-10-31T11:30:54Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.dynamic.tag"value="cty.NilVal"2024-10-31T11:30:54Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.expiration"value="cty.NilVal"2024-10-31T11:30:54Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.transition"value="cty.NilVal"2024-10-31T11:30:54Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.noncurrent_version_expiration"value="cty.NilVal"2024-10-31T11:30:54Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.noncurrent_version_transition"value="cty.NilVal"2024-10-31T11:30:54Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.principals"value="cty.NilVal"2024-10-31T11:30:54Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.condition"value="cty.NilVal"2024-10-31T11:30:54Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.expiration"value="cty.NilVal"2024-10-31T11:30:54Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.transition"value="cty.NilVal"2024-10-31T11:30:54Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.noncurrent_version_expiration"value="cty.NilVal"2024-10-31T11:30:54Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.noncurrent_version_transition"value="cty.NilVal"2024-10-31T11:30:54Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.principals"value="cty.NilVal"2024-10-31T11:30:54Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.condition"value="cty.NilVal"2024-10-31T11:30:55Z INFO [terraformexecutor] Ignore finding rule="aws-s3-encryption-customer-key"range="github.com/ministryofjustice/modernisation-platform-terraform-bastion-linux?ref=v4.2.0/github.com/ministryofjustice/modernisation-platform-terraform-s3-bucket?ref=568694e50e03630d99cb569eafa06a0b879a1239/main.tf:171-179"2024-10-31T11:30:55Z INFO Number of language-specific files num=02024-10-31T11:30:55Z INFO Detected config files num=9
alb.tf (terraform)
==================
Tests:3 (SUCCESSES:0, FAILURES:2, EXCEPTIONS:1)
Failures:2 (HIGH:2, CRITICAL:0)
HIGH: Application load balancer is not set to drop invalid headers.
════════════════════════════════════════
Passing unknown or invalid headers through to the target poses a potential risk of compromise.
By setting drop_invalid_header_fields to true, anything that does not conform to well known, defined headers will be removed by the load balancer.
See https://avd.aquasec.com/misconfig/avd-aws-0052
────────────────────────────────────────
alb.tf:130-153
────────────────────────────────────────
130 ┌ resource"aws_lb""external" {
131 │ name="${upper(local.application_name_short)}-LoadBalancer"132 │ internal=false133 │ load_balancer_type="application"134 │ security_groups=[aws_security_group.external_lb.id]
135 │ subnets=[data.aws_subnet.public_subnets_a.id, data.aws_subnet.public_subnets_b.id, data.aws_subnet.public_subnets_c.id]
136 │ enable_deletion_protection=local.lb_enable_deletion_protection137 │ idle_timeout=local.external_lb_idle_timeout138 └ enable_http2=false...
────────────────────────────────────────
HIGH: Load balancer is exposed publicly.
════════════════════════════════════════
There are many scenarios in which you would want to expose a load balancer to the wider internet, but this check exists as a warning to prevent accidental exposure of internal assets. You should ensure that this resource should be exposed publicly.
See https://avd.aquasec.com/misconfig/avd-aws-0053
────────────────────────────────────────
alb.tf:130-153
────────────────────────────────────────
130 ┌ resource"aws_lb""external" {
131 │ name="${upper(local.application_name_short)}-LoadBalancer"132 │ internal=false133 │ load_balancer_type="application"134 │ security_groups=[aws_security_group.external_lb.id]
135 │ subnets=[data.aws_subnet.public_subnets_a.id, data.aws_subnet.public_subnets_b.id, data.aws_subnet.public_subnets_c.id]
136 │ enable_deletion_protection=local.lb_enable_deletion_protection137 │ idle_timeout=local.external_lb_idle_timeout138 └ enable_http2=false...
────────────────────────────────────────
app_servers.tf (terraform)
==========================
Tests:5 (SUCCESSES:0, FAILURES:4, EXCEPTIONS:1)
Failures:4 (HIGH:4, CRITICAL:0)
HIGH: Instance does not require IMDS access to require a token.
════════════════════════════════════════
IMDS v2 (Instance Metadata Service) introduced session authentication tokens which improve security when talking to IMDS.
By default <code>aws_instance</code> resource sets IMDS session auth tokens to be optional.
To fully protect IMDS you need to enable session tokens by using <code>metadata_options</code> block and its <code>http_tokens</code> variable set to <code>required</code>.
See https://avd.aquasec.com/misconfig/avd-aws-0028
────────────────────────────────────────
app_servers.tf:193-195
via app_servers.tf:182-214 (aws_instance.app1)
────────────────────────────────────────
182resource"aws_instance""app1" {
...193 ┌ metadata_options {
194 │ http_tokens="optional"195 └ }
...214 }
────────────────────────────────────────
HIGH: Instance does not require IMDS access to require a token.
════════════════════════════════════════
IMDS v2 (Instance Metadata Service) introduced session authentication tokens which improve security when talking to IMDS.
By default <code>aws_instance</code> resource sets IMDS session auth tokens to be optional.
To fully protect IMDS you need to enable session tokens by using <code>metadata_options</code> block and its <code>http_tokens</code> variable set to <code>required</code>.
See https://avd.aquasec.com/misconfig/avd-aws-0028
────────────────────────────────────────
app_servers.tf:228-230
via app_servers.tf:216-249 (aws_instance.app2[0])
────────────────────────────────────────
216resource"aws_instance""app2" {
...228 ┌ metadata_options {
229 │ http_tokens="optional"230 └ }
...249 }
────────────────────────────────────────
HIGH: Root block device is not encrypted.
════════════════════════════════════════
Block devices should be encrypted to ensure sensitive data is held securely at rest.
See https://avd.aquasec.com/misconfig/avd-aws-0131
────────────────────────────────────────
app_servers.tf:197-203
via app_servers.tf:182-214 (aws_instance.app1)
────────────────────────────────────────
182resource"aws_instance""app1" {
...197 ┌ root_block_device {
198 │ tags=merge(
199 │ { "instance-scheduling" = "skip-scheduling" },
200 │ local.tags,
201 │ { "Name" = "${local.application_name_short}-app1-root" }
202 │ )
203 └ }
...
────────────────────────────────────────
HIGH: Root block device is not encrypted.
════════════════════════════════════════
Block devices should be encrypted to ensure sensitive data is held securely at rest.
See https://avd.aquasec.com/misconfig/avd-aws-0131
────────────────────────────────────────
app_servers.tf:232-238
via app_servers.tf:216-249 (aws_instance.app2[0])
────────────────────────────────────────
216resource"aws_instance""app2" {
...232 ┌ root_block_device {
233 │ tags=merge(
234 │ { "instance-scheduling" = "skip-scheduling" },
235 │ local.tags,
236 │ { "Name" = "${local.application_name_short}-app2-root" }
237 │ )
238 └ }
...
────────────────────────────────────────
backup_lambda.tf (terraform)
============================
Tests:3 (SUCCESSES:0, FAILURES:2, EXCEPTIONS:1)
Failures:2 (HIGH:2, CRITICAL:0)
HIGH: Bucket does not have encryption enabled
════════════════════════════════════════
S3 Buckets should be encrypted to protect the data that is stored within them if access is compromised.
See https://avd.aquasec.com/misconfig/avd-aws-0088
────────────────────────────────────────
backup_lambda.tf:101-107
────────────────────────────────────────
101 ┌ resource"aws_s3_bucket""scripts" {
102 │ bucket="${local.application_name_short}-${local.environment}-scripts"103 │ tags=merge(
104 │ local.tags,
105 │ { Name ="${local.application_name_short}-${local.environment}-scripts" }
106 │ )
107 └ }
────────────────────────────────────────
HIGH: Bucket does not encrypt data with a customer managed key.
════════════════════════════════════════
Encryption using AWS keys provides protection for your S3 buckets. To increase control of the encryption and manage factors like rotation use customer managed keys.
See https://avd.aquasec.com/misconfig/avd-aws-0132
────────────────────────────────────────
backup_lambda.tf:101-107
────────────────────────────────────────
101 ┌ resource"aws_s3_bucket""scripts" {
102 │ bucket="${local.application_name_short}-${local.environment}-scripts"103 │ tags=merge(
104 │ local.tags,
105 │ { Name ="${local.application_name_short}-${local.environment}-scripts" }
106 │ )
107 └ }
────────────────────────────────────────
concurrent_manager.tf (terraform)
=================================
Tests:3 (SUCCESSES:0, FAILURES:2, EXCEPTIONS:1)
Failures:2 (HIGH:2, CRITICAL:0)
HIGH: Instance does not require IMDS access to require a token.
════════════════════════════════════════
IMDS v2 (Instance Metadata Service) introduced session authentication tokens which improve security when talking to IMDS.
By default <code>aws_instance</code> resource sets IMDS session auth tokens to be optional.
To fully protect IMDS you need to enable session tokens by using <code>metadata_options</code> block and its <code>http_tokens</code> variable set to <code>required</code>.
See https://avd.aquasec.com/misconfig/avd-aws-0028
────────────────────────────────────────
concurrent_manager.tf:171-173
via concurrent_manager.tf:160-192 (aws_instance.concurrent_manager)
────────────────────────────────────────
160resource"aws_instance""concurrent_manager" {
...171 ┌ metadata_options {
172 │ http_tokens="optional"173 └ }
...192 }
────────────────────────────────────────
HIGH: Root block device is not encrypted.
════════════════════════════════════════
Block devices should be encrypted to ensure sensitive data is held securely at rest.
See https://avd.aquasec.com/misconfig/avd-aws-0131
────────────────────────────────────────
concurrent_manager.tf:175-181
via concurrent_manager.tf:160-192 (aws_instance.concurrent_manager)
────────────────────────────────────────
160resource"aws_instance""concurrent_manager" {
...175 ┌ root_block_device {
176 │ tags=merge(
177 │ { "instance-scheduling" = "skip-scheduling" },
178 │ local.tags,
179 │ { "Name" = "${local.application_name_short}-concurrent-manager-root" }
180 │ )
181 └ }
...
────────────────────────────────────────
database.tf (terraform)
=======================
Tests:3 (SUCCESSES:0, FAILURES:2, EXCEPTIONS:1)
Failures:2 (HIGH:2, CRITICAL:0)
HIGH: Instance does not require IMDS access to require a token.
════════════════════════════════════════
IMDS v2 (Instance Metadata Service) introduced session authentication tokens which improve security when talking to IMDS.
By default <code>aws_instance</code> resource sets IMDS session auth tokens to be optional.
To fully protect IMDS you need to enable session tokens by using <code>metadata_options</code> block and its <code>http_tokens</code> variable set to <code>required</code>.
See https://avd.aquasec.com/misconfig/avd-aws-0028
────────────────────────────────────────
database.tf:194-196
via database.tf:183-212 (aws_instance.database)
────────────────────────────────────────
183resource"aws_instance""database" {
...194 ┌ metadata_options {
195 │ http_tokens="optional"196 └ }
...212 }
────────────────────────────────────────
HIGH: Root block device is not encrypted.
════════════════════════════════════════
Block devices should be encrypted to ensure sensitive data is held securely at rest.
See https://avd.aquasec.com/misconfig/avd-aws-0131
────────────────────────────────────────
database.tf:198-204
via database.tf:183-212 (aws_instance.database)
────────────────────────────────────────
183resource"aws_instance""database" {
...198 ┌ root_block_device {
199 │ tags=merge(
200 │ { "instance-scheduling" = "skip-scheduling" },
201 │ local.tags,
202 │ { "Name" = "${local.application_name_short}-database-root" }
203 │ )
204 └ }
...
────────────────────────────────────────
trivy_exitcode=1
Trivy will check the following folders:
terraform/environments/contract-work-administration
Running Trivy in terraform/environments/contract-work-administration
2024-10-31T12:28:20Z INFO [vulndb] Need to update DB
2024-10-31T12:28:20Z INFO [vulndb] Downloading vulnerability DB...
2024-10-31T12:28:20Z INFO [vulndb] Downloading artifact... repo="public.ecr.aws/aquasecurity/trivy-db:2"
2024-10-31T12:28:23Z INFO [vulndb] Artifact successfully downloaded repo="public.ecr.aws/aquasecurity/trivy-db:2"
2024-10-31T12:28:23Z INFO [vuln] Vulnerability scanning is enabled
2024-10-31T12:28:23Z INFO [misconfig] Misconfiguration scanning is enabled
2024-10-31T12:28:23Z INFO [misconfig] Need to update the built-in checks
2024-10-31T12:28:23Z INFO [misconfig] Downloading the built-in checks...
160.60 KiB / 160.60 KiB [------------------------------------------------------] 100.00% ? p/s 100ms2024-10-31T12:28:23Z INFO [secret] Secret scanning is enabled
2024-10-31T12:28:23Z INFO [secret] If your scanning is slow, please try '--scanners vuln' to disable secret scanning
2024-10-31T12:28:23Z INFO [secret] Please see also https://aquasecurity.github.io/trivy/v0.56/docs/scanner/secret#recommendation for faster secret detection
2024-10-31T12:28:24Z INFO [terraform scanner] Scanning root module file_path="."
2024-10-31T12:28:24Z WARN [terraform parser] Variable values was not found in the environment or variable files. Evaluating may not work correctly. module="root" variables="networking"
2024-10-31T12:28:25Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.aws_s3_object.user_public_keys" value="cty.NilVal"
2024-10-31T12:28:25Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.data.aws_subnet.local_account" value="cty.NilVal"
2024-10-31T12:28:25Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.dynamic.tag" value="cty.NilVal"
2024-10-31T12:28:25Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.dynamic.tag" value="cty.NilVal"
2024-10-31T12:28:26Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.expiration" value="cty.NilVal"
2024-10-31T12:28:26Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.transition" value="cty.NilVal"
2024-10-31T12:28:26Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.noncurrent_version_expiration" value="cty.NilVal"
2024-10-31T12:28:26Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.noncurrent_version_transition" value="cty.NilVal"
2024-10-31T12:28:26Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.principals" value="cty.NilVal"
2024-10-31T12:28:26Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.condition" value="cty.NilVal"
2024-10-31T12:28:26Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.expiration" value="cty.NilVal"
2024-10-31T12:28:26Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.transition" value="cty.NilVal"
2024-10-31T12:28:26Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.noncurrent_version_expiration" value="cty.NilVal"
2024-10-31T12:28:26Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.noncurrent_version_transition" value="cty.NilVal"
2024-10-31T12:28:26Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.principals" value="cty.NilVal"
2024-10-31T12:28:26Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.condition" value="cty.NilVal"
2024-10-31T12:28:27Z INFO [terraform executor] Ignore finding rule="aws-s3-encryption-customer-key" range="github.com/ministryofjustice/modernisation-platform-terraform-bastion-linux?ref=v4.2.0/github.com/ministryofjustice/modernisation-platform-terraform-s3-bucket?ref=568694e50e03630d99cb569eafa06a0b879a1239/main.tf:171-179"
2024-10-31T12:28:27Z INFO Number of language-specific files num=0
2024-10-31T12:28:27Z INFO Detected config files num=9
HIGH: Application load balancer is not set to drop invalid headers.
════════════════════════════════════════
Passing unknown or invalid headers through to the target poses a potential risk of compromise.
By setting drop_invalid_header_fields to true, anything that does not conform to well known, defined headers will be removed by the load balancer.
HIGH: Load balancer is exposed publicly.
════════════════════════════════════════
There are many scenarios in which you would want to expose a load balancer to the wider internet, but this check exists as a warning to prevent accidental exposure of internal assets. You should ensure that this resource should be exposed publicly.
HIGH: Instance does not require IMDS access to require a token.
════════════════════════════════════════
IMDS v2 (Instance Metadata Service) introduced session authentication tokens which improve security when talking to IMDS.
By default aws_instance resource sets IMDS session auth tokens to be optional.
To fully protect IMDS you need to enable session tokens by using metadata_options block and its http_tokens variable set to required.
HIGH: Instance does not require IMDS access to require a token.
════════════════════════════════════════
IMDS v2 (Instance Metadata Service) introduced session authentication tokens which improve security when talking to IMDS.
By default aws_instance resource sets IMDS session auth tokens to be optional.
To fully protect IMDS you need to enable session tokens by using metadata_options block and its http_tokens variable set to required.
HIGH: Root block device is not encrypted.
════════════════════════════════════════
Block devices should be encrypted to ensure sensitive data is held securely at rest.
HIGH: Root block device is not encrypted.
════════════════════════════════════════
Block devices should be encrypted to ensure sensitive data is held securely at rest.
HIGH: Bucket does not have encryption enabled
════════════════════════════════════════
S3 Buckets should be encrypted to protect the data that is stored within them if access is compromised.
HIGH: Bucket does not encrypt data with a customer managed key.
════════════════════════════════════════
Encryption using AWS keys provides protection for your S3 buckets. To increase control of the encryption and manage factors like rotation use customer managed keys.
HIGH: Instance does not require IMDS access to require a token.
════════════════════════════════════════
IMDS v2 (Instance Metadata Service) introduced session authentication tokens which improve security when talking to IMDS.
By default aws_instance resource sets IMDS session auth tokens to be optional.
To fully protect IMDS you need to enable session tokens by using metadata_options block and its http_tokens variable set to required.
HIGH: Root block device is not encrypted.
════════════════════════════════════════
Block devices should be encrypted to ensure sensitive data is held securely at rest.
HIGH: Instance does not require IMDS access to require a token.
════════════════════════════════════════
IMDS v2 (Instance Metadata Service) introduced session authentication tokens which improve security when talking to IMDS.
By default aws_instance resource sets IMDS session auth tokens to be optional.
To fully protect IMDS you need to enable session tokens by using metadata_options block and its http_tokens variable set to required.
HIGH: Root block device is not encrypted.
════════════════════════════════════════
Block devices should be encrypted to ensure sensitive data is held securely at rest.
*****************************
Setting default tflint config...
Running tflint --init...
Installing "terraform" plugin...
Installed "terraform" (source: github.com/terraform-linters/tflint-ruleset-terraform, version:0.9.1)
tflint will check the following folders:
terraform/environments/contract-work-administration
*****************************
Running tflint in terraform/environments/contract-work-administration
Excluding the following checks: terraform_unused_declarations
4issue(s) found:
Warning: Missing version constraint for provider "archive" in `required_providers` (terraform_required_providers)
on terraform/environments/contract-work-administration/backup_lambda.tf line 173:173:data"archive_file""connect_db" {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_required_providers.md
Warning: Missing version constraint for provider "template" in `required_providers` (terraform_required_providers)
on terraform/environments/contract-work-administration/cloudwatch.tf line 1126:1126:data"template_file""dashboard_no_ha" {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_required_providers.md
Warning: Missing version constraint for provider "local" in `required_providers` (terraform_required_providers)
on terraform/environments/contract-work-administration/data.tf line 11:11:data"local_file""cm_custom_metrics" {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_required_providers.md
Warning: Missing version constraint for provider "time" in `required_providers` (terraform_required_providers)
on terraform/environments/contract-work-administration/database.tf line 174:174:resource"time_sleep""wait_db_userdata_scripts" {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_required_providers.mdtflint_exitcode=2
Trivy Scan Failed
Show Output
*****************************
Trivy will check the following folders:
terraform/environments/contract-work-administration
*****************************
Running Trivy in terraform/environments/contract-work-administration
2024-10-31T12:28:20Z INFO [vulndb] Need to update DB
2024-10-31T12:28:20Z INFO [vulndb] Downloading vulnerability DB...2024-10-31T12:28:20Z INFO [vulndb] Downloading artifact...repo="public.ecr.aws/aquasecurity/trivy-db:2"2024-10-31T12:28:23Z INFO [vulndb] Artifact successfully downloaded repo="public.ecr.aws/aquasecurity/trivy-db:2"2024-10-31T12:28:23Z INFO [vuln] Vulnerability scanning is enabled
2024-10-31T12:28:23Z INFO [misconfig] Misconfiguration scanning is enabled
2024-10-31T12:28:23Z INFO [misconfig] Need to update the built-in checks
2024-10-31T12:28:23Z INFO [misconfig] Downloading the built-in checks...160.60 KiB /160.60 KiB [------------------------------------------------------] 100.00%? p/s 100ms2024-10-31T12:28:23Z INFO [secret] Secret scanning is enabled
2024-10-31T12:28:23Z INFO [secret] If your scanning is slow, please try '--scanners vuln' to disable secret scanning
2024-10-31T12:28:23Z INFO [secret] Please see also https://aquasecurity.github.io/trivy/v0.56/docs/scanner/secret#recommendation for faster secret detection2024-10-31T12:28:24Z INFO [terraformscanner] Scanning root module file_path="."2024-10-31T12:28:24Z WARN [terraformparser] Variable values was not found in the environment or variable files. Evaluating may not work correctly.module="root"variables="networking"2024-10-31T12:28:25Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.aws_s3_object.user_public_keys"value="cty.NilVal"2024-10-31T12:28:25Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.data.aws_subnet.local_account"value="cty.NilVal"2024-10-31T12:28:25Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.dynamic.tag"value="cty.NilVal"2024-10-31T12:28:25Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.dynamic.tag"value="cty.NilVal"2024-10-31T12:28:26Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.expiration"value="cty.NilVal"2024-10-31T12:28:26Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.transition"value="cty.NilVal"2024-10-31T12:28:26Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.noncurrent_version_expiration"value="cty.NilVal"2024-10-31T12:28:26Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.noncurrent_version_transition"value="cty.NilVal"2024-10-31T12:28:26Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.principals"value="cty.NilVal"2024-10-31T12:28:26Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.condition"value="cty.NilVal"2024-10-31T12:28:26Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.expiration"value="cty.NilVal"2024-10-31T12:28:26Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.transition"value="cty.NilVal"2024-10-31T12:28:26Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.noncurrent_version_expiration"value="cty.NilVal"2024-10-31T12:28:26Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.noncurrent_version_transition"value="cty.NilVal"2024-10-31T12:28:26Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.principals"value="cty.NilVal"2024-10-31T12:28:26Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.condition"value="cty.NilVal"2024-10-31T12:28:27Z INFO [terraformexecutor] Ignore finding rule="aws-s3-encryption-customer-key"range="github.com/ministryofjustice/modernisation-platform-terraform-bastion-linux?ref=v4.2.0/github.com/ministryofjustice/modernisation-platform-terraform-s3-bucket?ref=568694e50e03630d99cb569eafa06a0b879a1239/main.tf:171-179"2024-10-31T12:28:27Z INFO Number of language-specific files num=02024-10-31T12:28:27Z INFO Detected config files num=9
alb.tf (terraform)
==================
Tests:3 (SUCCESSES:0, FAILURES:2, EXCEPTIONS:1)
Failures:2 (HIGH:2, CRITICAL:0)
HIGH: Application load balancer is not set to drop invalid headers.
════════════════════════════════════════
Passing unknown or invalid headers through to the target poses a potential risk of compromise.
By setting drop_invalid_header_fields to true, anything that does not conform to well known, defined headers will be removed by the load balancer.
See https://avd.aquasec.com/misconfig/avd-aws-0052
────────────────────────────────────────
alb.tf:130-153
────────────────────────────────────────
130 ┌ resource"aws_lb""external" {
131 │ name="${upper(local.application_name_short)}-LoadBalancer"132 │ internal=false133 │ load_balancer_type="application"134 │ security_groups=[aws_security_group.external_lb.id]
135 │ subnets=[data.aws_subnet.public_subnets_a.id, data.aws_subnet.public_subnets_b.id, data.aws_subnet.public_subnets_c.id]
136 │ enable_deletion_protection=local.lb_enable_deletion_protection137 │ idle_timeout=local.external_lb_idle_timeout138 └ enable_http2=false...
────────────────────────────────────────
HIGH: Load balancer is exposed publicly.
════════════════════════════════════════
There are many scenarios in which you would want to expose a load balancer to the wider internet, but this check exists as a warning to prevent accidental exposure of internal assets. You should ensure that this resource should be exposed publicly.
See https://avd.aquasec.com/misconfig/avd-aws-0053
────────────────────────────────────────
alb.tf:130-153
────────────────────────────────────────
130 ┌ resource"aws_lb""external" {
131 │ name="${upper(local.application_name_short)}-LoadBalancer"132 │ internal=false133 │ load_balancer_type="application"134 │ security_groups=[aws_security_group.external_lb.id]
135 │ subnets=[data.aws_subnet.public_subnets_a.id, data.aws_subnet.public_subnets_b.id, data.aws_subnet.public_subnets_c.id]
136 │ enable_deletion_protection=local.lb_enable_deletion_protection137 │ idle_timeout=local.external_lb_idle_timeout138 └ enable_http2=false...
────────────────────────────────────────
app_servers.tf (terraform)
==========================
Tests:5 (SUCCESSES:0, FAILURES:4, EXCEPTIONS:1)
Failures:4 (HIGH:4, CRITICAL:0)
HIGH: Instance does not require IMDS access to require a token.
════════════════════════════════════════
IMDS v2 (Instance Metadata Service) introduced session authentication tokens which improve security when talking to IMDS.
By default <code>aws_instance</code> resource sets IMDS session auth tokens to be optional.
To fully protect IMDS you need to enable session tokens by using <code>metadata_options</code> block and its <code>http_tokens</code> variable set to <code>required</code>.
See https://avd.aquasec.com/misconfig/avd-aws-0028
────────────────────────────────────────
app_servers.tf:193-195
via app_servers.tf:182-214 (aws_instance.app1)
────────────────────────────────────────
182resource"aws_instance""app1" {
...193 ┌ metadata_options {
194 │ http_tokens="optional"195 └ }
...214 }
────────────────────────────────────────
HIGH: Instance does not require IMDS access to require a token.
════════════════════════════════════════
IMDS v2 (Instance Metadata Service) introduced session authentication tokens which improve security when talking to IMDS.
By default <code>aws_instance</code> resource sets IMDS session auth tokens to be optional.
To fully protect IMDS you need to enable session tokens by using <code>metadata_options</code> block and its <code>http_tokens</code> variable set to <code>required</code>.
See https://avd.aquasec.com/misconfig/avd-aws-0028
────────────────────────────────────────
app_servers.tf:228-230
via app_servers.tf:216-249 (aws_instance.app2[0])
────────────────────────────────────────
216resource"aws_instance""app2" {
...228 ┌ metadata_options {
229 │ http_tokens="optional"230 └ }
...249 }
────────────────────────────────────────
HIGH: Root block device is not encrypted.
════════════════════════════════════════
Block devices should be encrypted to ensure sensitive data is held securely at rest.
See https://avd.aquasec.com/misconfig/avd-aws-0131
────────────────────────────────────────
app_servers.tf:197-203
via app_servers.tf:182-214 (aws_instance.app1)
────────────────────────────────────────
182resource"aws_instance""app1" {
...197 ┌ root_block_device {
198 │ tags=merge(
199 │ { "instance-scheduling" = "skip-scheduling" },
200 │ local.tags,
201 │ { "Name" = "${local.application_name_short}-app1-root" }
202 │ )
203 └ }
...
────────────────────────────────────────
HIGH: Root block device is not encrypted.
════════════════════════════════════════
Block devices should be encrypted to ensure sensitive data is held securely at rest.
See https://avd.aquasec.com/misconfig/avd-aws-0131
────────────────────────────────────────
app_servers.tf:232-238
via app_servers.tf:216-249 (aws_instance.app2[0])
────────────────────────────────────────
216resource"aws_instance""app2" {
...232 ┌ root_block_device {
233 │ tags=merge(
234 │ { "instance-scheduling" = "skip-scheduling" },
235 │ local.tags,
236 │ { "Name" = "${local.application_name_short}-app2-root" }
237 │ )
238 └ }
...
────────────────────────────────────────
backup_lambda.tf (terraform)
============================
Tests:3 (SUCCESSES:0, FAILURES:2, EXCEPTIONS:1)
Failures:2 (HIGH:2, CRITICAL:0)
HIGH: Bucket does not have encryption enabled
════════════════════════════════════════
S3 Buckets should be encrypted to protect the data that is stored within them if access is compromised.
See https://avd.aquasec.com/misconfig/avd-aws-0088
────────────────────────────────────────
backup_lambda.tf:101-107
────────────────────────────────────────
101 ┌ resource"aws_s3_bucket""scripts" {
102 │ bucket="${local.application_name_short}-${local.environment}-scripts"103 │ tags=merge(
104 │ local.tags,
105 │ { Name ="${local.application_name_short}-${local.environment}-scripts" }
106 │ )
107 └ }
────────────────────────────────────────
HIGH: Bucket does not encrypt data with a customer managed key.
════════════════════════════════════════
Encryption using AWS keys provides protection for your S3 buckets. To increase control of the encryption and manage factors like rotation use customer managed keys.
See https://avd.aquasec.com/misconfig/avd-aws-0132
────────────────────────────────────────
backup_lambda.tf:101-107
────────────────────────────────────────
101 ┌ resource"aws_s3_bucket""scripts" {
102 │ bucket="${local.application_name_short}-${local.environment}-scripts"103 │ tags=merge(
104 │ local.tags,
105 │ { Name ="${local.application_name_short}-${local.environment}-scripts" }
106 │ )
107 └ }
────────────────────────────────────────
concurrent_manager.tf (terraform)
=================================
Tests:3 (SUCCESSES:0, FAILURES:2, EXCEPTIONS:1)
Failures:2 (HIGH:2, CRITICAL:0)
HIGH: Instance does not require IMDS access to require a token.
════════════════════════════════════════
IMDS v2 (Instance Metadata Service) introduced session authentication tokens which improve security when talking to IMDS.
By default <code>aws_instance</code> resource sets IMDS session auth tokens to be optional.
To fully protect IMDS you need to enable session tokens by using <code>metadata_options</code> block and its <code>http_tokens</code> variable set to <code>required</code>.
See https://avd.aquasec.com/misconfig/avd-aws-0028
────────────────────────────────────────
concurrent_manager.tf:173-175
via concurrent_manager.tf:162-194 (aws_instance.concurrent_manager)
────────────────────────────────────────
162resource"aws_instance""concurrent_manager" {
...173 ┌ metadata_options {
174 │ http_tokens="optional"175 └ }
...194 }
────────────────────────────────────────
HIGH: Root block device is not encrypted.
════════════════════════════════════════
Block devices should be encrypted to ensure sensitive data is held securely at rest.
See https://avd.aquasec.com/misconfig/avd-aws-0131
────────────────────────────────────────
concurrent_manager.tf:177-183
via concurrent_manager.tf:162-194 (aws_instance.concurrent_manager)
────────────────────────────────────────
162resource"aws_instance""concurrent_manager" {
...177 ┌ root_block_device {
178 │ tags=merge(
179 │ { "instance-scheduling" = "skip-scheduling" },
180 │ local.tags,
181 │ { "Name" = "${local.application_name_short}-concurrent-manager-root" }
182 │ )
183 └ }
...
────────────────────────────────────────
database.tf (terraform)
=======================
Tests:3 (SUCCESSES:0, FAILURES:2, EXCEPTIONS:1)
Failures:2 (HIGH:2, CRITICAL:0)
HIGH: Instance does not require IMDS access to require a token.
════════════════════════════════════════
IMDS v2 (Instance Metadata Service) introduced session authentication tokens which improve security when talking to IMDS.
By default <code>aws_instance</code> resource sets IMDS session auth tokens to be optional.
To fully protect IMDS you need to enable session tokens by using <code>metadata_options</code> block and its <code>http_tokens</code> variable set to <code>required</code>.
See https://avd.aquasec.com/misconfig/avd-aws-0028
────────────────────────────────────────
database.tf:194-196
via database.tf:183-212 (aws_instance.database)
────────────────────────────────────────
183resource"aws_instance""database" {
...194 ┌ metadata_options {
195 │ http_tokens="optional"196 └ }
...212 }
────────────────────────────────────────
HIGH: Root block device is not encrypted.
════════════════════════════════════════
Block devices should be encrypted to ensure sensitive data is held securely at rest.
See https://avd.aquasec.com/misconfig/avd-aws-0131
────────────────────────────────────────
database.tf:198-204
via database.tf:183-212 (aws_instance.database)
────────────────────────────────────────
183resource"aws_instance""database" {
...198 ┌ root_block_device {
199 │ tags=merge(
200 │ { "instance-scheduling" = "skip-scheduling" },
201 │ local.tags,
202 │ { "Name" = "${local.application_name_short}-database-root" }
203 │ )
204 └ }
...
────────────────────────────────────────
trivy_exitcode=1
Trivy will check the following folders:
terraform/environments/contract-work-administration
Running Trivy in terraform/environments/contract-work-administration
2024-10-31T12:50:38Z INFO [vulndb] Need to update DB
2024-10-31T12:50:38Z INFO [vulndb] Downloading vulnerability DB...
2024-10-31T12:50:38Z INFO [vulndb] Downloading artifact... repo="public.ecr.aws/aquasecurity/trivy-db:2"
2024-10-31T12:50:41Z INFO [vulndb] Artifact successfully downloaded repo="public.ecr.aws/aquasecurity/trivy-db:2"
2024-10-31T12:50:41Z INFO [vuln] Vulnerability scanning is enabled
2024-10-31T12:50:41Z INFO [misconfig] Misconfiguration scanning is enabled
2024-10-31T12:50:41Z INFO [misconfig] Need to update the built-in checks
2024-10-31T12:50:41Z INFO [misconfig] Downloading the built-in checks...
2024-10-31T12:50:41Z ERROR [misconfig] Falling back to embedded checks err="failed to download built-in policies: download error: OCI repository error: 1 error occurred:\n\t* GET https://ghcr.io/v2/aquasecurity/trivy-checks/manifests/1: TOOMANYREQUESTS: retry-after: 806.57µs, allowed: 44000/minute\n\n"
2024-10-31T12:50:41Z INFO [secret] Secret scanning is enabled
2024-10-31T12:50:41Z INFO [secret] If your scanning is slow, please try '--scanners vuln' to disable secret scanning
2024-10-31T12:50:41Z INFO [secret] Please see also https://aquasecurity.github.io/trivy/v0.56/docs/scanner/secret#recommendation for faster secret detection
2024-10-31T12:50:42Z INFO [terraform scanner] Scanning root module file_path="."
2024-10-31T12:50:42Z WARN [terraform parser] Variable values was not found in the environment or variable files. Evaluating may not work correctly. module="root" variables="networking"
2024-10-31T12:50:43Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.aws_s3_object.user_public_keys" value="cty.NilVal"
2024-10-31T12:50:43Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.data.aws_subnet.local_account" value="cty.NilVal"
2024-10-31T12:50:43Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.dynamic.tag" value="cty.NilVal"
2024-10-31T12:50:43Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.dynamic.tag" value="cty.NilVal"
2024-10-31T12:50:44Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.expiration" value="cty.NilVal"
2024-10-31T12:50:44Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.transition" value="cty.NilVal"
2024-10-31T12:50:44Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.noncurrent_version_expiration" value="cty.NilVal"
2024-10-31T12:50:44Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.noncurrent_version_transition" value="cty.NilVal"
2024-10-31T12:50:44Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.principals" value="cty.NilVal"
2024-10-31T12:50:44Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.condition" value="cty.NilVal"
2024-10-31T12:50:44Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.expiration" value="cty.NilVal"
2024-10-31T12:50:44Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.transition" value="cty.NilVal"
2024-10-31T12:50:44Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.noncurrent_version_expiration" value="cty.NilVal"
2024-10-31T12:50:44Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.noncurrent_version_transition" value="cty.NilVal"
2024-10-31T12:50:44Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.principals" value="cty.NilVal"
2024-10-31T12:50:44Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.condition" value="cty.NilVal"
2024-10-31T12:50:45Z INFO [terraform executor] Ignore finding rule="aws-s3-encryption-customer-key" range="github.com/ministryofjustice/modernisation-platform-terraform-bastion-linux?ref=v4.2.0/github.com/ministryofjustice/modernisation-platform-terraform-s3-bucket?ref=568694e50e03630d99cb569eafa06a0b879a1239/main.tf:171-179"
2024-10-31T12:50:45Z INFO Number of language-specific files num=0
2024-10-31T12:50:45Z INFO Detected config files num=9
HIGH: Application load balancer is not set to drop invalid headers.
════════════════════════════════════════
Passing unknown or invalid headers through to the target poses a potential risk of compromise.
By setting drop_invalid_header_fields to true, anything that does not conform to well known, defined headers will be removed by the load balancer.
HIGH: Load balancer is exposed publicly.
════════════════════════════════════════
There are many scenarios in which you would want to expose a load balancer to the wider internet, but this check exists as a warning to prevent accidental exposure of internal assets. You should ensure that this resource should be exposed publicly.
HIGH: Instance does not require IMDS access to require a token.
════════════════════════════════════════
IMDS v2 (Instance Metadata Service) introduced session authentication tokens which improve security when talking to IMDS.
By default aws_instance resource sets IMDS session auth tokens to be optional.
To fully protect IMDS you need to enable session tokens by using metadata_options block and its http_tokens variable set to required.
See https://avd.aquasec.com/misconfig/avd-aws-0028
────────────────────────────────────────
app_servers.tf:194
via app_servers.tf:193-195 (metadata_options)
via app_servers.tf:182-214 (aws_instance.app1)
────────────────────────────────────────
182 resource "aws_instance" "app1" {
...
194 [ http_tokens = "optional"
...
214 }
────────────────────────────────────────
HIGH: Instance does not require IMDS access to require a token.
════════════════════════════════════════
IMDS v2 (Instance Metadata Service) introduced session authentication tokens which improve security when talking to IMDS.
By default aws_instance resource sets IMDS session auth tokens to be optional.
To fully protect IMDS you need to enable session tokens by using metadata_options block and its http_tokens variable set to required.
See https://avd.aquasec.com/misconfig/avd-aws-0028
────────────────────────────────────────
app_servers.tf:229
via app_servers.tf:228-230 (metadata_options)
via app_servers.tf:216-249 (aws_instance.app2[0])
────────────────────────────────────────
216 resource "aws_instance" "app2" {
...
229 [ http_tokens = "optional"
...
249 }
────────────────────────────────────────
HIGH: Root block device is not encrypted.
════════════════════════════════════════
Block devices should be encrypted to ensure sensitive data is held securely at rest.
HIGH: Root block device is not encrypted.
════════════════════════════════════════
Block devices should be encrypted to ensure sensitive data is held securely at rest.
HIGH: Bucket does not have encryption enabled
════════════════════════════════════════
S3 Buckets should be encrypted to protect the data that is stored within them if access is compromised.
HIGH: Bucket does not encrypt data with a customer managed key.
════════════════════════════════════════
Encryption using AWS keys provides protection for your S3 buckets. To increase control of the encryption and manage factors like rotation use customer managed keys.
HIGH: Instance does not require IMDS access to require a token.
════════════════════════════════════════
IMDS v2 (Instance Metadata Service) introduced session authentication tokens which improve security when talking to IMDS.
By default aws_instance resource sets IMDS session auth tokens to be optional.
To fully protect IMDS you need to enable session tokens by using metadata_options block and its http_tokens variable set to required.
See https://avd.aquasec.com/misconfig/avd-aws-0028
────────────────────────────────────────
concurrent_manager.tf:172
via concurrent_manager.tf:171-173 (metadata_options)
via concurrent_manager.tf:160-192 (aws_instance.concurrent_manager)
────────────────────────────────────────
160 resource "aws_instance" "concurrent_manager" {
...
172 [ http_tokens = "optional"
...
192 }
────────────────────────────────────────
HIGH: Root block device is not encrypted.
════════════════════════════════════════
Block devices should be encrypted to ensure sensitive data is held securely at rest.
HIGH: Instance does not require IMDS access to require a token.
════════════════════════════════════════
IMDS v2 (Instance Metadata Service) introduced session authentication tokens which improve security when talking to IMDS.
By default aws_instance resource sets IMDS session auth tokens to be optional.
To fully protect IMDS you need to enable session tokens by using metadata_options block and its http_tokens variable set to required.
See https://avd.aquasec.com/misconfig/avd-aws-0028
────────────────────────────────────────
database.tf:195
via database.tf:194-196 (metadata_options)
via database.tf:183-212 (aws_instance.database)
────────────────────────────────────────
183 resource "aws_instance" "database" {
...
195 [ http_tokens = "optional"
...
212 }
────────────────────────────────────────
HIGH: Root block device is not encrypted.
════════════════════════════════════════
Block devices should be encrypted to ensure sensitive data is held securely at rest.
*****************************
Setting default tflint config...
Running tflint --init...
Installing "terraform" plugin...
Installed "terraform" (source: github.com/terraform-linters/tflint-ruleset-terraform, version:0.9.1)
tflint will check the following folders:
terraform/environments/contract-work-administration
*****************************
Running tflint in terraform/environments/contract-work-administration
Excluding the following checks: terraform_unused_declarations
4issue(s) found:
Warning: Missing version constraint for provider "archive" in `required_providers` (terraform_required_providers)
on terraform/environments/contract-work-administration/backup_lambda.tf line 173:173:data"archive_file""connect_db" {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_required_providers.md
Warning: Missing version constraint for provider "template" in `required_providers` (terraform_required_providers)
on terraform/environments/contract-work-administration/cloudwatch.tf line 1126:1126:data"template_file""dashboard_no_ha" {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_required_providers.md
Warning: Missing version constraint for provider "local" in `required_providers` (terraform_required_providers)
on terraform/environments/contract-work-administration/data.tf line 11:11:data"local_file""cm_custom_metrics" {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_required_providers.md
Warning: Missing version constraint for provider "time" in `required_providers` (terraform_required_providers)
on terraform/environments/contract-work-administration/database.tf line 174:174:resource"time_sleep""wait_db_userdata_scripts" {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_required_providers.mdtflint_exitcode=2
Trivy Scan Failed
Show Output
*****************************
Trivy will check the following folders:
terraform/environments/contract-work-administration
*****************************
Running Trivy in terraform/environments/contract-work-administration
2024-10-31T12:50:38Z INFO [vulndb] Need to update DB
2024-10-31T12:50:38Z INFO [vulndb] Downloading vulnerability DB...2024-10-31T12:50:38Z INFO [vulndb] Downloading artifact...repo="public.ecr.aws/aquasecurity/trivy-db:2"2024-10-31T12:50:41Z INFO [vulndb] Artifact successfully downloaded repo="public.ecr.aws/aquasecurity/trivy-db:2"2024-10-31T12:50:41Z INFO [vuln] Vulnerability scanning is enabled
2024-10-31T12:50:41Z INFO [misconfig] Misconfiguration scanning is enabled
2024-10-31T12:50:41Z INFO [misconfig] Need to update the built-in checks
2024-10-31T12:50:41Z INFO [misconfig] Downloading the built-in checks...2024-10-31T12:50:41Z ERROR [misconfig] Falling back to embedded checks err="failed to download built-in policies: download error: OCI repository error: 1 error occurred:\n\t* GET https://ghcr.io/v2/aquasecurity/trivy-checks/manifests/1: TOOMANYREQUESTS: retry-after: 806.57µs, allowed: 44000/minute\n\n"2024-10-31T12:50:41Z INFO [secret] Secret scanning is enabled
2024-10-31T12:50:41Z INFO [secret] If your scanning is slow, please try '--scanners vuln' to disable secret scanning
2024-10-31T12:50:41Z INFO [secret] Please see also https://aquasecurity.github.io/trivy/v0.56/docs/scanner/secret#recommendation for faster secret detection2024-10-31T12:50:42Z INFO [terraformscanner] Scanning root module file_path="."2024-10-31T12:50:42Z WARN [terraformparser] Variable values was not found in the environment or variable files. Evaluating may not work correctly.module="root"variables="networking"2024-10-31T12:50:43Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.aws_s3_object.user_public_keys"value="cty.NilVal"2024-10-31T12:50:43Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.data.aws_subnet.local_account"value="cty.NilVal"2024-10-31T12:50:43Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.dynamic.tag"value="cty.NilVal"2024-10-31T12:50:43Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.dynamic.tag"value="cty.NilVal"2024-10-31T12:50:44Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.expiration"value="cty.NilVal"2024-10-31T12:50:44Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.transition"value="cty.NilVal"2024-10-31T12:50:44Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.noncurrent_version_expiration"value="cty.NilVal"2024-10-31T12:50:44Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.noncurrent_version_transition"value="cty.NilVal"2024-10-31T12:50:44Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.principals"value="cty.NilVal"2024-10-31T12:50:44Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.condition"value="cty.NilVal"2024-10-31T12:50:44Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.expiration"value="cty.NilVal"2024-10-31T12:50:44Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.transition"value="cty.NilVal"2024-10-31T12:50:44Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.noncurrent_version_expiration"value="cty.NilVal"2024-10-31T12:50:44Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.noncurrent_version_transition"value="cty.NilVal"2024-10-31T12:50:44Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.principals"value="cty.NilVal"2024-10-31T12:50:44Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.condition"value="cty.NilVal"2024-10-31T12:50:45Z INFO [terraformexecutor] Ignore finding rule="aws-s3-encryption-customer-key"range="github.com/ministryofjustice/modernisation-platform-terraform-bastion-linux?ref=v4.2.0/github.com/ministryofjustice/modernisation-platform-terraform-s3-bucket?ref=568694e50e03630d99cb569eafa06a0b879a1239/main.tf:171-179"2024-10-31T12:50:45Z INFO Number of language-specific files num=02024-10-31T12:50:45Z INFO Detected config files num=9
alb.tf (terraform)
==================
Tests:3 (SUCCESSES:0, FAILURES:2, EXCEPTIONS:1)
Failures:2 (HIGH:2, CRITICAL:0)
HIGH: Application load balancer is not set to drop invalid headers.
════════════════════════════════════════
Passing unknown or invalid headers through to the target poses a potential risk of compromise.
By setting drop_invalid_header_fields to true, anything that does not conform to well known, defined headers will be removed by the load balancer.
See https://avd.aquasec.com/misconfig/avd-aws-0052
────────────────────────────────────────
alb.tf:130-153
────────────────────────────────────────
130 ┌ resource"aws_lb""external" {
131 │ name="${upper(local.application_name_short)}-LoadBalancer"132 │ internal=false133 │ load_balancer_type="application"134 │ security_groups=[aws_security_group.external_lb.id]
135 │ subnets=[data.aws_subnet.public_subnets_a.id, data.aws_subnet.public_subnets_b.id, data.aws_subnet.public_subnets_c.id]
136 │ enable_deletion_protection=local.lb_enable_deletion_protection137 │ idle_timeout=local.external_lb_idle_timeout138 └ enable_http2=false...
────────────────────────────────────────
HIGH: Load balancer is exposed publicly.
════════════════════════════════════════
There are many scenarios in which you would want to expose a load balancer to the wider internet, but this check exists as a warning to prevent accidental exposure of internal assets. You should ensure that this resource should be exposed publicly.
See https://avd.aquasec.com/misconfig/avd-aws-0053
────────────────────────────────────────
alb.tf:132
via alb.tf:130-153 (aws_lb.external)
────────────────────────────────────────
130resource"aws_lb""external" {
...132 [ internal = false...153 }
────────────────────────────────────────
app_servers.tf (terraform)
==========================Tests:5 (SUCCESSES:0, FAILURES:4, EXCEPTIONS:1)
Failures:4 (HIGH:4, CRITICAL:0)
HIGH:InstancedoesnotrequireIMDSaccesstorequireatoken.
════════════════════════════════════════
IMDSv2 (Instance Metadata Service) introducedsessionauthenticationtokenswhichimprovesecuritywhentalkingtoIMDS.Bydefault<code>aws_instance</code>resourcesetsIMDSsessionauthtokenstobeoptional.TofullyprotectIMDSyouneedtoenablesessiontokensbyusing<code>metadata_options</code>blockandits<code>http_tokens</code>variablesetto<code>required</code>.Seehttps://avd.aquasec.com/misconfig/avd-aws-0028
────────────────────────────────────────
app_servers.tf:194viaapp_servers.tf:193-195 (metadata_options)
viaapp_servers.tf:182-214 (aws_instance.app1)
────────────────────────────────────────
182resource"aws_instance""app1" {
...194 [ http_tokens ="optional"...214 }
────────────────────────────────────────
HIGH:InstancedoesnotrequireIMDSaccesstorequireatoken.
════════════════════════════════════════
IMDSv2 (Instance Metadata Service) introducedsessionauthenticationtokenswhichimprovesecuritywhentalkingtoIMDS.Bydefault<code>aws_instance</code>resourcesetsIMDSsessionauthtokenstobeoptional.TofullyprotectIMDSyouneedtoenablesessiontokensbyusing<code>metadata_options</code>blockandits<code>http_tokens</code>variablesetto<code>required</code>.Seehttps://avd.aquasec.com/misconfig/avd-aws-0028
────────────────────────────────────────
app_servers.tf:229viaapp_servers.tf:228-230 (metadata_options)
viaapp_servers.tf:216-249 (aws_instance.app2[0])
────────────────────────────────────────
216resource"aws_instance""app2" {
...229 [ http_tokens ="optional"...249 }
────────────────────────────────────────
HIGH:Rootblockdeviceisnotencrypted.
════════════════════════════════════════
Blockdevicesshouldbeencryptedtoensuresensitivedataisheldsecurelyatrest.Seehttps://avd.aquasec.com/misconfig/avd-aws-0131
────────────────────────────────────────
app_servers.tf:182-214
────────────────────────────────────────
182 ┌ resource"aws_instance""app1" {
183 │ ami = local.application_data.accounts[local.environment].app_ami_id
184 │ availability_zone ="eu-west-2a"185 │ instance_type = local.application_data.accounts[local.environment].app_instance_type
186 │ monitoring =true187 │ vpc_security_group_ids = [aws_security_group.app.id]
188 │ subnet_id = data.aws_subnet.private_subnets_a.id
189 │ iam_instance_profile = aws_iam_instance_profile.cwa.id
190 └ key_name = aws_key_pair.cwa.key_name
...
────────────────────────────────────────
HIGH: Root block device is not encrypted.
════════════════════════════════════════
Block devices should be encrypted to ensure sensitive data is held securely at rest.
See https://avd.aquasec.com/misconfig/avd-aws-0131
────────────────────────────────────────
app_servers.tf:216-249
────────────────────────────────────────
216 ┌ resource "aws_instance""app2" {
217 │ count =contains(["development2", "testing"], local.environment) ?0:1218 │ ami = local.application_data.accounts[local.environment].app_ami_id
219 │ availability_zone ="eu-west-2a"220 │ instance_type = local.application_data.accounts[local.environment].app_instance_type
221 │ monitoring =true222 │ vpc_security_group_ids = [aws_security_group.app.id]
223 │ subnet_id = data.aws_subnet.private_subnets_a.id
224 └ iam_instance_profile = aws_iam_instance_profile.cwa.id
...
────────────────────────────────────────
backup_lambda.tf (terraform)
============================
Tests:3 (SUCCESSES:0, FAILURES:2, EXCEPTIONS:1)
Failures:2 (HIGH:2, CRITICAL:0)
HIGH: Bucket does not have encryption enabled
════════════════════════════════════════
S3 Buckets should be encrypted to protect the data that is stored within them ifaccessiscompromised.
See https://avd.aquasec.com/misconfig/avd-aws-0088
────────────────────────────────────────
backup_lambda.tf:101-107
────────────────────────────────────────
101 ┌ resource "aws_s3_bucket""scripts" {
102 │ bucket ="${local.application_name_short}-${local.environment}-scripts"103 │ tags =merge(
104 │ local.tags,
105 │ { Name ="${local.application_name_short}-${local.environment}-scripts" }
106 │ )
107 └ }
────────────────────────────────────────
HIGH: Bucket does not encrypt data with a customer managed key.
════════════════════════════════════════
Encryption using AWS keys provides protection foryourS3buckets.Toincreasecontroloftheencryptionandmanagefactorslikerotationusecustomermanagedkeys.
See https://avd.aquasec.com/misconfig/avd-aws-0132
────────────────────────────────────────
backup_lambda.tf:101-107
────────────────────────────────────────
101 ┌ resource "aws_s3_bucket""scripts" {
102 │ bucket ="${local.application_name_short}-${local.environment}-scripts"103 │ tags =merge(
104 │ local.tags,
105 │ { Name ="${local.application_name_short}-${local.environment}-scripts" }
106 │ )
107 └ }
────────────────────────────────────────
concurrent_manager.tf (terraform)
=================================
Tests:3 (SUCCESSES:0, FAILURES:2, EXCEPTIONS:1)
Failures:2 (HIGH:2, CRITICAL:0)
HIGH: Instance does not require IMDS access to require a token.
════════════════════════════════════════
IMDS v2 (Instance Metadata Service) introduced session authentication tokens which improve security when talking to IMDS.
By default <code>aws_instance</code> resource sets IMDS session auth tokens to be optional.
To fully protect IMDS you need to enable session tokens by using <code>metadata_options</code> block and its <code>http_tokens</code> variable set to <code>required</code>.
See https://avd.aquasec.com/misconfig/avd-aws-0028
────────────────────────────────────────
concurrent_manager.tf:172
via concurrent_manager.tf:171-173 (metadata_options)
via concurrent_manager.tf:160-192 (aws_instance.concurrent_manager)
────────────────────────────────────────
160 resource "aws_instance""concurrent_manager" {
...172 [ http_tokens ="optional"...192 }
────────────────────────────────────────
HIGH: Root block device is not encrypted.
════════════════════════════════════════
Block devices should be encrypted to ensure sensitive data is held securely at rest.
See https://avd.aquasec.com/misconfig/avd-aws-0131
────────────────────────────────────────
concurrent_manager.tf:160-192
────────────────────────────────────────
160 ┌ resource "aws_instance""concurrent_manager" {
161 │ ami = local.application_data.accounts[local.environment].cm_ami_id
162 │ availability_zone ="eu-west-2a"163 │ instance_type = local.application_data.accounts[local.environment].cm_instance_type
164 │ monitoring =true165 │ vpc_security_group_ids = [aws_security_group.concurrent_manager.id]
166 │ subnet_id = data.aws_subnet.private_subnets_a.id
167 │ iam_instance_profile = aws_iam_instance_profile.cwa.id
168 └ key_name = aws_key_pair.cwa.key_name
...
────────────────────────────────────────
database.tf (terraform)
=======================
Tests:3 (SUCCESSES:0, FAILURES:2, EXCEPTIONS:1)
Failures:2 (HIGH:2, CRITICAL:0)
HIGH: Instance does not require IMDS access to require a token.
════════════════════════════════════════
IMDS v2 (Instance Metadata Service) introduced session authentication tokens which improve security when talking to IMDS.
By default <code>aws_instance</code> resource sets IMDS session auth tokens to be optional.
To fully protect IMDS you need to enable session tokens by using <code>metadata_options</code> block and its <code>http_tokens</code> variable set to <code>required</code>.
See https://avd.aquasec.com/misconfig/avd-aws-0028
────────────────────────────────────────
database.tf:195
via database.tf:194-196 (metadata_options)
via database.tf:183-212 (aws_instance.database)
────────────────────────────────────────
183 resource "aws_instance""database" {
...195 [ http_tokens ="optional"...212 }
────────────────────────────────────────
HIGH: Root block device is not encrypted.
════════════════════════════════════════
Block devices should be encrypted to ensure sensitive data is held securely at rest.
See https://avd.aquasec.com/misconfig/avd-aws-0131
────────────────────────────────────────
database.tf:183-212
────────────────────────────────────────
183 ┌ resource "aws_instance""database" {
184 │ ami = local.application_data.accounts[local.environment].db_ami_id
185 │ availability_zone ="eu-west-2a"186 │ instance_type = local.application_data.accounts[local.environment].db_instance_type
187 │ monitoring =true188 │ vpc_security_group_ids = [aws_security_group.database.id]
189 │ subnet_id = data.aws_subnet.data_subnets_a.id
190 │ iam_instance_profile = aws_iam_instance_profile.cwa.id
191 └ key_name = aws_key_pair.cwa.key_name
...
────────────────────────────────────────
trivy_exitcode=1
Trivy will check the following folders:
terraform/environments/contract-work-administration
Running Trivy in terraform/environments/contract-work-administration
2024-11-01T09:33:00Z INFO [vulndb] Need to update DB
2024-11-01T09:33:00Z INFO [vulndb] Downloading vulnerability DB...
2024-11-01T09:33:00Z INFO [vulndb] Downloading artifact... repo="public.ecr.aws/aquasecurity/trivy-db:2"
2024-11-01T09:33:02Z INFO [vulndb] Artifact successfully downloaded repo="public.ecr.aws/aquasecurity/trivy-db:2"
2024-11-01T09:33:02Z INFO [vuln] Vulnerability scanning is enabled
2024-11-01T09:33:02Z INFO [misconfig] Misconfiguration scanning is enabled
2024-11-01T09:33:02Z INFO [misconfig] Need to update the built-in checks
2024-11-01T09:33:02Z INFO [misconfig] Downloading the built-in checks...
2024-11-01T09:33:02Z ERROR [misconfig] Falling back to embedded checks err="failed to download built-in policies: download error: oci download error: failed to fetch the layer: GET https://ghcr.io/v2/aquasecurity/trivy-checks/blobs/sha256:c2b4fe1cd51083ede5606a38fb24e7fafb06fd2632c9cf6d9c63f5a80a6c67dc: TOOMANYREQUESTS: retry-after: 226.974µs, allowed: 44000/minute"
2024-11-01T09:33:02Z INFO [secret] Secret scanning is enabled
2024-11-01T09:33:02Z INFO [secret] If your scanning is slow, please try '--scanners vuln' to disable secret scanning
2024-11-01T09:33:02Z INFO [secret] Please see also https://aquasecurity.github.io/trivy/v0.56/docs/scanner/secret#recommendation for faster secret detection
2024-11-01T09:33:04Z INFO [terraform scanner] Scanning root module file_path="."
2024-11-01T09:33:04Z WARN [terraform parser] Variable values was not found in the environment or variable files. Evaluating may not work correctly. module="root" variables="networking"
2024-11-01T09:33:05Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.aws_s3_object.user_public_keys" value="cty.NilVal"
2024-11-01T09:33:05Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.data.aws_subnet.local_account" value="cty.NilVal"
2024-11-01T09:33:05Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.dynamic.tag" value="cty.NilVal"
2024-11-01T09:33:05Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.dynamic.tag" value="cty.NilVal"
2024-11-01T09:33:05Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.expiration" value="cty.NilVal"
2024-11-01T09:33:05Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.transition" value="cty.NilVal"
2024-11-01T09:33:05Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.noncurrent_version_expiration" value="cty.NilVal"
2024-11-01T09:33:05Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.noncurrent_version_transition" value="cty.NilVal"
2024-11-01T09:33:05Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.principals" value="cty.NilVal"
2024-11-01T09:33:05Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.condition" value="cty.NilVal"
2024-11-01T09:33:05Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.expiration" value="cty.NilVal"
2024-11-01T09:33:05Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.transition" value="cty.NilVal"
2024-11-01T09:33:05Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.noncurrent_version_expiration" value="cty.NilVal"
2024-11-01T09:33:05Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.noncurrent_version_transition" value="cty.NilVal"
2024-11-01T09:33:05Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.principals" value="cty.NilVal"
2024-11-01T09:33:05Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.condition" value="cty.NilVal"
2024-11-01T09:33:06Z INFO [terraform executor] Ignore finding rule="aws-s3-encryption-customer-key" range="github.com/ministryofjustice/modernisation-platform-terraform-bastion-linux?ref=v4.2.0/github.com/ministryofjustice/modernisation-platform-terraform-s3-bucket?ref=568694e50e03630d99cb569eafa06a0b879a1239/main.tf:171-179"
2024-11-01T09:33:06Z INFO Number of language-specific files num=0
2024-11-01T09:33:06Z INFO Detected config files num=9
HIGH: Application load balancer is not set to drop invalid headers.
════════════════════════════════════════
Passing unknown or invalid headers through to the target poses a potential risk of compromise.
By setting drop_invalid_header_fields to true, anything that does not conform to well known, defined headers will be removed by the load balancer.
HIGH: Load balancer is exposed publicly.
════════════════════════════════════════
There are many scenarios in which you would want to expose a load balancer to the wider internet, but this check exists as a warning to prevent accidental exposure of internal assets. You should ensure that this resource should be exposed publicly.
HIGH: Instance does not require IMDS access to require a token.
════════════════════════════════════════
IMDS v2 (Instance Metadata Service) introduced session authentication tokens which improve security when talking to IMDS.
By default aws_instance resource sets IMDS session auth tokens to be optional.
To fully protect IMDS you need to enable session tokens by using metadata_options block and its http_tokens variable set to required.
See https://avd.aquasec.com/misconfig/avd-aws-0028
────────────────────────────────────────
app_servers.tf:194
via app_servers.tf:193-195 (metadata_options)
via app_servers.tf:182-214 (aws_instance.app1)
────────────────────────────────────────
182 resource "aws_instance" "app1" {
...
194 [ http_tokens = "optional"
...
214 }
────────────────────────────────────────
HIGH: Instance does not require IMDS access to require a token.
════════════════════════════════════════
IMDS v2 (Instance Metadata Service) introduced session authentication tokens which improve security when talking to IMDS.
By default aws_instance resource sets IMDS session auth tokens to be optional.
To fully protect IMDS you need to enable session tokens by using metadata_options block and its http_tokens variable set to required.
See https://avd.aquasec.com/misconfig/avd-aws-0028
────────────────────────────────────────
app_servers.tf:229
via app_servers.tf:228-230 (metadata_options)
via app_servers.tf:216-249 (aws_instance.app2[0])
────────────────────────────────────────
216 resource "aws_instance" "app2" {
...
229 [ http_tokens = "optional"
...
249 }
────────────────────────────────────────
HIGH: Root block device is not encrypted.
════════════════════════════════════════
Block devices should be encrypted to ensure sensitive data is held securely at rest.
HIGH: Root block device is not encrypted.
════════════════════════════════════════
Block devices should be encrypted to ensure sensitive data is held securely at rest.
HIGH: Bucket does not have encryption enabled
════════════════════════════════════════
S3 Buckets should be encrypted to protect the data that is stored within them if access is compromised.
HIGH: Bucket does not encrypt data with a customer managed key.
════════════════════════════════════════
Encryption using AWS keys provides protection for your S3 buckets. To increase control of the encryption and manage factors like rotation use customer managed keys.
HIGH: Instance does not require IMDS access to require a token.
════════════════════════════════════════
IMDS v2 (Instance Metadata Service) introduced session authentication tokens which improve security when talking to IMDS.
By default aws_instance resource sets IMDS session auth tokens to be optional.
To fully protect IMDS you need to enable session tokens by using metadata_options block and its http_tokens variable set to required.
See https://avd.aquasec.com/misconfig/avd-aws-0028
────────────────────────────────────────
concurrent_manager.tf:172
via concurrent_manager.tf:171-173 (metadata_options)
via concurrent_manager.tf:160-192 (aws_instance.concurrent_manager)
────────────────────────────────────────
160 resource "aws_instance" "concurrent_manager" {
...
172 [ http_tokens = "optional"
...
192 }
────────────────────────────────────────
HIGH: Root block device is not encrypted.
════════════════════════════════════════
Block devices should be encrypted to ensure sensitive data is held securely at rest.
HIGH: Instance does not require IMDS access to require a token.
════════════════════════════════════════
IMDS v2 (Instance Metadata Service) introduced session authentication tokens which improve security when talking to IMDS.
By default aws_instance resource sets IMDS session auth tokens to be optional.
To fully protect IMDS you need to enable session tokens by using metadata_options block and its http_tokens variable set to required.
See https://avd.aquasec.com/misconfig/avd-aws-0028
────────────────────────────────────────
database.tf:195
via database.tf:194-196 (metadata_options)
via database.tf:183-212 (aws_instance.database)
────────────────────────────────────────
183 resource "aws_instance" "database" {
...
195 [ http_tokens = "optional"
...
212 }
────────────────────────────────────────
HIGH: Root block device is not encrypted.
════════════════════════════════════════
Block devices should be encrypted to ensure sensitive data is held securely at rest.
*****************************
Setting default tflint config...
Running tflint --init...
Installing "terraform" plugin...
Installed "terraform" (source: github.com/terraform-linters/tflint-ruleset-terraform, version:0.9.1)
tflint will check the following folders:
terraform/environments/contract-work-administration
*****************************
Running tflint in terraform/environments/contract-work-administration
Excluding the following checks: terraform_unused_declarations
4issue(s) found:
Warning: Missing version constraint for provider "archive" in `required_providers` (terraform_required_providers)
on terraform/environments/contract-work-administration/backup_lambda.tf line 173:173:data"archive_file""connect_db" {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_required_providers.md
Warning: Missing version constraint for provider "template" in `required_providers` (terraform_required_providers)
on terraform/environments/contract-work-administration/cloudwatch.tf line 1126:1126:data"template_file""dashboard_no_ha" {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_required_providers.md
Warning: Missing version constraint for provider "local" in `required_providers` (terraform_required_providers)
on terraform/environments/contract-work-administration/data.tf line 11:11:data"local_file""cm_custom_metrics" {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_required_providers.md
Warning: Missing version constraint for provider "time" in `required_providers` (terraform_required_providers)
on terraform/environments/contract-work-administration/database.tf line 174:174:resource"time_sleep""wait_db_userdata_scripts" {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_required_providers.mdtflint_exitcode=2
Trivy Scan Failed
Show Output
*****************************
Trivy will check the following folders:
terraform/environments/contract-work-administration
*****************************
Running Trivy in terraform/environments/contract-work-administration
2024-11-01T09:33:00Z INFO [vulndb] Need to update DB
2024-11-01T09:33:00Z INFO [vulndb] Downloading vulnerability DB...2024-11-01T09:33:00Z INFO [vulndb] Downloading artifact...repo="public.ecr.aws/aquasecurity/trivy-db:2"2024-11-01T09:33:02Z INFO [vulndb] Artifact successfully downloaded repo="public.ecr.aws/aquasecurity/trivy-db:2"2024-11-01T09:33:02Z INFO [vuln] Vulnerability scanning is enabled
2024-11-01T09:33:02Z INFO [misconfig] Misconfiguration scanning is enabled
2024-11-01T09:33:02Z INFO [misconfig] Need to update the built-in checks
2024-11-01T09:33:02Z INFO [misconfig] Downloading the built-in checks...2024-11-01T09:33:02Z ERROR [misconfig] Falling back to embedded checks err="failed to download built-in policies: download error: oci download error: failed to fetch the layer: GET https://ghcr.io/v2/aquasecurity/trivy-checks/blobs/sha256:c2b4fe1cd51083ede5606a38fb24e7fafb06fd2632c9cf6d9c63f5a80a6c67dc: TOOMANYREQUESTS: retry-after: 226.974µs, allowed: 44000/minute"2024-11-01T09:33:02Z INFO [secret] Secret scanning is enabled
2024-11-01T09:33:02Z INFO [secret] If your scanning is slow, please try '--scanners vuln' to disable secret scanning
2024-11-01T09:33:02Z INFO [secret] Please see also https://aquasecurity.github.io/trivy/v0.56/docs/scanner/secret#recommendation for faster secret detection2024-11-01T09:33:04Z INFO [terraformscanner] Scanning root module file_path="."2024-11-01T09:33:04Z WARN [terraformparser] Variable values was not found in the environment or variable files. Evaluating may not work correctly.module="root"variables="networking"2024-11-01T09:33:05Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.aws_s3_object.user_public_keys"value="cty.NilVal"2024-11-01T09:33:05Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.data.aws_subnet.local_account"value="cty.NilVal"2024-11-01T09:33:05Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.dynamic.tag"value="cty.NilVal"2024-11-01T09:33:05Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.dynamic.tag"value="cty.NilVal"2024-11-01T09:33:05Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.expiration"value="cty.NilVal"2024-11-01T09:33:05Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.transition"value="cty.NilVal"2024-11-01T09:33:05Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.noncurrent_version_expiration"value="cty.NilVal"2024-11-01T09:33:05Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.noncurrent_version_transition"value="cty.NilVal"2024-11-01T09:33:05Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.principals"value="cty.NilVal"2024-11-01T09:33:05Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.condition"value="cty.NilVal"2024-11-01T09:33:05Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.expiration"value="cty.NilVal"2024-11-01T09:33:05Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.transition"value="cty.NilVal"2024-11-01T09:33:05Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.noncurrent_version_expiration"value="cty.NilVal"2024-11-01T09:33:05Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.noncurrent_version_transition"value="cty.NilVal"2024-11-01T09:33:05Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.principals"value="cty.NilVal"2024-11-01T09:33:05Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.condition"value="cty.NilVal"2024-11-01T09:33:06Z INFO [terraformexecutor] Ignore finding rule="aws-s3-encryption-customer-key"range="github.com/ministryofjustice/modernisation-platform-terraform-bastion-linux?ref=v4.2.0/github.com/ministryofjustice/modernisation-platform-terraform-s3-bucket?ref=568694e50e03630d99cb569eafa06a0b879a1239/main.tf:171-179"2024-11-01T09:33:06Z INFO Number of language-specific files num=02024-11-01T09:33:06Z INFO Detected config files num=9
alb.tf (terraform)
==================
Tests:3 (SUCCESSES:0, FAILURES:2, EXCEPTIONS:1)
Failures:2 (HIGH:2, CRITICAL:0)
HIGH: Application load balancer is not set to drop invalid headers.
════════════════════════════════════════
Passing unknown or invalid headers through to the target poses a potential risk of compromise.
By setting drop_invalid_header_fields to true, anything that does not conform to well known, defined headers will be removed by the load balancer.
See https://avd.aquasec.com/misconfig/avd-aws-0052
────────────────────────────────────────
alb.tf:130-153
────────────────────────────────────────
130 ┌ resource"aws_lb""external" {
131 │ name="${upper(local.application_name_short)}-LoadBalancer"132 │ internal=false133 │ load_balancer_type="application"134 │ security_groups=[aws_security_group.external_lb.id]
135 │ subnets=[data.aws_subnet.public_subnets_a.id, data.aws_subnet.public_subnets_b.id, data.aws_subnet.public_subnets_c.id]
136 │ enable_deletion_protection=local.lb_enable_deletion_protection137 │ idle_timeout=local.external_lb_idle_timeout138 └ enable_http2=false...
────────────────────────────────────────
HIGH: Load balancer is exposed publicly.
════════════════════════════════════════
There are many scenarios in which you would want to expose a load balancer to the wider internet, but this check exists as a warning to prevent accidental exposure of internal assets. You should ensure that this resource should be exposed publicly.
See https://avd.aquasec.com/misconfig/avd-aws-0053
────────────────────────────────────────
alb.tf:132
via alb.tf:130-153 (aws_lb.external)
────────────────────────────────────────
130resource"aws_lb""external" {
...132 [ internal = false...153 }
────────────────────────────────────────
app_servers.tf (terraform)
==========================Tests:5 (SUCCESSES:0, FAILURES:4, EXCEPTIONS:1)
Failures:4 (HIGH:4, CRITICAL:0)
HIGH:InstancedoesnotrequireIMDSaccesstorequireatoken.
════════════════════════════════════════
IMDSv2 (Instance Metadata Service) introducedsessionauthenticationtokenswhichimprovesecuritywhentalkingtoIMDS.Bydefault<code>aws_instance</code>resourcesetsIMDSsessionauthtokenstobeoptional.TofullyprotectIMDSyouneedtoenablesessiontokensbyusing<code>metadata_options</code>blockandits<code>http_tokens</code>variablesetto<code>required</code>.Seehttps://avd.aquasec.com/misconfig/avd-aws-0028
────────────────────────────────────────
app_servers.tf:194viaapp_servers.tf:193-195 (metadata_options)
viaapp_servers.tf:182-214 (aws_instance.app1)
────────────────────────────────────────
182resource"aws_instance""app1" {
...194 [ http_tokens ="optional"...214 }
────────────────────────────────────────
HIGH:InstancedoesnotrequireIMDSaccesstorequireatoken.
════════════════════════════════════════
IMDSv2 (Instance Metadata Service) introducedsessionauthenticationtokenswhichimprovesecuritywhentalkingtoIMDS.Bydefault<code>aws_instance</code>resourcesetsIMDSsessionauthtokenstobeoptional.TofullyprotectIMDSyouneedtoenablesessiontokensbyusing<code>metadata_options</code>blockandits<code>http_tokens</code>variablesetto<code>required</code>.Seehttps://avd.aquasec.com/misconfig/avd-aws-0028
────────────────────────────────────────
app_servers.tf:229viaapp_servers.tf:228-230 (metadata_options)
viaapp_servers.tf:216-249 (aws_instance.app2[0])
────────────────────────────────────────
216resource"aws_instance""app2" {
...229 [ http_tokens ="optional"...249 }
────────────────────────────────────────
HIGH:Rootblockdeviceisnotencrypted.
════════════════════════════════════════
Blockdevicesshouldbeencryptedtoensuresensitivedataisheldsecurelyatrest.Seehttps://avd.aquasec.com/misconfig/avd-aws-0131
────────────────────────────────────────
app_servers.tf:182-214
────────────────────────────────────────
182 ┌ resource"aws_instance""app1" {
183 │ ami = local.application_data.accounts[local.environment].app_ami_id
184 │ availability_zone ="eu-west-2a"185 │ instance_type = local.application_data.accounts[local.environment].app_instance_type
186 │ monitoring =true187 │ vpc_security_group_ids = [aws_security_group.app.id]
188 │ subnet_id = data.aws_subnet.private_subnets_a.id
189 │ iam_instance_profile = aws_iam_instance_profile.cwa.id
190 └ key_name = aws_key_pair.cwa.key_name
...
────────────────────────────────────────
HIGH: Root block device is not encrypted.
════════════════════════════════════════
Block devices should be encrypted to ensure sensitive data is held securely at rest.
See https://avd.aquasec.com/misconfig/avd-aws-0131
────────────────────────────────────────
app_servers.tf:216-249
────────────────────────────────────────
216 ┌ resource "aws_instance""app2" {
217 │ count =contains(["development2", "testing"], local.environment) ?0:1218 │ ami = local.application_data.accounts[local.environment].app_ami_id
219 │ availability_zone ="eu-west-2a"220 │ instance_type = local.application_data.accounts[local.environment].app_instance_type
221 │ monitoring =true222 │ vpc_security_group_ids = [aws_security_group.app.id]
223 │ subnet_id = data.aws_subnet.private_subnets_a.id
224 └ iam_instance_profile = aws_iam_instance_profile.cwa.id
...
────────────────────────────────────────
backup_lambda.tf (terraform)
============================
Tests:3 (SUCCESSES:0, FAILURES:2, EXCEPTIONS:1)
Failures:2 (HIGH:2, CRITICAL:0)
HIGH: Bucket does not have encryption enabled
════════════════════════════════════════
S3 Buckets should be encrypted to protect the data that is stored within them ifaccessiscompromised.
See https://avd.aquasec.com/misconfig/avd-aws-0088
────────────────────────────────────────
backup_lambda.tf:101-107
────────────────────────────────────────
101 ┌ resource "aws_s3_bucket""scripts" {
102 │ bucket ="${local.application_name_short}-${local.environment}-scripts"103 │ tags =merge(
104 │ local.tags,
105 │ { Name ="${local.application_name_short}-${local.environment}-scripts" }
106 │ )
107 └ }
────────────────────────────────────────
HIGH: Bucket does not encrypt data with a customer managed key.
════════════════════════════════════════
Encryption using AWS keys provides protection foryourS3buckets.Toincreasecontroloftheencryptionandmanagefactorslikerotationusecustomermanagedkeys.
See https://avd.aquasec.com/misconfig/avd-aws-0132
────────────────────────────────────────
backup_lambda.tf:101-107
────────────────────────────────────────
101 ┌ resource "aws_s3_bucket""scripts" {
102 │ bucket ="${local.application_name_short}-${local.environment}-scripts"103 │ tags =merge(
104 │ local.tags,
105 │ { Name ="${local.application_name_short}-${local.environment}-scripts" }
106 │ )
107 └ }
────────────────────────────────────────
concurrent_manager.tf (terraform)
=================================
Tests:3 (SUCCESSES:0, FAILURES:2, EXCEPTIONS:1)
Failures:2 (HIGH:2, CRITICAL:0)
HIGH: Instance does not require IMDS access to require a token.
════════════════════════════════════════
IMDS v2 (Instance Metadata Service) introduced session authentication tokens which improve security when talking to IMDS.
By default <code>aws_instance</code> resource sets IMDS session auth tokens to be optional.
To fully protect IMDS you need to enable session tokens by using <code>metadata_options</code> block and its <code>http_tokens</code> variable set to <code>required</code>.
See https://avd.aquasec.com/misconfig/avd-aws-0028
────────────────────────────────────────
concurrent_manager.tf:172
via concurrent_manager.tf:171-173 (metadata_options)
via concurrent_manager.tf:160-192 (aws_instance.concurrent_manager)
────────────────────────────────────────
160 resource "aws_instance""concurrent_manager" {
...172 [ http_tokens ="optional"...192 }
────────────────────────────────────────
HIGH: Root block device is not encrypted.
════════════════════════════════════════
Block devices should be encrypted to ensure sensitive data is held securely at rest.
See https://avd.aquasec.com/misconfig/avd-aws-0131
────────────────────────────────────────
concurrent_manager.tf:160-192
────────────────────────────────────────
160 ┌ resource "aws_instance""concurrent_manager" {
161 │ ami = local.application_data.accounts[local.environment].cm_ami_id
162 │ availability_zone ="eu-west-2a"163 │ instance_type = local.application_data.accounts[local.environment].cm_instance_type
164 │ monitoring =true165 │ vpc_security_group_ids = [aws_security_group.concurrent_manager.id]
166 │ subnet_id = data.aws_subnet.private_subnets_a.id
167 │ iam_instance_profile = aws_iam_instance_profile.cwa.id
168 └ key_name = aws_key_pair.cwa.key_name
...
────────────────────────────────────────
database.tf (terraform)
=======================
Tests:3 (SUCCESSES:0, FAILURES:2, EXCEPTIONS:1)
Failures:2 (HIGH:2, CRITICAL:0)
HIGH: Instance does not require IMDS access to require a token.
════════════════════════════════════════
IMDS v2 (Instance Metadata Service) introduced session authentication tokens which improve security when talking to IMDS.
By default <code>aws_instance</code> resource sets IMDS session auth tokens to be optional.
To fully protect IMDS you need to enable session tokens by using <code>metadata_options</code> block and its <code>http_tokens</code> variable set to <code>required</code>.
See https://avd.aquasec.com/misconfig/avd-aws-0028
────────────────────────────────────────
database.tf:195
via database.tf:194-196 (metadata_options)
via database.tf:183-212 (aws_instance.database)
────────────────────────────────────────
183 resource "aws_instance""database" {
...195 [ http_tokens ="optional"...212 }
────────────────────────────────────────
HIGH: Root block device is not encrypted.
════════════════════════════════════════
Block devices should be encrypted to ensure sensitive data is held securely at rest.
See https://avd.aquasec.com/misconfig/avd-aws-0131
────────────────────────────────────────
database.tf:183-212
────────────────────────────────────────
183 ┌ resource "aws_instance""database" {
184 │ ami = local.application_data.accounts[local.environment].db_ami_id
185 │ availability_zone ="eu-west-2a"186 │ instance_type = local.application_data.accounts[local.environment].db_instance_type
187 │ monitoring =true188 │ vpc_security_group_ids = [aws_security_group.database.id]
189 │ subnet_id = data.aws_subnet.data_subnets_a.id
190 │ iam_instance_profile = aws_iam_instance_profile.cwa.id
191 └ key_name = aws_key_pair.cwa.key_name
...
────────────────────────────────────────
trivy_exitcode=1
Trivy will check the following folders:
terraform/environments/contract-work-administration
Running Trivy in terraform/environments/contract-work-administration
2024-11-01T10:15:16Z INFO [vulndb] Need to update DB
2024-11-01T10:15:16Z INFO [vulndb] Downloading vulnerability DB...
2024-11-01T10:15:16Z INFO [vulndb] Downloading artifact... repo="public.ecr.aws/aquasecurity/trivy-db:2"
2024-11-01T10:15:18Z INFO [vulndb] Artifact successfully downloaded repo="public.ecr.aws/aquasecurity/trivy-db:2"
2024-11-01T10:15:18Z INFO [vuln] Vulnerability scanning is enabled
2024-11-01T10:15:18Z INFO [misconfig] Misconfiguration scanning is enabled
2024-11-01T10:15:18Z INFO [misconfig] Need to update the built-in checks
2024-11-01T10:15:18Z INFO [misconfig] Downloading the built-in checks...
160.60 KiB / 160.60 KiB [---------------------------------------------------------] 100.00% ? p/s 0s2024-11-01T10:15:18Z INFO [secret] Secret scanning is enabled
2024-11-01T10:15:18Z INFO [secret] If your scanning is slow, please try '--scanners vuln' to disable secret scanning
2024-11-01T10:15:18Z INFO [secret] Please see also https://aquasecurity.github.io/trivy/v0.56/docs/scanner/secret#recommendation for faster secret detection
2024-11-01T10:15:19Z INFO [terraform scanner] Scanning root module file_path="."
2024-11-01T10:15:19Z WARN [terraform parser] Variable values was not found in the environment or variable files. Evaluating may not work correctly. module="root" variables="networking"
2024-11-01T10:15:20Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.aws_s3_object.user_public_keys" value="cty.NilVal"
2024-11-01T10:15:20Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.data.aws_subnet.local_account" value="cty.NilVal"
2024-11-01T10:15:20Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.dynamic.tag" value="cty.NilVal"
2024-11-01T10:15:20Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.dynamic.tag" value="cty.NilVal"
2024-11-01T10:15:21Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.expiration" value="cty.NilVal"
2024-11-01T10:15:21Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.transition" value="cty.NilVal"
2024-11-01T10:15:21Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.noncurrent_version_expiration" value="cty.NilVal"
2024-11-01T10:15:21Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.noncurrent_version_transition" value="cty.NilVal"
2024-11-01T10:15:21Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.principals" value="cty.NilVal"
2024-11-01T10:15:21Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.condition" value="cty.NilVal"
2024-11-01T10:15:21Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.expiration" value="cty.NilVal"
2024-11-01T10:15:21Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.transition" value="cty.NilVal"
2024-11-01T10:15:21Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.noncurrent_version_expiration" value="cty.NilVal"
2024-11-01T10:15:21Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.noncurrent_version_transition" value="cty.NilVal"
2024-11-01T10:15:21Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.principals" value="cty.NilVal"
2024-11-01T10:15:21Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.condition" value="cty.NilVal"
2024-11-01T10:15:22Z INFO [terraform executor] Ignore finding rule="aws-s3-encryption-customer-key" range="github.com/ministryofjustice/modernisation-platform-terraform-bastion-linux?ref=v4.2.0/github.com/ministryofjustice/modernisation-platform-terraform-s3-bucket?ref=568694e50e03630d99cb569eafa06a0b879a1239/main.tf:171-179"
2024-11-01T10:15:23Z INFO Number of language-specific files num=0
2024-11-01T10:15:23Z INFO Detected config files num=9
HIGH: Application load balancer is not set to drop invalid headers.
════════════════════════════════════════
Passing unknown or invalid headers through to the target poses a potential risk of compromise.
By setting drop_invalid_header_fields to true, anything that does not conform to well known, defined headers will be removed by the load balancer.
HIGH: Load balancer is exposed publicly.
════════════════════════════════════════
There are many scenarios in which you would want to expose a load balancer to the wider internet, but this check exists as a warning to prevent accidental exposure of internal assets. You should ensure that this resource should be exposed publicly.
HIGH: Instance does not require IMDS access to require a token.
════════════════════════════════════════
IMDS v2 (Instance Metadata Service) introduced session authentication tokens which improve security when talking to IMDS.
By default aws_instance resource sets IMDS session auth tokens to be optional.
To fully protect IMDS you need to enable session tokens by using metadata_options block and its http_tokens variable set to required.
HIGH: Instance does not require IMDS access to require a token.
════════════════════════════════════════
IMDS v2 (Instance Metadata Service) introduced session authentication tokens which improve security when talking to IMDS.
By default aws_instance resource sets IMDS session auth tokens to be optional.
To fully protect IMDS you need to enable session tokens by using metadata_options block and its http_tokens variable set to required.
HIGH: Root block device is not encrypted.
════════════════════════════════════════
Block devices should be encrypted to ensure sensitive data is held securely at rest.
HIGH: Root block device is not encrypted.
════════════════════════════════════════
Block devices should be encrypted to ensure sensitive data is held securely at rest.
HIGH: Bucket does not have encryption enabled
════════════════════════════════════════
S3 Buckets should be encrypted to protect the data that is stored within them if access is compromised.
HIGH: Bucket does not encrypt data with a customer managed key.
════════════════════════════════════════
Encryption using AWS keys provides protection for your S3 buckets. To increase control of the encryption and manage factors like rotation use customer managed keys.
HIGH: Instance does not require IMDS access to require a token.
════════════════════════════════════════
IMDS v2 (Instance Metadata Service) introduced session authentication tokens which improve security when talking to IMDS.
By default aws_instance resource sets IMDS session auth tokens to be optional.
To fully protect IMDS you need to enable session tokens by using metadata_options block and its http_tokens variable set to required.
HIGH: Root block device is not encrypted.
════════════════════════════════════════
Block devices should be encrypted to ensure sensitive data is held securely at rest.
HIGH: Instance does not require IMDS access to require a token.
════════════════════════════════════════
IMDS v2 (Instance Metadata Service) introduced session authentication tokens which improve security when talking to IMDS.
By default aws_instance resource sets IMDS session auth tokens to be optional.
To fully protect IMDS you need to enable session tokens by using metadata_options block and its http_tokens variable set to required.
HIGH: Root block device is not encrypted.
════════════════════════════════════════
Block devices should be encrypted to ensure sensitive data is held securely at rest.
*****************************
Setting default tflint config...
Running tflint --init...
Installing "terraform" plugin...
Installed "terraform" (source: github.com/terraform-linters/tflint-ruleset-terraform, version:0.9.1)
tflint will check the following folders:
terraform/environments/contract-work-administration
*****************************
Running tflint in terraform/environments/contract-work-administration
Excluding the following checks: terraform_unused_declarations
4issue(s) found:
Warning: Missing version constraint for provider "archive" in `required_providers` (terraform_required_providers)
on terraform/environments/contract-work-administration/backup_lambda.tf line 173:173:data"archive_file""connect_db" {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_required_providers.md
Warning: Missing version constraint for provider "template" in `required_providers` (terraform_required_providers)
on terraform/environments/contract-work-administration/cloudwatch.tf line 1126:1126:data"template_file""dashboard_no_ha" {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_required_providers.md
Warning: Missing version constraint for provider "time" in `required_providers` (terraform_required_providers)
on terraform/environments/contract-work-administration/concurrent_manager.tf line 151:151:resource"time_sleep""wait_cm_custom_script" {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_required_providers.md
Warning: Missing version constraint for provider "local" in `required_providers` (terraform_required_providers)
on terraform/environments/contract-work-administration/data.tf line 11:11:data"local_file""cm_custom_metrics" {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_required_providers.mdtflint_exitcode=2
Trivy Scan Failed
Show Output
*****************************
Trivy will check the following folders:
terraform/environments/contract-work-administration
*****************************
Running Trivy in terraform/environments/contract-work-administration
2024-11-01T10:15:16Z INFO [vulndb] Need to update DB
2024-11-01T10:15:16Z INFO [vulndb] Downloading vulnerability DB...2024-11-01T10:15:16Z INFO [vulndb] Downloading artifact...repo="public.ecr.aws/aquasecurity/trivy-db:2"2024-11-01T10:15:18Z INFO [vulndb] Artifact successfully downloaded repo="public.ecr.aws/aquasecurity/trivy-db:2"2024-11-01T10:15:18Z INFO [vuln] Vulnerability scanning is enabled
2024-11-01T10:15:18Z INFO [misconfig] Misconfiguration scanning is enabled
2024-11-01T10:15:18Z INFO [misconfig] Need to update the built-in checks
2024-11-01T10:15:18Z INFO [misconfig] Downloading the built-in checks...160.60 KiB /160.60 KiB [---------------------------------------------------------] 100.00%? p/s 0s2024-11-01T10:15:18Z INFO [secret] Secret scanning is enabled
2024-11-01T10:15:18Z INFO [secret] If your scanning is slow, please try '--scanners vuln' to disable secret scanning
2024-11-01T10:15:18Z INFO [secret] Please see also https://aquasecurity.github.io/trivy/v0.56/docs/scanner/secret#recommendation for faster secret detection2024-11-01T10:15:19Z INFO [terraformscanner] Scanning root module file_path="."2024-11-01T10:15:19Z WARN [terraformparser] Variable values was not found in the environment or variable files. Evaluating may not work correctly.module="root"variables="networking"2024-11-01T10:15:20Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.aws_s3_object.user_public_keys"value="cty.NilVal"2024-11-01T10:15:20Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.data.aws_subnet.local_account"value="cty.NilVal"2024-11-01T10:15:20Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.dynamic.tag"value="cty.NilVal"2024-11-01T10:15:20Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.dynamic.tag"value="cty.NilVal"2024-11-01T10:15:21Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.expiration"value="cty.NilVal"2024-11-01T10:15:21Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.transition"value="cty.NilVal"2024-11-01T10:15:21Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.noncurrent_version_expiration"value="cty.NilVal"2024-11-01T10:15:21Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.noncurrent_version_transition"value="cty.NilVal"2024-11-01T10:15:21Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.principals"value="cty.NilVal"2024-11-01T10:15:21Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.condition"value="cty.NilVal"2024-11-01T10:15:21Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.expiration"value="cty.NilVal"2024-11-01T10:15:21Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.transition"value="cty.NilVal"2024-11-01T10:15:21Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.noncurrent_version_expiration"value="cty.NilVal"2024-11-01T10:15:21Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.noncurrent_version_transition"value="cty.NilVal"2024-11-01T10:15:21Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.principals"value="cty.NilVal"2024-11-01T10:15:21Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.condition"value="cty.NilVal"2024-11-01T10:15:22Z INFO [terraformexecutor] Ignore finding rule="aws-s3-encryption-customer-key"range="github.com/ministryofjustice/modernisation-platform-terraform-bastion-linux?ref=v4.2.0/github.com/ministryofjustice/modernisation-platform-terraform-s3-bucket?ref=568694e50e03630d99cb569eafa06a0b879a1239/main.tf:171-179"2024-11-01T10:15:23Z INFO Number of language-specific files num=02024-11-01T10:15:23Z INFO Detected config files num=9
alb.tf (terraform)
==================
Tests:3 (SUCCESSES:0, FAILURES:2, EXCEPTIONS:1)
Failures:2 (HIGH:2, CRITICAL:0)
HIGH: Application load balancer is not set to drop invalid headers.
════════════════════════════════════════
Passing unknown or invalid headers through to the target poses a potential risk of compromise.
By setting drop_invalid_header_fields to true, anything that does not conform to well known, defined headers will be removed by the load balancer.
See https://avd.aquasec.com/misconfig/avd-aws-0052
────────────────────────────────────────
alb.tf:130-153
────────────────────────────────────────
130 ┌ resource"aws_lb""external" {
131 │ name="${upper(local.application_name_short)}-LoadBalancer"132 │ internal=false133 │ load_balancer_type="application"134 │ security_groups=[aws_security_group.external_lb.id]
135 │ subnets=[data.aws_subnet.public_subnets_a.id, data.aws_subnet.public_subnets_b.id, data.aws_subnet.public_subnets_c.id]
136 │ enable_deletion_protection=local.lb_enable_deletion_protection137 │ idle_timeout=local.external_lb_idle_timeout138 └ enable_http2=false...
────────────────────────────────────────
HIGH: Load balancer is exposed publicly.
════════════════════════════════════════
There are many scenarios in which you would want to expose a load balancer to the wider internet, but this check exists as a warning to prevent accidental exposure of internal assets. You should ensure that this resource should be exposed publicly.
See https://avd.aquasec.com/misconfig/avd-aws-0053
────────────────────────────────────────
alb.tf:130-153
────────────────────────────────────────
130 ┌ resource"aws_lb""external" {
131 │ name="${upper(local.application_name_short)}-LoadBalancer"132 │ internal=false133 │ load_balancer_type="application"134 │ security_groups=[aws_security_group.external_lb.id]
135 │ subnets=[data.aws_subnet.public_subnets_a.id, data.aws_subnet.public_subnets_b.id, data.aws_subnet.public_subnets_c.id]
136 │ enable_deletion_protection=local.lb_enable_deletion_protection137 │ idle_timeout=local.external_lb_idle_timeout138 └ enable_http2=false...
────────────────────────────────────────
app_servers.tf (terraform)
==========================
Tests:5 (SUCCESSES:0, FAILURES:4, EXCEPTIONS:1)
Failures:4 (HIGH:4, CRITICAL:0)
HIGH: Instance does not require IMDS access to require a token.
════════════════════════════════════════
IMDS v2 (Instance Metadata Service) introduced session authentication tokens which improve security when talking to IMDS.
By default <code>aws_instance</code> resource sets IMDS session auth tokens to be optional.
To fully protect IMDS you need to enable session tokens by using <code>metadata_options</code> block and its <code>http_tokens</code> variable set to <code>required</code>.
See https://avd.aquasec.com/misconfig/avd-aws-0028
────────────────────────────────────────
app_servers.tf:193-195
via app_servers.tf:182-214 (aws_instance.app1)
────────────────────────────────────────
182resource"aws_instance""app1" {
...193 ┌ metadata_options {
194 │ http_tokens="optional"195 └ }
...214 }
────────────────────────────────────────
HIGH: Instance does not require IMDS access to require a token.
════════════════════════════════════════
IMDS v2 (Instance Metadata Service) introduced session authentication tokens which improve security when talking to IMDS.
By default <code>aws_instance</code> resource sets IMDS session auth tokens to be optional.
To fully protect IMDS you need to enable session tokens by using <code>metadata_options</code> block and its <code>http_tokens</code> variable set to <code>required</code>.
See https://avd.aquasec.com/misconfig/avd-aws-0028
────────────────────────────────────────
app_servers.tf:228-230
via app_servers.tf:216-249 (aws_instance.app2[0])
────────────────────────────────────────
216resource"aws_instance""app2" {
...228 ┌ metadata_options {
229 │ http_tokens="optional"230 └ }
...249 }
────────────────────────────────────────
HIGH: Root block device is not encrypted.
════════════════════════════════════════
Block devices should be encrypted to ensure sensitive data is held securely at rest.
See https://avd.aquasec.com/misconfig/avd-aws-0131
────────────────────────────────────────
app_servers.tf:197-203
via app_servers.tf:182-214 (aws_instance.app1)
────────────────────────────────────────
182resource"aws_instance""app1" {
...197 ┌ root_block_device {
198 │ tags=merge(
199 │ { "instance-scheduling" = "skip-scheduling" },
200 │ local.tags,
201 │ { "Name" = "${local.application_name_short}-app1-root" }
202 │ )
203 └ }
...
────────────────────────────────────────
HIGH: Root block device is not encrypted.
════════════════════════════════════════
Block devices should be encrypted to ensure sensitive data is held securely at rest.
See https://avd.aquasec.com/misconfig/avd-aws-0131
────────────────────────────────────────
app_servers.tf:232-238
via app_servers.tf:216-249 (aws_instance.app2[0])
────────────────────────────────────────
216resource"aws_instance""app2" {
...232 ┌ root_block_device {
233 │ tags=merge(
234 │ { "instance-scheduling" = "skip-scheduling" },
235 │ local.tags,
236 │ { "Name" = "${local.application_name_short}-app2-root" }
237 │ )
238 └ }
...
────────────────────────────────────────
backup_lambda.tf (terraform)
============================
Tests:3 (SUCCESSES:0, FAILURES:2, EXCEPTIONS:1)
Failures:2 (HIGH:2, CRITICAL:0)
HIGH: Bucket does not have encryption enabled
════════════════════════════════════════
S3 Buckets should be encrypted to protect the data that is stored within them if access is compromised.
See https://avd.aquasec.com/misconfig/avd-aws-0088
────────────────────────────────────────
backup_lambda.tf:101-107
────────────────────────────────────────
101 ┌ resource"aws_s3_bucket""scripts" {
102 │ bucket="${local.application_name_short}-${local.environment}-scripts"103 │ tags=merge(
104 │ local.tags,
105 │ { Name ="${local.application_name_short}-${local.environment}-scripts" }
106 │ )
107 └ }
────────────────────────────────────────
HIGH: Bucket does not encrypt data with a customer managed key.
════════════════════════════════════════
Encryption using AWS keys provides protection for your S3 buckets. To increase control of the encryption and manage factors like rotation use customer managed keys.
See https://avd.aquasec.com/misconfig/avd-aws-0132
────────────────────────────────────────
backup_lambda.tf:101-107
────────────────────────────────────────
101 ┌ resource"aws_s3_bucket""scripts" {
102 │ bucket="${local.application_name_short}-${local.environment}-scripts"103 │ tags=merge(
104 │ local.tags,
105 │ { Name ="${local.application_name_short}-${local.environment}-scripts" }
106 │ )
107 └ }
────────────────────────────────────────
concurrent_manager.tf (terraform)
=================================
Tests:3 (SUCCESSES:0, FAILURES:2, EXCEPTIONS:1)
Failures:2 (HIGH:2, CRITICAL:0)
HIGH: Instance does not require IMDS access to require a token.
════════════════════════════════════════
IMDS v2 (Instance Metadata Service) introduced session authentication tokens which improve security when talking to IMDS.
By default <code>aws_instance</code> resource sets IMDS session auth tokens to be optional.
To fully protect IMDS you need to enable session tokens by using <code>metadata_options</code> block and its <code>http_tokens</code> variable set to <code>required</code>.
See https://avd.aquasec.com/misconfig/avd-aws-0028
────────────────────────────────────────
concurrent_manager.tf:171-173
via concurrent_manager.tf:160-192 (aws_instance.concurrent_manager)
────────────────────────────────────────
160resource"aws_instance""concurrent_manager" {
...171 ┌ metadata_options {
172 │ http_tokens="optional"173 └ }
...192 }
────────────────────────────────────────
HIGH: Root block device is not encrypted.
════════════════════════════════════════
Block devices should be encrypted to ensure sensitive data is held securely at rest.
See https://avd.aquasec.com/misconfig/avd-aws-0131
────────────────────────────────────────
concurrent_manager.tf:175-181
via concurrent_manager.tf:160-192 (aws_instance.concurrent_manager)
────────────────────────────────────────
160resource"aws_instance""concurrent_manager" {
...175 ┌ root_block_device {
176 │ tags=merge(
177 │ { "instance-scheduling" = "skip-scheduling" },
178 │ local.tags,
179 │ { "Name" = "${local.application_name_short}-concurrent-manager-root" }
180 │ )
181 └ }
...
────────────────────────────────────────
database.tf (terraform)
=======================
Tests:3 (SUCCESSES:0, FAILURES:2, EXCEPTIONS:1)
Failures:2 (HIGH:2, CRITICAL:0)
HIGH: Instance does not require IMDS access to require a token.
════════════════════════════════════════
IMDS v2 (Instance Metadata Service) introduced session authentication tokens which improve security when talking to IMDS.
By default <code>aws_instance</code> resource sets IMDS session auth tokens to be optional.
To fully protect IMDS you need to enable session tokens by using <code>metadata_options</code> block and its <code>http_tokens</code> variable set to <code>required</code>.
See https://avd.aquasec.com/misconfig/avd-aws-0028
────────────────────────────────────────
database.tf:194-196
via database.tf:183-212 (aws_instance.database)
────────────────────────────────────────
183resource"aws_instance""database" {
...194 ┌ metadata_options {
195 │ http_tokens="optional"196 └ }
...212 }
────────────────────────────────────────
HIGH: Root block device is not encrypted.
════════════════════════════════════════
Block devices should be encrypted to ensure sensitive data is held securely at rest.
See https://avd.aquasec.com/misconfig/avd-aws-0131
────────────────────────────────────────
database.tf:198-204
via database.tf:183-212 (aws_instance.database)
────────────────────────────────────────
183resource"aws_instance""database" {
...198 ┌ root_block_device {
199 │ tags=merge(
200 │ { "instance-scheduling" = "skip-scheduling" },
201 │ local.tags,
202 │ { "Name" = "${local.application_name_short}-database-root" }
203 │ )
204 └ }
...
────────────────────────────────────────
trivy_exitcode=1
Trivy will check the following folders:
terraform/environments/contract-work-administration
Running Trivy in terraform/environments/contract-work-administration
2024-11-01T15:29:03Z INFO [vulndb] Need to update DB
2024-11-01T15:29:03Z INFO [vulndb] Downloading vulnerability DB...
2024-11-01T15:29:03Z INFO [vulndb] Downloading artifact... repo="public.ecr.aws/aquasecurity/trivy-db:2"
2024-11-01T15:29:05Z INFO [vulndb] Artifact successfully downloaded repo="public.ecr.aws/aquasecurity/trivy-db:2"
2024-11-01T15:29:05Z INFO [vuln] Vulnerability scanning is enabled
2024-11-01T15:29:05Z INFO [misconfig] Misconfiguration scanning is enabled
2024-11-01T15:29:05Z INFO [misconfig] Need to update the built-in checks
2024-11-01T15:29:05Z INFO [misconfig] Downloading the built-in checks...
160.60 KiB / 160.60 KiB [------------------------------------------------------] 100.00% ? p/s 100ms2024-11-01T15:29:06Z INFO [secret] Secret scanning is enabled
2024-11-01T15:29:06Z INFO [secret] If your scanning is slow, please try '--scanners vuln' to disable secret scanning
2024-11-01T15:29:06Z INFO [secret] Please see also https://aquasecurity.github.io/trivy/v0.56/docs/scanner/secret#recommendation for faster secret detection
2024-11-01T15:29:08Z INFO [terraform scanner] Scanning root module file_path="."
2024-11-01T15:29:08Z WARN [terraform parser] Variable values was not found in the environment or variable files. Evaluating may not work correctly. module="root" variables="networking"
2024-11-01T15:29:09Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.aws_s3_object.user_public_keys" value="cty.NilVal"
2024-11-01T15:29:09Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.data.aws_subnet.local_account" value="cty.NilVal"
2024-11-01T15:29:09Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.dynamic.tag" value="cty.NilVal"
2024-11-01T15:29:09Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.dynamic.tag" value="cty.NilVal"
2024-11-01T15:29:10Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.expiration" value="cty.NilVal"
2024-11-01T15:29:10Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.transition" value="cty.NilVal"
2024-11-01T15:29:10Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.noncurrent_version_expiration" value="cty.NilVal"
2024-11-01T15:29:10Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.noncurrent_version_transition" value="cty.NilVal"
2024-11-01T15:29:10Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.principals" value="cty.NilVal"
2024-11-01T15:29:10Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.condition" value="cty.NilVal"
2024-11-01T15:29:10Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.expiration" value="cty.NilVal"
2024-11-01T15:29:10Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.transition" value="cty.NilVal"
2024-11-01T15:29:10Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.noncurrent_version_expiration" value="cty.NilVal"
2024-11-01T15:29:10Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.noncurrent_version_transition" value="cty.NilVal"
2024-11-01T15:29:10Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.principals" value="cty.NilVal"
2024-11-01T15:29:10Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.condition" value="cty.NilVal"
2024-11-01T15:29:11Z INFO [terraform executor] Ignore finding rule="aws-s3-encryption-customer-key" range="github.com/ministryofjustice/modernisation-platform-terraform-bastion-linux?ref=v4.2.0/github.com/ministryofjustice/modernisation-platform-terraform-s3-bucket?ref=568694e50e03630d99cb569eafa06a0b879a1239/main.tf:171-179"
2024-11-01T15:29:11Z INFO Number of language-specific files num=0
2024-11-01T15:29:11Z INFO Detected config files num=9
HIGH: Application load balancer is not set to drop invalid headers.
════════════════════════════════════════
Passing unknown or invalid headers through to the target poses a potential risk of compromise.
By setting drop_invalid_header_fields to true, anything that does not conform to well known, defined headers will be removed by the load balancer.
HIGH: Load balancer is exposed publicly.
════════════════════════════════════════
There are many scenarios in which you would want to expose a load balancer to the wider internet, but this check exists as a warning to prevent accidental exposure of internal assets. You should ensure that this resource should be exposed publicly.
HIGH: Instance does not require IMDS access to require a token.
════════════════════════════════════════
IMDS v2 (Instance Metadata Service) introduced session authentication tokens which improve security when talking to IMDS.
By default aws_instance resource sets IMDS session auth tokens to be optional.
To fully protect IMDS you need to enable session tokens by using metadata_options block and its http_tokens variable set to required.
HIGH: Instance does not require IMDS access to require a token.
════════════════════════════════════════
IMDS v2 (Instance Metadata Service) introduced session authentication tokens which improve security when talking to IMDS.
By default aws_instance resource sets IMDS session auth tokens to be optional.
To fully protect IMDS you need to enable session tokens by using metadata_options block and its http_tokens variable set to required.
HIGH: Root block device is not encrypted.
════════════════════════════════════════
Block devices should be encrypted to ensure sensitive data is held securely at rest.
HIGH: Root block device is not encrypted.
════════════════════════════════════════
Block devices should be encrypted to ensure sensitive data is held securely at rest.
HIGH: Bucket does not have encryption enabled
════════════════════════════════════════
S3 Buckets should be encrypted to protect the data that is stored within them if access is compromised.
HIGH: Bucket does not encrypt data with a customer managed key.
════════════════════════════════════════
Encryption using AWS keys provides protection for your S3 buckets. To increase control of the encryption and manage factors like rotation use customer managed keys.
HIGH: Instance does not require IMDS access to require a token.
════════════════════════════════════════
IMDS v2 (Instance Metadata Service) introduced session authentication tokens which improve security when talking to IMDS.
By default aws_instance resource sets IMDS session auth tokens to be optional.
To fully protect IMDS you need to enable session tokens by using metadata_options block and its http_tokens variable set to required.
HIGH: Root block device is not encrypted.
════════════════════════════════════════
Block devices should be encrypted to ensure sensitive data is held securely at rest.
HIGH: Instance does not require IMDS access to require a token.
════════════════════════════════════════
IMDS v2 (Instance Metadata Service) introduced session authentication tokens which improve security when talking to IMDS.
By default aws_instance resource sets IMDS session auth tokens to be optional.
To fully protect IMDS you need to enable session tokens by using metadata_options block and its http_tokens variable set to required.
HIGH: Root block device is not encrypted.
════════════════════════════════════════
Block devices should be encrypted to ensure sensitive data is held securely at rest.
*****************************
Setting default tflint config...
Running tflint --init...
Installing "terraform" plugin...
Installed "terraform" (source: github.com/terraform-linters/tflint-ruleset-terraform, version:0.9.1)
tflint will check the following folders:
terraform/environments/contract-work-administration
*****************************
Running tflint in terraform/environments/contract-work-administration
Excluding the following checks: terraform_unused_declarations
4issue(s) found:
Warning: Missing version constraint for provider "time" in `required_providers` (terraform_required_providers)
on terraform/environments/contract-work-administration/backup_lambda.tf line 119:119:resource"time_sleep""wait_for_provision_files" {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_required_providers.md
Warning: Missing version constraint for provider "archive" in `required_providers` (terraform_required_providers)
on terraform/environments/contract-work-administration/backup_lambda.tf line 173:173:data"archive_file""connect_db" {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_required_providers.md
Warning: Missing version constraint for provider "template" in `required_providers` (terraform_required_providers)
on terraform/environments/contract-work-administration/cloudwatch.tf line 1126:1126:data"template_file""dashboard_no_ha" {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_required_providers.md
Warning: Missing version constraint for provider "local" in `required_providers` (terraform_required_providers)
on terraform/environments/contract-work-administration/data.tf line 11:11:data"local_file""cm_custom_metrics" {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_required_providers.mdtflint_exitcode=2
Trivy Scan Failed
Show Output
*****************************
Trivy will check the following folders:
terraform/environments/contract-work-administration
*****************************
Running Trivy in terraform/environments/contract-work-administration
2024-11-01T15:29:03Z INFO [vulndb] Need to update DB
2024-11-01T15:29:03Z INFO [vulndb] Downloading vulnerability DB...2024-11-01T15:29:03Z INFO [vulndb] Downloading artifact...repo="public.ecr.aws/aquasecurity/trivy-db:2"2024-11-01T15:29:05Z INFO [vulndb] Artifact successfully downloaded repo="public.ecr.aws/aquasecurity/trivy-db:2"2024-11-01T15:29:05Z INFO [vuln] Vulnerability scanning is enabled
2024-11-01T15:29:05Z INFO [misconfig] Misconfiguration scanning is enabled
2024-11-01T15:29:05Z INFO [misconfig] Need to update the built-in checks
2024-11-01T15:29:05Z INFO [misconfig] Downloading the built-in checks...160.60 KiB /160.60 KiB [------------------------------------------------------] 100.00%? p/s 100ms2024-11-01T15:29:06Z INFO [secret] Secret scanning is enabled
2024-11-01T15:29:06Z INFO [secret] If your scanning is slow, please try '--scanners vuln' to disable secret scanning
2024-11-01T15:29:06Z INFO [secret] Please see also https://aquasecurity.github.io/trivy/v0.56/docs/scanner/secret#recommendation for faster secret detection2024-11-01T15:29:08Z INFO [terraformscanner] Scanning root module file_path="."2024-11-01T15:29:08Z WARN [terraformparser] Variable values was not found in the environment or variable files. Evaluating may not work correctly.module="root"variables="networking"2024-11-01T15:29:09Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.aws_s3_object.user_public_keys"value="cty.NilVal"2024-11-01T15:29:09Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.data.aws_subnet.local_account"value="cty.NilVal"2024-11-01T15:29:09Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.dynamic.tag"value="cty.NilVal"2024-11-01T15:29:09Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.dynamic.tag"value="cty.NilVal"2024-11-01T15:29:10Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.expiration"value="cty.NilVal"2024-11-01T15:29:10Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.transition"value="cty.NilVal"2024-11-01T15:29:10Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.noncurrent_version_expiration"value="cty.NilVal"2024-11-01T15:29:10Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.noncurrent_version_transition"value="cty.NilVal"2024-11-01T15:29:10Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.principals"value="cty.NilVal"2024-11-01T15:29:10Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.condition"value="cty.NilVal"2024-11-01T15:29:10Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.expiration"value="cty.NilVal"2024-11-01T15:29:10Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.transition"value="cty.NilVal"2024-11-01T15:29:10Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.noncurrent_version_expiration"value="cty.NilVal"2024-11-01T15:29:10Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.noncurrent_version_transition"value="cty.NilVal"2024-11-01T15:29:10Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.principals"value="cty.NilVal"2024-11-01T15:29:10Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.condition"value="cty.NilVal"2024-11-01T15:29:11Z INFO [terraformexecutor] Ignore finding rule="aws-s3-encryption-customer-key"range="github.com/ministryofjustice/modernisation-platform-terraform-bastion-linux?ref=v4.2.0/github.com/ministryofjustice/modernisation-platform-terraform-s3-bucket?ref=568694e50e03630d99cb569eafa06a0b879a1239/main.tf:171-179"2024-11-01T15:29:11Z INFO Number of language-specific files num=02024-11-01T15:29:11Z INFO Detected config files num=9
alb.tf (terraform)
==================
Tests:3 (SUCCESSES:0, FAILURES:2, EXCEPTIONS:1)
Failures:2 (HIGH:2, CRITICAL:0)
HIGH: Application load balancer is not set to drop invalid headers.
════════════════════════════════════════
Passing unknown or invalid headers through to the target poses a potential risk of compromise.
By setting drop_invalid_header_fields to true, anything that does not conform to well known, defined headers will be removed by the load balancer.
See https://avd.aquasec.com/misconfig/avd-aws-0052
────────────────────────────────────────
alb.tf:130-153
────────────────────────────────────────
130 ┌ resource"aws_lb""external" {
131 │ name="${upper(local.application_name_short)}-LoadBalancer"132 │ internal=false133 │ load_balancer_type="application"134 │ security_groups=[aws_security_group.external_lb.id]
135 │ subnets=[data.aws_subnet.public_subnets_a.id, data.aws_subnet.public_subnets_b.id, data.aws_subnet.public_subnets_c.id]
136 │ enable_deletion_protection=local.lb_enable_deletion_protection137 │ idle_timeout=local.external_lb_idle_timeout138 └ enable_http2=false...
────────────────────────────────────────
HIGH: Load balancer is exposed publicly.
════════════════════════════════════════
There are many scenarios in which you would want to expose a load balancer to the wider internet, but this check exists as a warning to prevent accidental exposure of internal assets. You should ensure that this resource should be exposed publicly.
See https://avd.aquasec.com/misconfig/avd-aws-0053
────────────────────────────────────────
alb.tf:130-153
────────────────────────────────────────
130 ┌ resource"aws_lb""external" {
131 │ name="${upper(local.application_name_short)}-LoadBalancer"132 │ internal=false133 │ load_balancer_type="application"134 │ security_groups=[aws_security_group.external_lb.id]
135 │ subnets=[data.aws_subnet.public_subnets_a.id, data.aws_subnet.public_subnets_b.id, data.aws_subnet.public_subnets_c.id]
136 │ enable_deletion_protection=local.lb_enable_deletion_protection137 │ idle_timeout=local.external_lb_idle_timeout138 └ enable_http2=false...
────────────────────────────────────────
app_servers.tf (terraform)
==========================
Tests:5 (SUCCESSES:0, FAILURES:4, EXCEPTIONS:1)
Failures:4 (HIGH:4, CRITICAL:0)
HIGH: Instance does not require IMDS access to require a token.
════════════════════════════════════════
IMDS v2 (Instance Metadata Service) introduced session authentication tokens which improve security when talking to IMDS.
By default <code>aws_instance</code> resource sets IMDS session auth tokens to be optional.
To fully protect IMDS you need to enable session tokens by using <code>metadata_options</code> block and its <code>http_tokens</code> variable set to <code>required</code>.
See https://avd.aquasec.com/misconfig/avd-aws-0028
────────────────────────────────────────
app_servers.tf:192-194
via app_servers.tf:181-213 (aws_instance.app1)
────────────────────────────────────────
181resource"aws_instance""app1" {
...192 ┌ metadata_options {
193 │ http_tokens="optional"194 └ }
...213 }
────────────────────────────────────────
HIGH: Instance does not require IMDS access to require a token.
════════════════════════════════════════
IMDS v2 (Instance Metadata Service) introduced session authentication tokens which improve security when talking to IMDS.
By default <code>aws_instance</code> resource sets IMDS session auth tokens to be optional.
To fully protect IMDS you need to enable session tokens by using <code>metadata_options</code> block and its <code>http_tokens</code> variable set to <code>required</code>.
See https://avd.aquasec.com/misconfig/avd-aws-0028
────────────────────────────────────────
app_servers.tf:227-229
via app_servers.tf:215-248 (aws_instance.app2[0])
────────────────────────────────────────
215resource"aws_instance""app2" {
...227 ┌ metadata_options {
228 │ http_tokens="optional"229 └ }
...248 }
────────────────────────────────────────
HIGH: Root block device is not encrypted.
════════════════════════════════════════
Block devices should be encrypted to ensure sensitive data is held securely at rest.
See https://avd.aquasec.com/misconfig/avd-aws-0131
────────────────────────────────────────
app_servers.tf:196-202
via app_servers.tf:181-213 (aws_instance.app1)
────────────────────────────────────────
181resource"aws_instance""app1" {
...196 ┌ root_block_device {
197 │ tags=merge(
198 │ { "instance-scheduling" = "skip-scheduling" },
199 │ local.tags,
200 │ { "Name" = "${local.application_name_short}-app1-root" }
201 │ )
202 └ }
...
────────────────────────────────────────
HIGH: Root block device is not encrypted.
════════════════════════════════════════
Block devices should be encrypted to ensure sensitive data is held securely at rest.
See https://avd.aquasec.com/misconfig/avd-aws-0131
────────────────────────────────────────
app_servers.tf:231-237
via app_servers.tf:215-248 (aws_instance.app2[0])
────────────────────────────────────────
215resource"aws_instance""app2" {
...231 ┌ root_block_device {
232 │ tags=merge(
233 │ { "instance-scheduling" = "skip-scheduling" },
234 │ local.tags,
235 │ { "Name" = "${local.application_name_short}-app2-root" }
236 │ )
237 └ }
...
────────────────────────────────────────
backup_lambda.tf (terraform)
============================
Tests:3 (SUCCESSES:0, FAILURES:2, EXCEPTIONS:1)
Failures:2 (HIGH:2, CRITICAL:0)
HIGH: Bucket does not have encryption enabled
════════════════════════════════════════
S3 Buckets should be encrypted to protect the data that is stored within them if access is compromised.
See https://avd.aquasec.com/misconfig/avd-aws-0088
────────────────────────────────────────
backup_lambda.tf:101-107
────────────────────────────────────────
101 ┌ resource"aws_s3_bucket""scripts" {
102 │ bucket="${local.application_name_short}-${local.environment}-scripts"103 │ tags=merge(
104 │ local.tags,
105 │ { Name ="${local.application_name_short}-${local.environment}-scripts" }
106 │ )
107 └ }
────────────────────────────────────────
HIGH: Bucket does not encrypt data with a customer managed key.
════════════════════════════════════════
Encryption using AWS keys provides protection for your S3 buckets. To increase control of the encryption and manage factors like rotation use customer managed keys.
See https://avd.aquasec.com/misconfig/avd-aws-0132
────────────────────────────────────────
backup_lambda.tf:101-107
────────────────────────────────────────
101 ┌ resource"aws_s3_bucket""scripts" {
102 │ bucket="${local.application_name_short}-${local.environment}-scripts"103 │ tags=merge(
104 │ local.tags,
105 │ { Name ="${local.application_name_short}-${local.environment}-scripts" }
106 │ )
107 └ }
────────────────────────────────────────
concurrent_manager.tf (terraform)
=================================
Tests:3 (SUCCESSES:0, FAILURES:2, EXCEPTIONS:1)
Failures:2 (HIGH:2, CRITICAL:0)
HIGH: Instance does not require IMDS access to require a token.
════════════════════════════════════════
IMDS v2 (Instance Metadata Service) introduced session authentication tokens which improve security when talking to IMDS.
By default <code>aws_instance</code> resource sets IMDS session auth tokens to be optional.
To fully protect IMDS you need to enable session tokens by using <code>metadata_options</code> block and its <code>http_tokens</code> variable set to <code>required</code>.
See https://avd.aquasec.com/misconfig/avd-aws-0028
────────────────────────────────────────
concurrent_manager.tf:170-172
via concurrent_manager.tf:159-191 (aws_instance.concurrent_manager)
────────────────────────────────────────
159resource"aws_instance""concurrent_manager" {
...170 ┌ metadata_options {
171 │ http_tokens="optional"172 └ }
...191 }
────────────────────────────────────────
HIGH: Root block device is not encrypted.
════════════════════════════════════════
Block devices should be encrypted to ensure sensitive data is held securely at rest.
See https://avd.aquasec.com/misconfig/avd-aws-0131
────────────────────────────────────────
concurrent_manager.tf:174-180
via concurrent_manager.tf:159-191 (aws_instance.concurrent_manager)
────────────────────────────────────────
159resource"aws_instance""concurrent_manager" {
...174 ┌ root_block_device {
175 │ tags=merge(
176 │ { "instance-scheduling" = "skip-scheduling" },
177 │ local.tags,
178 │ { "Name" = "${local.application_name_short}-concurrent-manager-root" }
179 │ )
180 └ }
...
────────────────────────────────────────
database.tf (terraform)
=======================
Tests:3 (SUCCESSES:0, FAILURES:2, EXCEPTIONS:1)
Failures:2 (HIGH:2, CRITICAL:0)
HIGH: Instance does not require IMDS access to require a token.
════════════════════════════════════════
IMDS v2 (Instance Metadata Service) introduced session authentication tokens which improve security when talking to IMDS.
By default <code>aws_instance</code> resource sets IMDS session auth tokens to be optional.
To fully protect IMDS you need to enable session tokens by using <code>metadata_options</code> block and its <code>http_tokens</code> variable set to <code>required</code>.
See https://avd.aquasec.com/misconfig/avd-aws-0028
────────────────────────────────────────
database.tf:194-196
via database.tf:183-212 (aws_instance.database)
────────────────────────────────────────
183resource"aws_instance""database" {
...194 ┌ metadata_options {
195 │ http_tokens="optional"196 └ }
...212 }
────────────────────────────────────────
HIGH: Root block device is not encrypted.
════════════════════════════════════════
Block devices should be encrypted to ensure sensitive data is held securely at rest.
See https://avd.aquasec.com/misconfig/avd-aws-0131
────────────────────────────────────────
database.tf:198-204
via database.tf:183-212 (aws_instance.database)
────────────────────────────────────────
183resource"aws_instance""database" {
...198 ┌ root_block_device {
199 │ tags=merge(
200 │ { "instance-scheduling" = "skip-scheduling" },
201 │ local.tags,
202 │ { "Name" = "${local.application_name_short}-database-root" }
203 │ )
204 └ }
...
────────────────────────────────────────
trivy_exitcode=1
Trivy will check the following folders:
terraform/environments/contract-work-administration
Running Trivy in terraform/environments/contract-work-administration
2024-11-01T15:33:06Z INFO [vulndb] Need to update DB
2024-11-01T15:33:06Z INFO [vulndb] Downloading vulnerability DB...
2024-11-01T15:33:06Z INFO [vulndb] Downloading artifact... repo="public.ecr.aws/aquasecurity/trivy-db:2"
2024-11-01T15:33:08Z INFO [vulndb] Artifact successfully downloaded repo="public.ecr.aws/aquasecurity/trivy-db:2"
2024-11-01T15:33:08Z INFO [vuln] Vulnerability scanning is enabled
2024-11-01T15:33:08Z INFO [misconfig] Misconfiguration scanning is enabled
2024-11-01T15:33:08Z INFO [misconfig] Need to update the built-in checks
2024-11-01T15:33:08Z INFO [misconfig] Downloading the built-in checks...
160.60 KiB / 160.60 KiB [------------------------------------------------------] 100.00% ? p/s 100ms2024-11-01T15:33:09Z INFO [secret] Secret scanning is enabled
2024-11-01T15:33:09Z INFO [secret] If your scanning is slow, please try '--scanners vuln' to disable secret scanning
2024-11-01T15:33:09Z INFO [secret] Please see also https://aquasecurity.github.io/trivy/v0.56/docs/scanner/secret#recommendation for faster secret detection
2024-11-01T15:33:10Z INFO [terraform scanner] Scanning root module file_path="."
2024-11-01T15:33:10Z WARN [terraform parser] Variable values was not found in the environment or variable files. Evaluating may not work correctly. module="root" variables="networking"
2024-11-01T15:33:12Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.aws_s3_object.user_public_keys" value="cty.NilVal"
2024-11-01T15:33:12Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.data.aws_subnet.local_account" value="cty.NilVal"
2024-11-01T15:33:12Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.dynamic.tag" value="cty.NilVal"
2024-11-01T15:33:12Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.dynamic.tag" value="cty.NilVal"
2024-11-01T15:33:12Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.expiration" value="cty.NilVal"
2024-11-01T15:33:12Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.transition" value="cty.NilVal"
2024-11-01T15:33:12Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.noncurrent_version_expiration" value="cty.NilVal"
2024-11-01T15:33:12Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.noncurrent_version_transition" value="cty.NilVal"
2024-11-01T15:33:12Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.principals" value="cty.NilVal"
2024-11-01T15:33:12Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.condition" value="cty.NilVal"
2024-11-01T15:33:12Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.expiration" value="cty.NilVal"
2024-11-01T15:33:12Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.transition" value="cty.NilVal"
2024-11-01T15:33:12Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.noncurrent_version_expiration" value="cty.NilVal"
2024-11-01T15:33:12Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.noncurrent_version_transition" value="cty.NilVal"
2024-11-01T15:33:12Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.principals" value="cty.NilVal"
2024-11-01T15:33:12Z ERROR [terraform evaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable. block="module.bastion_linux.module.s3-bucket.dynamic.condition" value="cty.NilVal"
2024-11-01T15:33:14Z INFO [terraform executor] Ignore finding rule="aws-s3-encryption-customer-key" range="github.com/ministryofjustice/modernisation-platform-terraform-bastion-linux?ref=v4.2.0/github.com/ministryofjustice/modernisation-platform-terraform-s3-bucket?ref=568694e50e03630d99cb569eafa06a0b879a1239/main.tf:171-179"
2024-11-01T15:33:14Z INFO Number of language-specific files num=0
2024-11-01T15:33:14Z INFO Detected config files num=9
HIGH: Application load balancer is not set to drop invalid headers.
════════════════════════════════════════
Passing unknown or invalid headers through to the target poses a potential risk of compromise.
By setting drop_invalid_header_fields to true, anything that does not conform to well known, defined headers will be removed by the load balancer.
HIGH: Load balancer is exposed publicly.
════════════════════════════════════════
There are many scenarios in which you would want to expose a load balancer to the wider internet, but this check exists as a warning to prevent accidental exposure of internal assets. You should ensure that this resource should be exposed publicly.
HIGH: Instance does not require IMDS access to require a token.
════════════════════════════════════════
IMDS v2 (Instance Metadata Service) introduced session authentication tokens which improve security when talking to IMDS.
By default aws_instance resource sets IMDS session auth tokens to be optional.
To fully protect IMDS you need to enable session tokens by using metadata_options block and its http_tokens variable set to required.
HIGH: Instance does not require IMDS access to require a token.
════════════════════════════════════════
IMDS v2 (Instance Metadata Service) introduced session authentication tokens which improve security when talking to IMDS.
By default aws_instance resource sets IMDS session auth tokens to be optional.
To fully protect IMDS you need to enable session tokens by using metadata_options block and its http_tokens variable set to required.
HIGH: Root block device is not encrypted.
════════════════════════════════════════
Block devices should be encrypted to ensure sensitive data is held securely at rest.
HIGH: Root block device is not encrypted.
════════════════════════════════════════
Block devices should be encrypted to ensure sensitive data is held securely at rest.
HIGH: Bucket does not have encryption enabled
════════════════════════════════════════
S3 Buckets should be encrypted to protect the data that is stored within them if access is compromised.
HIGH: Bucket does not encrypt data with a customer managed key.
════════════════════════════════════════
Encryption using AWS keys provides protection for your S3 buckets. To increase control of the encryption and manage factors like rotation use customer managed keys.
HIGH: Instance does not require IMDS access to require a token.
════════════════════════════════════════
IMDS v2 (Instance Metadata Service) introduced session authentication tokens which improve security when talking to IMDS.
By default aws_instance resource sets IMDS session auth tokens to be optional.
To fully protect IMDS you need to enable session tokens by using metadata_options block and its http_tokens variable set to required.
HIGH: Root block device is not encrypted.
════════════════════════════════════════
Block devices should be encrypted to ensure sensitive data is held securely at rest.
HIGH: Instance does not require IMDS access to require a token.
════════════════════════════════════════
IMDS v2 (Instance Metadata Service) introduced session authentication tokens which improve security when talking to IMDS.
By default aws_instance resource sets IMDS session auth tokens to be optional.
To fully protect IMDS you need to enable session tokens by using metadata_options block and its http_tokens variable set to required.
HIGH: Root block device is not encrypted.
════════════════════════════════════════
Block devices should be encrypted to ensure sensitive data is held securely at rest.
*****************************
Setting default tflint config...
Running tflint --init...
Installing "terraform" plugin...
Installed "terraform" (source: github.com/terraform-linters/tflint-ruleset-terraform, version:0.9.1)
tflint will check the following folders:
terraform/environments/contract-work-administration
*****************************
Running tflint in terraform/environments/contract-work-administration
Excluding the following checks: terraform_unused_declarations
4issue(s) found:
Warning: Missing version constraint for provider "archive" in `required_providers` (terraform_required_providers)
on terraform/environments/contract-work-administration/backup_lambda.tf line 173:173:data"archive_file""connect_db" {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_required_providers.md
Warning: Missing version constraint for provider "template" in `required_providers` (terraform_required_providers)
on terraform/environments/contract-work-administration/cloudwatch.tf line 1126:1126:data"template_file""dashboard_no_ha" {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_required_providers.md
Warning: Missing version constraint for provider "local" in `required_providers` (terraform_required_providers)
on terraform/environments/contract-work-administration/data.tf line 11:11:data"local_file""cm_custom_metrics" {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_required_providers.md
Warning: Missing version constraint for provider "time" in `required_providers` (terraform_required_providers)
on terraform/environments/contract-work-administration/database.tf line 174:174:resource"time_sleep""wait_db_userdata_scripts" {
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.1/docs/rules/terraform_required_providers.mdtflint_exitcode=2
Trivy Scan Failed
Show Output
*****************************
Trivy will check the following folders:
terraform/environments/contract-work-administration
*****************************
Running Trivy in terraform/environments/contract-work-administration
2024-11-01T15:33:06Z INFO [vulndb] Need to update DB
2024-11-01T15:33:06Z INFO [vulndb] Downloading vulnerability DB...2024-11-01T15:33:06Z INFO [vulndb] Downloading artifact...repo="public.ecr.aws/aquasecurity/trivy-db:2"2024-11-01T15:33:08Z INFO [vulndb] Artifact successfully downloaded repo="public.ecr.aws/aquasecurity/trivy-db:2"2024-11-01T15:33:08Z INFO [vuln] Vulnerability scanning is enabled
2024-11-01T15:33:08Z INFO [misconfig] Misconfiguration scanning is enabled
2024-11-01T15:33:08Z INFO [misconfig] Need to update the built-in checks
2024-11-01T15:33:08Z INFO [misconfig] Downloading the built-in checks...160.60 KiB /160.60 KiB [------------------------------------------------------] 100.00%? p/s 100ms2024-11-01T15:33:09Z INFO [secret] Secret scanning is enabled
2024-11-01T15:33:09Z INFO [secret] If your scanning is slow, please try '--scanners vuln' to disable secret scanning
2024-11-01T15:33:09Z INFO [secret] Please see also https://aquasecurity.github.io/trivy/v0.56/docs/scanner/secret#recommendation for faster secret detection2024-11-01T15:33:10Z INFO [terraformscanner] Scanning root module file_path="."2024-11-01T15:33:10Z WARN [terraformparser] Variable values was not found in the environment or variable files. Evaluating may not work correctly.module="root"variables="networking"2024-11-01T15:33:12Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.aws_s3_object.user_public_keys"value="cty.NilVal"2024-11-01T15:33:12Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.data.aws_subnet.local_account"value="cty.NilVal"2024-11-01T15:33:12Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.dynamic.tag"value="cty.NilVal"2024-11-01T15:33:12Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.dynamic.tag"value="cty.NilVal"2024-11-01T15:33:12Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.expiration"value="cty.NilVal"2024-11-01T15:33:12Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.transition"value="cty.NilVal"2024-11-01T15:33:12Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.noncurrent_version_expiration"value="cty.NilVal"2024-11-01T15:33:12Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.noncurrent_version_transition"value="cty.NilVal"2024-11-01T15:33:12Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.principals"value="cty.NilVal"2024-11-01T15:33:12Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.condition"value="cty.NilVal"2024-11-01T15:33:12Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.expiration"value="cty.NilVal"2024-11-01T15:33:12Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.transition"value="cty.NilVal"2024-11-01T15:33:12Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.noncurrent_version_expiration"value="cty.NilVal"2024-11-01T15:33:12Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.noncurrent_version_transition"value="cty.NilVal"2024-11-01T15:33:12Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.principals"value="cty.NilVal"2024-11-01T15:33:12Z ERROR [terraformevaluator] Failed to expand block. Invalid "for-each" argument. Must be known and iterable.block="module.bastion_linux.module.s3-bucket.dynamic.condition"value="cty.NilVal"2024-11-01T15:33:14Z INFO [terraformexecutor] Ignore finding rule="aws-s3-encryption-customer-key"range="github.com/ministryofjustice/modernisation-platform-terraform-bastion-linux?ref=v4.2.0/github.com/ministryofjustice/modernisation-platform-terraform-s3-bucket?ref=568694e50e03630d99cb569eafa06a0b879a1239/main.tf:171-179"2024-11-01T15:33:14Z INFO Number of language-specific files num=02024-11-01T15:33:14Z INFO Detected config files num=9
alb.tf (terraform)
==================
Tests:3 (SUCCESSES:0, FAILURES:2, EXCEPTIONS:1)
Failures:2 (HIGH:2, CRITICAL:0)
HIGH: Application load balancer is not set to drop invalid headers.
════════════════════════════════════════
Passing unknown or invalid headers through to the target poses a potential risk of compromise.
By setting drop_invalid_header_fields to true, anything that does not conform to well known, defined headers will be removed by the load balancer.
See https://avd.aquasec.com/misconfig/avd-aws-0052
────────────────────────────────────────
alb.tf:130-153
────────────────────────────────────────
130 ┌ resource"aws_lb""external" {
131 │ name="${upper(local.application_name_short)}-LoadBalancer"132 │ internal=false133 │ load_balancer_type="application"134 │ security_groups=[aws_security_group.external_lb.id]
135 │ subnets=[data.aws_subnet.public_subnets_a.id, data.aws_subnet.public_subnets_b.id, data.aws_subnet.public_subnets_c.id]
136 │ enable_deletion_protection=local.lb_enable_deletion_protection137 │ idle_timeout=local.external_lb_idle_timeout138 └ enable_http2=false...
────────────────────────────────────────
HIGH: Load balancer is exposed publicly.
════════════════════════════════════════
There are many scenarios in which you would want to expose a load balancer to the wider internet, but this check exists as a warning to prevent accidental exposure of internal assets. You should ensure that this resource should be exposed publicly.
See https://avd.aquasec.com/misconfig/avd-aws-0053
────────────────────────────────────────
alb.tf:130-153
────────────────────────────────────────
130 ┌ resource"aws_lb""external" {
131 │ name="${upper(local.application_name_short)}-LoadBalancer"132 │ internal=false133 │ load_balancer_type="application"134 │ security_groups=[aws_security_group.external_lb.id]
135 │ subnets=[data.aws_subnet.public_subnets_a.id, data.aws_subnet.public_subnets_b.id, data.aws_subnet.public_subnets_c.id]
136 │ enable_deletion_protection=local.lb_enable_deletion_protection137 │ idle_timeout=local.external_lb_idle_timeout138 └ enable_http2=false...
────────────────────────────────────────
app_servers.tf (terraform)
==========================
Tests:5 (SUCCESSES:0, FAILURES:4, EXCEPTIONS:1)
Failures:4 (HIGH:4, CRITICAL:0)
HIGH: Instance does not require IMDS access to require a token.
════════════════════════════════════════
IMDS v2 (Instance Metadata Service) introduced session authentication tokens which improve security when talking to IMDS.
By default <code>aws_instance</code> resource sets IMDS session auth tokens to be optional.
To fully protect IMDS you need to enable session tokens by using <code>metadata_options</code> block and its <code>http_tokens</code> variable set to <code>required</code>.
See https://avd.aquasec.com/misconfig/avd-aws-0028
────────────────────────────────────────
app_servers.tf:192-194
via app_servers.tf:181-213 (aws_instance.app1)
────────────────────────────────────────
181resource"aws_instance""app1" {
...192 ┌ metadata_options {
193 │ http_tokens="optional"194 └ }
...213 }
────────────────────────────────────────
HIGH: Instance does not require IMDS access to require a token.
════════════════════════════════════════
IMDS v2 (Instance Metadata Service) introduced session authentication tokens which improve security when talking to IMDS.
By default <code>aws_instance</code> resource sets IMDS session auth tokens to be optional.
To fully protect IMDS you need to enable session tokens by using <code>metadata_options</code> block and its <code>http_tokens</code> variable set to <code>required</code>.
See https://avd.aquasec.com/misconfig/avd-aws-0028
────────────────────────────────────────
app_servers.tf:227-229
via app_servers.tf:215-248 (aws_instance.app2[0])
────────────────────────────────────────
215resource"aws_instance""app2" {
...227 ┌ metadata_options {
228 │ http_tokens="optional"229 └ }
...248 }
────────────────────────────────────────
HIGH: Root block device is not encrypted.
════════════════════════════════════════
Block devices should be encrypted to ensure sensitive data is held securely at rest.
See https://avd.aquasec.com/misconfig/avd-aws-0131
────────────────────────────────────────
app_servers.tf:196-202
via app_servers.tf:181-213 (aws_instance.app1)
────────────────────────────────────────
181resource"aws_instance""app1" {
...196 ┌ root_block_device {
197 │ tags=merge(
198 │ { "instance-scheduling" = "skip-scheduling" },
199 │ local.tags,
200 │ { "Name" = "${local.application_name_short}-app1-root" }
201 │ )
202 └ }
...
────────────────────────────────────────
HIGH: Root block device is not encrypted.
════════════════════════════════════════
Block devices should be encrypted to ensure sensitive data is held securely at rest.
See https://avd.aquasec.com/misconfig/avd-aws-0131
────────────────────────────────────────
app_servers.tf:231-237
via app_servers.tf:215-248 (aws_instance.app2[0])
────────────────────────────────────────
215resource"aws_instance""app2" {
...231 ┌ root_block_device {
232 │ tags=merge(
233 │ { "instance-scheduling" = "skip-scheduling" },
234 │ local.tags,
235 │ { "Name" = "${local.application_name_short}-app2-root" }
236 │ )
237 └ }
...
────────────────────────────────────────
backup_lambda.tf (terraform)
============================
Tests:3 (SUCCESSES:0, FAILURES:2, EXCEPTIONS:1)
Failures:2 (HIGH:2, CRITICAL:0)
HIGH: Bucket does not have encryption enabled
════════════════════════════════════════
S3 Buckets should be encrypted to protect the data that is stored within them if access is compromised.
See https://avd.aquasec.com/misconfig/avd-aws-0088
────────────────────────────────────────
backup_lambda.tf:101-107
────────────────────────────────────────
101 ┌ resource"aws_s3_bucket""scripts" {
102 │ bucket="${local.application_name_short}-${local.environment}-scripts"103 │ tags=merge(
104 │ local.tags,
105 │ { Name ="${local.application_name_short}-${local.environment}-scripts" }
106 │ )
107 └ }
────────────────────────────────────────
HIGH: Bucket does not encrypt data with a customer managed key.
════════════════════════════════════════
Encryption using AWS keys provides protection for your S3 buckets. To increase control of the encryption and manage factors like rotation use customer managed keys.
See https://avd.aquasec.com/misconfig/avd-aws-0132
────────────────────────────────────────
backup_lambda.tf:101-107
────────────────────────────────────────
101 ┌ resource"aws_s3_bucket""scripts" {
102 │ bucket="${local.application_name_short}-${local.environment}-scripts"103 │ tags=merge(
104 │ local.tags,
105 │ { Name ="${local.application_name_short}-${local.environment}-scripts" }
106 │ )
107 └ }
────────────────────────────────────────
concurrent_manager.tf (terraform)
=================================
Tests:3 (SUCCESSES:0, FAILURES:2, EXCEPTIONS:1)
Failures:2 (HIGH:2, CRITICAL:0)
HIGH: Instance does not require IMDS access to require a token.
════════════════════════════════════════
IMDS v2 (Instance Metadata Service) introduced session authentication tokens which improve security when talking to IMDS.
By default <code>aws_instance</code> resource sets IMDS session auth tokens to be optional.
To fully protect IMDS you need to enable session tokens by using <code>metadata_options</code> block and its <code>http_tokens</code> variable set to <code>required</code>.
See https://avd.aquasec.com/misconfig/avd-aws-0028
────────────────────────────────────────
concurrent_manager.tf:170-172
via concurrent_manager.tf:159-191 (aws_instance.concurrent_manager)
────────────────────────────────────────
159resource"aws_instance""concurrent_manager" {
...170 ┌ metadata_options {
171 │ http_tokens="optional"172 └ }
...191 }
────────────────────────────────────────
HIGH: Root block device is not encrypted.
════════════════════════════════════════
Block devices should be encrypted to ensure sensitive data is held securely at rest.
See https://avd.aquasec.com/misconfig/avd-aws-0131
────────────────────────────────────────
concurrent_manager.tf:174-180
via concurrent_manager.tf:159-191 (aws_instance.concurrent_manager)
────────────────────────────────────────
159resource"aws_instance""concurrent_manager" {
...174 ┌ root_block_device {
175 │ tags=merge(
176 │ { "instance-scheduling" = "skip-scheduling" },
177 │ local.tags,
178 │ { "Name" = "${local.application_name_short}-concurrent-manager-root" }
179 │ )
180 └ }
...
────────────────────────────────────────
database.tf (terraform)
=======================
Tests:3 (SUCCESSES:0, FAILURES:2, EXCEPTIONS:1)
Failures:2 (HIGH:2, CRITICAL:0)
HIGH: Instance does not require IMDS access to require a token.
════════════════════════════════════════
IMDS v2 (Instance Metadata Service) introduced session authentication tokens which improve security when talking to IMDS.
By default <code>aws_instance</code> resource sets IMDS session auth tokens to be optional.
To fully protect IMDS you need to enable session tokens by using <code>metadata_options</code> block and its <code>http_tokens</code> variable set to <code>required</code>.
See https://avd.aquasec.com/misconfig/avd-aws-0028
────────────────────────────────────────
database.tf:194-196
via database.tf:183-212 (aws_instance.database)
────────────────────────────────────────
183resource"aws_instance""database" {
...194 ┌ metadata_options {
195 │ http_tokens="optional"196 └ }
...212 }
────────────────────────────────────────
HIGH: Root block device is not encrypted.
════════════════════════════════════════
Block devices should be encrypted to ensure sensitive data is held securely at rest.
See https://avd.aquasec.com/misconfig/avd-aws-0131
────────────────────────────────────────
database.tf:198-204
via database.tf:183-212 (aws_instance.database)
────────────────────────────────────────
183resource"aws_instance""database" {
...198 ┌ root_block_device {
199 │ tags=merge(
200 │ { "instance-scheduling" = "skip-scheduling" },
201 │ local.tags,
202 │ { "Name" = "${local.application_name_short}-database-root" }
203 │ )
204 └ }
...
────────────────────────────────────────
trivy_exitcode=1
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.