API Security for Mobile and Web Apps
The server is the control point.
Hello. In this lesson I will take you through 3 ideas, one at a time.
Why it matters: The server is the control point. After each idea I will ask you one quick question.
In this lessonFollows you as you read
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.
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.
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.
- 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
Pick five endpoints. For each, write who may call it, the record-level rule and the rate limit.
Mark it complete to track your progress on this device.