Skip to content

Commit f6b3e6b

Browse files
committed
feat: add security check for CORS configuration to warn against open origins
1 parent 9037237 commit f6b3e6b

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

infrastructure/terraform/api_gateway.tf

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,3 +99,17 @@ resource "aws_lambda_permission" "check_status_apigw" {
9999
principal = "apigateway.amazonaws.com"
100100
source_arn = "${aws_apigatewayv2_api.api.execution_arn}/*/*"
101101
}
102+
103+
# =============================================================================
104+
# Security checks
105+
# =============================================================================
106+
107+
# Emit a non-fatal warning when CORS is open to all origins.
108+
# This is acceptable during development but should be restricted in production
109+
# to the GitHub Pages URL (e.g., ["https://yourusername.github.io"]).
110+
check "cors_not_wildcard" {
111+
assert {
112+
condition = !contains(var.allowed_origins, "*")
113+
error_message = "WARNING: allowed_origins contains '*' — CORS is open to every origin. Restrict to your frontend URL in production (e.g., [\"https://yourusername.github.io\"])."
114+
}
115+
}

0 commit comments

Comments
 (0)