IBM developerWorks
           Security and Cryptography
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsSystem AdministrationSecurity and Cryptography

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here!
  #1  
Old March 21st, 2008, 12:38 PM
bauhsoj bauhsoj is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2005
Posts: 197 bauhsoj User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 9 h 2 m 58 sec
Reputation Power: 3
Question PHP-Extension - Mcrypt_encrypt() vulnerabilities

I have someone that wants to start storing the BIN (Bank Identification Number) which is the first 6 digits of their customer's encrypted credit card number. They want the BIN unencrypted though for quick lookups with fraud detection services.

However, I have read that certain encryption schemes are vulnerable if the first few chars of the encrypted string are available to allow analysis of the encrypted string. To top it off, in another part of the database they already store the last four digits unencrypted so that they can do quick lookups of past transactions.

Separate of storing the full number, these are not a security risk, but I do not want to put my client's customer's at risk by using the wrong encryption scheme that could be easily hacked by making available the first 6 and last 4 numbers of the encrypted string.

Currently they are using MCRYPT_BLOWFISH with MCRYPT_MODE_CBC. Should I recommend they re-encrypt under something else?

Reply With Quote
  #2  
Old March 21st, 2008, 02:15 PM
Hammer65's Avatar
Hammer65 Hammer65 is offline
Web Developer/Musician
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Nov 2004
Location: Lincoln Nebraska
Posts: 2,038 Hammer65 User rank is Colonel (50000 - 60000 Reputation Level)Hammer65 User rank is Colonel (50000 - 60000 Reputation Level)Hammer65 User rank is Colonel (50000 - 60000 Reputation Level)Hammer65 User rank is Colonel (50000 - 60000 Reputation Level)Hammer65 User rank is Colonel (50000 - 60000 Reputation Level)Hammer65 User rank is Colonel (50000 - 60000 Reputation Level)Hammer65 User rank is Colonel (50000 - 60000 Reputation Level)Hammer65 User rank is Colonel (50000 - 60000 Reputation Level)Hammer65 User rank is Colonel (50000 - 60000 Reputation Level)Hammer65 User rank is Colonel (50000 - 60000 Reputation Level)Hammer65 User rank is Colonel (50000 - 60000 Reputation Level)Hammer65 User rank is Colonel (50000 - 60000 Reputation Level) 
Time spent in forums: 3 Weeks 1 Day 22 h 58 m 11 sec
Reputation Power: 578
Send a message via AIM to Hammer65
Storing any credit card information on a web server, is extremely risky. Doing so actually violates the agreement for vendors to offer credit card payment. The major credit card companies have rules in place, that expose the vendor to massive fines and liability if they violate the terms for handling such data as set forth in the agreement.

For one, they do not a allow storing of credit card information encrypted or not on any computer directly connected to the internet.

The amount of money we are talking about here is more than you are likely to see in your entire lifetime, especially if there is a security breach. To say that it's not recommended is putting it lightly.
__________________
"Strange women lying in ponds distributing swords is no basis for a system of government. Supreme executive power derives from a mandate from the masses, not from some farcical aquatic ceremony! Well, but you can't expect to wield supreme executive power just 'cause some watery tart threw a sword at you! I mean, if I went 'round saying I was an emperor just because some moistened bint had lobbed a scimitar at me, they'd put me away!"

Last edited by Hammer65 : March 21st, 2008 at 02:20 PM.

Reply With Quote
  #3  
Old March 21st, 2008, 02:43 PM
bauhsoj bauhsoj is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2005
Posts: 197 bauhsoj User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 9 h 2 m 58 sec
Reputation Power: 3
Quote:
Originally Posted by Hammer65
Storing any credit card information on a web server, is extremely risky. Doing so actually violates the agreement for vendors to offer credit card payment. The major credit card companies have rules in place, that expose the vendor to massive fines and liability if they violate the terms for handling such data as set forth in the agreement.

For one, they do not a allow storing of credit card information encrypted or not on any computer directly connected to the internet.


If that were the case then why does Amazon.com openly show that they store credit card details from past purchases. You can even select which past card you want charged without even entering the card number again. It's not just them. I have seen dozens of major sites that do this. How is it they are not being fined for such blatant storage?

According to Visa and MasterCard's PCI Data Security Standard Compliance requirements you can in fact store credit card numbers so long as they are stored under strong encryption or in a truncated format.

In fact, if you check further you will find that even as of last year major credit card companies required that those numbers be stored! It is only recent that the allowance of storing those numbers in truncated form was added to the compliance standards.

There are even services available from third parties you can also pay to store the credit card data to drastically reduce your liability should something go wrong. But, regrettably, the company I am doing this work for doesn't use one of those services soooo....I still need to know what encryption method is best.

Reply With Quote
  #4  
Old March 21st, 2008, 02:58 PM
brandon509 brandon509 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2008
Posts: 16 brandon509 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 11 m 52 sec
Reputation Power: 0
I'm pretty certain that amazon breaks the rules on purpose, But they have the money to pay the fines, and its worth it to them.

Reply With Quote
  #5  
Old March 21st, 2008, 03:05 PM
Hammer65's Avatar
Hammer65 Hammer65 is offline
Web Developer/Musician
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Nov 2004
Location: Lincoln Nebraska
Posts: 2,038 Hammer65 User rank is Colonel (50000 - 60000 Reputation Level)Hammer65 User rank is Colonel (50000 - 60000 Reputation Level)Hammer65 User rank is Colonel (50000 - 60000 Reputation Level)Hammer65 User rank is Colonel (50000 - 60000 Reputation Level)Hammer65 User rank is Colonel (50000 - 60000 Reputation Level)Hammer65 User rank is Colonel (50000 - 60000 Reputation Level)Hammer65 User rank is Colonel (50000 - 60000 Reputation Level)Hammer65 User rank is Colonel (50000 - 60000 Reputation Level)Hammer65 User rank is Colonel (50000 - 60000 Reputation Level)Hammer65 User rank is Colonel (50000 - 60000 Reputation Level)Hammer65 User rank is Colonel (50000 - 60000 Reputation Level)Hammer65 User rank is Colonel (50000 - 60000 Reputation Level) 
Time spent in forums: 3 Weeks 1 Day 22 h 58 m 11 sec
Reputation Power: 578
Send a message via AIM to Hammer65
Quote:
Originally Posted by bauhsoj
If that were the case then why does Amazon.com openly show that they store credit card details from past purchases. You can even select which past card you want charged without even entering the card number again. It's not just them. I have seen dozens of major sites that do this. How is it they are not being fined for such blatant storage?


Amazon has their own servers and their own security staff to handle the technical requirements.

Quote:
According to Visa and MasterCard's PCI Data Security Standard Compliance requirements you can in fact store credit card numbers so long as they are stored under strong encryption or in a truncated format.


The network requirements as set forth in section 1.1 of PCI are beyond what you could get with any hosting plan even with a dedicated machine. It isn't just the machine itself but the network, the password maintenance and the manpower to administer it.

Quote:
There are even services available from third parties you can also pay to store the credit card data to drastically reduce your liability should something go wrong. But, regrettably, the company I am doing this work for doesn't use one of those services soooo....I still need to know what encryption method is best.


A payment gateway is a much better solution. Suit yourself but even the developer of an application that causes theft will be liable.

Reply With Quote
  #6  
Old March 24th, 2008, 06:40 AM
jharnois's Avatar
jharnois jharnois is offline
mod_dev_shed
Dev Shed God 19th Plane (14000 - 14499 posts)
 
Join Date: Sep 2002
Location: Atlanta, GA
Posts: 14,299 jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level) 
Time spent in forums: 1 Month 1 Week 2 Days 1 h 54 m 17 sec
Reputation Power: 760
Thread moved from PHP to Security/Cryptography ... while you're using PHP's mcrypt_encrypt, you're generally talking about security practices and the vulnerability of Blowfish, which is not PHP specific.

A PHP related question would generally discuss the syntactic use of mcrypt_encrypt, so please feel free to start another thread in the PHP forum and reference this one as background information when you get to that point.


My opinion on the subject ... the larger companies like Amazon probably have a database security specialist, a web server / operating system specialist, and a network security specialist (at least) to handle their security, so you're in over you're head unless you're all of these things. So find these people and employ them contractually for this project and pass the costs on to your customer. If you're customer's not willing to pay for this expertise, then they have no business storing this information.
__________________
# Jeremy

Explain your problem instead of asking how to do what you decided was the solution.

Reply With Quote
  #7  
Old March 24th, 2008, 12:38 PM
fishtoprecords's Avatar
fishtoprecords fishtoprecords is offline
Contributing User
Click here for more information.
 
Join Date: Sep 2007
Location: outside Washington DC
Posts: 964 fishtoprecords User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)fishtoprecords User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)fishtoprecords User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)fishtoprecords User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)fishtoprecords User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)fishtoprecords User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)fishtoprecords User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)fishtoprecords User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)fishtoprecords User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)fishtoprecords User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)fishtoprecords User rank is Lieutenant Colonel (40000 - 50000 Reputation Level) 
Time spent in forums: 1 Week 3 Days 23 h 26 m 10 sec
Reputation Power: 418
You can be sure that Amazon has several networking specialists and several serious security folks. Its a cost of doing business for them.

Storing any of the PAN (personal account number, aka credit card number) on a server on the Internet is a really bad idea. Encrypted or not.

It makes your server have valuable data, which makes you more likely to be attacked. This is not about virus and spam, its about money.

Storing the leading digits only is less dangerous, but still not a good idea.

If you store any valuable data enciphered, where do you store the key? The answer to this is far more important than which cipher you use, DES, AES, Blowfish, etc.

If you store the key on a disk in your server, the bad guys will find it and all of your security is gone. You would be amazed at the number of folks who should, and sometimes even do, know better than store the key somewhere safe like /etc or /var

Reply With Quote
  #8  
Old March 25th, 2008, 07:09 PM
bauhsoj bauhsoj is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2005
Posts: 197 bauhsoj User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 9 h 2 m 58 sec
Reputation Power: 3
Quote:
Originally Posted by fishtoprecords
You would be amazed at the number of folks who should, and sometimes even do, know better than store the key somewhere safe like /etc or /var


Please explain.

I know the current configuration re-encrypts everything using a key the administrator has to manually enter each time, so it isn't stored except in that person's head. The data is therefore only encrypted with a locatable key on the server for the 6 or so hours until the new key is entered for re-encryption by one of their corporate officers. I also know they wipe the card data entirely at regular intervals when all potential charges to the card holder are complete. There just isn't any need to hold onto the data outside of the transaction id after that point according to their business needs.

Reply With Quote
  #9  
Old March 25th, 2008, 07:14 PM
fishtoprecords's Avatar
fishtoprecords fishtoprecords is offline
Contributing User
Click here for more information.
 
Join Date: Sep 2007
Location: outside Washington DC
Posts: 964 fishtoprecords User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)fishtoprecords User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)fishtoprecords User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)fishtoprecords User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)fishtoprecords User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)fishtoprecords User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)fishtoprecords User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)fishtoprecords User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)fishtoprecords User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)fishtoprecords User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)fishtoprecords User rank is Lieutenant Colonel (40000 - 50000 Reputation Level) 
Time spent in forums: 1 Week 3 Days 23 h 26 m 10 sec
Reputation Power: 418
Oh, if this setup requires a human to enter a key every time the server starts, that is much better. Most sites don't want to do that, especially if the server is in a lights-out data center without 24x7 staffing.

For the paranoid, VeriSign and RSA offer key fob devices that let you enter different keys each time, so that you are safe from replay attacks.

Reply With Quote
Reply

Viewing: Dev Shed ForumsSystem AdministrationSecurity and Cryptography > PHP-Extension - [PHP's] mcrypt_encrypt() vulnerabilities


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway