cncoder/serverless-litellm/cloudfront-waf-hardening
Claude Code and agent skill by cncoder/serverless-litellm
- community
Checking that the SKILL.md file is still in the repository.
Harden ALB-backed services (LiteLLM, generic APIs) behind CloudFront + WAF. Creates CloudFront distribution with secret origin header, WAF Web ACL with path whitelist, and locks down ALB Security Group to CloudFront-only. Use when deploying any internet-facing ALB service that should not be directly accessible.
Install
npx vskill@latest install cncoder/serverless-litellm/cloudfront-waf-hardeningSKILL.md
The same SKILL.md was published earlier as cncoder/serverless-litellm/cloudfront-waf-hardening.
CloudFront + WAF Hardening
Lock down an ALB-backed service so it is only reachable through CloudFront, with WAF path-level access control.
When to Activate
- Deploying LiteLLM (or any API proxy) on EKS/ECS behind an ALB
- User asks to "add CloudFront" or "lock down ALB" or "hide the ALB"
- Hardening an existing internet-facing ALB
- Restricting public access to API-only paths (no Admin UI)
Architecture
Three layers of defense:
- ALB Security Group — only allows CloudFront IP ranges (AWS managed prefix list)
- WAF header verification — blocks requests without the correct
X-CloudFront-Secret - WAF path whitelist — even valid CloudFront requests are blocked if the path is not allowed
Prerequisites
- AWS CLI v2 with sufficient IAM permissions (wafv2, cloudfront, ec2, elasticloadbalancing)
- An existing ALB with a known ARN
- The ALB's Security Group ID
- (Optional) An existing K8s Ingress group if using EKS ALB Controller
Step-by-Step Procedure
Step 1: Generate a CloudFront Secret
Store this value securely. It will be configured in both CloudFront (origin header) and WAF (match rule).
Step 2: Create CloudFront Distribution
Generate the distribution config with a custom origin header:
Key config notes:
- CachePolicyId
4135ea2d-...= AWS managedCachingDisabled(pass everything through) - OriginRequestPolicyId
216adef6-...= AWS managedAllViewer(forward all headers/query strings) - OriginReadTimeout = 60s (max default; request AWS Support increase for >60s non-streaming)
- Streaming responses (SSE) are NOT limited by OriginReadTimeout
Step 3: Lock Down ALB Security Group
Remove any 0.0.0.0/0 or specific IP rules, replace with CloudFront managed prefix list:
IMPORTANT: Review existing SG rules before revoking. Only remove rules that allowed direct public access. Keep internal/VPC rules intact.
Step 4: Create WAF Web ACL with Path Whitelist
Step 5: Associate WAF with ALB
Step 6: Verify
Run these tests to confirm the hardening is complete:
Path Whitelist Templates
LiteLLM (API proxy only, no Admin UI)
LiteLLM (API + key management)
LiteLLM (full access including Admin UI)
Generic API service
Modifying Path Whitelist
To update allowed paths after initial setup:
Timeout Considerations
| Component | Default | Recommended for LLM | Notes | |
|---|---|---|---|---|
| CloudFront OriginReadTimeout | 30s | 60s (max default) | Request AWS Support for >60s | |
| ALB Idle Timeout | 60s | 600s | aws elbv2 modify-load-balancer-attributes | |
| LiteLLM request_timeout | 600s | 600s | In proxy config YAML | |
| K8s Ingress idle timeout | 60s | 600s | alb.ingress.kubernetes.io/load-balancer-attributes: idle_timeout.seconds=600 |
Streaming (SSE): CloudFront OriginReadTimeout does NOT apply to streaming responses. Once the first byte arrives within the timeout window, the stream continues indefinitely.
Rollback
If something breaks:
Gotchas & Lessons Learned
- WAF SearchString is base64-encoded in
--cli-input-json— usebase64.b64encode()in Python - CloudFront `ForwardedValues` conflicts with CachePolicyId — never set both; remove ForwardedValues entirely when using cache policies
- CloudFront OriginReadTimeout max is 60s by default — need AWS Support ticket for higher values. Does NOT affect streaming.
- WAF association may silently fail — always verify with
get-web-acl-for-resourceafter associating - SG prefix list vs CIDR — use the AWS managed prefix list
com.amazonaws.global.cloudfront.origin-facing(auto-updated), not hardcoded CloudFront IP ranges - Test WAF from a clean network — local proxy/VPN may interfere with WAF testing (Stash proxy, corporate VPN, etc.)
Cost Impact
| Resource | Monthly Cost | |
|---|---|---|
| CloudFront | ~$0-5 (low traffic API) | |
| WAF Web ACL | ~$5 + $0.60/M requests | |
| No additional ALB cost | $0 (same ALB) |
Total additional cost: ~$5-10/month for production-grade security hardening.
Security
- Security scanPassed, 95 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/cloudfront-waf-hardening/SKILL.md
Popularity
- 7-day trend score
- 5
Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/cncoder/serverless-litellm/cloudfront-waf-hardening)