Autor Beitrag
Aya
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1964
Erhaltene Danke: 15

MacOSX 10.6.7
Xcode / C++
BeitragVerfasst: Do 07.07.11 08:16 
Hi,

es gibt im MySQL ja dieses PREPARE:
dev.mysql.com/doc/re...ared-statements.html

Weiß jemand ob das SQL Injection sicher ist?
Also wenn ich z.B. hier:

PREPARE stmt1 FROM 'SELECT * FROM customers WHERE name = ?';
SET @a = [userinput];
EXECUTE stmt1 USING @a;

Ist es hier noch moeglich SQL Injections zu machen indem man z.B. irgendwie 'SELECT irgendwas' oder 'DELETE..' als UserInput bekommt?

Aya

_________________
Aya
I aim for my endless dreams and I know they will come true!
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Do 07.07.11 12:10 
Sofern Du deine Parameter z.B. direkt über die API und nicht als SQL-Befehl setzt, sind Prepared Statements gegen SQL-Injections geschützt.

Hintergrund ist der, dass man durch die Parameter SQL schon im Vorfeld mitteilt, wo Parameter sind und somit eine Durchmischung von verschiedenen Programmkontexten (Code und Daten) vermeidet.

Bei deinem Beispiel wäre die SET-Zeile angreifbar. Dafür gibt es aber in PHP eine direkte Funktion (mysql_bind_param), mit der das vermieden werden kann.

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.