1 Unauthenticated Endpoints and Verb Abuse
REST APIs have several common security weaknesses that attackers routinely probe for.
Unauthenticated endpoints:
// Vulnerable: forgot to add auth middleware
app.get("/api/admin/users", async (req, res) => {
// No authentication check! Any user can list all users.
const users = await User.find();
res.json(users);
});HTTP verb abuse:
// Only GET is tested, but the route accepts all methods
app.use("/api/profile/:id", profileHandler);
// Attacker sends DELETE /api/profile/123 — deletes the account!
// Or sends PUT /api/profile/1 with isAdmin: trueMissing object-level authorization (IDOR):
// Auth checks user is logged in, but not that they own the resource
app.get("/api/invoices/:id", authenticate, async (req, res) => {
const invoice = await Invoice.findById(req.params.id);
res.json(invoice); // Any authenticated user can access any invoice!
});