Skip to content

sec(iac): require AWS_IAM auth on production Lambda Function URL (closes #424)#885

Closed
cristim wants to merge 1 commit into
feat/multicloud-web-frontendfrom
fix/424-wave21
Closed

sec(iac): require AWS_IAM auth on production Lambda Function URL (closes #424)#885
cristim wants to merge 1 commit into
feat/multicloud-web-frontendfrom
fix/424-wave21

Conversation

@cristim
Copy link
Copy Markdown
Member

@cristim cristim commented May 30, 2026

Summary

  • Set enable_cdn = true in github-prod.tfvars and github-staging.tfvars, which activates the full AWS_IAM auth chain for the Lambda Function URL in production and staging environments.
  • The compute.tf local lambda_function_url_auth_type is derived from enable_cdn, so this single lever closes the exposure described in sec(iac): production Lambda Function URL uses authorization_type=NONE — no IAM gate #424 without touching any module logic.
  • Dev environment retains enable_cdn = false (auth_type = NONE) because the browser-served SPA hits the Lambda URL directly and cannot SigV4-sign.

Auth chain (prod/staging with enable_cdn = true)

Browser -> CloudFront distribution
  -> OAC (aws_cloudfront_origin_access_control.lambda, signing_behavior = "always", sigv4)
    -> Lambda Function URL (authorization_type = "AWS_IAM")
      <- aws_lambda_permission.function_url_cloudfront
         (principal = cloudfront.amazonaws.com, source_arn = distribution ARN)

The Function URL rejects every request not SigV4-signed by the OAC-bearing distribution. Direct hits to the Function URL hostname return HTTP 403, even for requests with valid application-layer credentials.

The OAC resource, the CloudFront permission, and the derived auth-type local were all introduced in the base branch (feat/multicloud-web-frontend) as part of the preparatory refactor. This PR activates the mechanism for prod and staging by flipping enable_cdn = true.

Rollout notes

  • Production and staging are not yet deployed (the lambda_allowed_origins still carry .invalid placeholder origins). Any accidental terraform apply will fail fast at hostname resolution until the operator sets real origins and custom domain names.
  • When the environments are provisioned, set lambda_allowed_origins to the CloudFront distribution domain (or custom domain if configured) before applying.

Test plan

  • Verify terraform fmt -check passes on changed files (CI)
  • Verify tflint passes on terraform/environments/aws/ (CI)
  • Confirm locals.lambda_function_url_auth_type = "AWS_IAM" for prod/staging plan output after enable_cdn = true
  • Confirm aws_lambda_permission.function_url_cloudfront[0] is created (count = 1) in plan
  • Confirm aws_lambda_permission.function_url[0] (principal = "*") is NOT created in plan (count = 0 when auth_type = AWS_IAM)
  • Post-deploy: confirm direct HTTP request to Lambda Function URL returns 403
  • Post-deploy: confirm browser via CloudFront returns 200

Closes #424

 #424)

Set enable_cdn = true in github-prod.tfvars and github-staging.tfvars.
The compute.tf local derives lambda_function_url_auth_type = "AWS_IAM"
when enable_cdn = true, so these two tfvars changes are the single lever
that activates the full security chain:

  CloudFront OAC (frontend module) -> SigV4-signed request
    -> Lambda Function URL (authorization_type = AWS_IAM)
      -> aws_lambda_permission.function_url_cloudfront
         (principal = cloudfront.amazonaws.com, source_arn = distribution ARN)

The dev environment retains enable_cdn = false (NONE auth) because the
browser-served SPA hits the Lambda URL directly and cannot SigV4-sign.
Auth in dev is enforced at the application layer (login session, CSRF,
API keys) as documented in compute.tf.

Prod and staging lambda_allowed_origins still carry .invalid placeholders
(the envs are not yet deployed); any accidental terraform apply will fail
fast at hostname resolution until the operator supplies real origins.
@cristim cristim added triaged Item has been triaged priority/p1 Next up; this sprint severity/high Significant harm urgency/this-sprint Within the current sprint impact/all-users Affects every user effort/m Days type/security Security finding labels May 30, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 30, 2026

Warning

Review limit reached

@cristim, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 37 minutes and 17 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: abdb9c43-578f-4a3d-850f-50d68d4513e6

📥 Commits

Reviewing files that changed from the base of the PR and between 4956d66 and f36330b.

📒 Files selected for processing (2)
  • terraform/environments/aws/github-prod.tfvars
  • terraform/environments/aws/github-staging.tfvars
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/424-wave21

Comment @coderabbitai help to get the list of available commands and usage tips.

@cristim
Copy link
Copy Markdown
Member Author

cristim commented May 30, 2026

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 30, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@cristim cristim closed this May 31, 2026
@cristim cristim deleted the fix/424-wave21 branch June 3, 2026 21:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

effort/m Days impact/all-users Affects every user priority/p1 Next up; this sprint severity/high Significant harm triaged Item has been triaged type/security Security finding urgency/this-sprint Within the current sprint

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant