How to fix: REST endpoint allows DELETE
REST endpoint exposes DELETE without authentication.
Why it matters
Unauthenticated DELETE endpoints allow any internet-reachable client to permanently destroy resources, enabling data-loss attacks or cascading failures in downstream systems that depend on those records.
REST endpoint exposes DELETE without authentication.
How to fix it
- 1Require authentication on all state-changing verbs (DELETE, PATCH, PUT, POST)
- 2Return 401 for missing tokens and 403 for insufficient scope
- 3Use middleware to enforce auth before any route handler runs
Code examples
Express.js: auth guard middleware
function requireAuth(req, res, next) {
const token = req.headers.authorization?.split(' ')[1];
if (!token) return res.status(401).json({ error: 'Unauthorized' });
try {
req.user = jwt.verify(token, process.env.JWT_SECRET);
next();
} catch {
res.status(401).json({ error: 'Invalid token' });
}
}
// Apply before DELETE route
router.delete('/resource/:id', requireAuth, deleteHandler);Next.js Route Handler: auth check
import { getSession } from '@/lib/auth';
import { NextResponse } from 'next/server';
export async function DELETE(req: Request) {
const session = await getSession();
if (!session) {
return NextResponse.json({ error: 'Unauthorized' }, { status: 401 });
}
// ... delete logic
}References
Detected automatically by VulnRadar. The check id is api-rest-allow-methods-delete, stable across every scan so you can filter or diff on it.
More api checks
- LowTRACE method referenced in API response body
- LowGraphQL introspection field suggestions
- MediumGraphQL endpoint has no rate-limit headers
- LowOpenAPI server URL leaks internal host
- LowCORS preflight result not cached
- HighBearer token in URL query string
- MediumJSONP callback parameter accepted
- InfoPUT method listed in Allow header
Questions
- How severe is REST endpoint allows DELETE?
- VulnRadar rates this info severity in the api category. The severity is fixed per check, not scored per site, so the same finding is the same severity on every scan.
- Does VulnRadar check for this automatically?
- Yes. It runs as part of every scan under the check id api-rest-allow-methods-delete, which stays the same between runs so you can filter, diff, or gate CI on it.
- Which standards does REST endpoint allows DELETE map to?
- It maps to CWE-284. In the OWASP Top 10 it falls under A01:2021.
Missing a check?
The detection set is open. If you know a misconfiguration this does not catch, propose it: the issue template asks for the threat model, how to detect it, the false-positive risk, and a test fixture, which is the same thing a maintainer would have to work out anyway.