<s>
A	O
heap	B-General_Concept
overflow	I-General_Concept
,	O
heap	B-General_Concept
overrun	I-General_Concept
,	O
or	O
heap	O
smashing	O
is	O
a	O
type	O
of	O
buffer	B-General_Concept
overflow	I-General_Concept
that	O
occurs	O
in	O
the	O
heap	O
data	O
area	O
.	O
</s>
<s>
Heap	B-General_Concept
overflows	I-General_Concept
are	O
exploitable	O
in	O
a	O
different	O
manner	O
to	O
that	O
of	O
stack-based	B-Error_Name
overflows	I-Error_Name
.	O
</s>
<s>
Memory	O
on	O
the	O
heap	O
is	O
dynamically	B-Language
allocated	I-Language
at	B-Library
runtime	I-Library
and	O
typically	O
contains	O
program	O
data	O
.	O
</s>
<s>
Exploitation	O
is	O
performed	O
by	O
corrupting	O
this	O
data	O
in	O
specific	O
ways	O
to	O
cause	O
the	O
application	O
to	O
overwrite	O
internal	O
structures	O
such	O
as	O
linked	B-Data_Structure
list	I-Data_Structure
pointers	O
.	O
</s>
<s>
The	O
canonical	O
heap	B-General_Concept
overflow	I-General_Concept
technique	O
overwrites	O
dynamic	O
memory	O
allocation	O
linkage	O
(	O
such	O
as	O
malloc	B-Language
metadata	O
)	O
and	O
uses	O
the	O
resulting	O
pointer	O
exchange	O
to	O
overwrite	O
a	O
program	O
function	B-Language
pointer	I-Language
.	O
</s>
<s>
For	O
example	O
,	O
on	O
older	O
versions	O
of	O
Linux	B-Application
,	O
two	O
buffers	O
allocated	O
next	O
to	O
each	O
other	O
on	O
the	O
heap	O
could	O
result	O
in	O
the	O
first	O
buffer	O
overwriting	O
the	O
second	O
buffer	O
's	O
metadata	O
.	O
</s>
<s>
On	O
operating	B-General_Concept
systems	I-General_Concept
without	O
memory	B-General_Concept
protection	I-General_Concept
,	O
this	O
could	O
be	O
any	O
process	O
on	O
the	O
system	O
.	O
</s>
<s>
For	O
example	O
,	O
a	O
Microsoft	O
JPEG	O
GDI+	B-Operating_System
buffer	B-General_Concept
overflow	I-General_Concept
vulnerability	O
could	O
allow	O
remote	O
execution	O
of	O
code	O
on	O
the	O
affected	O
machine	O
.	O
</s>
<s>
iOS	B-Application
jailbreaking	I-Application
often	O
uses	O
heap	B-General_Concept
overflows	I-General_Concept
to	O
gain	O
arbitrary	O
code	O
execution	O
.	O
</s>
<s>
As	O
with	O
buffer	B-General_Concept
overflows	I-General_Concept
there	O
are	O
primarily	O
three	O
ways	O
to	O
protect	O
against	O
heap	B-General_Concept
overflows	I-General_Concept
.	O
</s>
<s>
Several	O
modern	O
operating	B-General_Concept
systems	I-General_Concept
such	O
as	O
Windows	O
and	O
Linux	B-Application
provide	O
some	O
implementation	O
of	O
all	O
three	O
.	O
</s>
<s>
Since	O
version	O
2.3.6	O
the	O
GNU	B-Language
libc	I-Language
includes	O
protections	O
that	O
can	O
detect	O
heap	B-General_Concept
overflows	I-General_Concept
after	O
the	O
fact	O
,	O
for	O
example	O
by	O
checking	O
pointer	O
consistency	O
when	O
calling	O
unlink	O
.	O
</s>
<s>
In	O
addition	O
,	O
Linux	B-Application
has	O
included	O
support	O
for	O
ASLR	O
since	O
2005	O
,	O
although	O
PaX	B-Device
introduced	O
a	O
better	O
implementation	O
years	O
before	O
.	O
</s>
<s>
Also	O
Linux	B-Application
has	O
included	O
support	O
for	O
NX-bit	B-General_Concept
since	O
2004	O
.	O
</s>
<s>
Microsoft	O
has	O
included	O
protections	O
against	O
heap	O
resident	O
buffer	B-General_Concept
overflows	I-General_Concept
since	O
April	O
2003	O
in	O
Windows	B-Application
Server	I-Application
2003	I-Application
and	O
August	O
2004	O
in	O
Windows	B-Application
XP	I-Application
with	O
Service	O
Pack	O
2	O
.	O
</s>
<s>
Later	O
versions	O
of	O
Windows	O
such	O
as	O
Vista	B-Application
,	O
Server	O
2008	O
and	O
Windows	O
7	O
include	O
:	O
Removal	O
of	O
commonly	O
targeted	O
data	O
structures	O
,	O
heap	O
entry	O
metadata	O
randomization	O
,	O
expanded	O
role	O
of	O
heap	O
header	O
cookie	O
,	O
randomized	O
heap	O
base	O
address	O
,	O
function	B-Language
pointer	I-Language
encoding	O
,	O
termination	O
of	O
heap	O
corruption	O
and	O
algorithm	O
variation	O
.	O
</s>
