Phase 6 · API Gateways, Rate Limiting, and Key Lifecycle · Lesson 2 of 2
Exercise
·
20 min
·
+20 pts
A rate-limiting and key-management policy is where the gateway concepts become concrete: you decide, tier by tier, how fast each caller may go, how much they get per month, and how their keys are scoped, rotated, and revoked. In this exercise you design that policy for MeshAPI, a company exposing one public API across five consumer tiers. First make two design decisions, then write the full policy as YAML — the shape a gateway's configuration actually takes.
MeshAPI exposes a single REST API consumed by five tiers:
Quick check
The internal-service tier is MeshAPI's own services calling each other inside the zero-trust mesh. How should they authenticate and be rate-limited?
Quick check
A Pro customer reports their API key was committed to a public GitHub repo. What is the correct response?
The free tier discovering you forgot to set a rate limit
Now write the full policy. For each of the five tiers define the authentication method, the rate limit (with the algorithm), the monthly quota, the key scopes, and the rotation/revocation policy. Replace every placeholder comment.
Exercise
~15 min
Design MeshAPI's rate-limit and key-management policy
OWASP API4 + SOC 2 CC6.1 Finding
Define rate limits and key lifecycle for five API tiers
ID:
API-GW-6.3.2
Criterion:
Each tier limited and metered; keys scoped, rotated, and revocable; internal uses mTLS
Severity:
Design task
Design authentication, rate limits, quotas, key scopes, and rotation/revocation for MeshAPI's anonymous, free, pro, enterprise, and internal-service tiers.
Auditor Notes
Limits scale by tier and are keyed on the API key / authenticated identity, not IP. Anonymous: no key, low IP-or-global limit, read-only public scope only. Free: one key, tight rate limit + low monthly quota, read scope. Pro: higher limit + quota, read/write scope, scheduled rotation (e.g. 90d), immediate revoke on leak. Enterprise: negotiated high limits + SLA, scoped keys, rotation + revoke. Internal-service: mTLS (no bearer key), very high/no public limit but still metered + logged for anomaly detection. All tiers: rate limit returns 429 with Retry-After; keys stored as hashes; revocation tied to offboarding/leak with logged timestamp + reason.
Write your remediation plan in YAML below. Fill in every field — replace all placeholder comments.
A rate-limit and key policy is the gateway turning "secure and meter the API" into concrete, auditable configuration: limits that scale by tier and are keyed on identity (not IP), quotas tied to plans, least-privilege scopes per key, mTLS for internal service traffic, and a key lifecycle where rotation is routine and revocation is immediate and logged. This is the direct mitigation for OWASP API4 and the source of much of your access-control evidence. You now have all three layers of API security — auth, the OWASP failure modes, and the gateway that enforces them. The capstone brings them together on one company's API.