Click here to register.
      
Bazaar


     Re: WebGUI::Crypt > Re: WebGUI::Crypt Goto page «Previous Page   1 2    Next Page»

WebGUI::Crypt

User patspam
Date 9/29/2008 12:10 am
Views 1463
Rating 0    Rate [
|
]
Previous · Next
User Message
patspam
Hi team,

I need to encrypt confidential information that is stored in my WebGUI database. Sooner or later you might want to do this too. Or your lawyer might tell you to. Here's my thoughts on one way it could be done. Please let me know if you think this is useful, flawed, lame, etc..

The Why
  • Confidentiality attacks against the database are more generally more lucrative than eavesdropping; the database is the equivalent of the "bank vault"
  • SSH, HTTPS, VPNs etc.. protect data in transit. Database encryption protects the data at rest.
  • Access controls, backup, recovery plans, regular audits, secure connections all important, but database encryption is the last line of defence
  • Database encryption can help with:
    • External attacks (access to the live database, stolen database backups, SQL injection, etc..)
    • Internal attacks (database admin, QA staff with read-only db accounts, "casual reading" by super-admins, etc..)
  • Privacy and Security Legislation, Corporate Compliance Agreements, Trade Regulations, Business Reputation, e.g. in the USA:
    • Health Insurance Portability & Accounting Act (1996 - Health Data)
    • Sarbanes-Oxley Act (2002 - Financial Data)
    • Gramm-Leech-Bliley Act (2005 - Financial Data)
    • California Information Practices Act (2005 - Privacy)
    • Children's Online Privacy Protection Act (1998 - Privacy)
    • Payment Card Industry (PCI) Data Security Standard, requirement 3.4 (Financial Data)
  • File-system encryption is too transparent, doesn't help much
The How
  • WebGUI::Crypt namespace
  • WebGUI Site config file used to choose Crypt provider:
    {...
        crypt: {
            provider: 'WebGUI::Crypt::MyProvider',
            provider_specific_option_x: '...'
        }
    }
  • Provider implements an encryption strategy (some possible providers discussed in the next section)
  • Extra "encrypt this field" Yes/No option added to Field definition dialog in Wobjects such as UserProfile, Thingy, Survey2, DataForm, etc.. When selected, Wobject automatically calls WebGUI::Crypt provider's encrypt() and decrypt() subroutines prior to reading/writing that field to the database
    • N.B. This might be best done via the new WebGUI 8 Form API
    • N.B. Encryption is a performance hog so users would only want to enable this for fields that really need to be protected (identifying confidential data is the responsibility of the site admin)
    • N.B. General caveats of db encryption applies. Manual SQL will need to change (e.g. keywords such as ORDER BY won't work unless we get clever and add in extra fields such as "first_letter" for encrypted fields)
Here are some possible crypt providers:

WebGUI::Crypt::Simple
  • Single encryption key, stored in broad-daylight in the webgui site config file.
    {...
        crypt: {
            provider: 'WebGUI::Crypt::Simple',
            key: 'ABCDEFG'
        }
    }
  • Uses Crypt::CBC to encrypt() and decrypt() via a symmetric key
  • Key only as safe as the webgui account on your modperl server(s)
  • Minimal performance hit, no real scalability problems
  • A good candidate for the first "proof of concept" crypt provider due to its simplicity
  • A possbile extension that JT thinks is lame =p
    • If the key is specified as "ask" then prompt the sys-admin to enter the key at modperl start-up
    • Means that key is stored in memory and not in the webgui site config file (but it might end up in your O/S swap file, etc..)
    • Will annoy the hell out of your sys-admin, and any security improvements are arguable
    • The whole "modperl restarts as soon as it starts" thing thwarted me from figuring out how to make this work
WebGUI::Crypt::IPC
  • Do the encryption in a separate process and have modperl request encryption/encryption via IPC
  • Log all crypto requests and monitor for suspicious spikes in activity
  • Again, could prompt for key on service start
  • Again, no fundamental improvements in security, but may increase the difficulty in extracting the key via obfuscation if separate process runs off compiled code (although it could still be extracted from memory, swap, etc..)
  • Increased performance hit, but no scalability issues (you just need to run the service on every modperl server)
WebGUI::Crypt::HSM
  • Use a dedicated, Hardware Security Module (HSM), connected via serial port, local network etc..
  • All crypto requests go via HSM. Log and monitor for suspicious activity.
  • Key never leaves HSM. 
  • HSM is preferably a commercial-grade, tamper-proof device, but could also be a locked-down regular server
  • The recommended approach according to "Cryptography in the Database: The Last Line of Defense", Kevin Kenan , Symantic Press/Addison Wesley
  • Much increased performance hit, scalability issues
The Flaws
  • I've only proposed crypto solutions that use a single key to encrypt/decrypt everything. Mature crypto systems have an entire key management infrastructure so that columns can be mapped to keys, keys can be introduced and revoked, retired after key fatigue sets in, etc..
  • Implementing crypto badly can be worse than no crypto at all because it creates a false sense of security, might lock you out of your own data, etc..
  • None of the providers I've mentioned are perfect, they all suck. Then again, storing confidential information in plaintext sucks more.
Does this sound like something you would want to use? Legislation in most countries at the moment only suggests/implies encryption rather than demanding it outright in most domains, but the emphasis is growing. I'm going to need something like this for my own projects. If you think you'll be in the same boat at some stage please help me shape the idea into something useful.

Cheers,

Patrick


Back to Top
Rate [
|
]
 
 
knowmad

Hey Patrick,

Good discussion and explanation of the issues and possible solutions. Before we decide on how to encrypt, I think we need to discuss what to encrypt.

It doesn't make sense to me that the whole database gets encrypted. There'd be a double performance hit of decryption plus the loss of the ability to do page caching.

For the sites we've rolled out, the only tables with sensitive data that I can think of are the user profile info and the shopping cart data.

In addition, it would be useful to be able to encrypt some of the external databases though I'm not sure your solution intends to support that feature. We'd potentially need to be able to use it outside of WebGUI so that non-WebGUI services could decrypt the data.

 

William

----
Knowmad Technologies
http://www.knowmad.com



Back to Top
Rate [
|
]
 
 
patspam
Hi William,

Thansk for the insightful comments.

Yeah you're absolutely right, you only want to encrypt the absolute minimum because of the performance hit and also because any column that gets encrypted becomes harder to use in SQL.

I hadn't thought about page caching. Do you mean that you'd have to turn off server-side page caching so that (unencrypted) sensitive data doesn't get written to disk?

In my case it's all about "Personally Identifiable Information" (PII). Since that's such a gray area, I want the site admin to be able to define which columns constitute PII.

There's nothing stopping you from decrypting the data outside of WebGUI. For example, WebGUI::Crypt::Simple uses Crypt::CBC, which you can use in external perl code (as long as you are in posession of the key). Furthermore, Crypt::CBC uses standard crypto algorithms, so you can also work with the data from non-perl code.

Cheers,

Patrick

On Tue, Sep 30, 2008 at 2:54 AM, <william@knowmad.com> wrote:
knowmad wrote:

Hey Patrick,

Good discussion and explanation of the issues and possible solutions. Before we decide on how to encrypt, I think we need to discuss what to encrypt.

It doesn't make sense to me that the whole database gets encrypted. There'd be a double performance hit of decryption plus the loss of the ability to do page caching.

For the sites we've rolled out, the only tables with sensitive data that I can think of are the user profile info and the shopping cart data.

In addition, it would be useful to be able to encrypt some of the external databases though I'm not sure your solution intends to support that feature. We'd potentially need to be able to use it outside of WebGUI so that non-WebGUI services could decrypt the data.

 

William

----
Knowmad Technologies
http://www.knowmad.com



http://www.plainblack.com/webgui/dev/discuss/webguicrypt/1


--

Plain Black&#44; makers of WebGUI
http://plainblack.com




Back to Top
Rate [
|
]
 
 
arjan

He Patrick,

Very nice discussion of the options.

Right now, I don't think I would use this. It's not something I would want to use, but I can very well image that it will be demanded of us in the future. First to store emailadresses safely and profile data. But also the contents of mailboxes. We also run a website where medical specialists have subsites and use WebGUI's mailboxes to email with patients. But potentially anything, because if you're building a site with medical or privacy sensitive data it's nice to have all kinds of assets at your disposal.

I also agree with Williams last two remarks: it's usefull to be able to encrypt an external database and it's very nice if you could use it outside of WebGUI.

I don't know much about this subject, but it seems that it requires an analysis of the whole proces of storage in a database, data transfer mechanisms, database authorization and access controls, and database auditing. Database encryption makes sense if you have an overview over all the duplication of the data and the whole proces of acess. That doesn't seem that easy.

Somebody who used to work with us and used be active in the WebGUI community, Leenert Bottelberghs, does know a lot about encryption and storage. I'll point him to this thread.

 

Kind regards,

Arjan Widlak

United Knowledge
Internet for the public sector

www.unitedknowledge.nl



Back to Top
Rate [
|
]
 
 
patspam
Hey Arjan,

Yeah I'm going to be in exactly the same position with mailboxes, in my case communication between clients and therapists. That's pretty much 10/10 on the confidentiality scale as far as I'm concerned. To enable encryption of Inbox Messages I was thinking about adding the "encrypt?" option to Settings > Messaging in the admin console. Not that any of this may ever see its way into the core, but I like to build it as if it will.

Thanks for your feedback, and that would be fantastic if Leenert can provide some expert comments. The extent of my research is the aforementioned book "Cryptography in the Database: The Last Line of Defense" and some discussion with the author.

Regards,

Patrick

On Tue, Sep 30, 2008 at 7:34 AM, <arjan@unitedknowledge.nl> wrote:
arjan wrote:

He Patrick,

Very nice discussion of the options.

Right now, I don't think I would use this. It's not something I would want to use, but I can very well image that it will be demanded of us in the future. First to store emailadresses safely and profile data. But also the contents of mailboxes. We also run a website where medical specialists have subsites and use WebGUI's mailboxes to email with patients. But potentially anything, because if you're building a site with medical or privacy sensitive data it's nice to have all kinds of assets at your disposal.

I also agree with Williams last two remarks: it's usefull to be able to encrypt an external database and it's very nice if you could use it outside of WebGUI.

I don't know much about this subject, but it seems that it requires an analysis of the whole proces of storage in a database, data transfer mechanisms, database authorization and access controls, and database auditing. Database encryption makes sense if you have an overview over all the duplication of the data and the whole proces of acess. That doesn't seem that easy.

Somebody who used to work with us and used be active in the WebGUI community, Leenert Bottelberghs, does know a lot about encryption and storage. I'll point him to this thread.

 

Kind regards,

Arjan Widlak

United Knowledge
Internet for the public sector

www.unitedknowledge.nl



http://www.plainblack.com/webgui/dev/discuss/webguicrypt/2


--

Plain Black&#44; makers of WebGUI
http://plainblack.com




Back to Top
Rate [
|
]
 
 
arjan

Hi Patrick,


Leendert mentioned these things:

- start with why to encrypt and afterwards have a good look at what to encrypt

- don't forget about the downsides of encryption! Except an impact on performance also: difficult recovery on data corruption, potential damage on loss of keys, etc.

- encryption on the database is useless if all the links in the chain before the database are not completely secure already. Think first and formost about the direct access to the data (eg. therapists and patients). Most illegal entry is accomplished by guessing the password. A strong password that changes frequently is the start. And all data exchange over SSL as well.

- MySQL has some good encryption features. In MySQL 5 is AES available, this is very usable.

 

Kind regards,

Arjan Widlak

United Knowledge
Internet for the public sector

www.unitedknowledge.nl



Back to Top
Rate [
|
]
 
 
perlmonkey2

WebGUI::Crypt::Simple seems like a great idea as the conf files and swap are inherently more secure than the database.  I don't see how this is anything but an improvement over no security.

WebGUI::Crypt::IPC also is a great idea.  IPC can be offloaded to other machines for load balancing, and the key can be protected so that it can never be compromised, and only accessed if the webserver's root account is compromised.  The only real gain here is that if root is compromised, the data can only be accessed from this machine (that and the crypto load balancing).  The data can't be taken home for later decryption.

 

But in the end, the easiest vector is WebGUI itself.  If WebGUI::Auth is defeated, then all the system controls in the world won't keep WebGUI from doing what it is supposed to do; serve up the data to an account with permissions to view it.



Back to Top
Rate [
|
]
 
 
JT
I've waited to respond to this to see what the community had to say.  
In general I'd agree that this is a nice thing to have in the core,  
and definitely not only important but required by some sites.

My primary concern with this is performance, which is why I wouldn't  
support whole database encryption. Most stuff simply doesn't need to  
be encrypted.

On the fields that do need to be encrypted, I think that we shouldn't  
use a perl module to do it. Instead, I think we should use MySQL's  
native encryption mechanisms. Because I don't think it's important to  
encrypt information in memory, you really only need it encrypted in  
transport (covered by SSL) and storage (the database). If you have to  
worry about whether the memory of your running processes is  
compromised, then you have a whole hell of a lot of problems, and  
encryption isn't likely to help you out of them. In addition, handling  
encryption inside of WebGUI using perl modules would be ten times  
slower than doing it at the field level in the database.

Anyway, that's my two cents.


Back to Top
Rate [
|
]
 
 
patspam
Heya JT,

On Fri, Oct 3, 2008 at 9:16 AM, <jt@plainblack.com> wrote:
JT wrote:

I've waited to respond to this to see what the community had to say.  
In general I'd agree that this is a nice thing to have in the core,  
and definitely not only important but required by some sites.

Great!

My primary concern with this is performance, which is why I wouldn't  
support whole database encryption. Most stuff simply doesn't need to  
be encrypted.

Agreed.

On the fields that do need to be encrypted, I think that we shouldn't  
use a perl module to do it. Instead, I think we should use MySQL's  
native encryption mechanisms. Because I don't think it's important to  
encrypt information in memory, you really only need it encrypted in  
transport (covered by SSL) and storage (the database). If you have to  
worry about whether the memory of your running processes is  
compromised, then you have a whole hell of a lot of problems, and  
encryption isn't likely to help you out of them. In addition, handling  
encryption inside of WebGUI using perl modules would be ten times  
slower than doing it at the field level in the database.

A MySQL native encryption provider would be fine, the important thing to me is that we use some form of pluggable crypt provider mechanism that allows me to plug in a provider that talks to a dedicated hardware encryption device to ensure that modperl/db/etc.. never sees the key (e.g. WebGUI::Crypt::HSM). Anything short of that fails to cut the mustard in terms of my own security requirements.

Here's my breakdown of the pros/cons of the providers discussed thus far:
  • MySQL native encryption - fast. key stored in webgui config file. compromise of modperl enough to steal data and key. compromise of db server may yield key too.
  • WebGUI::Crypt::Simple - slow. key stored in webgui config file. compromise of modperl enough to steal data and key. compromise of db server only yields encrypted data, not key.
  • WebGUI::Crypt::HSM - fast. compromise of modperl enough to decrypt data request-by-request via live HSM. key never leaves HSM.
I've implemented a first stab at WebGUI::Crypt and the WebGUI::Crypt::Simple provider (with 85% test coverage), and added a couple of lines to WebGUI::Inbox so that the message field is encrypted in the db. It's available on my github account here.

New files:
  • lib/WebGUI/Crypt.pm - the pluggable crypt layer
  • lib/WebGUI/Crypt/Simple.pm - a simple proof of concept provider that uses Crypt::CBC
  • t/Crypt/Crypt.t
  • t/Crypt/Simple.t
Modified files:
  • Session.pm - so that you can do: $session->crypt->encrypt("..")
  • Inbox.pm - to demonstrate simple encrypting of the message field
  • t/Inbox.t
Comments:
  • WebGUI::Crypt::Simple uses AES by default (Crypt::Rijndael), but you can specify any Crypt::CBC supported cipher in the WebGUI site config file
  • I'm using hex-encoding of the ciphertext in WebGUI::Inbox so that message field db type didn't need to change to binary (but obviously would be more efficient to store as binary)
  • Crypt::CBC generates a random initialization vector and prepends this to the encrypted data as a standard header that can be re-read at decryption time. This is necessary to prevent various cryptographic attacks on the database. A WebGUI::Crypt::MySQL provider would need to generate and handle this manually.
Cheers,

Patrick


Back to Top
Rate [
|
]
 
 
JT


A MySQL native encryption provider would be fine, the important thing to me is that we use some form of pluggable crypt provider mechanism that allows me to plug in a provider that talks to a dedicated hardware encryption device to ensure that modperl/db/etc.. never sees the key (e.g. WebGUI::Crypt::HSM). Anything short of that fails to cut the mustard in terms of my own security requirements.

Here's my breakdown of the pros/cons of the providers discussed thus far:
  • MySQL native encryption - fast. key stored in webgui config file. compromise of modperl enough to steal data and key. compromise of db server may yield key too.
  • WebGUI::Crypt::Simple - slow. key stored in webgui config file. compromise of modperl enough to steal data and key. compromise of db server only yields encrypted data, not key.
  • WebGUI::Crypt::HSM - fast. compromise of modperl enough to decrypt data request-by-request via live HSM. key never leaves HSM.

I don't understand, without a big duplication of code, how you can use a MySQL native encryption format and a Perl based one. The advantage of the MySQL native one is that you do it right in the SQL query. If you're making it pluggable, then it simply can't go into the query. And at that point it's no longer MySQL native even if you are actually using MySQL to encrypt or decrypt the content, because you have to pass the content off to some "Crypto" module.


JT Smithph: 703-286-2525 x810fx: 312-264-5382
Create like a god. Command like a king. Work like a slave.


Back to Top
Rate [
|
]
 
 
     Re: WebGUI::Crypt > Re: WebGUI::Crypt Goto page «Previous Page   1 2    Next Page»



Recent Discussions Color Key

Design:

Development:

Et Cetera:

Install/Upgrade:  

Smoketest:

Template Group:


Re: Site paid for by advertizing by Klaus - Fri @ 02:27am

Smoke Test for WebGUI (Stable) (2008-11-21) by botaction - Fri @ 12:37am

Re: Site paid for by advertizing by pwrightson - Thu @ 10:59am

Re: Site paid for by advertizing by JT - Thu @ 08:58am

Re: Regelmäßiger Termin für Usertreffen in der Rhein-Neckar-Region by Klaus - Thu @ 06:11am

Smoke Test for WebGUI (Stable) (2008-11-20) by botaction - Thu @ 12:00am

Smoke Test for SVN (2008-11-20) by botaction - Thu @ 12:00am

Re: Improving page layouts by fdillon - Wed @ 08:38pm

Re: Improving page layouts by knowmad - Wed @ 08:25pm

Re: Site paid for by advertizing by knowmad - Wed @ 08:07pm

Re: SSL Configuration? by knowmad - Wed @ 07:51pm

Re: The Death of the Collaboration System by preaction - Wed @ 07:39pm