Lesson 3 of 4 · 30 min

API Security for Mobile and Web Apps

The server is the control point.

XDQ Tutor · AI guide

Hello. In this lesson I will take you through 3 ideas, one at a time.

  1. Never trust the client
  2. Rate limits and abuse
  3. Input and output

Why it matters: The server is the control point. After each idea I will ask you one quick question.

Never trust the client

The short version: Every check the app performs can be bypassed by calling the API directly.

Every check the app performs can be bypassed by calling the API directly. Authentication, authorisation, validation and limits must all be enforced on the server.

For each endpoint ask: who may call it, on which records, how often. Missing record-level checks are among the commonest serious faults.

Quick check

Why enforce checks on the server?

Rate limits and abuse

The short version: Limit requests per user and per device.

Limit requests per user and per device. Add stricter limits on login, password reset, one-time codes and anything that sends messages or costs money.

Watch for automated abuse: many accounts from one device, scripted sign-ups, card testing. Alert on patterns, not only on errors.

Quick check

Which endpoints need the strictest rate limits?

Input and output

The short version: Validate every input against a schema.

Validate every input against a schema. Return only the fields the client needs. An endpoint that returns the whole user record because it was easier will one day expose a field it should not.

Keep error messages helpful to users and unhelpful to attackers: no stack traces, no hints about which part of a login failed.

Key takeaways
  • All checks are enforced on the server
  • Authorise per record, not just per endpoint
  • Tighter limits on login, codes and costly actions
  • Validate inputs and return minimal fields
Try it

Pick five endpoints. For each, write who may call it, the record-level rule and the rate limit.

That is the lesson.
Mark it complete to track your progress on this device.
← PreviousSecure Storage and Secrets in Mobile AppsNext lesson →Dependency Scanning and Security Release Gates