HTML Injection
Input is returned in a page without HTML encoding, so an attacker can inject markup such as forms and links, although script execution is prevented.
| Severity | Medium |
| CVSS 3.1 | 5.4 CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:L/I:L/A:N Open in the calculator |
| CVSS 4.0 | 5.1 CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:A/VC:L/VI:L/VA:N/SC:N/SI:N/SA:N Open in the calculator |
| CWE | CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting') |
| OWASP Top 10 | A05:2025 Injection |
| MITRE ATT&CK | T1598.003 Spearphishing Link |
| Category | Input Validation |
Description
The application includes values from the request in its HTML responses without encoding them, so markup in the input is rendered by the browser. Unlike cross-site scripting, script execution is prevented, typically because a filter removes script elements and event handlers or because a Content Security Policy blocks inline script.
Even without script, injected markup can change what the victim sees and does. An attacker who persuades a victim to follow a crafted link can present content on the application's own domain, which makes credential phishing through an injected login form that submits to the attacker's server considerably more convincing. The markup can also insert links and images, add a <meta> refresh that redirects the page, or add a <base> element that changes where relative links point. An unclosed attribute or tag can capture the rest of the page, including any tokens in it, and send it to the attacker's server, a technique known as dangling markup injection, although some browsers block its common forms. The attacker cannot run script, so they cannot act within the victim's session directly.
The weakness typically shows itself on a test when harmless markup, such as a heading or a link, submitted in a parameter is rendered rather than displayed as text. The root cause is the same missing output encoding as in cross-site scripting, and a weak filter often means the finding can be developed into full cross-site scripting: if the filter that prevents script can be bypassed, the impact rises to match.
Remediation
Fix the missing encoding rather than the symptoms:
- Encode all untrusted data for the context in which it appears, as for cross-site scripting: HTML entity encoding for element content and attribute encoding for quoted attribute values, using a template engine that encodes automatically. Do not rely on filters that remove particular tags.
- Where formatted text must be accepted, sanitise it with a maintained HTML sanitiser using a strict allowlist that excludes forms, inputs,
metaandbaseelements. - Strengthen the Content Security Policy with
form-action 'self', so that injected forms cannot submit to other sites, andbase-uri 'none'or'self', so that injected base elements are ignored.
Confirm the fix by repeating the original markup in each affected parameter and checking that it is displayed as text.
References
- cheatsheetseries.owasp.org/cheatsheets/Cross_Site_Scripting_Prevention_Cheat_Sheet.html
- developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Content-Security-Policy/form-action
- developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Content-Security-Policy/base-uri
- owasp.org/Top10/2025/A05_2025-Injection
Add This Finding to Your Library
In Pental this write-up is in Settings, Library. Add to my library copies it into your own, rated in your firm's CVSS version, ready to put in your own words.
Free trialYour trial starts when your portal goes live, not when you sign up, so the time you spend setting up does not count. · No card required
Only need the reporting? Our reporting tool is free and open source, with the same library.