Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Garbage Collection & Secure Programming

by Anonymous Monk
on May 03, 2006 at 02:10 UTC ( [id://547038]=note: print w/replies, xml ) Need Help??


in reply to Garbage Collection & Secure Programming

I think it is best to understand *why* a buffer overflow is a security risk and then to look at the analogous issues with Perl programming. A buffer overflow is typically used as follows...

1. Attacker locates buggy code that harbors buffer overflow opportunity

2. Attacker crafts input that overflows buffer, placing custom code into location in memory that is executable and further crafts input so that that custom code is jumped to and executed.

3. The custom code is typically code that gives the attacker a root shell or some such.

In other words, the nature of the attack is predicated on the ability of C/C++ code to address memory directly. This is key. In Perl, we don't have the ability to address memory directly, thus rendering buffer overflows an improbability (throwing away the potential for exploits of interpreter bugs).

Attacking Perl code is different. Since Perl doesn't address memory, you can't overflow a buffer and write root-shell-launchers to stack/heap areas. Rather, you must take a different approach. The goal is the same - a root-shell-launcher. So...

1. Find a Perl daemon running as root or some other privileged user id that you'd like to mess about with

2. Craft input to the Perl deamon that takes advantage of bugs in the code to launch a root-shell launcher

No buffers to overflow? No problem...

1. back-ticks

2. system()

3. /e enabled regexes

4. piped open() calls

etc.

In other words, use the same approach as in attacking C/C++ - find privileged code that doesn't sufficiently validate input and take advantage of that to craft custom inputs to the code that will launch a root shell.

This is why we use taint mode in all CGI programming. Remember - all insecure code is that way because it makes assumptions that are not always true. Validate your input in all cases and security problems vanish. Easily stated, much less easily done. Good luck.

,welchavw - can't always be bothered to login, now can I?

  • Comment on Re: Garbage Collection & Secure Programming

Replies are listed 'Best First'.
Re^2: Garbage Collection & Secure Programming
by sgt (Deacon) on May 03, 2006 at 21:28 UTC
    just a comment on point 2. If you find input that overflows some buffer, it can be enough to crash the application (sigsegv, sigbus etc...) you don't need to put extra code in memory etc... that would be some kind of virus, a tougher exploit to craft

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://547038]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (4)
As of 2024-04-24 17:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found