Any form is SQL is basically a table. The way you use it is what determines its capabilities (e.g. unique item properties).
The security issues with SQL (including other SQL variants like MySQL) are generally SQL injection.
For example, if you had a table which stored a player's kills and deaths:
PHP Code:
+-----------+------+-------+
|account |kills |deaths |
+-----------+------+-------+
|Stefan |100 |20 |
|unixmad |0 |132 |
|cbk1994 |23 |92 |
+-----------+------+-------+
And had a player command like "/checkstats Stefan", your code might be like
PHP Code:
function onActionServerSide(cmd, acc) {
if (cmd == "checkStats") {
temp.req = requestSQL("SELECT * FROM points WHERE account = '" @ acc @ "'", true);
temp.stats = {req.rows[0].kills, req.rows[0].deaths};
player.chat = format("Stats for %s: %s (kills), %s (deaths)", acc, stats[0], stats[1]);
}
}
// assume there is a clientside trigger
This may seem totally benign but a tricky player might use the chat command
which would turn your SQL into
Quote:
|
SELECT * FROM points WHERE account = ''error lul'
|
which would obviously cause a syntax error, and depending on the situation, could be a problem. It's not hard to see how you could cause a problem like this. Take a bank system, for example, where a player is changing their PIN
PHP Code:
UPDATE bank SET pin = '1234' WHERE account = 'cbk1994'
If the PIN can be anything, the player could do this:
PHP Code:
UPDATE bank SET pin = '1234', balance = 100000, account = 'cbk1994' WHERE account = 'cbk1994'
This is a perfectly valid SQL query but could be abused. The PIN they would use to cause this problem is
Quote:
|
1234', balance = 100000, account = 'cbk1994
|
You see the problem?
Fortunately it's easy to fix.
Instead of:
PHP Code:
req("UPDATE bank SET pin = '" @ pin @ "' WHERE account = '" @ player.account @ "'");
you use:
PHP Code:
req("UPDATE bank SET pin = '" @ pin.escape() @ "' WHERE account = '" @ player.account.escape() @ "'");
Notice that I used
str.escape(). This turns a string like "Chris' house" to "Chris'' house". The way it is escaped is different between different SQL variants. When SQLite reads "Chris'' house", it knows that the two apostrophes are for escaping and that there should really just be one, so the string is still inserted as "Chris' house".
Essentially,
Quote:
|
Originally Posted by http://www.cgisecurity.com/questions/sql.shtml
SQL Injection happens when a developer accepts user input that is directly placed into a SQL Statement and doesn't properly filter out dangerous characters. This can allow an attacker to not only steal data from your database, but also modify and delete it.
|
Sorry for the long reply, eventually that would have been part of the guide.