In the previous article, we looked into a mindset of signature writer. This is the core/heart of signature writing and what I have written alone is not enough to complete it. We would see about mindset and the thought process from time to time from here on, but it would be more of added feature to the other parts of signature writing. In this part, we would look into basics of web application attacks, the common types, the mindset of the attacker and the mindset of signature writer in this section of attacks, how to write good signatures in this category and how to test them.
Web Applications have been common target for different range of attackers, starting from the newbies to the pro’s. Newbies [whom some might call as script kiddies, but I don't want to because they aren't really kiddies anymore] are good at gathering easy tools, put them together and just start the attack process, while pro’s on the other hand apparently might recon for a very long time and take very little time to attack and cover the tracks. The following are the 3 categories of web application attacks that we come across most often:
The reason for dividing the server into “Private” and “Public” is because, all the content that you have inside Public_html or www folder is most commonly public to the world, and the rest of the server side stuff that you do not want people to see is on the private side[outside public_html]. Of course, files that aren’t linked or indexed would not be searchable, although this does not mean that they can never be found. Simple logic is to not keep any private stuff that you do not want to share with the outside world, inside public folder. As shown in the above diagram, the following are the most common web application attacks that we would also be looking into today:
- PHP File Inclusion/Remote File Inclusion
- SQL Injection
- Cross-site Scripting [XSS]
Remote File Inclusion [also known as PHP File Inclusion for remote PHP file inclusion vulnerability]
From the Wikipedia:
Remote File Inclusion (RFI) is a type of vulnerability most often found on websites, it allows an attacker to include a remote file usually through a script on the web server. The vulnerability occurs due to the use of user supplied input without proper validation. This can lead to something as minimal as outputting the contents of the file, but depending on the severity, to list a few it can lead to:
The above description is describing about XSS as a file inclusion because it is possible to push a file through XSS, although we would look into it later. Here we are looking at file inclusion over a variable in a file that does not have limits defined properly. Here is an example of PHP File Inclusion:
In the above example,
- Vulnerable File Frame : /file_frame.php?
- Vulnerable Variable : variable=
- Possible attacking script : http://www.malwareinc.com/malicious.php
- Other variables : f and s [they do not play any role in this exploit attempt]
Hence, what is happening is that the attacker is trying to push the file malicious.php which resides in malwareinc.com into your website’s file_frame.php file where the variable “variable” does not check its input bounds. Primarily, file inclusions occur since the user inputs does not get evaluated or processed, to filter out the bad ones when necessary.
SQL Injection
Definition SQL Injection from the Wikipedia:
SQL injection is a code injection technique that exploits a security vulnerability occurring in the database layer of an application. The vulnerability is present when user input is either incorrectly filtered for string literal escape characters embedded in SQL statements or user input is not strongly typed and thereby unexpectedly executed. It is an instance of a more general class of vulnerabilities that can occur whenever one programming or scripting language is embedded inside another. SQL injection attacks are also known as SQL insertion attacks.[1]
SQL injection is basically attacking the database layer, although it still has to go through the public files and the vulnerabilities in it. Which means that SQL injection is not targeting the vulnerability in the database itself, but the implementation of the file that attempts in connecting to the backend. Let us look at an example that would help us understand this more clearly:

In the above example,
- Vulnerable File Frame : /file_frame.php?
- Vulnerable Variable : variable=
- Possible attacking script : ‘ OR 1=1;#
- Other variables : f and s [they do not play any role in this exploit attempt]
In this example, the attacker knows [or finds out] that “variable=” parameter directly fills in the a value into a SQL query, as shown in the following example:
If the user input is pasted in the above query inside the PHP file, without parsing or sanitizing user input, then the query would change into the following input as shown below:
The modification inserts the value 1 into var1 and then tells the query OR 1=1, which means OR “TRUE”. Anything OR’ed with TRUE is always a TRUE,
- TRUE OR TRUE = TRUE
- FALSE OR TRUE = TRUE
Since 1=1 is always going to be true, semi-colon “;” ends the statement and “# or –” comments out the rest of the line , “select* from table” would display all the contents of the table irrespective of the where condition. From the above example, it could be clearly seen that the SQL injection targets the vulnerability in the file frame and the variable inside the file, for passing rogue[unexpected] value into the query, that could make the query run stuff that you do not want it to run. Since the query itself is ran from the apache server it is presumably running from a higher privilege, which could give external users to:
- SELECT
- UNION SELECT
- DELETE
- ALTER TABLE
- UPDATE
- DROP
- and more SQL queries.
This is why, user input validation is the most important step in a web application. Now, let us took at the final web application exploit type that we are going to look into, in this blog post.
Cross-site Scripting [XSS]
Definition from the Wikipedia:
Cross-site scripting (XSS) is a type of computer security vulnerability typically found in web applications which enable malicious attackers to inject client-side script into web pages viewed by other users. An exploited cross-site scripting vulnerability can be used by attackers to bypass access controls such as the same origin policy. Cross-site scripting carried out on websites were roughly 80% of all security vulnerabilities documented by Symantec as of 2007.[1] Their impact may range from a petty nuisance to a significant security risk, depending on the sensitivity of the data handled by the vulnerable site, and the nature of any security mitigations implemented by the site’s owner.
There are several types of XSS and there are many-many subcategories too. There is a really good site that describes this in a very huge list by Rsnake: ha.ckers.org. There was XSSDB from GNU citizen that has not been working for long time. Let us look into a simple example:

In the above example,
- Vulnerable File Frame : /file_frame.php?
- Vulnerable Variable : variable=
- Possible attacking script : <script>alert(‘XSS’)</script>
If the above exploit works, the users clicking on the above link would have a alert box opened up displaying XSS. Thereby, the attacker could take the user to the site he would like the user to download the malicious code from, or run malicious stuff on the user’s system even without redirecting to malicious site. There are several kinds of XSS, and one of the largest XSS web portal is XSSED. About XSSED:

The XSSed project was created in early February 2007 by Kevin Fernandez and DP. It provides information on all things related to cross-site scripting vulnerabilities and is the largest online archive of XSS vulnerable websites.
We started this project with the scope of increasing security and privacy on the web. Professional and amateur webmasters and web developers are notified about any cross-site scripting vulnerability affecting their online properties. The importance of securing their web applications is emphasized through the informational and educational content which we provide.
What we do is to simply validate all the submitted XSS vulnerable websites and then publish them on the archive. We actively assist all website owners to remediate the cross-site scripting issues by bringing them up to their attention on a timely manner. You will be helped by us for any problems you may face when trying to correct the XSS flaws. Please contact us.
Now that we have looked into the 3 types of web application exploits, let us look deep into the commonality in them:
- User input is not parsed
- Variable not sanitized
- Boundaries not fixed
- The entire file gets vulnerable
- Attackers gain web server privilege
There are also PHP parameters in the php.ini file which need to be checked for register_globals, filesize and other parameters. But we wont look into that in this article, since this is more of the signature writing document and not a complete web application security document. Although, for further reading, refer to OWASP for their work related to this. They have done a great deal of work in application security domain.
Hence, the common parameters in the all the above attacks are:
- File Frame
- Variable
- Attack Vector
Hence, this is what we would be considering for generating the signature. Let us look at putting the above parameters into a sample template that could generate and compare the signature with existing ET signatures [although I am not going into the implementation part, since it would be part of the Sign Analytics Project]:

Wouldn’t it be cool to have semi-automated signature generation engine that could aid you in generating signatures and testing them. Well, the answer is Yes! That is why, we are in the process of making one for you, but we need time or more volunteers to complete it, a.k.a. “to make it happen”. Let us continue looking into web application exploit signatures that are in ET to protect the users from such attacks:
SQL Injection
#by tinytwitty
alert tcp $EXTERNAL_NET any -> $HTTP_SERVERS $HTTP_PORTS (msg:”ET WEB_SPECIFIC_APPS 2z Project SQL Injection Attempt — rating.php rating SELECT”; flow:established,to_server; uricontent:”/includes/rating.php?“; nocase; uricontent:”rating=“; nocase; uricontent:”SELECT“; nocase; pcre:”/.+SELECT.+FROM/Ui”; classtype:web-application-attack; reference:cve,CVE-2007-2898; reference:url,www.securityfocus.com/archive/1/archive/1/469351/100/0/threaded; reference:url,doc.emergingthreats.net/2004059; reference:url,www.emergingthreats.net/cgi-bin/cvsweb.cgi/sigs/WEB_SPECIFIC_APPS/WEB_2z_project; sid:2004059; rev:7;)
alert tcp $EXTERNAL_NET any -> $HTTP_SERVERS $HTTP_PORTS (msg:”ET WEB_SPECIFIC_APPS 2z Project SQL Injection Attempt — rating.php rating UNION SELECT”; flow:established,to_server; uricontent:”/includes/rating.php?“; nocase; uricontent:”rating=“; nocase; uricontent:”UNION“; nocase; pcre:”/.+UNION\s+SELECT/Ui”; classtype:web-application-attack; reference:cve,CVE-2007-2898; reference:url,www.securityfocus.com/archive/1/archive/1/469351/100/0/threaded; reference:url,doc.emergingthreats.net/2004060; reference:url,www.emergingthreats.net/cgi-bin/cvsweb.cgi/sigs/WEB_SPECIFIC_APPS/WEB_2z_project; sid:2004060; rev:7;)
alert tcp $EXTERNAL_NET any -> $HTTP_SERVERS $HTTP_PORTS (msg:”ET WEB_SPECIFIC_APPS 2z Project SQL Injection Attempt — rating.php rating INSERT”; flow:established,to_server; uricontent:”/includes/rating.php?“; nocase; uricontent:”rating=“; nocase; uricontent:”INSERT“; nocase; pcre:”/.+INSERT.+INTO/Ui”; classtype:web-application-attack; reference:cve,CVE-2007-2898; reference:url,www.securityfocus.com/archive/1/archive/1/469351/100/0/threaded; reference:url,doc.emergingthreats.net/2004061; reference:url,www.emergingthreats.net/cgi-bin/cvsweb.cgi/sigs/WEB_SPECIFIC_APPS/WEB_2z_project; sid:2004061; rev:7;)
alert tcp $EXTERNAL_NET any -> $HTTP_SERVERS $HTTP_PORTS (msg:”ET WEB_SPECIFIC_APPS 2z Project SQL Injection Attempt — rating.php rating DELETE”; flow:established,to_server; uricontent:”/includes/rating.php?“; nocase; uricontent:”rating=“; nocase; uricontent:”DELETE“; nocase; pcre:”/.+DELETE.+FROM/Ui”; classtype:web-application-attack; reference:cve,CVE-2007-2898; reference:url,www.securityfocus.com/archive/1/archive/1/469351/100/0/threaded; reference:url,doc.emergingthreats.net/2004062; reference:url,www.emergingthreats.net/cgi-bin/cvsweb.cgi/sigs/WEB_SPECIFIC_APPS/WEB_2z_project; sid:2004062; rev:7;)
alert tcp $EXTERNAL_NET any -> $HTTP_SERVERS $HTTP_PORTS (msg:”ET WEB_SPECIFIC_APPS 2z Project SQL Injection Attempt — rating.php rating ASCII”; flow:established,to_server; uricontent:”/includes/rating.php?“; nocase; uricontent:”rating=“; nocase; uricontent:”SELECT“; nocase; pcre:”/.+ASCII\(.+SELECT/Ui”; classtype:web-application-attack; reference:cve,CVE-2007-2898; reference:url,www.securityfocus.com/archive/1/archive/1/469351/100/0/threaded; reference:url,doc.emergingthreats.net/2004063; reference:url,www.emergingthreats.net/cgi-bin/cvsweb.cgi/sigs/WEB_SPECIFIC_APPS/WEB_2z_project; sid:2004063; rev:7;)
alert tcp $EXTERNAL_NET any -> $HTTP_SERVERS $HTTP_PORTS (msg:”ET WEB_SPECIFIC_APPS 2z Project SQL Injection Attempt — rating.php rating UPDATE”; flow:established,to_server; uricontent:”/includes/rating.php?“; nocase; uricontent:”rating=“; nocase; uricontent:”UPDATE“; nocase; pcre:”/.+UPDATE.+SET/Ui”; classtype:web-application-attack; reference:cve,CVE-2007-2898; reference:url,www.securityfocus.com/archive/1/archive/1/469351/100/0/threaded; reference:url,doc.emergingthreats.net/2004064; reference:url,www.emergingthreats.net/cgi-bin/cvsweb.cgi/sigs/WEB_SPECIFIC_APPS/WEB_2z_project; sid:2004064; rev:7;)
From all the above, the stuff in BOLD text explains what we looked at in the above discussion: File frame, variable and attack vector.
XSS Signature
#by tinytwitty
alert tcp $EXTERNAL_NET any -> $HTTP_SERVERS $HTTP_PORTS (msg:”ET WEB_SERVER Adobe RoboHelp XSS Attempt whstart.js”; flow:established,to_server; uricontent:”/whstart.js?“; nocase; pcre:”/<?(java|vb)?script>?.*<.+\/script>?/Ui”; classtype:web-application-attack; reference:cve,CVE-2007-1280; reference:url,www.securityfocus.com/archive/1/archive/1/468360/100/0/threaded; reference:url,doc.emergingthreats.net/2003897; reference:url,www.emergingthreats.net/cgi-bin/cvsweb.cgi/sigs/WEB_SERVER/WEB_Adobe; sid:2003897; rev:6;)
PHP Inclusion
#by stillsecure
alert tcp $EXTERNAL_NET any -> $HTTP_SERVERS $HTTP_PORTS (msg:”ET WEB_SPECIFIC_APPS Flatchat pmscript.php with Parameter Local File Inclusion”; flow:to_server,established; content:”GET “; depth:4; uricontent:”/pmscript.php?“; nocase; uricontent:”with=“; nocase; content:”../”; classtype:web-application-attack; reference:url,milw0rm.com/exploits/8549; reference:bugtraq,34734; reference:url,doc.emergingthreats.net/2009745; reference:url,www.emergingthreats.net/cgi-bin/cvsweb.cgi/sigs/WEB_SPECIFIC_APPS/WEB_Flatchat; sid:2009745; rev:3;)
From all the above examples, it is understandable that the above signatures can be semi-automated in the template we showed above. I hope that you get a clear picture of the commonalities and functionality of web application attacks and writing signatures to protect yourself from it. Thank you for choosing signature analytics!