Secure REST APIs with OWASP API Security Top 10
OWASP API Security Top 10 is a defender checklist for REST and similar APIs: stop broken object-level authorisation, enforce authentication, limit data exposure and abuse, harden config and business flows, and log what matters — without treating the list as an attack recipe.
Friends! In an app "logged in = safe" is false. API endpoints handle object IDs, tokens, rate limits, and schemas. Today: OWASP API Security Top 10 defence view — high-level risks + blue habits. No exploit PoC. Own lab / written authorisation only.
मित्रांनो! App मध्ये "login झाला = safe" नाही. API endpoints object IDs, tokens, rate limits, and schemas handle करतात. आज OWASP API Security Top 10 defence view — high-level risks + blue habits. Exploit PoC नाही. Own lab / written authorisation only.
मित्रों! App में "login हो गया = safe" नहीं. API endpoints object IDs, tokens, rate limits, and schemas handle करते हैं. आज OWASP API Security Top 10 defence view — high-level risks + blue habits. Exploit PoC नहीं. Own lab / written authorisation only.
Quick answer
Secure REST APIs — vertical defender checklist:
- Authorise every object access (user A must not read user B’s
/orders/{id}). - Authenticate strongly; expire and rotate tokens; never put secrets in URLs.
- Return only fields the client needs (mass assignment / excess data out).
- Rate-limit and detect abuse (credential stuffing, scraping bursts).
- Validate schemas; reject unexpected properties.
- Harden admin and debug endpoints; no open Swagger in production without auth.
- Log auth failures, authz denials, and admin API use — with owners who wake up.
Tiny mental model:
Client → Gateway (authn / authz / rate / schema) → API → data
Broken object authz = IDOR-class pain
“Works in Postman” ≠ production-safe
What do I need before this guide?
- Web risk vocabulary: OWASP Top 10 explained simply.
- Optional access-control cousin: What is XSS and how to prevent it (different bug class, same “untrusted input” mindset).
- Optional cloud identity: Cloud IAM least privilege.
What is the OWASP API Security Top 10 (defence view)?
Client requests hit an API gateway that enforces authn, authz, rate limits and logging before the REST API and data store.
Client requests API gateway ला भेटतात जे authn, authz, rate limits आणि logging enforce करतो REST API आणि data store आधी.
Client requests API gateway से टकराते हैं जो authn, authz, rate limits और logging enforce करता है REST API और data store से पहले.
Names evolve with OWASP editions; the themes defenders keep teaching:
- Broken object level authorisation — change an ID, see someone else’s record.
- Broken authentication — weak tokens, long-lived secrets, missing MFA on admin APIs.
- Broken object property level authorisation — client sets
isAdmin=trueor reads hidden fields. - Unrestricted resource consumption — no rate / cost limits; one client starves others.
- Broken function level authorisation — normal user hits admin-only routes.
- Unrestricted access to sensitive business flows — checkout, OTP, password reset abused at scale.
- Server-side request forgery (SSRF) themes — API fetches attacker-controlled URLs (high-level).
- Security misconfiguration — verbose errors, open CORS, default keys, unused HTTP methods.
- Improper inventory management — shadow/old API versions still live.
- Unsafe consumption of APIs — trusting third-party API data blindly.
Educational warning: this guide explains what to fix and how to verify on systems you own. It does not walk exploit payloads, bypass chains, or attack scripts.
Real incident: Optus (2022) — API exposure themes
Public reporting on Australia’s Optus 2022 customer-data incident described large-scale exposure tied to API access control / authentication weaknesses in public analyses. Millions of customer records were affected; regulators and boards treated API inventory and authz as board-level topics afterward.
Takeaways (vertical):
- What happened — customer PII exposure at national scale with API pathways discussed publicly.
- What went wrong (theme) — insufficient gates between the internet and sensitive customer objects.
- Care-take — inventory every internet-facing API version (v1 leftovers kill you).
- Care-take — object-level authz tests in CI beat “we have a WAF” slides.
- Care-take — rate limits and anomaly alerts on bulk export-shaped traffic.
- Bonus parallel — Capital One–era cloud lessons: identity + SSRF-class themes still belong in API threat models.
Red Team vs Blue Team (awareness only)
Red Team — what attackers try
- Swap IDs and roles to reach other tenants’ objects (high-level IDOR theme).
- Replay or steal long-lived bearer tokens from logs and mobile storage.
- Abuse unauthenticated “forgot password” / OTP send flows for spam or lockouts.
- Probe old
/v1hosts that never got the new gateway rules.
Blue Team — defend, detect, respond
- Deny-by-default authz on every object and admin function.
- Short-lived tokens; bind sessions to device / risk signals where supported.
- Schema allow-lists; strip unknown properties server-side.
- Gateway rate limits + bot / stuffing detections.
- Central logs of 401/403 spikes and bulk downloads; page humans.
How do I harden a REST API step by step?
Step 1 — Inventory what is live
- List public hostnames, versions, and who owns each service.
- Mark which routes touch PII, payments, or admin actions.
- Kill or lock forgotten staging / docs endpoints.
Step 2 — Fix object and function authorisation
- For every
GET/PATCH/DELETE /resource/{id}, prove the caller owns that id (or has a role). - Never trust client-supplied user ids for authorisation decisions alone.
- Separate “logged in” from “allowed to do this action”.
Step 3 — Tighten authentication
- Prefer OAuth2 / OIDC patterns maintained by your platform — not homemade JWT crypto.
- Rotate signing keys; set short TTLs; revoke on logout / risk.
- MFA for human admin API access; workload identities for services.
Step 4 — Shrink data and schemas
- Response DTOs with explicit fields — no dumping ORM entities.
- Reject unexpected JSON properties on write.
- Paginate list endpoints; cap page size server-side.
Step 5 — Abuse and SSRF-class limits
- Per-token and per-IP rate limits on auth and export routes.
- If your API fetches URLs, allow-list destinations; block link-local / metadata ranges (follow current cloud guidance).
- Cost controls for expensive search / report jobs.
Step 6 — Observe and verify (authorised lab)
- In a lab API you own, write automated tests: user A denied on user B’s object.
- Confirm 401/403 appear in your logs with request ids.
- Load-test only against your lab — never stranger APIs on the public internet.
- Document residual risks for the service owner.
Ravindra Bagale's Tip
💡 Students leave Swagger UI public for "documentation clarity". In production, unauthenticated docs = a free attack-surface map. Put auth behind the gateway, keep an inventory sheet. In interviews say: object-level authz + rate limit + schema allow-list. Never forget!
Ravindra Bagale's Tip – मराठी
💡 Students Swagger UI public ठेवून "documentation clarity" समजतात. Production मध्ये unauthenticated docs = free attack surface map. Auth behind gateway, inventory sheet सोबत. Interview मध्ये बोला: object-level authz + rate limit + schema allow-list. बिल्कुल विसरू नका!
Ravindra Bagale's Tip – हिंदी
💡 Students Swagger UI public रखकर "documentation clarity" समझते हैं. Production में unauthenticated docs = free attack surface map. Auth behind gateway, inventory sheet के साथ. Interview में बोलो: object-level authz + rate limit + schema allow-list. बिल्कुल मत भूलो!
Gateway vs application — who does what?
- Gateway / edge — TLS termination, WAF-ish filters, global rate limits, JWT validation, routing.
- Application — fine-grained object authz, business rules, field-level filtering, domain logging.
- Neither layer alone is enough: a perfect gateway with a blind app still leaks objects; a careful app behind an open debug port still burns.
- Put request ids on every response so SOC can join gateway and app logs.
- Document which team owns 401 vs 403 vs 429 tuning.
Care-take — API habits that survive audits
- One owner per API; quarterly inventory of versions.
- Authz unit/integration tests in the pipeline (see DevSecOps guide).
- Secrets in a manager — not in mobile apps or git.
- CORS allow-lists that match real frontends only.
- Break-glass admin routes monitored like root cloud logins.
- Tabletop: “bulk
/customersexport at 3 a.m. IST — who gets paged?”
How do I fix common API security mistakes?
Ghabru naka 😅 — these are the usual ones:
| Symptom | Likely cause | Fix |
|---|---|---|
| User sees another user’s order | Missing object authz | Check ownership / tenant on every id |
| Token in server access logs | Auth header logged raw | Redact secrets; shorten TTL |
| Staging API still on internet | Inventory gap | Private network or strong auth; decommission |
| “Works without Auth header” | Misconfig / open CORS combo | Default deny; gateway policy tests |
| OTP SMS flood complaints | Unbounded business flow | Rate limit + CAPTCHA/risk + monitor |
| Huge JSON dumps to mobile | Excess data exposure | Explicit response models |
Try it at home
On a toy API you control (local Flask/Express or a cloud free tier):
- Create two users; prove user A gets HTTP 403 on user B’s resource id.
- Add a crude per-IP rate limit on
/login; confirm your own lab client eventually gets 429. - List three fields you would never return on a public profile endpoint.
- Write one Optus-2022 lesson sentence in your own words.
- Do not probe random company APIs — that is not a lab.
Learn it properly
Course lessons:
- What OWASP and the Top 10 are
- Broken access control and IDOR
- Authentication and cryptographic failures
- The rest — design, components, integrity, logging
- IAM done right
Related guides: OWASP Top 10 simply · SQL injection prevention · Cloud IAM least privilege · DevSecOps pipeline
Got it? API security = object authz + strong authn + less data + rate limits + inventory + logs. Optus-era lesson: take internet-facing customer APIs seriously. No exploit recipes — tests and gateway policies. Next: learn threat hunting for beginners.
समजलं का? API security = object authz + strong authn + less data + rate limits + inventory + logs. Optus-era lesson: internet-facing customer APIs serious घ्या. Exploit recipes नको — tests आणि gateway policies. आता threat hunting beginners साठी शिका.
समझ में आया? API security = object authz + strong authn + less data + rate limits + inventory + logs. Optus-era lesson: internet-facing customer APIs serious लो. Exploit recipes नहीं — tests और gateway policies. आगे threat hunting beginners के लिए सीखो.
Frequently asked questions
What is the OWASP API Security Top 10?
A community checklist of critical API risks — use it as a defence and testing agenda, not an attack recipe.
What is broken object level authorisation?
When changing an object id lets a caller reach another user’s record — fix with server-side ownership checks.
Are API keys in mobile apps safe?
Treat them as public; put real secrets on the server and use short-lived user tokens.
Is an open Swagger UI OK in production?
Not without authentication — unauthenticated docs map your attack surface for free.
How does Optus 2022 relate?
Public analyses emphasised API access-control weaknesses at scale — inventory and authz tests matter.
Where are deeper lessons on this site?
OWASP Top 10 chapters, IDOR/access-control lessons and IAM done right.