Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

Re: Use PPI to Find SQL Injection Attacks

by jZed (Prior)
on Aug 14, 2007 at 18:14 UTC ( #632560=note: print w/replies, xml ) Need Help??

in reply to Use PPI to Find SQL Injection Attacks

Unless I'm misreading, some of the more serious false negatives include:
$dbh->do(qq{ /* comment */ INSERT INTO foo VALUES('$bad_stuff') }); $dbh->do(qq{ INSERT INTO foo VALUES($bad_stuff) }); $dbh->do( sprintf( "INSERT INTO foo VALUES(%s)", $bad_stuff ));
A better approach might be to find all the prepare() and do() statements and run them through a safe DBI subclass that does the prepare and evaluates what it prepared.

Replies are listed 'Best First'.
Re^2: Use PPI to Find SQL Injection Attacks
by Ovid (Cardinal) on Aug 14, 2007 at 18:58 UTC

    Excellent points on the SQL. I like the DBI subclass idea. Can you point me to some examples? I've never tried to do anything like that before.


    New address of my CGI Course.

      A minimal DBI subclass can be found here: Interpolate binds into SQL on error - DBI subclassing (possibly not the best example but since I wrote it I knew where to find it :-)). Basically you'd need to redefine execute() to do nothing, and redefine prepare() (in MyDBI::db) to do your injection checking.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://632560]
[Corion]: Muh. Maybe I should give a talk about how to program for auditors, as I find that this changes my approach to programs a bit ;)
[Corion]: (well, especially logging, as about everything about every decision a program makes could/should be logged :))

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (8)
As of 2017-05-23 15:53 GMT
Find Nodes?
    Voting Booth?