[Israel.pm] perl memory and buffer overflows

Gaal Yahas gaal at forum2.org
Sun Dec 26 10:37:19 PST 2004

amit sides wrote:

>>> im very intersting at perl secure programing and how to avoid 
>>> buffer-overflow and how to mange the memory with perl.
>>> i wonder if you guys know any good guide/book about it.
>> This kind of bug isn't a normal concern of a Perl programmer. All Perl
>> data structures grow as needed, so you can't exploitably smash the stack
>> just by pushing large inputs at perl functions. In fact, Perl does not
>> *have* automatic variables a la c at all. All variables are allocated on
>> a heap and managed with reference counting.
> cant i overflow the heap , and to overwrite the perl code there to my 
> code ?

Theoretically yes, but it takes a bug in the perl interpreter, not in
the particular Perl program you are attacking; in that case there's not
much difference if you're overflowing the heap or the stack, since
neither should happen "easily".

$long_string = "A" x $huge_number might cause an out of memeory error,
but that's something completely different from

      char *x = malloc(16);
      memcpy(x, &attacking_code, 666666666); /* evil */


Gaal Yahas <gaal at forum2.org>

More information about the Perl mailing list