<s>
Cross-site	B-Protocol
request	I-Protocol
forgery	I-Protocol
,	O
also	O
known	O
as	O
one-click	O
attack	O
or	O
session	B-Protocol
riding	I-Protocol
and	O
abbreviated	O
as	O
CSRF	B-Protocol
(	O
sometimes	O
pronounced	O
sea-surf	O
)	O
or	O
XSRF	B-Protocol
,	O
is	O
a	O
type	O
of	O
malicious	O
exploit	O
of	O
a	O
website	O
or	O
web	B-Application
application	I-Application
where	O
unauthorized	O
commands	O
are	O
submitted	O
from	O
a	O
user	O
that	O
the	O
web	B-Application
application	I-Application
trusts	O
.	O
</s>
<s>
There	O
are	O
many	O
ways	O
in	O
which	O
a	O
malicious	O
website	O
can	O
transmit	O
such	O
commands	O
;	O
specially-crafted	O
image	O
tags	O
,	O
hidden	O
forms	O
,	O
and	O
JavaScript	B-Language
fetch	O
or	O
XMLHttpRequests	B-Protocol
,	O
for	O
example	O
,	O
can	O
all	O
work	O
without	O
the	O
user	O
's	O
interaction	O
or	O
even	O
knowledge	O
.	O
</s>
<s>
Unlike	O
cross-site	O
scripting	O
(	O
XSS	O
)	O
,	O
which	O
exploits	O
the	O
trust	O
a	O
user	O
has	O
for	O
a	O
particular	O
site	O
,	O
CSRF	B-Protocol
exploits	O
the	O
trust	O
that	O
a	O
site	O
has	O
in	O
a	O
user	O
's	O
browser	B-Application
.	O
</s>
<s>
In	O
a	O
CSRF	B-Protocol
attack	I-Protocol
,	O
an	O
innocent	O
end	O
user	O
is	O
tricked	O
by	O
an	O
attacker	O
into	O
submitting	O
a	O
web	O
request	O
that	O
they	O
did	O
not	O
intend	O
.	O
</s>
<s>
The	O
term	O
"	O
CSRF	B-Protocol
"	O
is	O
also	O
used	O
as	O
an	O
abbreviation	O
in	O
defences	O
against	O
CSRF	B-Protocol
attacks	I-Protocol
,	O
such	O
as	O
techniques	O
that	O
use	O
header	O
data	O
,	O
form	O
data	O
,	O
or	O
cookies	B-Application
,	O
to	O
test	O
for	O
and	O
prevent	O
such	O
attacks	O
.	O
</s>
<s>
In	O
a	O
CSRF	B-Protocol
attack	I-Protocol
,	O
the	O
attacker	O
's	O
goal	O
is	O
to	O
cause	O
an	O
innocent	O
victim	O
to	O
unknowingly	O
submit	O
a	O
maliciously	O
crafted	O
web	O
request	O
to	O
a	O
website	O
that	O
the	O
victim	O
has	O
privileged	O
access	O
to	O
.	O
</s>
<s>
This	O
web	O
request	O
can	O
be	O
crafted	O
to	O
include	O
URL	B-Protocol
parameters	I-Protocol
,	O
cookies	B-Application
and	O
other	O
data	O
that	O
appear	O
normal	O
to	O
the	O
web	O
server	O
processing	O
the	O
request	O
.	O
</s>
<s>
At	O
risk	O
are	O
web	B-Application
applications	I-Application
that	O
perform	O
actions	O
based	O
on	O
input	O
from	O
trusted	O
and	O
authenticated	O
users	O
without	O
requiring	O
the	O
user	O
to	O
authorize	O
(	O
e.g.	O
</s>
<s>
A	O
user	O
who	O
is	O
authenticated	O
by	O
a	O
cookie	B-Application
saved	O
in	O
the	O
user	O
's	O
web	B-Application
browser	I-Application
could	O
unknowingly	O
send	O
an	O
HTTP	B-Protocol
request	O
to	O
a	O
site	O
that	O
trusts	O
the	O
user	O
and	O
thereby	O
cause	O
an	O
unwanted	O
action	O
.	O
</s>
<s>
A	O
general	O
property	O
of	O
web	B-Application
browsers	I-Application
is	O
that	O
they	O
will	O
automatically	O
and	O
invisibly	O
include	O
any	O
cookies	B-Application
(	O
including	O
session	O
cookies	B-Application
and	O
others	O
)	O
used	O
by	O
a	O
given	O
domain	O
in	O
any	O
web	O
request	O
sent	O
to	O
that	O
domain	O
.	O
</s>
<s>
This	O
property	O
is	O
exploited	O
by	O
CSRF	B-Protocol
attacks	I-Protocol
.	O
</s>
<s>
In	O
the	O
event	O
that	O
a	O
user	O
is	O
tricked	O
into	O
inadvertently	O
submitting	O
a	O
request	O
through	O
their	O
browser	B-Application
these	O
automatically	O
included	O
cookies	B-Application
will	O
cause	O
the	O
forged	O
request	O
to	O
appear	O
real	O
to	O
the	O
web	O
server	O
and	O
it	O
will	O
perform	O
any	O
appropriately	O
requested	O
actions	O
including	O
returning	O
data	O
,	O
manipulating	O
session	O
state	O
,	O
or	O
making	O
changes	O
to	O
the	O
victim	O
's	O
account	O
.	O
</s>
<s>
In	O
order	O
for	O
a	O
CSRF	B-Protocol
attack	I-Protocol
to	O
work	O
,	O
an	O
attacker	O
must	O
identify	O
a	O
reproducible	O
web	O
request	O
that	O
executes	O
a	O
specific	O
action	O
such	O
as	O
changing	O
an	O
account	O
password	O
on	O
the	O
target	O
page	O
.	O
</s>
<s>
Once	O
the	O
victim	O
has	O
clicked	O
the	O
link	O
,	O
their	O
browser	B-Application
will	O
automatically	O
include	O
any	O
cookies	B-Application
used	O
by	O
that	O
website	O
and	O
submit	O
the	O
request	O
to	O
the	O
web	O
server	O
.	O
</s>
<s>
The	O
web	O
server	O
will	O
not	O
be	O
able	O
to	O
identify	O
the	O
forgery	O
because	O
the	O
request	O
was	O
made	O
by	O
a	O
user	O
that	O
was	O
logged	O
in	O
,	O
and	O
submitted	O
all	O
the	O
requisite	O
cookies	B-Application
.	O
</s>
<s>
Cross-site	B-Protocol
request	I-Protocol
forgery	I-Protocol
is	O
an	O
example	O
of	O
a	O
confused	O
deputy	O
attack	O
against	O
a	O
web	B-Application
browser	I-Application
because	O
the	O
web	B-Application
browser	I-Application
is	O
tricked	O
into	O
submitting	O
a	O
forged	O
request	O
by	O
a	O
less	O
privileged	O
attacker	O
.	O
</s>
<s>
CSRF	B-Protocol
commonly	O
has	O
the	O
following	O
characteristics	O
:	O
</s>
<s>
It	O
involves	O
sites	O
that	O
rely	O
on	O
a	O
user	O
's	O
identity	B-Application
.	O
</s>
<s>
It	O
exploits	O
the	O
site	O
's	O
trust	O
in	O
that	O
identity	B-Application
.	O
</s>
<s>
It	O
tricks	O
the	O
user	O
's	O
browser	B-Application
into	O
sending	O
HTTP	B-Protocol
requests	I-Protocol
to	O
a	O
target	O
site	O
where	O
the	O
user	O
is	O
already	O
authenticated	O
.	O
</s>
<s>
It	O
involves	O
HTTP	B-Protocol
requests	I-Protocol
that	O
have	O
side	O
effects	O
.	O
</s>
<s>
CSRF	B-Protocol
Token	O
vulnerabilities	O
have	O
been	O
known	O
and	O
in	O
some	O
cases	O
exploited	O
since	O
2001	O
.	O
</s>
<s>
Because	O
it	O
is	O
carried	O
out	O
from	O
the	O
user	O
's	O
IP	B-Protocol
address	I-Protocol
,	O
some	O
website	O
logs	O
might	O
not	O
have	O
evidence	O
of	O
CSRF	B-Protocol
.	O
</s>
<s>
The	O
Netflix	O
website	O
in	O
2006	O
had	O
numerous	O
vulnerabilities	O
to	O
CSRF	B-Protocol
,	O
which	O
could	O
have	O
allowed	O
an	O
attacker	O
to	O
perform	O
actions	O
such	O
as	O
adding	O
a	O
DVD	O
to	O
the	O
victim	O
's	O
rental	O
queue	O
,	O
changing	O
the	O
shipping	O
address	O
on	O
the	O
account	O
,	O
or	O
altering	O
the	O
victim	O
's	O
login	O
credentials	O
to	O
fully	O
compromise	O
the	O
account	O
.	O
</s>
<s>
The	O
online	O
banking	O
web	B-Application
application	I-Application
of	O
ING	O
Direct	O
was	O
vulnerable	O
to	O
a	O
CSRF	B-Protocol
attack	I-Protocol
that	O
allowed	O
illicit	O
money	O
transfers	O
.	O
</s>
<s>
Popular	O
video	O
website	O
YouTube	B-General_Concept
was	O
also	O
vulnerable	O
to	O
CSRF	B-Protocol
in	O
2008	O
and	O
this	O
allowed	O
any	O
attacker	O
to	O
perform	O
nearly	O
all	O
actions	O
of	O
any	O
user	O
.	O
</s>
<s>
McAfee	O
Secure	O
was	O
also	O
vulnerable	O
to	O
CSRF	B-Protocol
and	O
it	O
allowed	O
attackers	O
to	O
change	O
their	O
company	O
system	O
.	O
</s>
<s>
The	O
attack	O
carrier	O
link	O
may	O
be	O
placed	O
in	O
a	O
location	O
that	O
the	O
victim	O
is	O
likely	O
to	O
visit	O
while	O
logged	O
into	O
the	O
target	O
site	O
(	O
for	O
example	O
,	O
a	O
discussion	B-Application
forum	I-Application
)	O
,	O
or	O
sent	O
in	O
an	O
HTML	O
email	O
body	O
or	O
attachment	O
.	O
</s>
<s>
A	O
real	O
CSRF	B-Protocol
vulnerability	O
in	O
uTorrent	B-Application
(	O
)	O
exploited	O
the	O
fact	O
that	O
its	O
web	O
console	O
accessible	O
at	O
localhost:8080	O
allowed	O
critical	O
actions	O
to	O
be	O
executed	O
using	O
a	O
simple	O
GET	O
request	O
:	O
</s>
<s>
Attacks	O
were	O
launched	O
by	O
placing	O
malicious	O
,	O
automatic-action	O
HTML	O
image	O
elements	O
on	O
forums	O
and	O
email	O
spam	O
,	O
so	O
that	O
browsers	B-Application
visiting	O
these	O
pages	O
would	O
open	O
them	O
automatically	O
,	O
without	O
much	O
user	O
action	O
.	O
</s>
<s>
People	O
running	O
vulnerable	O
uTorrent	B-Application
version	O
at	O
the	O
same	O
time	O
as	O
opening	O
these	O
pages	O
were	O
susceptible	O
to	O
the	O
attack	O
.	O
</s>
<s>
CSRF	B-Protocol
attacks	I-Protocol
using	O
image	O
tags	O
are	O
often	O
made	O
from	O
Internet	B-Application
forums	I-Application
,	O
where	O
users	O
are	O
allowed	O
to	O
post	O
images	O
but	O
not	O
JavaScript	B-Language
,	O
for	O
example	O
using	O
BBCode	B-Language
:	O
</s>
<s>
When	O
accessing	O
the	O
attack	O
link	O
to	O
the	O
local	O
uTorrent	B-Application
application	O
at	O
,	O
the	O
browser	B-Application
would	O
also	O
always	O
automatically	O
send	O
any	O
existing	O
cookies	B-Application
for	O
that	O
domain	O
.	O
</s>
<s>
This	O
general	O
property	O
of	O
web	B-Application
browsers	I-Application
enables	O
CSRF	B-Protocol
attacks	I-Protocol
to	O
exploit	O
their	O
targeted	O
vulnerabilities	O
and	O
execute	O
hostile	O
actions	O
as	O
long	O
as	O
the	O
user	O
is	O
logged	O
into	O
the	O
target	O
website	O
(	O
in	O
this	O
example	O
,	O
the	O
local	O
uTorrent	B-Application
web	O
interface	O
)	O
at	O
the	O
time	O
of	O
the	O
attack	O
.	O
</s>
<s>
In	O
the	O
uTorrent	B-Application
example	O
described	O
above	O
,	O
the	O
attack	O
was	O
facilitated	O
by	O
the	O
fact	O
that	O
uTorrent	B-Application
's	O
web	O
interface	O
used	O
GET	O
request	O
for	O
critical	O
state-changing	O
operations	O
(	O
change	O
credentials	O
,	O
download	O
a	O
file	O
etc	O
.	O
</s>
<s>
Because	O
of	O
this	O
assumption	O
,	O
many	O
existing	O
CSRF	B-Protocol
prevention	O
mechanisms	O
in	O
web	B-Application
frameworks	I-Application
will	O
not	O
cover	O
GET	O
requests	O
,	O
but	O
rather	O
apply	O
the	O
protection	O
only	O
to	O
HTTP	B-Protocol
methods	O
that	O
are	O
intended	O
to	O
be	O
state-changing	O
.	O
</s>
<s>
An	O
attacker	O
may	O
forge	O
a	O
request	O
to	O
log	O
the	O
victim	O
into	O
a	O
target	O
website	O
using	O
the	O
attacker	O
's	O
credentials	O
;	O
this	O
is	O
known	O
as	O
login	O
CSRF	B-Protocol
.	O
</s>
<s>
Login	O
CSRF	B-Protocol
makes	O
various	O
novel	O
attacks	O
possible	O
;	O
for	O
instance	O
,	O
an	O
attacker	O
can	O
later	O
log	O
into	O
the	O
site	O
with	O
his	O
legitimate	O
credentials	O
and	O
view	O
private	O
information	O
like	O
activity	O
history	O
that	O
has	O
been	O
saved	O
in	O
the	O
account	O
.	O
</s>
<s>
This	O
attack	O
has	O
been	O
demonstrated	O
against	O
Google	B-Application
and	O
Yahoo	B-Application
.	O
</s>
<s>
Depending	O
on	O
the	O
type	O
,	O
the	O
HTTP	B-Protocol
request	O
methods	O
vary	O
in	O
their	O
susceptibility	O
to	O
the	O
CSRF	B-Protocol
attacks	I-Protocol
(	O
due	O
to	O
the	O
differences	O
in	O
their	O
handling	O
by	O
the	O
web	B-Application
browsers	I-Application
)	O
.	O
</s>
<s>
Therefore	O
,	O
the	O
protective	O
measures	O
against	O
an	O
attack	O
depend	O
on	O
the	O
method	O
of	O
the	O
HTTP	B-Protocol
request	O
.	O
</s>
<s>
In	O
HTTP	B-Protocol
GET	O
the	O
CSRF	B-Protocol
exploitation	O
is	O
trivial	O
,	O
using	O
methods	O
described	O
above	O
,	O
such	O
as	O
a	O
simple	O
hyperlink	O
containing	O
manipulated	O
parameters	O
and	O
automatically	O
loaded	O
by	O
an	O
IMG	O
tag	O
.	O
</s>
<s>
By	O
the	O
HTTP	B-Protocol
specification	O
however	O
,	O
GET	O
should	O
be	O
used	O
as	O
a	O
safe	O
method	O
,	O
that	O
is	O
,	O
not	O
significantly	O
changing	O
user	O
's	O
state	O
in	O
the	O
application	O
.	O
</s>
<s>
Applications	O
using	O
GET	O
for	O
such	O
operations	O
should	O
switch	O
to	O
HTTP	B-Protocol
POST	I-Protocol
or	O
use	O
anti-CSRF	O
protection	O
.	O
</s>
<s>
the	O
HTTP	B-Protocol
POST	I-Protocol
vulnerability	O
to	O
CSRF	B-Protocol
depends	O
on	O
the	O
usage	O
scenario	O
:	O
</s>
<s>
In	O
simplest	O
form	O
of	O
POST	O
with	O
data	O
encoded	O
as	O
a	O
query	B-Protocol
string	I-Protocol
(	O
field1	O
=	O
value1&field2	O
=	O
value2	O
)	O
CSRF	B-Protocol
attack	I-Protocol
is	O
easily	O
implemented	O
using	O
a	O
simple	O
HTML	B-General_Concept
form	I-General_Concept
and	O
anti-CSRF	O
measures	O
must	O
be	O
applied	O
.	O
</s>
<s>
other	O
HTTP	B-Protocol
methods	O
(	O
PUT	O
,	O
DELETE	O
etc	O
.	O
)	O
</s>
<s>
Additionally	O
,	O
while	O
typically	O
described	O
as	O
a	O
static	O
type	O
of	O
attack	O
,	O
CSRF	B-Protocol
can	O
also	O
be	O
dynamically	O
constructed	O
as	O
part	O
of	O
a	O
payload	O
for	O
a	O
cross-site	O
scripting	O
attack	O
,	O
as	O
demonstrated	O
by	O
the	O
Samy	O
worm	O
,	O
or	O
constructed	O
on	O
the	O
fly	O
from	O
session	O
information	O
leaked	O
via	O
offsite	O
content	O
and	O
sent	O
to	O
a	O
target	O
as	O
a	O
malicious	O
URL	O
.	O
</s>
<s>
CSRF	B-Protocol
tokens	O
could	O
also	O
be	O
sent	O
to	O
a	O
client	O
by	O
an	O
attacker	O
due	O
to	O
session	B-Protocol
fixation	I-Protocol
or	O
other	O
vulnerabilities	O
,	O
or	O
guessed	O
via	O
a	O
brute-force	O
attack	O
,	O
rendered	O
on	O
a	O
malicious	O
page	O
that	O
generates	O
thousands	O
of	O
failed	O
requests	O
.	O
</s>
<s>
The	O
attack	O
class	O
of	O
"	O
Dynamic	O
CSRF	B-Protocol
"	O
,	O
or	O
using	O
a	O
per-client	O
payload	O
for	O
session-specific	O
forgery	O
,	O
was	O
described	O
in	O
2009	O
by	O
Nathan	O
Hamiel	O
and	O
Shawn	O
Moyer	O
at	O
the	O
BlackHat	O
Briefings	O
,	O
though	O
the	O
taxonomy	O
has	O
yet	O
to	O
gain	O
wider	O
adoption	O
.	O
</s>
<s>
A	O
new	O
vector	O
for	O
composing	O
dynamic	O
CSRF	B-Protocol
attacks	I-Protocol
was	O
presented	O
by	O
Oren	O
Ofer	O
at	O
a	O
local	O
OWASP	O
chapter	O
meeting	O
in	O
January	O
2012	O
–	O
"	O
AJAX	B-Device
Hammer	O
–	O
Dynamic	O
CSRF	B-Protocol
"	O
.	O
</s>
<s>
Severity	O
metrics	O
have	O
been	O
issued	O
for	O
CSRF	B-Protocol
token	O
vulnerabilities	O
that	O
result	O
in	O
remote	O
code	O
execution	O
with	O
root	B-Application
privileges	I-Application
as	O
well	O
as	O
a	O
vulnerability	O
that	O
can	O
compromise	O
a	O
root	B-Protocol
certificate	I-Protocol
,	O
which	O
will	O
completely	O
undermine	O
a	O
public	B-Architecture
key	I-Architecture
infrastructure	I-Architecture
.	O
</s>
<s>
Several	O
things	O
have	O
to	O
happen	O
for	O
cross-site	B-Protocol
request	I-Protocol
forgery	I-Protocol
to	O
succeed	O
:	O
</s>
<s>
The	O
attacker	O
must	O
target	O
either	O
a	O
site	O
that	O
does	O
n't	O
check	O
the	O
referrer	B-Protocol
header	I-Protocol
or	O
a	O
victim	O
with	O
a	O
browser	B-Application
or	O
plugin	O
that	O
allows	O
referer	B-Protocol
spoofing	I-Protocol
.	O
</s>
<s>
(	O
Multiple	O
targets	O
can	O
be	O
simulated	O
by	O
including	O
multiple	O
images	O
on	O
a	O
page	O
,	O
or	O
by	O
using	O
JavaScript	B-Language
to	O
introduce	O
a	O
delay	O
between	O
clicks	O
.	O
)	O
</s>
<s>
Most	O
CSRF	B-Protocol
prevention	O
techniques	O
work	O
by	O
embedding	O
additional	O
authentication	O
data	O
into	O
requests	O
that	O
allows	O
the	O
web	B-Application
application	I-Application
to	O
detect	O
requests	O
from	O
unauthorized	O
locations	O
.	O
</s>
<s>
Synchronizer	O
token	O
pattern	O
(	O
STP	O
)	O
is	O
a	O
technique	O
where	O
a	O
token	O
,	O
secret	O
and	O
unique	O
value	O
for	O
each	O
request	O
,	O
is	O
embedded	O
by	O
the	O
web	B-Application
application	I-Application
in	O
all	O
HTML	B-General_Concept
forms	I-General_Concept
and	O
verified	O
on	O
the	O
server	O
side	O
.	O
</s>
<s>
using	O
a	O
hash	B-Algorithm
chain	I-Algorithm
of	O
random	O
seed	O
)	O
.	O
</s>
<s>
Example	O
of	O
STP	O
set	O
by	O
Django	B-Language
in	O
a	O
HTML	B-General_Concept
form	I-General_Concept
:	O
</s>
<s>
It	O
can	O
be	O
relaxed	O
by	O
using	O
per	O
session	O
CSRF	B-Protocol
token	O
instead	O
of	O
per	O
request	O
CSRF	B-Protocol
token	O
.	O
</s>
<s>
Web	B-Application
applications	I-Application
that	O
use	O
JavaScript	B-Language
for	O
the	O
majority	O
of	O
their	O
operations	O
may	O
use	O
the	O
following	O
anti-CSRF	O
technique	O
:	O
</s>
<s>
On	O
an	O
initial	O
visit	O
without	O
an	O
associated	O
server	O
session	O
,	O
the	O
web	B-Application
application	I-Application
sets	O
a	O
cookie	B-Application
.	O
</s>
<s>
Security	O
of	O
this	O
technique	O
is	O
based	O
on	O
the	O
assumption	O
that	O
only	O
JavaScript	B-Language
running	O
on	O
the	O
client	O
side	O
of	O
an	O
HTTPS	B-Protocol
connection	O
to	O
the	O
server	O
that	O
initially	O
set	O
the	O
cookie	B-Application
will	O
be	O
able	O
to	O
read	O
the	O
cookie	B-Application
's	O
value	O
.	O
</s>
<s>
JavaScript	B-Language
running	O
from	O
a	O
rogue	O
file	O
or	O
email	O
should	O
not	O
be	O
able	O
to	O
successfully	O
read	O
the	O
cookie	B-Application
value	O
to	O
copy	O
into	O
the	O
custom	O
header	O
.	O
</s>
<s>
Even	O
though	O
the	O
cookie	B-Application
may	O
be	O
automatically	O
sent	O
with	O
the	O
rogue	O
request	O
,	O
subject	O
to	O
the	O
cookies	B-Application
SameSite	O
policy	O
,	O
the	O
server	O
will	O
still	O
expect	O
a	O
valid	O
header	O
.	O
</s>
<s>
The	O
CSRF	B-Protocol
token	O
itself	O
should	O
be	O
unique	O
and	O
unpredictable	O
.	O
</s>
<s>
It	O
may	O
be	O
generated	O
randomly	O
,	O
or	O
it	O
may	O
be	O
derived	O
from	O
the	O
session	O
token	O
using	O
HMAC	B-Algorithm
:	O
</s>
<s>
The	O
CSRF	B-Protocol
token	O
cookie	B-Application
must	O
not	O
have	O
httpOnly	O
flag	O
,	O
as	O
it	O
is	O
intended	O
to	O
be	O
read	O
by	O
JavaScript	B-Language
by	O
design	O
.	O
</s>
<s>
This	O
technique	O
is	O
implemented	O
by	O
many	O
modern	O
frameworks	O
,	O
such	O
as	O
Django	B-Language
and	O
AngularJS	B-Application
.	O
</s>
<s>
Because	O
the	O
token	O
remains	O
constant	O
over	O
the	O
whole	O
user	O
session	O
,	O
it	O
works	O
well	O
with	O
AJAX	B-Device
applications	O
,	O
but	O
does	O
not	O
enforce	O
sequence	O
of	O
events	O
in	O
the	O
web	B-Application
application	I-Application
.	O
</s>
<s>
The	O
protection	O
provided	O
by	O
this	O
technique	O
can	O
be	O
thwarted	O
if	O
the	O
target	O
website	O
disables	O
its	O
same-origin	B-Protocol
policy	I-Protocol
using	O
one	O
of	O
the	O
following	O
techniques	O
:	O
</s>
<s>
Similarly	O
to	O
the	O
cookie-to-header	O
approach	O
,	O
but	O
without	O
involving	O
JavaScript	B-Language
,	O
a	O
site	O
can	O
set	O
a	O
CSRF	B-Protocol
token	O
as	O
a	O
cookie	B-Application
,	O
and	O
also	O
insert	O
it	O
as	O
a	O
hidden	O
field	O
in	O
each	O
HTML	B-General_Concept
form	I-General_Concept
.	O
</s>
<s>
When	O
the	O
form	O
is	O
submitted	O
,	O
the	O
site	O
can	O
check	O
that	O
the	O
cookie	B-Application
token	O
matches	O
the	O
form	O
token	O
.	O
</s>
<s>
The	O
same-origin	B-Protocol
policy	I-Protocol
prevents	O
an	O
attacker	O
from	O
reading	O
or	O
setting	O
cookies	B-Application
on	O
the	O
target	O
domain	O
,	O
so	O
they	O
cannot	O
put	O
a	O
valid	O
token	O
in	O
their	O
crafted	O
form	O
.	O
</s>
<s>
An	O
additional	O
"	O
SameSite	O
"	O
attribute	O
can	O
be	O
included	O
when	O
the	O
server	O
sets	O
a	O
cookie	B-Application
,	O
instructing	O
the	O
browser	B-Application
on	O
whether	O
to	O
attach	O
the	O
cookie	B-Application
to	O
cross-site	O
requests	O
.	O
</s>
<s>
If	O
this	O
attribute	O
is	O
set	O
to	O
"	O
strict	O
"	O
,	O
then	O
the	O
cookie	B-Application
will	O
only	O
be	O
sent	O
on	O
same-site	O
requests	O
,	O
making	O
CSRF	B-Protocol
ineffective	O
.	O
</s>
<s>
However	O
,	O
this	O
requires	O
the	O
browser	B-Application
to	O
recognise	O
and	O
correctly	O
implement	O
the	O
attribute	O
.	O
</s>
<s>
Browser	B-Application
extensions	O
such	O
as	O
RequestPolicy	O
(	O
for	O
Mozilla	B-Application
Firefox	I-Application
)	O
or	O
uMatrix	O
(	O
for	O
both	O
Firefox	B-Application
and	O
Google	O
Chrome/Chromium	O
)	O
can	O
prevent	O
CSRF	B-Protocol
by	O
providing	O
a	O
default-deny	O
policy	O
for	O
cross-site	O
requests	O
.	O
</s>
<s>
The	O
CsFire	O
extension	O
(	O
also	O
for	O
Firefox	B-Application
)	O
can	O
mitigate	O
the	O
impact	O
of	O
CSRF	B-Protocol
with	O
less	O
impact	O
on	O
normal	O
browsing	O
,	O
by	O
removing	O
authentication	O
information	O
from	O
cross-site	O
requests	O
.	O
</s>
<s>
The	O
NoScript	B-Operating_System
extension	O
for	O
Firefox	B-Application
mitigates	O
CSRF	B-Protocol
threats	O
by	O
distinguishing	O
trusted	O
from	O
untrusted	O
sites	O
,	O
and	O
removing	O
authentication	O
&	O
payloads	O
from	O
POST	B-Protocol
requests	I-Protocol
sent	O
by	O
untrusted	O
sites	O
to	O
trusted	O
ones	O
.	O
</s>
<s>
The	O
Application	O
Boundary	O
Enforcer	O
module	O
in	O
NoScript	B-Operating_System
also	O
blocks	O
requests	O
sent	O
from	O
internet	O
pages	O
to	O
local	O
sites	O
(	O
e.g.	O
</s>
<s>
localhost	B-Protocol
)	O
,	O
preventing	O
CSRF	B-Protocol
attacks	I-Protocol
on	O
local	O
services	O
(	O
such	O
as	O
uTorrent	B-Application
)	O
or	O
routers	O
.	O
</s>
<s>
The	O
Self	O
Destructing	O
Cookies	B-Application
extension	O
for	O
Firefox	B-Application
does	O
not	O
directly	O
protect	O
from	O
CSRF	B-Protocol
,	O
but	O
can	O
reduce	O
the	O
attack	O
window	O
,	O
by	O
deleting	O
cookies	B-Application
as	O
soon	O
as	O
they	O
are	O
no	O
longer	O
associated	O
with	O
an	O
open	O
tab	O
.	O
</s>
<s>
Various	O
other	O
techniques	O
have	O
been	O
used	O
or	O
proposed	O
for	O
CSRF	B-Protocol
prevention	O
historically	O
:	O
</s>
<s>
Verifying	O
that	O
the	O
request	O
's	O
headers	O
contain	O
X-Requested-With	O
(	O
used	O
by	O
Ruby	B-Application
on	I-Application
Rails	I-Application
before	O
v2.0	O
and	O
Django	B-Language
before	O
v1.2.5	O
)	O
,	O
or	O
checking	O
the	O
HTTP	B-Protocol
Referer	I-Protocol
header	O
and/or	O
HTTP	B-Protocol
Origin	O
header	O
.	O
</s>
<s>
However	O
,	O
this	O
is	O
insecure	O
–	O
a	O
combination	O
of	O
browser	B-Application
plugins	O
and	O
redirects	O
can	O
allow	O
an	O
attacker	O
to	O
provide	O
custom	O
HTTP	B-Protocol
headers	I-Protocol
on	O
a	O
request	O
to	O
any	O
website	O
,	O
hence	O
allowing	O
a	O
forged	O
request	O
.	O
</s>
<s>
Checking	O
the	O
HTTP	B-Protocol
Referer	I-Protocol
header	O
to	O
see	O
if	O
the	O
request	O
is	O
coming	O
from	O
an	O
authorized	O
page	O
is	O
commonly	O
used	O
for	O
embedded	O
network	O
devices	O
because	O
it	O
does	O
not	O
increase	O
memory	O
requirements	O
.	O
</s>
<s>
However	O
,	O
a	O
request	O
that	O
omits	O
the	O
Referer	B-Protocol
header	I-Protocol
must	O
be	O
treated	O
as	O
unauthorized	O
because	O
an	O
attacker	O
can	O
suppress	O
the	O
Referer	B-Protocol
header	I-Protocol
by	O
issuing	O
requests	O
from	O
FTP	O
or	O
HTTPS	B-Protocol
URLs	O
.	O
</s>
<s>
This	O
strict	O
Referer	B-Protocol
validation	O
may	O
cause	O
issues	O
with	O
browsers	B-Application
or	O
proxies	O
that	O
omit	O
the	O
Referer	B-Protocol
header	I-Protocol
for	O
privacy	O
reasons	O
.	O
</s>
<s>
Also	O
,	O
old	O
versions	O
of	O
Flash	O
(	O
before	O
9.0.18	O
)	O
allow	O
malicious	O
Flash	O
to	O
generate	O
GET	O
or	O
POST	B-Protocol
requests	I-Protocol
with	O
arbitrary	O
HTTP	B-Protocol
request	O
headers	O
using	O
CRLF	B-Protocol
Injection	I-Protocol
.	O
</s>
<s>
Similar	O
CRLF	B-Protocol
injection	I-Protocol
vulnerabilities	O
in	O
a	O
client	O
can	O
be	O
used	O
to	O
spoof	O
the	O
referrer	B-Protocol
of	O
an	O
HTTP	B-Protocol
request	O
.	O
</s>
<s>
POST	B-Protocol
request	I-Protocol
method	O
was	O
for	O
a	O
while	O
perceived	O
as	O
immune	O
to	O
trivial	O
CSRF	B-Protocol
attacks	I-Protocol
using	O
parameters	O
in	O
URL	O
(	O
using	O
GET	O
method	O
)	O
.	O
</s>
<s>
However	O
,	O
both	O
POST	O
and	O
any	O
other	O
HTTP	B-Protocol
method	O
can	O
be	O
now	O
easily	O
executed	O
using	O
XMLHttpRequest	B-Protocol
.	O
</s>
<s>
Filtering	O
out	O
unexpected	O
GET	O
requests	O
still	O
prevents	O
some	O
particular	O
attacks	O
,	O
such	O
as	O
cross-site	O
attacks	O
using	O
malicious	O
image	O
URLs	O
or	O
link	O
addresses	O
and	O
cross-site	O
information	O
leakage	O
through	O
<script>	O
elements	O
(	O
JavaScript	B-Language
hijacking	O
)	O
;	O
it	O
also	O
prevents	O
(	O
non-security-related	O
)	O
problems	O
with	O
aggressive	O
web	B-Application
crawlers	I-Application
and	O
link	B-Protocol
prefetching	I-Protocol
.	O
</s>
<s>
Cross-site	O
scripting	O
(	O
XSS	O
)	O
vulnerabilities	O
(	O
even	O
in	O
other	O
applications	O
running	O
on	O
the	O
same	O
domain	O
)	O
allow	O
attackers	O
to	O
bypass	O
essentially	O
all	O
CSRF	B-Protocol
preventions	O
.	O
</s>
