Variant · Low-Medium

CWE-82: Improper Neutralization of Script in Attributes of IMG Tags in a Web Page

The web application does not neutralize or incorrectly neutralizes scripting elements within attributes of HTML IMG tags, such as the src attribute.

CWE-82 · Variant Level ·8 CVEs ·2 Mitigations

Description

The web application does not neutralize or incorrectly neutralizes scripting elements within attributes of HTML IMG tags, such as the src attribute.

Attackers can embed XSS exploits into the values for IMG attributes (e.g. SRC) that is streamed and then executed in a victim's browser. Note that when the page is loaded into a user's browsers, the exploit will automatically execute.

Potential Impact

Confidentiality, Integrity, Availability

Read Application Data, Execute Unauthorized Code or Commands

Mitigations & Prevention

Implementation

Use and specify an output encoding that can be handled by the downstream component that is reading the output. Common encodings include ISO-8859-1, UTF-7, and UTF-8. When an encoding is not specified, a downstream component may choose a different encoding, either by assuming a default encoding or automatically inferring which encoding is being used, which can be erroneous. When the encodings are inconsistent, the downstream component might treat some character or byte sequences as special, even

Implementation Defense in Depth

To help mitigate XSS attacks against the user's session cookie, set the session cookie to be HttpOnly. In browsers that support the HttpOnly feature (such as more recent versions of Internet Explorer and Firefox), this attribute can prevent the user's session cookie from being accessible to malicious client-side scripts that use document.cookie. This is not a complete solution, since HttpOnly is not supported by all browsers. More importantly, XmlHttpRequest and other powerful browser technologi

Real-World CVE Examples

CVE IDDescription
CVE-2006-3211Stored XSS in a guestbook application using a javascript: URI in a bbcode img tag.
CVE-2002-1649javascript URI scheme in IMG tag.
CVE-2002-1803javascript URI scheme in IMG tag.
CVE-2002-1804javascript URI scheme in IMG tag.
CVE-2002-1805javascript URI scheme in IMG tag.
CVE-2002-1806javascript URI scheme in IMG tag.
CVE-2002-1807javascript URI scheme in IMG tag.
CVE-2002-1808javascript URI scheme in IMG tag.

Taxonomy Mappings

  • PLOVER: — Script in IMG tags
  • Software Fault Patterns: SFP24 — Tainted input to command

Frequently Asked Questions

What is CWE-82?

CWE-82 (Improper Neutralization of Script in Attributes of IMG Tags in a Web Page) is a software weakness identified by MITRE's Common Weakness Enumeration. It is classified as a Variant-level weakness. The web application does not neutralize or incorrectly neutralizes scripting elements within attributes of HTML IMG tags, such as the src attribute.

How can CWE-82 be exploited?

Attackers can exploit CWE-82 (Improper Neutralization of Script in Attributes of IMG Tags in a Web Page) to read application data, execute unauthorized code or commands. This weakness is typically introduced during the Implementation phase of software development.

How do I prevent CWE-82?

Key mitigations include: Use and specify an output encoding that can be handled by the downstream component that is reading the output. Common encodings include ISO-8859-1, UTF-7, and UTF-8. When an encoding is not specified,

What is the severity of CWE-82?

CWE-82 is classified as a Variant-level weakness (Low-Medium abstraction). It has been observed in 8 real-world CVEs.