Diagnostic playbook
Reflected XSS via search/name parameter in HTML body context
Web / Cross-Site Scripting
Knowledge identity
Definition and taxonomy
Summary
User-supplied text is reflected into an HTML body context without context-aware output encoding, allowing injection of arbitrary HTML/JavaScript.
Severity rationale
Demonstrated unencoded reflection of attacker-controlled HTML/script into an HTML body context (Hello <payload>) in an authorized lab. Execution would occur in any victim browser following a crafted link; impact depends on session/role protections. Rated medium with high/self-XSS limits as standard for reflected XSS.
Aliases
Reflected cross-site scripting, non-persistent XSS
Standards
CWE-79 CAPEC-591 A03:2021-Injection
CVSS vector
CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N
1. First Signal
What should make an agent suspicious
Symptoms
A unique marker returns unencoded in the response body; < and > pass through literally rather than as entities; script/event-handler payloads appear verbatim.
Prerequisites
Authorized lab session. Parameter value reflected into an HTML context without encoding.
2. Recognition Logic
How to recognize this next time
If user-controlled text appears in HTML body content, first identify the output context, then test whether special characters are encoded. If a filter removes <script>, try nested tags (<scr<script>ipt>) or non-script vectors (img onerror).
3. Diagnostic Procedure
Safe checks, in order
- Confirm authorized scope. 2. Submit a unique marker and confirm reflection. 3. Send special characters and check for encoding. 4. Try <script>alert(1)</script> then adapt to the filter. 5. Use inert marker payloads only. 6. Record the response-context and confirm no encoding.
4. Proof
Evidence
DVWA xss_r: low name=<script>alert(1)</script> reflected raw; medium nested <scr<script>ipt> bypass produced <script>alert(1)</script> and <IMG SRC=x onerror=alert(1)> survived; high <IMG SRC=x onerror=alert(1)> survived while script keywords were stripped.
5. Controls
Negative checks
Plain text marker probe123 rendered as text only; direct <script> was stripped at medium (blocked-control); impossible level with htmlspecialchars encodes the same payloads.
6. Avoid Bad Memory
False positives and traps
Reflection alone is not XSS; output must be in an executable context and special characters must be unencoded. Search highlighting or escaped entities are not proof.
7. Why It Matters
Impact
Attacker-controlled script executes in a victim's browser via a crafted link, enabling session theft or UI redressing depending on app protections.
8. Why It Happened
Root cause
Output reflection without context-aware encoding (htmlspecialchars absent); filter-based defenses (str_replace/preg_replace) only handle known patterns.
9. Fix
Remediation and prevention
Apply context-aware output encoding for HTML body context (htmlspecialchars with ENT_QUOTES and proper charset). Do not rely on pattern filters.
10. Re-test
Verification steps
- After fix, submit <script>alert(1)</script> and confirm it renders as visible text. 2. Confirm page source shows <script>. 3. Repeat with event-handler payloads. 4. Add regression test.
Reference
Tools and sources
Tools used
curl for reproducible reflection checks, docker exec for read-only source review
References
OWASP XSS Prevention Cheat Sheet; CWE-79; PortSwigger Reflected XSS
Intelligence
Products and history
Technologies
PHP, HTML, browser
Affected products / versions
DVWA (Damn Vulnerable Web Application) current master
History
First documented in DVWA xss_r module low/medium/high in the 2026-08 benchmark run.
Exploit knowledge
Variants and references
Attack surface
name query parameter reflected into <pre>Hello {name}</pre> in the HTML body
Exploit maturity
proof-of-concept
Known variants
Reflected HTML injection, event-handler payloads (img onerror), nested-tag script bypass for str_replace filters, case/obfuscated script variants for regex filters
Defensive signatures
Query parameters whose values reappear unencoded in the response body, special characters < > " & not percent/entity encoded, filter bypass payloads with nested tags or event handlers
Reproduction commands
Low (no filter): curl -s -b $JAR "http://127.0.0.1:4280/vulnerabilities/xss_r/?name=%3Cscript%3Ealert(1)%3C/script%3E" # Hello <script>alert(1)</script> Medium (strips literal <script>): curl -s -b $JAR "http://127.0.0.1:4280/vulnerabilities/xss_r/?name=%3Cscr%3Cscript%3Eipt%3Ealert(1)%3C/script%3E" # nested bypass -> <script>alert(1)</script> curl -s -b $JAR "http://127.0.0.1:4280/vulnerabilities/xss_r/?name=%3CIMG%20SRC=x%20onerror=alert(1)%3E" High (regex strips 'script'): curl -s -b $JAR "http://127.0.0.1:4280/vulnerabilities/xss_r/?name=%3CIMG%20SRC=x%20onerror=alert(1)%3E" # no script keyword -> survives
Exploit references
No external references stored; all evidence from the authorized local lab.
Case provenance