Is Your REST API Secure, or Just Working?
A REST API can pass every happy-path test and still be unsafe. Security bugs often hide in the edges: missing authorization checks, tokens logged by accident, permissive CORS, weak validation or endpoints that can be brute-forced without limits.
This article covers common REST API security mistakes developers still make and how to avoid them before they become production incidents.
Authentication Is Not Authorization
Authentication answers "who is this user?" Authorization answers "is this user allowed to do this action?" Mixing them up is one of the most common API mistakes.
A valid JWT or session only proves identity. Every sensitive operation still needs a permission check based on the resource being accessed.
app.get("/api/projects/:id", requireAuth, async (req, res) => {
const project = await getProject(req.params.id)
if (!project || project.ownerId !== req.user.id) {
return res.status(404).json({ error: "Not found" })
}
return res.json(project)
})
Trusting Client Input Too Much
The client can be changed, scripted or bypassed. Any validation that matters must happen on the server: schema validation, type checks, length limits, enum constraints and business rules.
Validate request bodies, query params and path params. Also validate what the user is allowed to change; do not accept entire database objects from the client if only two fields should be editable.
Leaking Secrets Through Logs and Errors
Error messages should help legitimate developers debug without giving attackers a map. Avoid returning stack traces, SQL details, token values or internal service names in production responses.
Logs are just as important. Authorization headers, cookies, API keys and password reset tokens should be redacted before they reach log storage.
⚠️ Warning: Treat logs as sensitive data. If a bearer token lands in centralized logs, anyone with log access may be able to impersonate that user until the token expires.
Permissive CORS and Missing Rate Limits
CORS controls which browser origins may read responses from your API. It is not an authentication system, but a careless Access-Control-Allow-Origin: * on credentialed endpoints can widen exposure.
Rate limiting is the other missing layer. Login, password reset, invitation, search and expensive report endpoints need limits to reduce brute force, scraping and accidental overload.
Resources
- OWASP API Security Top 10
- OWASP Cheat Sheet Series
- MDN: CORS
- JWT Best Current Practices: RFC 8725
- NIST Digital Identity Guidelines
Conclusion
REST API security is mostly about refusing to trust the wrong boundary. Authenticate users, authorize resources, validate input, redact secrets, configure CORS deliberately and rate-limit risky endpoints.
Share this article with a teammate before the next API review.

