Web Design Forums

Database Systems Help

Discussion and help on database systems such as MySQL, MSSql, SQLite, PostgreSQL

PostgreSQL (or other database) autoboxing



Site of the Month Voting - Now Open. CAST YOUR VOTE NOW!

Reply
 
LinkBack Thread Tools
Old June 2 '07, 01:58 PM (#1)
filburt1 is offline
bored
 
filburt1's Avatar
 
Join Date: July 2002
Location: Maryland, US
Posts: 11,785
filburt1 is a name known to allfilburt1 is a name known to allfilburt1 is a name known to allfilburt1 is a name known to allfilburt1 is a name known to allfilburt1 is a name known to all
PostgreSQL (or other database) autoboxing

I'm thinking of adding security to a database in the following way:
  • Encrypt some of the more sensitive columns (password, e-mail, etc.) using blowfish, 3DES, etc. (not a hashing algorithm like MD5 because the data must be kept intact)
  • Set a connection session variable that contains the private key
  • For every request to write to and to read from an encrypted column, have PostgreSQL automatically recognize that the request is for encrypted data, and appropriate encrypt/decrypt the request/response using the previously set private key.
This way, the appropriate fields in the database are encrypted, so if the entire database is stolen or broken into, it's useless. Because the private key is set through a session variable and not actually stored anywhere in the database, the data is still effectively unreadable.

However, I don't know if that last bullet point is doable. Can PostgreSQL or other RDBMSs "autobox" data like that (convert data from one form to another without explicitly being told to)?

As a final example, this query:
Code:
UPDATE users SET password = 'foo' WHERE id = 1
...would implicitly update user ID 1's password to an encrypted form of 'foo' rather than the literal text 'foo.' Similarly, this query:
Code:
SELECT password FROM users WHERE id = 1
...would implicitly decrypt and return the password for user ID 1 rather than return his encrypted password.

So, possible?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old June 2 '07, 02:18 PM (#2)
Shadowfiend is offline
Code beautifully and honorably
 
Shadowfiend's Avatar
 
Join Date: June 2005
Location: Atlanta, GA
Posts: 4,143
Shadowfiend has a reputation beyond reputeShadowfiend has a reputation beyond reputeShadowfiend has a reputation beyond reputeShadowfiend has a reputation beyond reputeShadowfiend has a reputation beyond reputeShadowfiend has a reputation beyond reputeShadowfiend has a reputation beyond reputeShadowfiend has a reputation beyond reputeShadowfiend has a reputation beyond reputeShadowfiend has a reputation beyond reputeShadowfiend has a reputation beyond repute
Er... But what happens if the session expires? Where does the private key reside in permanence? (I know I'm not addressing your direct question, but I'm trying to grasp how you want to make this work.)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old June 2 '07, 02:21 PM (#3)
filburt1 is offline
bored
 
filburt1's Avatar
 
Join Date: July 2002
Location: Maryland, US
Posts: 11,785
filburt1 is a name known to allfilburt1 is a name known to allfilburt1 is a name known to allfilburt1 is a name known to allfilburt1 is a name known to allfilburt1 is a name known to all
It's the database session, not a PHP session. What would happen:
  1. Database exists with encrypted data and no private key stored.
  2. My PHP application needs to run a query, so it connects to the database. A database connection session starts.
  3. The application runs a query to set a variable for this connection session containing the private key.
  4. The application runs whatever queries it needs for the page.
  5. The connection closes, and implicitly in the process, the session variable is destroyed.
Therefore, the private key only exists during the life of the connection, so the only point of attack is through the application itself rather than directly through PostgreSQL.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old June 2 '07, 02:25 PM (#4)
Shadowfiend is offline
Code beautifully and honorably
 
Shadowfiend's Avatar
 
Join Date: June 2005
Location: Atlanta, GA
Posts: 4,143
Shadowfiend has a reputation beyond reputeShadowfiend has a reputation beyond reputeShadowfiend has a reputation beyond reputeShadowfiend has a reputation beyond reputeShadowfiend has a reputation beyond reputeShadowfiend has a reputation beyond reputeShadowfiend has a reputation beyond reputeShadowfiend has a reputation beyond reputeShadowfiend has a reputation beyond reputeShadowfiend has a reputation beyond reputeShadowfiend has a reputation beyond repute
So you're storing the private key alongside the application on the web server, then? If so, what makes you think that a compromised database server doesn't mean a compromised web server?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old June 2 '07, 02:26 PM (#5)
filburt1 is offline
bored
 
filburt1's Avatar
 
Join Date: July 2002
Location: Maryland, US
Posts: 11,785
filburt1 is a name known to allfilburt1 is a name known to allfilburt1 is a name known to allfilburt1 is a name known to allfilburt1 is a name known to allfilburt1 is a name known to all
I can't really think of another way of storing the private key, which is the core problem.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old June 2 '07, 02:35 PM (#6)
Shadowfiend is offline
Code beautifully and honorably
 
Shadowfiend's Avatar
 
Join Date: June 2005
Location: Atlanta, GA
Posts: 4,143
Shadowfiend has a reputation beyond reputeShadowfiend has a reputation beyond reputeShadowfiend has a reputation beyond reputeShadowfiend has a reputation beyond reputeShadowfiend has a reputation beyond reputeShadowfiend has a reputation beyond reputeShadowfiend has a reputation beyond reputeShadowfiend has a reputation beyond reputeShadowfiend has a reputation beyond reputeShadowfiend has a reputation beyond reputeShadowfiend has a reputation beyond repute
Well, yeah, that's always the problem Public-key cryptography operates on the assumption that the private key is kept under lock and key at all times. I'm not so sure it's suited to this particular class of problem. It seems like in this case using encryption would be more of a discouragement than a preventative measure. Sure, the person who's just ripping along doing whatever won't be able to get the data, but the guy who really wants to will. And the guy who's just doing whatever can be discouraged just as easily by a simpler method... Maybe even as simple as ROT-13

Nonetheless, to address your original question -- I don't know of a way to do that, no. Though depending on Postgre's extensibility (I don't know what it is), maybe you could write a plugin or something?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old June 2 '07, 05:54 PM (#7)
smoseley is online now
WDF Moderator
 
smoseley's Avatar
 
Join Date: March 2003
Location: Miami, FL
Posts: 8,719
smoseley has much to be proud ofsmoseley has much to be proud ofsmoseley has much to be proud ofsmoseley has much to be proud ofsmoseley has much to be proud ofsmoseley has much to be proud ofsmoseley has much to be proud ofsmoseley has much to be proud ofsmoseley has much to be proud ofsmoseley has much to be proud of
Hash the password. There's no reason not to.

As for email... if you must encrypt it, why not just store the key as a constant in your code?

Maybe you should begin your security dilemma by eliminating the ability of people stealing your database.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old June 2 '07, 05:57 PM (#8)
smoseley is online now
WDF Moderator
 
smoseley's Avatar
 
Join Date: March 2003
Location: Miami, FL
Posts: 8,719
smoseley has much to be proud ofsmoseley has much to be proud ofsmoseley has much to be proud ofsmoseley has much to be proud ofsmoseley has much to be proud ofsmoseley has much to be proud ofsmoseley has much to be proud ofsmoseley has much to be proud ofsmoseley has much to be proud ofsmoseley has much to be proud of
Oh, btw, if this is in Java... just make an "Crypt" class that has static methods to encrypt and decrypt data... Crypt.encrypt() and Crypt.decrypt(). Put your key in there as a constant, compile it, and lose the source. Just don't forget the key!!!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old June 2 '07, 06:06 PM (#9)
filburt1 is offline
bored
 
filburt1's Avatar
 
Join Date: July 2002
Location: Maryland, US
Posts: 11,785
filburt1 is a name known to allfilburt1 is a name known to allfilburt1 is a name known to allfilburt1 is a name known to allfilburt1 is a name known to allfilburt1 is a name known to all
It's PHP.

Obviously this is an extra layer of protection on top of other security. If I could 100% ensure that the database could never be accessed, I wouldn't even bother to encrypt things like passwords, but this is just extra insurance.

(and things like e-mails can't be hashed, unlike passwords)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old June 2 '07, 06:27 PM (#10)
Shadowfiend is offline
Code beautifully and honorably
 
Shadowfiend's Avatar
 
Join Date: June 2005
Location: Atlanta, GA
Posts: 4,143
Shadowfiend has a reputation beyond reputeShadowfiend has a reputation beyond reputeShadowfiend has a reputation beyond reputeShadowfiend has a reputation beyond reputeShadowfiend has a reputation beyond reputeShadowfiend has a reputation beyond reputeShadowfiend has a reputation beyond reputeShadowfiend has a reputation beyond reputeShadowfiend has a reputation beyond reputeShadowfiend has a reputation beyond reputeShadowfiend has a reputation beyond repute
Not to mention the fact that reverse-engineering compiled Java code and producing almost identical source-code is generally less-than-difficult. If someone's determined enough to go looking for a private key, then they're probably determined enough to reverse-engineer Java.

Nonetheless, if you were to take that approach, you could just as easily use it from PHP by running the external Java application to do the encrypting/decrypting.

I see why you'd do this -- especially with personal information like email. But I'm not sure that it will actually offer a significant security increase. It seems similar to how DRM in HDDVDs/Blu-Ray uses a private key that's already in the hands of the user in the form of a player for the relevant format. If the person can get to the key (and it's fair to assume that if they got to your database, they can probably get to the key)... That's it. It's really down to whether they're interested enough to decrypt the data, and if they aren't, then even simple encryption will likely discourage them. But then, I may be completely wrong.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old June 2 '07, 06:33 PM (#11)
filburt1 is offline
bored
 
filburt1's Avatar
 
Join Date: July 2002
Location: Maryland, US
Posts: 11,785
filburt1 is a name known to allfilburt1 is a name known to allfilburt1 is a name known to allfilburt1 is a name known to allfilburt1 is a name known to allfilburt1 is a name known to all
Blu-Ray/HD-DVD was cracked because they managed to get a working key out of some playback software, not because (I believe) it can crack the actual encryption on the disk; rather, it is just using a known key to retrieve the video stream just like a player would. And normal DVDs are hackable because they use a short key.

This would use a 256-bit key combined with some strong encryption algorithm that would take years to brute force. The issue is just securing the private key in the first place, which as you mentioned, is a problem for any encryption situation.

But all that aside, is the main question of this thread--PostgreSQL autoboxing--possible?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old June 2 '07, 06:52 PM (#12)
Shadowfiend is offline
Code beautifully and honorably
 
Shadowfiend's Avatar
 
Join Date: June 2005
Location: Atlanta, GA
Posts: 4,143
Shadowfiend has a reputation beyond reputeShadowfiend has a reputation beyond reputeShadowfiend has a reputation beyond reputeShadowfiend has a reputation beyond reputeShadowfiend has a reputation beyond reputeShadowfiend has a reputation beyond reputeShadowfiend has a reputation beyond reputeShadowfiend has a reputation beyond reputeShadowfiend has a reputation beyond reputeShadowfiend has a reputation beyond reputeShadowfiend has a reputation beyond repute
Right. I was saying the encryption became worthless because the key was handed to the user, as is necessary in such cases, so the user didn't *have* to crack it, they could just extract the key (admittedly not the easiest process, but clearly easy enough) from their playback system. Once that's done once, you release it in the wild and... The rest is history.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

  Web Design Forums » Programming Help » Database Systems Help

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

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
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Reverse-engineering PostgreSQL database to a Visio document filburt1 Database Systems Help 3 November 27 '09 03:18 AM
Add, View, Edit & Delete from to MySQL database, Live Example (News System) making Database Systems Help 7 January 5 '09 11:59 AM
Connect to database file rather than database on server CPW PHP 7 April 25 '07 05:54 PM
Error dropping database.... will7 PHP 1 March 19 '05 01:43 PM

 
User Infomation
Your Avatar

Site Of The Month
Nominate Your Site Now!

Advertisement
WolfCMS.org

Latest Articles
- by RickM
- by bfsog

Advertisement

Partner Links



All times are GMT -4. The time now is 02:06 PM.


WebDesignForums.net is Copyright © 2010 RikeMedia.

SEO by vBSEO

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164