Recent

Author Topic: Database with table encryption needed  (Read 1586 times)

thehidden

  • Jr. Member
  • **
  • Posts: 68
  • Freelancer
Database with table encryption needed
« on: May 11, 2019, 12:18:55 am »
Hi,

I have a customer request to use a database with table encryption. Meaning that even the database administrator can not read/add/alter the database content. Password for the tables will be send by my software to the database server. Database administrator can do everything else on the DB Server, exept accessing the content of the table.

Does anybody knows a database which works together with Free Pascal/Lazarus and has this feature? SQLite has it, but this is a single user Database.

Thank you for help in advance.

TheHidden
I am mostly writing software for Image/Video based Process Documentation and Warehouse/Invoicing.
Other Software only if the project is interesting.

lucamar

  • Hero Member
  • *****
  • Posts: 3447
Re: Database with table encryption needed
« Reply #1 on: May 11, 2019, 12:56:44 am »
Most database servers offer that possibility: PostgreSQL, Firebird, etc. In fact, SQLite is one of the few which doesn't have it as a core feature but through a plugin. :)

Google for: "<database> encryption" (p.e. "PostgreSQL encryption") to learn more
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus/FPC 2.0.8/3.0.4 & 2.0.10/3.2.0 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

thehidden

  • Jr. Member
  • **
  • Posts: 68
  • Freelancer
Re: Database with table encryption needed
« Reply #2 on: May 11, 2019, 03:25:05 pm »
Quote
Most database servers offer that possibility: PostgreSQL, Firebird, etc. In fact, SQLite is one of the few which doesn't have it as a core feature but through a plugin.

Yes, and the administrator is not EXCLUDED from accessing.

In other words: The DB Administrator has still full access, even the Database is encrypted. Exeption is SQLite for Single User, where the Password can be stored in the application.

But I need it for multiuser environements.

It is a must be that the DB Administrator is excluded from accessing/altering the table content. MsSQL 2016 could to it in theroy. In reality you would lost the usage of joins, where and between in SQL Statements.

Its is not that a DB Administrator is not trustworth. It is a legal requirement from my customer in germany for this kind of application.
I am mostly writing software for Image/Video based Process Documentation and Warehouse/Invoicing.
Other Software only if the project is interesting.

valdir.marcos

  • Hero Member
  • *****
  • Posts: 1018
Re: Database with table encryption needed
« Reply #3 on: May 11, 2019, 04:51:46 pm »
Hi,

I have a customer request to use a database with table encryption. Meaning that even the database administrator can not read/add/alter the database content. Password for the tables will be send by my software to the database server. Database administrator can do everything else on the DB Server, exept accessing the content of the table.

Does anybody knows a database which works together with Free Pascal/Lazarus and has this feature? SQLite has it, but this is a single user Database.

Thank you for help in advance.

TheHidden

Most database servers offer that possibility: PostgreSQL, Firebird, etc. In fact, SQLite is one of the few which doesn't have it as a core feature but through a plugin. :)

Google for: "<database> encryption" (p.e. "PostgreSQL encryption") to learn more

Quote
Most database servers offer that possibility: PostgreSQL, Firebird, etc. In fact, SQLite is one of the few which doesn't have it as a core feature but through a plugin.

Yes, and the administrator is not EXCLUDED from accessing.

In other words: The DB Administrator has still full access, even the Database is encrypted. Exeption is SQLite for Single User, where the Password can be stored in the application.

But I need it for multiuser environements.

It is a must be that the DB Administrator is excluded from accessing/altering the table content. MsSQL 2016 could to it in theroy. In reality you would lost the usage of joins, where and between in SQL Statements.

Its is not that a DB Administrator is not trustworth. It is a legal requirement from my customer in germany for this kind of application.
Unless you customer is highly proficient  in encryption techniques, you have some classic alternatives:
1. encrypt hard disk;
2. encrypt database;
3. encrypt via software only some fields from some tables. For instance: id, name, password etc.

If you want to go beyond that, you can customize the last solution by asking for a "pass phrase" each time your software or specific form is opened.
You can use that "pass phrase", which is unknown to everybody else besides your customer himself, to encrypt/decrypt stored information on database.

lucamar

  • Hero Member
  • *****
  • Posts: 3447
Re: Database with table encryption needed
« Reply #4 on: May 11, 2019, 05:09:41 pm »
Yes, and the administrator is not EXCLUDED from accessing.

In other words: The DB Administrator has still full access, even the Database is encrypted. Exeption is SQLite for Single User, where the Password can be stored in the application.

I think you're conflating two different issues: access control and data control.

Data from an encrypted database shouldn't be decodable by anyone without the key, not even the administrator. Indeed, probably one of the more frequent reasons to encrypt a database is to prevent having the data read in clear even if the server machine and/or the DB admin account themselves are compromised.

Access control is quite another thing: it just prevents someone else from sending/receiving data to the server: it's more a question of who can communicate with the DB server than of what those able to do it can do after that. You can see that having the DB admin unable to communicate with it is ... not a good idea :)
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus/FPC 2.0.8/3.0.4 & 2.0.10/3.2.0 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

thehidden

  • Jr. Member
  • **
  • Posts: 68
  • Freelancer
Re: Database with table encryption needed
« Reply #5 on: May 11, 2019, 05:41:54 pm »
Lucamar
Quote
I think you're conflating two different issues: access control and data control.
Not realy me, but tax law in germany.

The CPA from my customer is auditing the company and told my customer that the tax law requires that all actions in the database must be logged. No alternation, adding or deleting without a log entry. Even when it has been done by the DB Administrator. If last is not managed or possible by the Database Server, it must be ensured that the DB Administrator can not access the table content.

My customer has shown me the relevant parts of the tax law and the guidlines "GoB". Sorry, but it is realy written inside that an auditor can count on this "feature".



Vladir.marcos
Quote
Unless you customer is highly proficient  in encryption techniques, you have some classic alternatives:
1. encrypt hard disk;
2. encrypt database;
3. encrypt via software only some fields from some tables. For instance: id, name, password etc.

As written above, it looks like that I can use only 3. to get the order from my customer. Because the others does not fit their tax law.
I am mostly writing software for Image/Video based Process Documentation and Warehouse/Invoicing.
Other Software only if the project is interesting.

lucamar

  • Hero Member
  • *****
  • Posts: 3447
Re: Database with table encryption needed
« Reply #6 on: May 11, 2019, 05:49:54 pm »
Not realy me, but tax law in germany.

The CPA from my customer is auditing the company and told my customer that the tax law requires that all actions in the database must be logged. No alternation, adding or deleting without a log entry. Even when it has been done by the DB Administrator. If last is not managed or possible by the Database Server, it must be ensured that the DB Administrator can not access the table content.

My customer has shown me the relevant parts of the tax law and the guidlines "GoB". Sorry, but it is realy written inside that an auditor can count on this "feature".

Yes, I see. Hmmm ... there must be a way, or all German businesses would be outlaws :)

Let me chaeck a couple things: there may be a simpler way of preventing the admin from accessing some tables.

In the meantime you could check stackoverflow and similar; this is not really a FPC question but a general database one.
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus/FPC 2.0.8/3.0.4 & 2.0.10/3.2.0 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

john horst

  • Jr. Member
  • **
  • Posts: 66
    • JHorst
Re: Database with table encryption needed
« Reply #7 on: May 11, 2019, 06:00:42 pm »
This post is rather cringe... The accountant should hire a security professional. By doing what you are doing... lets me know you are not one. If you don't trust the Admin then get another Admin.

CouchDB is what you are looking for... You can tail, disk encrypt, has roles baked in, fault tolerent and it will keep revisions. Master Master replication. I hope you at least have the keys to the kingdom use a revocable cert....

I'm rather confused how you would keep a malicious admin from getting the top secret password being sent to the machine he is logged into....
« Last Edit: May 11, 2019, 06:02:56 pm by john horst »

lucamar

  • Hero Member
  • *****
  • Posts: 3447
Re: Database with table encryption needed
« Reply #8 on: May 11, 2019, 06:15:20 pm »
Been thinking about this and I think you should attack the problem from the other side.

The requirement is two-prong: either preventing the admin from accessing or log all accesses.

Preventing the admin from accessing is nigh impossible, so instead, look for a way to log accesses regardless of who makes them. That should be easier ... maybe.

We are already outside my experience-field, sorry.
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus/FPC 2.0.8/3.0.4 & 2.0.10/3.2.0 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

thehidden

  • Jr. Member
  • **
  • Posts: 68
  • Freelancer
Re: Database with table encryption needed
« Reply #9 on: May 11, 2019, 06:41:33 pm »
This post is rather cringe... The accountant should hire a security professional. By doing what you are doing... lets me know you are not one. If you don't trust the Admin then get another Admin.

CouchDB is what you are looking for... You can tail, disk encrypt, has roles baked in, fault tolerent and it will keep revisions. Master Master replication. I hope you at least have the keys to the kingdom use a revocable cert....

I'm rather confused how you would keep a malicious admin from getting the top secret password being sent to the machine he is logged into....

Sorry, but maybe wrong understood.

I am writing software and have got a request from a possible german customer.

My customer has an internal audit to simulate an official tax audit. They are testing 100 % Law Compliance.
Problem: As written above; DB Administrators, their possible access and the german tax law.
There is no reasen, question, concerns, etc. about a "trustworth" Administrator. It is simple Law compliance. Nothing more, nothing less.


If it is to complicated, I will tell my customer "Change the law, or change your location (Spain is nice, Ireland is nice) or have luck finding somebody else. As long as you are in germany, I don't sell you any software.".
I am mostly writing software for Image/Video based Process Documentation and Warehouse/Invoicing.
Other Software only if the project is interesting.

john horst

  • Jr. Member
  • **
  • Posts: 66
    • JHorst
Re: Database with table encryption needed
« Reply #10 on: May 11, 2019, 06:52:36 pm »
My point is, by having the password at two locations, the server and your app, you now have two places to retrieve the password. If you want the data encrypted inside, encrypt it with gpg or something and insert, don't give the admin the key to decrypt. That won't stop him from modifying though, only modifying the original doc.

Now, if this data is always being decrypted to plain text and displayed... then once again the key is useless. The key has to be stored somewhere even if you send it, memory perhaps?

I think  he is misinterpreting German law. You are asking the impossible.  The strategy is no different than a traditional password authentication. Take password -> bcrypt -> insert. It won't stop the admin from just removing the record or replacing.
« Last Edit: May 11, 2019, 07:11:37 pm by john horst »

thehidden

  • Jr. Member
  • **
  • Posts: 68
  • Freelancer
Re: Database with table encryption needed
« Reply #11 on: May 11, 2019, 07:08:54 pm »
My point is, by having the password at two locations, the server and your app, you now have two places to retrieve the password. If you want the data encrypted inside, encrypt it with gpg or something and insert, don't give the admin the key to decrypt.

Now, if this data is always being decrypted to plain text and displayed... then once again the key is useless. The key has to be stored somewhere even if you send it, memory perhaps?

I think  he is misinterpreting German law. You are asking the impossible.

Yes, I think you are right. It sounds like a Mission Impossible.
Thanks to all for your help. I was unsure if this can be handled or not.

Now I will give the customer a kick and let him know he need somebody else for writing a software keeping all the rules.
I am mostly writing software for Image/Video based Process Documentation and Warehouse/Invoicing.
Other Software only if the project is interesting.

john horst

  • Jr. Member
  • **
  • Posts: 66
    • JHorst
Re: Database with table encryption needed
« Reply #12 on: May 11, 2019, 07:32:02 pm »
Well don't give up that easy. I told you how to do it. I modified the post above.

Use CouchDb, set up roles, limit what the admin can and can't do. It keeps a revision. I keep all my source code in it, and you can replicate it as well. See real time changes by tailing / LOG. Store the password in a file on the same server as the db. Make sure it has proper permissions. This is the best you can do really, the proper thing. It's acid complaint and fault tolerant. If Germany has a problem they need to get over it lol.

Bonus it has Authentication baked in too. You don't have to worry about messing it up. :)
« Last Edit: May 11, 2019, 07:38:04 pm by john horst »

thehidden

  • Jr. Member
  • **
  • Posts: 68
  • Freelancer
Re: Database with table encryption needed
« Reply #13 on: May 11, 2019, 07:42:10 pm »
I must see if I can configure CouchDB by script from my application.

CouchDB isn't SQL. Must see how I can work with it. My current application I was planning to upgrade for this customer works with an SQL Database.

Maybe I will think about in the next few days.
I am mostly writing software for Image/Video based Process Documentation and Warehouse/Invoicing.
Other Software only if the project is interesting.

john horst

  • Jr. Member
  • **
  • Posts: 66
    • JHorst
Re: Database with table encryption needed
« Reply #14 on: May 11, 2019, 08:05:37 pm »
Well it sounds like a chore. The concept is still the same though. You can't guarantee without having a couple of copies of the same document in the database. A revision. You have to limit what the admin can modify, delete, which would be the record that was reinserted encrypted. The Admin can't see / change / delete that. 

 

TinyPortal © 2005-2018