πŸ’‰SSI Injection

What is SSI in simple terms?

Server-Side Includes (SSI) is a mechanism by which the web server processes special comments in HTML before the page is sent to the user.


That is:

  • The browser doesn't see SSI

  • SSI is executed on the server side.

  • The execution result is inserted directly into HTML

Essentially, it is a very primitive server-side templating engine that appeared long before PHP, JSP, etc.


Why SSI is dangerous

If:

  • The server allows SSI

  • And user input goes to a file that is processed by SSI

then the server will execute what was put there;

This is already:

  • reading server information

  • sometimes - command execution

  • sometimes - full RCE


File extensions (.shtml - NOT a guarantee)

SSI is typically included for:

  • .shtml

  • .shtm

  • .stm

But this is not a rule;

Admin can enable SSI:

  • for .html

  • for .txt

  • for any file in general

That's why:

  • SSI cannot be determined by extension alone

  • needs to be checked by behavior


SSI syntax

SSI looks like an HTML comment, but with a #:

Why is this important:

  • The browser ignores a regular HTML comment

  • The server interprets the SSI comment


Basic Directives

  • printenv

displays server environment variables;

Practical benefits:

  • find out PATH

  • find out user

  • CGI configuration

  • sometimes - sensitive variables

Often used as a first test, if it works, SSI is definitely enabled.


  • config

What it does:

  • changes the SSI configuration

  • most often used indirectly

Practice:

  • can help disguise errors

  • rarely used in direct attacks


  • echo

Prints server variables;

Useful variables:

  • DOCUMENT_NAME - file name

  • DOCUMENT_URI β€” path

  • DATE_LOCAL β€” server time

  • LAST_MODIFIED

Used:

  • to verify SSI

  • to collect information


  • include

inserts a file from the web root;

Restrictions:

  • You can't go beyond the web root


  • exec

executes a command on the server;

This:

  • full RCE

  • executed by the web server user (www-data, apache, iis)


Here you can see example requests:


References & More About SSI Injection

Last updated