CAPEC

Common Attack Pattern Enumeration and Classification
Common Attack Pattern Enumeration and Classification

A Community Knowledge Resource for Building Secure Software

Home > CAPEC List > Individual CAPEC Dictionary Definition (Release 1.1)   View the CAPEC List

Individual CAPEC Dictionary Definition (Release 1.1)
Individual CAPEC Dictionary Definition (Release 1.1)

XSS in IMG Tags
Attack Pattern ID
Pattern Abstraction: Detailed

91

Typical Severity

High

Description

Summary


Image tags are an often overlooked, but convenient, means for a Cross Site Scripting attack. The attacker can inject script contents into an image (IMG) tag in order to steal information from a victim's browser and execute malicious scripts.

Attack Prerequisites

Application permitting the inclusion or use of IMG tags

Typical Likelihood of Exploit

High Techniques for discovery of XSS as well as tools and means to exploit them are fairly widely available and understood

Methods of Attack
  • Injection
Examples-Instances

Description

An online discussion forum allows its members to post HTML-enabled messages, which can also include image tags.      
A malicious user can embed JavaScript in the IMG tags in his messages that get executed within the victim's browser whenever the victim reads these messages.      
The malicious user can leverage Cross Site Scripting in image tags to steal sensitive information, such as usernames, passwords or cookies, and impersonate other users on the forum.

Attacker Skill or Knowledge Required

Medium: Besides the ability to figure out possibilities of injection, the attacker requires moderate scripting skills to successfully leverage cross site scripting in image tags

Resources Required

None

Solutions and Mitigations

In addition to the traditional input fields, all other user controllable inputs, such as image tags within messages or the likes, must also be subjected to input validation. Such validation should ensure that content that can be potentially interpreted as script by the browser is appropriately filtered.

All output displayed to clients must be properly escaped. Escaping ensures that the browser interprets special scripting characters literally and not as script to be executed.

Attack Motivation-Consequences
  • Run Arbitrary Code
  • Information Leakage
Context Description


It is a misconception that Cross Site Scripting can be perpetrated only through input fields, such as text boxes or select fields.        
Image tags can be equally well abused to inject script into the victim's browser. The "src" attribute within the IMG tags points to the source of the image to be displayed.    
Since the source attribute allows the victim's browser to request content from locations other than the original server, an attacker can make this attribute point to a location of his choosing.    Making the victim point to such a location is accomplished by the traditional means of having the victim click on a link; however, script execution can also be achieved by simply having the victim view a message on a bulletin board.    
Second-order cross site scripting is the predominant means of script injection when using IMG tags.

Injection Vector

User-controllable input to the application. Any input that can legitimately accept and render HTML image tag can be used as an injection vector.

Payload

HTML Image tag pointing to script or location of attacker's choice.

Activation Zone

Victim's web browser.

Payload Activation Impact

Execution of the script in the victim's browser, contained in the image tag or from the location pointed to within the image tag.

Related Weaknesses
CWE-IDWeakness NameWeakness Relationship Type
82Failure to Sanitize Script in Attributes of IMG Tags in a Web PageTargeted
79Failure to Sanitize Directives in a Web Page (aka 'Cross-site scripting' (XSS))Targeted
74Failure to Sanitize Data into a Different Plane (aka 'Injection')Secondary
20Insufficient Input ValidationSecondary
Related Vulnerabilities
Vulnerability-IDVulnerability Description
CVE-2002-1808Cross-site scripting (XSS) vulnerability in Meunity Community System 1.1 allows remote attackers to inject arbitrary web script or HTML via JavaScript in an IMG tag when creating a topic.
CVE-2006-6919Firefox Sage extension 1.3.8 and earlier allows remote attackers to execute arbitrary JavaScript in the local context via an RSS feed with an img tag containing the script followed by an extra trailing ">", which Sage modifies to close the img element before the malicious script.
Related Security Principles
  • Reluctance To Trust
  • Defense In Depth
Related Guidelines
  • Never Use Unvalidated Input as Part of a Directive to any Internal Component
  • Treat the Entire Inherited Process Context as Unvalidated Input
Purpose

Penetration

Exploitation

CIA Impact
Confidentiality ImpactIntegrity ImpactAvailability Impact
HighHighHigh
Technical Context
Architectural ParadigmFrameworkPlatformLanguage
Client-ServerAllAllAll
Source
Submission(s)
SubmitterOrganizationDateComment
Chiradeep B. Chhaya2007-03-15First Draft
Modification(s)
ModifierOrganizationDateComment
Sean BarnumCigital, Inc2007-04-16Review and revise
 
Page Last Updated: April 18, 2008