Each of these vulns has a distinct defense. Fortunately none require exotic techniques — just rigorous application of standard patterns.
HTTP Verb Tampering Prevention
Configuration-Level
Use web server directives that cover all methods by default, not just enumerated ones:
| Server | Vulnerable | Correct |
|---|---|---|
| Apache | <Limit GET POST> | <LimitExcept POST> |
| Tomcat | <http-method>GET</http-method> | <http-method-omission> |
| ASP.NET | <allow verbs="GET"/> | <add> / <remove> with correct scope |
| nginx | limit_except GET { ... } | same, but with correct inverted logic |
Application-Level
- Apply authorization in middleware that runs for every request, regardless of method
- Don’t rely on
$_GET/$_POSTdiscrimination — use the parsed value, not the parameter source - Use
$_POSTor$_GETconsistently, never mix with$_REQUEST - Disable unused HTTP methods at the server level — if you don’t use
PUT, block it
Parameter Access Functions to Avoid
| Language | Dangerous | Safer |
|---|---|---|
| PHP | $_REQUEST['x'] | $_POST['x'] or $_GET['x'] — pick one, consistently |
| Java | request.getParameter('x') | request.getMethod() + getParameter() check |
| C# | Request['x'] | Request.Form['x'] or Request.QueryString['x'] |
IDOR Prevention
Primary Defense — Server-Side Authorization
Every request that references an object must verify the current user is authorized. The check happens on the backend, using the session-authenticated identity:
def get_document(doc_id):
doc = Document.get(doc_id)
if doc.owner_id != current_user.id and not current_user.is_admin:
raise Forbidden()
return docThe authorization check comes from the session (the trusted source), not from request parameters (attacker-controlled).
Secondary Defense — Secure Object References
Even with authorization, exposing predictable IDs in URLs is noisy:
- Use UUIDs or random tokens for public-facing references
- Generate server-side at object creation
- Store mapping in database; resolve at request time
- Never compute references on the front-end
Important: UUIDs alone don’t fix IDOR — if authorization is broken, replaying another user’s UUID still works. Use both defenses together.
Role-Based Access Control (RBAC)
Build a framework-level authorization system that:
- Defines roles clearly (admin, employee, customer)
- Assigns permissions to roles, not users
- Checks permissions on every request
- Reads the role from the session token, never from cookies or request params
Common failure: an app sets Cookie: role=admin and reads that cookie for authorization. The attacker just changes the cookie to admin. Always derive privileges from server-side session state.
Front-End Hygiene
- Don’t send admin-only API endpoints in the JavaScript bundle shipped to normal users
- Don’t include hidden form fields exposing internal user IDs
- Don’t expose hashing/signing functions in front-end code (attackers replicate them)
XXE Prevention
Primary Defense — Disable External Entities
Every XML parser has a setting to disable external entity resolution. Turn it on.
PHP (libxml):
libxml_disable_entity_loader(true);Java (DocumentBuilderFactory):
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
factory.setFeature("http://xml.org/sax/features/external-general-entities", false);
factory.setFeature("http://xml.org/sax/features/external-parameter-entities", false);Python (lxml):
parser = etree.XMLParser(resolve_entities=False, no_network=True).NET (XmlDocument):
XmlDocument doc = new XmlDocument();
doc.XmlResolver = null; // or new XmlUrlResolver() with no networkDon’t Parse XML If You Don’t Need To
The best XXE defense: use a format that doesn’t have external entities. JSON doesn’t have the concept. YAML has its own issues (deserialization) but no XXE.
If the app’s actual data model is simple, consider migrating XML endpoints to JSON.
Input Validation
If XML must be accepted:
- Reject any input containing
<!DOCTYPEor<!ENTITY - Reject external entity declarations (
SYSTEM,PUBLIC) - Use a strict schema to validate XML structure before parsing
Note: this is secondary defense. The parser configuration is primary.
Network Isolation
Even if XXE succeeds, limit the damage:
- Block outbound HTTP from the application server (prevents OOB exfil and SSRF-via-XXE)
- Disable the PHP Expect extension unless explicitly needed
- Run the app in a container with read-only filesystem and no access to secrets
Combined Patterns
Validate Everywhere
Don’t rely on a single checkpoint. Apply validation at multiple layers:
- Reverse proxy — strip dangerous methods, enforce size limits
- Application middleware — authenticate, authorize, log
- Business logic — validate input semantics
- Data layer — parameterized queries, prepared statements
A failure at one layer doesn’t compromise the whole system.
Monitor the Boundaries
- Log all requests that fail authorization — IDOR attempts look like a user requesting many different IDs rapidly
- Alert on unusual HTTP methods against your endpoints
- Monitor outbound network from app servers — unexpected egress is often XXE/SSRF exfiltration
Keep Dependencies Updated
Historical XXE vulnerabilities in parsers (libxml2, Java XML libraries) are the most common source of 0-day XXE in otherwise-secure applications. Pin and monitor.
Checklist Summary
- HTTP Verb Tampering:
LimitExcept, consistent parameter handling, no$_REQUEST - IDOR: server-side authorization on every request, UUIDs as defense in depth, no client-side hashing
- XXE: disable external entities in every XML parser, prefer JSON, network-isolate the app
- Across all: parameterized access, logged authorization failures, monitored egress
