attackmap-analyzer-terraform
Terraform / HCL infrastructure-as-code analyzer for AttackMap.
This analyzer is shaped differently from language analyzers — Terraform doesn't have routes in the application sense. Instead, it extracts:
- Public ingress — security groups (
ingressblocks only; open egress is ignored) and inbound firewall rules with0.0.0.0/0/::/0, Lambda Function URLs with no auth, API Gateway methods withauthorization = "NONE", S3 buckets with public ACLs (inline oraws_s3_bucket_acl), public bucket policies or disabled public-access blocks →entrypoint_hints - Asset inventory — S3 buckets, Azure storage accounts, GCS buckets, KMS keys, Cognito user pools →
service_hints - Databases —
aws_db_instanceandaws_rds_cluster(engine-aware: postgres / mysql / oracle / sqlserver / mariadb),aws_dynamodb_table,aws_elasticache_*,aws_documentdb_*, Azure PostgreSQL/MySQL/CosmosDB, GCP Cloud SQL →database_hints - Secrets —
aws_secretsmanager_secret,aws_ssm_parameter(SecureString),azurerm_key_vault, plusvariableblocks markedsensitive = trueor with secret-shaped names (*secret*,*token*,*password*,*key*), and secret-shaped string literals in.tfvars(kind="hardcoded") →secret_hints. A secret variable with a literal stringdefaultiskind="hardcoded"(the value is never echoed); a bare declaration keeps the default kind. - IAM blast radius — Allow statements with
Action "*"(0.7),Resource "*"(0.5) or unconditionedPrincipal "*"(0.7) inaws_iam_*_policy,aws_iam_roletrust/inline policies anddata "aws_iam_policy_document"→auth_hints - Cognito —
aws_cognito_user_pool→auth_hints - Modules —
module "x" { source = ... }→service_hintskeyedmodule:x - Misconfigurations →
cloud_misconfigs(AttackMap'sCloudMisconfigrecord, which core turns into findings with CWE/OWASP ids). Each record names the resource, carries itsfor_each/countand, for resources inside a local module, themodule.<name> (file:line)blocks that call it:iac_module_unpinned: git module sources without?ref=or pinned to a branch (main,master,develop, ...), and registry modules withoutversion. A tag (?ref=v1.2.3) or commit SHA is pinned.public_network_access:associate_public_ip_address = true(aws_instance, launch configurations and templates),publicly_accessible = trueRDS, andpublic_network_access_enabled = trueon anyazurerm_*resource.public_cluster_endpoint:aws_eks_clusterwhose API endpoint is public and open to0.0.0.0/0(both are the defaults, reported with lower confidence when left implicit).plaintext_listener:aws_lb_listeneronHTTPwithout a redirect default action, unless its load balancer isinternal = true.api_no_authorizer: API Gateway v1 methods withauthorization = "NONE"and no API key, and v2 HTTP routes withauthorization_type = "NONE"or none at all (the default).OPTIONS(CORS preflight) is skipped.unencrypted_storage:storage_encrypted = falseonaws_db_instance/aws_rds_cluster, andaws_db_instancewithout it (defaults to false; replicas, snapshot restores andkms_key_idare skipped).public_data_access: public S3 ACLs and policies, disabled public-access blocks, OpenSearch / Elasticsearchaccess_policiesopen toPrincipal "*", GCS buckets granted toallUsers/allAuthenticatedUsers(IAM, ACLs,predefined_acl = "publicRead"),allow_nested_items_to_be_public = trueand publicazurerm_storage_containers.public_invoker: Cloud Run / Cloud Functions invoker roles granted toallUsers/allAuthenticatedUsers, and Lambda function URLs withauthorization_type = "NONE".- kubernetes provider: privileged containers,
allow_privilege_escalation = true,host_network/host_pid/host_ipc,host_pathvolumes (high for the runtime socket,/,/etc,/proc,/var/lib/kubelet, ...),cluster-adminorsystem:authenticatedbindings, roles with*/escalate/bind/impersonate/pods/exec/ Secret read, andLoadBalancer/NodePortservices withoutload_balancer_source_ranges. - Only literal values are judged: an attribute set from
var.xor another reference is skipped.
- API Gateway v2 routes —
aws_apigatewayv2_routewithroute_key = "POST /charges"→ actualRouteentries - API Gateway v1 routes —
aws_api_gateway_methodon anaws_api_gateway_resourcechain (parent_id/path_partjoined back toroot_resource_id, across files) →Routeentries - Lambda function URLs —
aws_lambda_function_url→ anANY /Route - Route auth (AttackMap#256) — every route carries
auth/guards/guard_evidence.authorization/authorization_type=AWS_IAM,COGNITO_USER_POOLS,CUSTOMorJWT(or v1api_key_required = true) →required."NONE"written out →anonymous. Omitted or computed (var.x) →unknown.
All emissions populate AttackMap's Signal v2 fields (line numbers + evidence snippets) so downstream insights can cite infra/main.tf:NN.
Install
uv tool install attackmap --with attackmap-analyzer-terraform # from PyPI
# or: pip install attackmap-analyzer-terraform (installs attackmap too)
# or from source:
pip install git+https://github.com/mlaify/attackmap-analyzer-terraform.git
The analyzer is auto-discovered by AttackMap via the attackmap.analyzers entry-point group.
Usage with AttackMap
# Auto-discovered when installed:
attackmap analyze /path/to/terraform/repo
# Or invoke explicitly:
attackmap analyze /path/to/terraform/repo --module terraform
Detection
detect() returns true when any .tf, .tf.json, or .tfvars file is present in the tree, ignoring .terraform/ and AttackMap's shared skip list (.git/, node_modules/, vendor/, build/, dist/, out/, target/, ...). Skip directories are matched only inside the repo, so a checkout under e.g. /build/... is still scanned. Files are walked with attackmap.sdk.iter_repo_files, which does not follow symlinks out of the repo.
HCL block parsing
The analyzer parses HCL block bodies via brace-depth counting (with string-literal awareness so "{" inside strings" doesn't throw off the counter). Nested blocks like multiple ingress { } blocks inside a security group are handled correctly. Variable interpolation (${var.foo}, aws_iam_role.app.id) is not resolved — string literals and direct attribute values are what get extracted.
Coverage notes
- AWS is the most thoroughly covered provider. Azure and GCP have basic coverage (NSG/firewall open ingress, Storage Account / GCS bucket as service hints, PostgreSQL/MySQL/CosmosDB/CloudSQL as databases) — extend per resource type as needed.
- IAM wildcard detection matches JSON-shaped (
"Action": "*", heredoc or.tf.jsonstring) and HCL-shaped (Action = "*"injsonencode,actions = ["*"]inaws_iam_policy_document) policies. Apolicy = data.aws_iam_policy_document.x.jsonreference isn't followed; the data source is reported under its own name. .tf.jsonfiles get the same analysis as.tf..tfvarsfiles are checked for secret-shaped string literals (reported askind="hardcoded"with the value redacted).- API Gateway v1 methods become routes when their
resource_idresolves through literalaws_api_gateway_resourceblocks to aroot_resource_id. Methods on resources from modules or with interpolatedpath_parts only emit entrypoint hints. OpenAPIbody-defined REST APIs aren't parsed. - Lambda Function URLs with
authorization_type = "NONE"are flagged as open entrypoints. IAM-authorized URLs are emitted with the regularlambda_url:prefix. - Database
publicly_accessible = trueonaws_db_instanceproduces a separaterds_publicly_accessible:entrypoint hint in addition to the standard database hint.
License
MIT
Metadata
Release files for attackmap-analyzer-terraform 0.2.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| attackmap_analyzer_terraform-0.2.2.tar.gz | 51.1 kB | With provenance | Details for attackmap_analyzer_terraform-0.2.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| attackmap_analyzer_terraform-0.2.2-py3-none-any.whl | Python 3 | none | any | Details for attackmap_analyzer_terraform-0.2.2-py3-none-any.whl |
Total release size: 83.7 kB
Release files / attackmap_analyzer_terraform-0.2.2.tar.gz
| Download URL | attackmap_analyzer_terraform-0.2.2.tar.gz |
|---|---|
| Size | 51.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2f2c3ac3b3a6a5071ac3efb16c89646f74d4d46398357c71edd27037cac24c26
|
|
BLAKE2b-256 checksum How to use checksums |
bb9a8e934a131ff890a04305aeee669fb2e8177901fa2f9732f8c3a1626cabf6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 14, 2026.
Transparency logRelease files / attackmap_analyzer_terraform-0.2.2-py3-none-any.whl
| Download URL | attackmap_analyzer_terraform-0.2.2-py3-none-any.whl |
|---|---|
| Size | 32.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d676459fd2aa1effb8085caf91b29477d27a8712cab231576128d1541cddb3b4
|
|
BLAKE2b-256 checksum How to use checksums |
fc67dd2c7d2bdd09607de0593955635ac26949294ef180cafbae86d20dd9e5e2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 14, 2026.
Transparency logSecurity for attackmap-analyzer-terraform 0.2.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for attackmap_analyzer_terraform-0.2.2.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 14, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.