CAPEC-101 - Server Side Include (SSI) Injection

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.

Severity

Likelihood

Confidentiality

Integrity

Availability

  • Attack Methods 2
  • Injection
  • Protocol Manipulation
  • Purposes 2
  • Penetration
  • Exploitation
  • Sec Principles 2
  • Reluctance To Trust
  • Complete Mediation
  • Scopes 2
  • Read files or directories
  • Read application data
  • Confidentiality
  • Execute unauthorized code or commands
  • Availability
  • Integrity
  • Confidentiality

Medium level: 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.

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

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

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

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

Never Use Unvalidated Input as Part of a Directive to any Internal Component

Step 1 - Determine applicability

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

Tecnique ID: 1 - Environment(s) env-Web

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.

Tecnique ID: 2 - Environment(s) env-Web

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.

Indicator ID: 1 - Environment(s) env-Web

Type: Positive

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

Indicator ID: 2 - Environment(s) env-Web

Type: Positive

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

Indicator ID: 3 - Environment(s) env-Web

Type: Positive

IIS configurations contain server-side include compatibility.

Indicator ID: 4 - Environment(s) env-Web

Type: Inconclusive

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 Control ID: 1

Type: Preventative

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.


Step 2 - Attempt SSI

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

Tecnique ID: 1 - Environment(s) env-Web

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

Tecnique ID: 2 - Environment(s) env-Web

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.

Indicator ID: 1 - Environment(s) env-Web

Type: Positive

URL parameters are used.

Indicator ID: 2 - Environment(s) env-Web

Type: Inconclusive

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


Security Control ID: 1

Type: Detective

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).

Security Control ID: 2

Type: Detective

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.

Security Control ID: 3

Type: Preventative

Actively monitor the application and either deny or redirect requests from origins that appear to be automated.


Outcome ID: 1

Type: Success

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


Step 3 - 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.


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