Server Side Include (SSI) Injection
Attack Pattern ID: 101 (Standard Attack Pattern Completeness: Complete)Typical Severity: HighStatus: Draft
+ Description


An attacker can use Server Side Include (SSI) Injection to send code to a web application that then gets executed by the web server. Doing so enables the attacker to achieve similar results to Cross Site Scripting, viz., arbitrary code execution and information disclosure, albeit on a more limited scale, since the SSI directives are nowhere near as powerful as a full-fledged scripting language. Nonetheless, the attacker can conveniently gain access to sensitive files, such as password files, and execute shell commands.

Attack Execution Flow

  1. Determine applicability:

    The attacker determines whether server side includes are enabled on the target web server.

    Attack Step Techniques

    IDAttack Step Technique DescriptionEnvironments

    Look for popular page file names. The attacker will look for .shtml, .shtm, .asp, .aspx, and other well known strings in URLs to help determine whether SSI functionality is enabled.


    Fetch .htaccess file. In Apache web server installations, the .htaccess file may enable server side includes in specific locations. In those cases, the .htaccess file lives inside the directory where SSI is enabled, and is theoretically fetchable from the web server. Although most web servers deny fetching the .htaccess file, a misconfigured server will allow it. Thus, an attacker will frequently try it.



    IDtypeIndicator DescriptionEnvironments

    If .htaccess files are used, their contents should be checked for "Options Includes" or "Options IncludesNOEXEC".


    If apache is used, the contents of the httpd.conf file and similar configuration files should be checked for "Options Includes" or "Options IncludesNOEXEC".


    IIS configurations contain server-side include compatibility.


    Web pages that include mundane, but dynamic information (like the current date, a file's size, or some other data that SSI can produce) might be producing that content through SSI.


    Security Controls

    IDtypeSecurity Control Description
    Adding "AllowOverrides none" to the main httpd.conf file on an server (and the similar restrictions in other application servers) can prevent unexpected loosening of SSI functionality, even by internal developers.
  2. Attempt SSI:

    Look for user controllable input, including HTTP headers, that can carry server side include directives to the web server

    Attack Step Techniques

    IDAttack Step Technique DescriptionEnvironments

    Use a spidering tool to follow and record all links. Make special note of any links that include parameters in the URL.


    Use a proxy tool to record all links visited during a manual traversal of the web application. Make special note of any links that include parameters in the URL. Manual traversal of this type is frequently necessary to identify forms that are GET method forms rather than POST forms.



    IDtypeIndicator DescriptionEnvironments

    URL parameters are used.


    No parameters appear on the URL. Even though none appear, the web application may still use them if they are provided.



    IDtypeOutcome Description
    A list of URLs, with their corresponding parameters is created by the attacker.

    Security Controls

    IDtypeSecurity Control Description
    Monitor velocity of page fetching in web logs. Humans who view a page and select a link from it will click far slower and far less regularly than tools. Tools make requests very quickly and the requests are typically spaced apart regularly (e.g. 0.8 seconds between them).
    Create links on some pages that are visually hidden from web browsers. Using IFRAMES, images, or other HTML techniques, the links can be hidden from web browsing humans, but visible to spiders and programs. A request for the page, then, becomes a good predictor of an automated tool probing the application.
    Actively monitor the application and either deny or redirect requests from origins that appear to be automated.
  3. SecurityDatabase\Alert\Inject SSI:

    The attacker may then need to view a particular page in order to have the server execute the include directive and run a command or open a file on behalf of the attacker


    IDtypeOutcome Description
    The attacker views data (perhaps from a file) that he normally should not see.
    The attacker executes a command on the server, or influences the arguments to a command executed via SSI on the server.
+ Attack Prerequisites

A web server that supports server side includes and has them enabled

User controllable input that can carry include directives to the web server

+ Typical Likelihood of Exploit

Likelihood: Very High

It is fairly easy to determine whether server-side includes are permitted on the target server. An attacker can potentially glean a lot of information if SSI Injection were found to be possible.

+ Methods of Attack
  • Injection
  • Protocol Manipulation
+ Examples-Instances


Consider a website hosted on a server that permits Server Side Includes (SSI), such as Apache with the "Options Includes" directive enabled.

Whenever an error occurs, the HTTP Headers along with the entire request are logged, which can then be displayed on a page that allows review of such errors. A malicious user can inject SSI directives in the HTTP Headers of a request designed to create an error.

When these logs are eventually reviewed, the server parses the SSI directives and executes them.

+ Attacker Skills or Knowledge Required

Skill or Knowledge Level: Medium

The attacker needs to be aware of SSI technology, determine the nature of injection and be able to craft input that results in the SSI directives being executed.

+ Resources Required

None: Determining whether the server supports SSI does not require special tools, and nor does injecting directives that get executed.

+ Probing Techniques

The attacker can probe for enabled SSI by injecting content that can be interpreted as SSI directives and viewing the page output

+ Solutions and Mitigations

Set the OPTIONS IncludesNOEXEC in the global access.conf file or local .htaccess (Apache) file to deny SSI execution in directories that do not need them

All user controllable input must be appropriately sanitized before use in the application. This includes omitting, or encoding, certain characters or strings that have the potential of being interpreted as part of an SSI directive

Server Side Includes must be enabled only if there is a strong business reason to do so. Every additional component enabled on the web server increases the attack surface as well as administrative overhead

+ Attack Motivation-Consequences
  • Information Leakage
  • Run Arbitrary Code
+ Injection Vector

User controllable input

+ Payload

SSI directives that can cause disclosure of file contents or execution of commands

+ Activation Zone

The web server that parses and executes SSI directives before rendering the HTML page

+ Payload Activation Impact

The SSI directives cause the inclusion of certain file's contents or the execution of a shell command, as directed by the attacker

+ Related Weaknesses
CWE-IDWeakness NameWeakness Relationship Type
97Failure to Sanitize Server-Side Includes (SSI) Within a Web PageTargeted
74Failure to Sanitize Data into a Different Plane ('Injection')Secondary
20Improper Input ValidationSecondary
713OWASP Top Ten 2007 Category A2 - Injection FlawsSecondary
+ Related Attack Patterns
NatureTypeIDNameDescriptionView(s) this relationship pertains toView\(s\)
ChildOfCategoryCategory253Remote Code Inclusion 
Mechanism of Attack (primary)1000
ChildOfCategoryCategory369WASC Threat Classification 2.0 - WASC-36 - SSI Injection 
WASC Threat Classification 2.0333
+ Related Security Principles
  • Reluctance To Trust

  • Complete Mediation

+ Related Guidelines
  • Never Use Unvalidated Input as Part of a Directive to any Internal Component

+ Purposes
  • Penetration
  • Exploitation
+ CIA Impact
Confidentiality Impact: HighIntegrity Impact: HighAvailability Impact: High
+ Technical Context
Architectural Paradigms
+ Content History
Chiradeep B. Chhaya2007-04-20First Draft
Sean BarnumCigital, Inc2007-04-20Review and revision of content