Graal Forums  

Go Back   Graal Forums > Development Forums > Future Improvements
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 08-28-2009, 04:00 PM
TESTRETIS TESTRETIS is offline
Zvarri!
TESTRETIS's Avatar
Join Date: Oct 2003
Posts: 970
TESTRETIS has a spectacular aura about
Limitation of SQL Execution

Right now, I'm designing an interface on Classic to make a bridge way for the database and Staff. Although this makes a simplicity for others to use it, the vulnerabilities for requestsql() and requestsql2() exist.

If possible, I think it would be a wise idea to allow some sort of Server option to allow these commands to be executed only by certain allowed DB NPCs, Maybe classes, etc. The interface I'm designing though is compatible with anything that wants to request access to the databases, complete w/ permissions. But still, its security is still compromised due to the fact anyone with NC or Level access can cause unwanted hassles with our databases.
Reply With Quote
  #2  
Old 08-28-2009, 04:13 PM
Gambet Gambet is offline
Registered User
Join Date: Oct 2003
Posts: 2,712
Gambet is on a distinguished road
Couldn't you use callstack protection? You can't restrict the commands themselves but you can restrict whatever system you're using to write and access the information and make it so only that system can make alterations.
Reply With Quote
  #3  
Old 08-28-2009, 05:22 PM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
Quote:
Originally Posted by Gambet View Post
Couldn't you use callstack protection? You can't restrict the commands themselves but you can restrict whatever system you're using to write and access the information and make it so only that system can make alterations.
I think he's referring to someone just doing in a level or script somewhere.

PHP Code:
function onCreated() {
  
temp.statement "DELETE * FROM Important_Table";
  
requestsql(statementfalse);

But if they know how to do that then they're probably knowledgeable enough to use the restricted scripts anyway.

Best course of action, don't let people you don't trust have access to the scripts and levels, and filter through them if you have to. Besides there are so many better things they could do maliciously.
__________________
Quote:

Last edited by fowlplay4; 08-28-2009 at 05:39 PM..
Reply With Quote
  #4  
Old 08-28-2009, 05:57 PM
Gambet Gambet is offline
Registered User
Join Date: Oct 2003
Posts: 2,712
Gambet is on a distinguished road
Quote:
Originally Posted by fowlplay4 View Post
I think he's referring to someone just doing in a level or script somewhere.

PHP Code:
function onCreated() {
  
temp.statement "DELETE * FROM Important_Table";
  
requestsql(statementfalse);

But if they know how to do that then they're probably knowledgeable enough to use the restricted scripts anyway.

Best course of action, don't let people you don't trust have access to the scripts and levels, and filter through them if you have to. Besides there are so many better things they could do maliciously.
I suppose you could still incorporate callstack, though, by storing a backup of the data and making it so if the system that is supposed to access the database isn't the one updating the database then whatever changes made to the data is automatically reverted back to the backup.
Reply With Quote
  #5  
Old 08-30-2009, 11:54 AM
[email protected] sid.gottlieb@googlemail.com is offline
Banned
Join Date: Mar 2008
Posts: 861
sid.gottlieb@googlemail.com will become famous soon enough
HTML Code:
drop table [name]
Could cause an even bigger problem...
Reply With Quote
  #6  
Old 09-04-2009, 08:17 AM
napo_p2p napo_p2p is offline
oh snaps
napo_p2p's Avatar
Join Date: Sep 2003
Location: Pismo Beach, California
Posts: 2,118
napo_p2p has a spectacular aura aboutnapo_p2p has a spectacular aura about
Send a message via AIM to napo_p2p Send a message via MSN to napo_p2p
Quote:
Originally Posted by Gambet View Post
I suppose you could still incorporate callstack, though, by storing a backup of the data and making it so if the system that is supposed to access the database isn't the one updating the database then whatever changes made to the data is automatically reverted back to the backup.
How would one detect what's calling requestsql() to update the database?

Quote:
Originally Posted by [email protected] View Post
HTML Code:
drop table [name]
Could cause an even bigger problem...
Yes, especially since someone could get ALL the table names from sqlite_master. Luckily, backing up a SQLite database is as easy as copying a single file. Still, I agree that there should be some kind of built-in protection.
__________________
Scito hoc super omnia.
Haec vita est tua una sola.
Dum vita superest, utere maxime quoque puncto, momento, et hora quae habes.
Tempus neminem non manet.
Noli manere tempus.
Carpe Diem

Seize the Day.
Reply With Quote
  #7  
Old 09-04-2009, 10:27 AM
Inverness Inverness is offline
Incubator
Inverness's Avatar
Join Date: Aug 2004
Location: Houston, Texas
Posts: 3,613
Inverness is a jewel in the roughInverness is a jewel in the rough
I would propose something like a server option to limit the calling of requestsql() to a list of weapons, similar to what was done for Client-RC. This would need to protect against external class joins too, I don't know how or if the Client-RC did that.
__________________
Reply With Quote
  #8  
Old 09-04-2009, 12:54 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
At the very least, it should be disabled in level scripts.
__________________
Reply With Quote
  #9  
Old 09-04-2009, 04:04 PM
Gambet Gambet is offline
Registered User
Join Date: Oct 2003
Posts: 2,712
Gambet is on a distinguished road
Quote:
Originally Posted by napo_p2p View Post
How would one detect what's calling requestsql() to update the database?
You could use a loop to compare the database with the backup and revert the database to the backup if they aren't the same file, then when the main system updates the database, simply have it update the backup at the same time. Of course, if there's no way of protecting the backup file, then the backup file itself could be changed, but I suppose you could try hiding it as well as possible to avoid other people knowing about it (random file name).

This wouldn't be very secure unless you made some file name randomizer that always recreates the backup file with a different, random name so that no one can know its name unless they had direct rights to the file, which would help prevent people from messing with it that aren't supposed to. It would take some complex systems but I suppose it would be possible to mimic something like this.

Last edited by Gambet; 09-04-2009 at 04:17 PM..
Reply With Quote
  #10  
Old 09-04-2009, 05:20 PM
napo_p2p napo_p2p is offline
oh snaps
napo_p2p's Avatar
Join Date: Sep 2003
Location: Pismo Beach, California
Posts: 2,118
napo_p2p has a spectacular aura aboutnapo_p2p has a spectacular aura about
Send a message via AIM to napo_p2p Send a message via MSN to napo_p2p
Quote:
Originally Posted by Gambet View Post
You could use a loop to compare the database with the backup and revert the database to the backup if they aren't the same file, then when the main system updates the database, simply have it update the backup at the same time. Of course, if there's no way of protecting the backup file, then the backup file itself could be changed, but I suppose you could try hiding it as well as possible to avoid other people knowing about it (random file name).

This wouldn't be very secure unless you made some file name randomizer that always recreates the backup file with a different, random name so that no one can know its name unless they had direct rights to the file, which would help prevent people from messing with it that aren't supposed to. It would take some complex systems but I suppose it would be possible to mimic something like this.
Ahhh, I see what you're saying. However, for large databases with thousands of records, it isn't a very good idea to be looping. I guess one solution would be to keep track of the last inserted/updated record, and validate that instead.

buuuuuut, I'd still rather see built-in protection .
__________________
Scito hoc super omnia.
Haec vita est tua una sola.
Dum vita superest, utere maxime quoque puncto, momento, et hora quae habes.
Tempus neminem non manet.
Noli manere tempus.
Carpe Diem

Seize the Day.
Reply With Quote
  #11  
Old 09-04-2009, 09:55 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by Gambet View Post
You could use a loop to compare the database with the backup and revert the database to the backup if they aren't the same file, then when the main system updates the database, simply have it update the backup at the same time. Of course, if there's no way of protecting the backup file, then the backup file itself could be changed, but I suppose you could try hiding it as well as possible to avoid other people knowing about it (random file name).

This wouldn't be very secure unless you made some file name randomizer that always recreates the backup file with a different, random name so that no one can know its name unless they had direct rights to the file, which would help prevent people from messing with it that aren't supposed to. It would take some complex systems but I suppose it would be possible to mimic something like this.
This is all wrong (though logical) until Stefan allows .db files to be modified by script.
__________________
Reply With Quote
  #12  
Old 09-05-2009, 01:51 AM
Admins Admins is offline
Graal Administration
Join Date: Jan 2000
Location: Admins
Posts: 11,693
Admins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud of
It would be good to have some kind of script rights system, may be for the start some way to set general rights that apply to all npcs, weapons and levels, and then a way to define rights for each single object. So it could be used to disallow putnpc2 by level npcs, and also disallow sql access.
Reply With Quote
  #13  
Old 09-05-2009, 03:02 AM
Inverness Inverness is offline
Incubator
Inverness's Avatar
Join Date: Aug 2004
Location: Houston, Texas
Posts: 3,613
Inverness is a jewel in the roughInverness is a jewel in the rough
Quote:
Originally Posted by cbk1994 View Post
This is all wrong (though logical) until Stefan allows .db files to be modified by script.
We do not need to be modifying database files with anything but SQL queries or built-in functions. Anything else just invites trouble like file corruption or abuse.
__________________
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 08:03 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.