What is Body Data?
Body data is the main content sent in POST, PUT, and PATCH requests. It contains the actual information being submitted - form data, JSON payloads, file uploads, or API commands.MDN Web DocsRead more on HTTP message body.
Common Body Data Formats
JSON (application/json)
Form Data (application/x-www-form-urlencoded)
Multipart (multipart/form-data)
XML (application/xml)
Plain Text (text/plain)
Using Body Data in Policies
Basic Examples
Check for specific field:Advanced JSON Navigation
For nested JSON objects, use path notation:user.profile.email or user->profile->email
Array Access
items[0].name- First item’s nameitems[].name- Any item’s name
Security Patterns
SQL Injection Detection
XSS Prevention
Command Injection
Size and Content Validation
Prevent Large Payloads
Enforce Content Types
Best Practices
DO:
- Validate structure - Ensure expected fields exist
- Check data types - Numbers should be numbers
- Limit sizes - Prevent resource exhaustion
- Sanitize inputs - Block dangerous characters
- Log suspicious patterns - For security analysis
- Use specific paths - Target exact fields in JSON
DON’T:
- Parse complex formats in policies - Do that server-side
- Store sensitive data in logs
- Trust client validation - Always verify server-side
- Block common words - Too many false positives
- Ignore encoding - Base64 can hide attacks
Working with Different Content Types
JSON API Protection
Form Submission Validation
File Upload Security
Common Attack Patterns
Password Spraying
Credential Stuffing
API Abuse
Encoding Challenges
Base64 Detection
URL Encoding
Troubleshooting
“Can’t access nested fields”- Check JSON structure
- Verify path notation
- Ensure proper parsing
- Look for array vs object
- Confirm Content-Type header
- Check encoding (UTF-8, etc.)
- Verify body size limits
- Test with exact payload
Advanced Patterns
Business Logic Validation
Data Consistency Checks
Related Fields
- Request Method - Only some methods have bodies
- Headers - Content-Type describes body format
- Request Path - Different endpoints expect different bodies
- Query Parameters - Alternative to body for GET requests