--- name: wstg-errh-01 description: "Testing for Improper Error Handling" category: error-handling owasp_id: WSTG-ERRH-01 version: "1.0.0" author: cyberstrike-official tags: [error-handling, information-leak, stack-trace, wstg, errh] tech_stack: [] cwe_ids: [CWE-209] chains_with: [] prerequisites: [] severity_boost: {} --- # wstg-errh-01 ## Test ID WSTG-ERRH-01 ## Test Name Testing for Improper Error Handling ## High-Level Description Improper error handling can reveal sensitive information about the application's internal workings, including technology stack, database structure, file paths, and configuration details. Attackers use this information to craft more targeted attacks. Proper error handling should provide minimal information to users while logging detailed information securely on the server. --- ## What to Check ### Information Disclosure via Errors - [ ] Stack traces exposed - [ ] Database error messages - [ ] File path disclosure - [ ] Framework/version info - [ ] Debug information - [ ] Internal IP addresses - [ ] SQL queries in errors - [ ] Configuration details ### Error Scenarios to Test | Scenario | Potential Disclosure | | ----------------------- | -------------------- | | Invalid input | Framework info | | Database errors | SQL structure | | File operations | Path disclosure | | Authentication failures | User enumeration | | Authorization errors | Role information | | Server errors (500) | Stack traces | --- ## How to Test ### Step 1: Trigger Various Error Types ```bash #!/bin/bash TARGET="https://target.com" # Test 404 errors curl -s "$TARGET/nonexistent-page-12345" curl -s "$TARGET/../../../etc/passwd" curl -s "$TARGET/%00" # Test 500 errors curl -s "$TARGET/api/user?id='" curl -s "$TARGET/api/user?id=1 OR 1=1" curl -s -X POST "$TARGET/api/data" -d "invalid-json" # Test with malformed requests curl -s "$TARGET" -H "Content-Length: -1" curl -s "$TARGET" -H "Content-Type: application/invalid" # Test file operations curl -s "$TARGET/download?file=../../../etc/passwd" curl -s "$TARGET/download?file=/etc/passwd" # Test with long input curl -s "$TARGET/search?q=$(python3 -c 'print("A"*10000)')" ``` ### Step 2: Analyze Error Responses ```bash #!/bin/bash TARGET="https://target.com" # Collect errors and analyze payloads=( "'" "\"" ";" "../" "