Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

Re: Preventing malicious T-SQL injection attacks

by bart (Canon)
on Mar 05, 2007 at 11:18 UTC ( #603190=note: print w/replies, xml ) Need Help??

in reply to Preventing malicious T-SQL injection attacks

I think you ought to be able to use placeholders for the parameters. Thus, you provide just as many question marks as there are parameters (BTW don't the parameters start at index 0?), and pass the actual parameter in the do call.
$Command = "EXEC $SPROC " . join ', ', ('?') x $elements_in_array;
This will produce something that looks like
EXEC FOO ?, ?, ?
(I have no idea if this is the proper syntax for calling stored procedures in T-SQL — perhaps it needs parens?)
which later you call through
$dbh->do($Command, undef, @CHOICE[1 .. $elements_in_array])
(The undef comes in place of the \%attr in the docs.)

That ought to remove all possible problems related to dangerous values in ther parameters, as they're all treated as content of strings.

And yes, you should check if $PROC looks right, like a proper procedure name, for example with a regex.

Replies are listed 'Best First'.
A reply falls below the community's threshold of quality. You may see it by logging in.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (6)
As of 2021-04-23 06:15 GMT
Find Nodes?
    Voting Booth?

    No recent polls found