SQLite Security

Everything else that doesn't fall into one of the other PB categories.
User avatar
silvercover
User
User
Posts: 86
Joined: Sat Aug 04, 2007 6:57 pm

SQLite Security

Post by silvercover »

Hi,

I planned to use SQLite in my application. my question is how can I prevent unwanted access to my database and generally how can we protect our databases while they are running locally?

Thanks in advance.
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6175
Joined: Sat May 17, 2003 11:31 am
Contact:

Post by blueznl »

AFAIK not... perhaps thru the SQLite API but not via a PureBasic directly.
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB - upgrade incoming...)
( The path to enlightenment and the PureBasic Survival Guide right here... )
User avatar
pdwyer
Addict
Addict
Posts: 2813
Joined: Tue May 08, 2007 1:27 pm
Location: Chiba, Japan

Post by pdwyer »

Only normal file permissions for the db file itself
Paul Dwyer

“In nature, it’s not the strongest nor the most intelligent who survives. It’s the most adaptable to change” - Charles Darwin
“If you can't explain it to a six-year old you really don't understand it yourself.” - Albert Einstein
dige
Addict
Addict
Posts: 1432
Joined: Wed Apr 30, 2003 8:15 am
Location: Germany
Contact:

Post by dige »

Or you encrypt / decrypt the whole db file and use a :memorydb: during runtime..
User avatar
silvercover
User
User
Posts: 86
Joined: Sat Aug 04, 2007 6:57 pm

Post by silvercover »

Thank you guys.

dige,

where should I use this :memorydb:? in my query or what?

Thanks again. :)
User avatar
pdwyer
Addict
Addict
Posts: 2813
Joined: Tue May 08, 2007 1:27 pm
Location: Chiba, Japan

Post by pdwyer »

You'd have to put the decrypted file back on the disk though temporarily to read it into a :memory: db though wouldn't you?

@Silvercover, search the forums for ":memory:" and you should find it
Paul Dwyer

“In nature, it’s not the strongest nor the most intelligent who survives. It’s the most adaptable to change” - Charles Darwin
“If you can't explain it to a six-year old you really don't understand it yourself.” - Albert Einstein
dige
Addict
Addict
Posts: 1432
Joined: Wed Apr 30, 2003 8:15 am
Location: Germany
Contact:

Post by dige »

yes, like pdwyer told you... decrypt the dbfile, open a memory database and
copy the content.
its very easy, just read the sqlite_master table, to build a general solution.

if you need it once more safer, do not save the memory database content into a sqlite file, but rather into a memory block, cryp and save the memory afterwards..
User avatar
silvercover
User
User
Posts: 86
Joined: Sat Aug 04, 2007 6:57 pm

Post by silvercover »

When we have encrypted our date and save them, how can we show encrypted data when needed. I mean as far as I know there must be 2 way encryption/decryption method.

I know how to shape SELECT query with encrypted data but what to do with encrypted results?

Thank you guys.
dige
Addict
Addict
Posts: 1432
Joined: Wed Apr 30, 2003 8:15 am
Location: Germany
Contact:

Post by dige »

If you save encrypted data into the database, you can only use SELECT * , bcoz the data are not readable for database engine and lose a lot of SQL power

What we mean is, encrypt / decrypt the whole datafile...
User avatar
pdwyer
Addict
Addict
Posts: 2813
Joined: Tue May 08, 2007 1:27 pm
Location: Chiba, Japan

Post by pdwyer »

I think you mean you can't use LIKE %%, not select * which is just columns
Paul Dwyer

“In nature, it’s not the strongest nor the most intelligent who survives. It’s the most adaptable to change” - Charles Darwin
“If you can't explain it to a six-year old you really don't understand it yourself.” - Albert Einstein
dige
Addict
Addict
Posts: 1432
Joined: Wed Apr 30, 2003 8:15 am
Location: Germany
Contact:

Post by dige »

pdwyer wrote:I think you mean you can't use LIKE %%, not select * which is just columns
Yes, you're right. I mean you can't use the WHERE clause
User avatar
pdwyer
Addict
Addict
Posts: 2813
Joined: Tue May 08, 2007 1:27 pm
Location: Chiba, Japan

Post by pdwyer »

I suppose (thinking off the top of my head here) if you used a byte for byte simple encryption like xor, you might be able to match the search string with the encryption... for xor to be any good though you'd need a very long random key, which would make searching on it a problem :?

there might be some way to do it though.


hmmm, maybe not, unless the encryption was almost useless
Paul Dwyer

“In nature, it’s not the strongest nor the most intelligent who survives. It’s the most adaptable to change” - Charles Darwin
“If you can't explain it to a six-year old you really don't understand it yourself.” - Albert Einstein
User avatar
silvercover
User
User
Posts: 86
Joined: Sat Aug 04, 2007 6:57 pm

Post by silvercover »

@pdwyer

No I have not used byte level encryption.
if you need it once more safer, do not save the memory database content into a sqlite file, but rather into a memory block, cryp and save the memory afterwards..
I don't know how to do this. :(
User avatar
pdwyer
Addict
Addict
Posts: 2813
Joined: Tue May 08, 2007 1:27 pm
Location: Chiba, Japan

Post by pdwyer »

SQLite web page implies that there is an encryption feature, but I'm not sure if it's an add on for purchase though.

Looks like they are 3rd party tools like http://sqlite-crypt.com/

How secure does this need to be?
Paul Dwyer

“In nature, it’s not the strongest nor the most intelligent who survives. It’s the most adaptable to change” - Charles Darwin
“If you can't explain it to a six-year old you really don't understand it yourself.” - Albert Einstein
User avatar
silvercover
User
User
Posts: 86
Joined: Sat Aug 04, 2007 6:57 pm

Post by silvercover »

Mainly SQLite engine does not have native security protections. SQLite owners only offer a component for commercial purposes to be set on basic engine and that will be cost 2000 $. on the other side we can implement our security methods such as encryption.

At least basic protection would be OK.
Post Reply