Home
Calendar
Certifications
Columns
Features
Forum
Resources
Vitals
Latest Additions
April 2013 Free Giveaway Sponsor - eLearnSecurity
Human Intelligence to Navigate the Security Data Deluge
February 2013 Free Giveaway Winner of SANS CyberCon Training
Interview: Bugcrowd Founders on Herding Ninjas for Crowdsourced Bug Bounties
Network Forensics: The Tree in the Forest
March 2013 Free Giveaway Sponsor - Mile2
Book Review: Violent Python
February 2013 Free Giveaway Sponsor - SANS
Holiday 2012 Free Giveaway Winner of Metasploit Pro by Rapid7
Course Review: SANS FOR408 Computer Forensic Investigations – Windows In-Depth
The Security Consulting Sugar High
Tutorial: Fun with SMB on the Command Line
Interview: Ilia Kolochenko, CEO of High-Tech Bridge
October 2012 Free Giveaway Winner of LearningGate Training
The Broken: Assessing Corporate Security in 2012 to Make a Better 2013
EH-Net Login
Welcome Guest.
Username:
Password:
Remember me
Lost Password?
No account yet?
Register
Who's Online
We have 40 guests online
You are here:
Home
Ethical Hacking Discussions and Related Certifications
Web Applications
Secure Password Storage
EH-Net
May 25, 2013, 06:59:31 AM
Welcome,
Guest
. Please
login
or
register
.
Did you miss your
activation email?
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
News
: Go back to The Ethical Hacker Network Online Magazine
Home Page
Home
Help
Calendar
Login
Register
EH-Net
>
Ethical Hacking Discussions and Related Certifications
>
Web Applications
(Moderator:
don
) >
Secure Password Storage
Pages: [
1
]
Go Down
« previous
next »
Print
Author
Topic: Secure Password Storage (Read 5421 times)
0 Members and 1 Guest are viewing this topic.
Seen
Full Member
Offline
Posts: 134
Secure Password Storage
«
on:
December 27, 2011, 03:41:51 PM »
My friend has this website that acts as a portal to other sites, basically you log in to his site and it pulls information from various other accounts. I'm curious as to your input on his password storage method. He stores all the usernames and passwords for the various sites in a database encrypted with a key based on a user's master password for his site. That seems pretty standard to me. He didn't want to store the master password for his site in the database in case someone got access to the db and could therefore get all the passwords, which seems like a good idea. So he has the master password stored in plaintext in the script code of the user's home page on his site. While this doesn't seem like a great idea, it does have its advantages:
1. If someone is able to break in and access the database, they wouldn't be able to read the passwords for the other sites because they're encrypted (assuming of course, they can't do a SQL injection or something like that).
2. The user's master password can't be read by viewing the source because it's in a script. The only way I can think to read the password would be if an attacker could use some form of XSS or something similar to "break" the page and get it to spit out the code. Am I correct, or is there something else I should be wary of? Assuming of course, that an attacker is not able to download the source code off the site.
What are your thoughts on this method? Is there some other security issue/attack I need to take into account? Is there some way this could be made more secure, or a different technique he should try all together?
Thanks.
Logged
Sec+, eCPPT
ajohnson
Recruiters
Hero Member
Offline
Posts: 1060
aka dynamik
Re: Secure Password Storage
«
Reply #1 on:
December 27, 2011, 04:16:23 PM »
I'm not an expert on this type of thing, but a couple things jump out at me right away.
I assume the reason he didn't hash the password was so he could use it to decrypt the encrypted information. However, since the user is (obviously) inputting the password, he could just store that in a session variable for decryption, which would still allow him to store the hash of the password for authentication purposes. You would then run the risk of the key being stolen via XSS, but I think that would a much better configuration. Plus, if XSS is present, that could likely be leveraged to gain the same access even if the key wasn't present. If you didn't want to store the key in plain text in the session, you could use the user's IP to encrypt/decrypt it during processing, since that should be static throughout the session. See, I'm just brainstorming here
Absolutely do not assume something is safe because it is stored in a script that is not generally output in standard HTML. If there are command injection or file include vulnerabilities, those would likely allow the contents of the files to be displayed. I'm pretty sure I've also seen broken PHP configurations just dump the file instead of processing it; a future configuration change could be disastrous. Also, do not make the assumption that such a compromise would be isolated to a single user either. If they can list directory contents, cat files, etc.; it would likely be trivial do that for all users/directories/files.
«
Last Edit: December 27, 2011, 04:20:30 PM by dynamik
»
Logged
WIP: GCFA |
www.infosiege.net
| @infosiege
The day you stop learning is the day you start becoming obsolete.
hayabusa
Hero Member
Offline
Posts: 1633
Re: Secure Password Storage
«
Reply #2 on:
December 27, 2011, 04:40:15 PM »
You'd also be surprised at how easy it is, sometimes, to get said 'script'...
Logged
~ hayabusa ~
"All men can see these tactics whereby I conquer, but what none can see is the strategy out of which victory is evolved." - Sun Tzu, 'The Art of War'
OSCE, OSCP , GPEN, C|EH
unicityd
Full Member
Offline
Posts: 156
Bored IT Manager, Crypto Nerd
Re: Secure Password Storage
«
Reply #3 on:
December 27, 2011, 11:14:12 PM »
Quote
So he has the master password stored in plaintext in the script code of the user's home page on his site.
What kind of script? If the script is a client-side script (i.e. javascript), then any user can read it even if it's sourced in and not viewable using "right-click and View Source". If the user/attacker has trouble reading it in the browser, he can just use Wireshark to read it as it comes across the wire. This is a god-awful-never-even-think-about-it idea.
If the script is stored and executed server-side, it's trickier but still possible to recover the password. In this case, the attacker needs some sort of disclosure vulnerability. This is better, but not good.
The secure thing would be to not have a global master password. Then, users are responsible for their own data. If they forget their own master password, they lose their information and have to start over. The site could reset their master password, but the saved passwords for other sites would be lost. This is probably the best choice.
I don't know of a safe way to implement the global master password. If the password is stored on the server and an attacker gets unfiltered access to the server, the attacker has the password. If the password is sent to the client, everyone has the password. Ditch the global master.
Logged
BS in IT, CISSP, MS in IS Management (in progress)
Seen
Full Member
Offline
Posts: 134
Re: Secure Password Storage
«
Reply #4 on:
December 28, 2011, 12:41:23 AM »
Quote from: dynamik on December 27, 2011, 04:16:23 PM
I assume the reason he didn't hash the password was so he could use it to decrypt the encrypted information. However, since the user is (obviously) inputting the password, he could just store that in a session variable for decryption, which would still allow him to store the hash of the password for authentication purposes.
The hash of the plaintext of the password is used at the decryption key for the database, so storing the hash doesn't seem that much more secure. Although I suppose he could hash the "hashed" password and use that as a key. Storing the password in a session variable would be a good idea, however, this way the password would have to be stored in a database somewhere in order to verify that what a user enters is correct right? Or, I guess if it wasn't stored in a database and just used it as decryption key for the other passwords, then the login would fail if the database doesn't decrypt properly. Is it possible to test for that?
Quote from: unicityd on December 27, 2011, 11:14:12 PM
If the script is stored and executed server-side, it's trickier but still possible to recover the password. In this case, the attacker needs some sort of disclosure vulnerability. This is better, but not good.
The secure thing would be to not have a global master password. Then, users are responsible for their own data. If they forget their own master password, they lose their information and have to start over. The site could reset their master password, but the saved passwords for other sites would be lost. This is probably the best choice.
The script is server-side. I guess I'm not exactly sure what you're suggesting unicityd, or perhaps I wasn't clear in my description. There is no global master password, if by global you mean one password that will unlock all the passwords for all the users on the site. There is one password that will unlock all the passwords for a particular user on the site. Right now, there is no way to reset a password without having to renter all the passwords, because as you said, it's not very secure to have a global master password.
Thanks guys, you've given me a lot to think about.
Logged
Sec+, eCPPT
unicityd
Full Member
Offline
Posts: 156
Bored IT Manager, Crypto Nerd
Re: Secure Password Storage
«
Reply #5 on:
December 28, 2011, 01:19:46 AM »
I misunderstood; I thought he had a master password for the entire site in addition to each user's master.
I wondered why you were talking about XSS, but it makes more sense now. If the user's password/hash is stored in state then XSS could potentially recover it for an attacker.
In the case of per-user master passwords, they should not be stored in the database and the hash shouldn't either so it sounds like he got that right. The password/hash can be kept in state for the user's session. I don't know how you mean that he's storing it in the script. Do you mean it's put into the dynamically generated homepage of the user? If so, it's being sent to the user in the clear and would be vulnerable to XSS attacks (if any exist on the site).
Rather than pass it back to the user in plaintext, the site could encrypt it with a per-session key and hand it back to the user that way. The server could generate a new key for each session and use it to encrypt/decrypt the user's password hash during that session without ever storing it in the database. This limits the amount of time that the server ever has the hash accessible to itself and would be especially helpful for inactive sessions. XSS would not work because the user would only have the encrypted hash at any given time and server-side attacks would be limited because the server would only know how to decrypt the encrypted hash and would only have a few decrypted in memory at any given time.
Just to clarify, I'm assuming that he hashes the password with MD5, SHA, or a construction like PBKDF2. That hash would be used as the key to encrypt/decrypt the user's information in the database. Call this value 'hash(password)'. Your friend currently stores the plaintext password in a script for the user's home page, but I'm not clear on how exactly he is doing that. I'm suggesting that he generate a session key and encrypt the hash and pass that back to the user, call it 'encrypt(hash(password))'.
Does this make sense?
Logged
BS in IT, CISSP, MS in IS Management (in progress)
ajohnson
Recruiters
Hero Member
Offline
Posts: 1060
aka dynamik
Re: Secure Password Storage
«
Reply #6 on:
December 28, 2011, 08:18:03 AM »
Quote from: Seen on December 28, 2011, 12:41:23 AM
The hash of the plaintext of the password is used at the decryption key for the database, so storing the hash doesn't seem that much more secure. Although I suppose he could hash the "hashed" password and use that as a key. Storing the password in a session variable would be a good idea, however, this way the password would have to be stored in a database somewhere in order to verify that what a user enters is correct right?
Oh, when you said it was stored in plain text, I thought you were saying that it wasn't hashed. I wasn't saying you need to hash a hash. That still doesn't seem like the best configuration, but a salted hash is much better than a plain text password. That's all I was getting at.
Quote from: Seen on December 28, 2011, 12:41:23 AM
Or, I guess if it wasn't stored in a database and just used it as decryption key for the other passwords, then the login would fail if the database doesn't decrypt properly. Is it possible to test for that?
Yes, you could have a known text string (i.e. "success") stored that would be stored encrypted with the password, and that could be decrypted with the password upon login. I'm not sure if that provides any genuine benefit over a salted hash though. Instead of trying to crack the hash, an attacker would just use a brute-force or dictionary attack and compare it to the known plain text. If the site were compromised, it would probably be easy to identify the known plain text in the authentication code.
My next question was going to be how he handles password resets, but I just saw that you said that functionality isn't currently implemented. When a user changes his/her password, the users' passwords would just have to be read in, decrypted, re-encrypted with the new password, and then have the corresponding rows updated with the new encrypted password information. Hopefully nothing fails in the middle of that process though
Logged
WIP: GCFA |
www.infosiege.net
| @infosiege
The day you stop learning is the day you start becoming obsolete.
l33t5h@rk
Jr. Member
Offline
Posts: 79
Re: Secure Password Storage
«
Reply #7 on:
December 28, 2011, 10:21:25 AM »
What does the master password do exactly?
I have written an app before that used a similar setup but the master password was more of the value of an encryption key that was stored (hashed) in a configuration file, with the keys residing at the OS level.
Logged
Seen
Full Member
Offline
Posts: 134
Re: Secure Password Storage
«
Reply #8 on:
December 28, 2011, 01:37:11 PM »
Quote from: dynamik on December 28, 2011, 08:18:03 AM
Yes, you could have a known text string (i.e. "success") stored that would be stored encrypted with the password, and that could be decrypted with the password upon login. I'm not sure if that provides any genuine benefit over a salted hash though. Instead of trying to crack the hash, an attacker would just use a brute-force or dictionary attack and compare it to the known plain text. If the site were compromised, it would probably be easy to identify the known plain text in the authentication code.
I had that same thought this morning
I think I'll have my friend use a salted hash and then read a value from the database, if it's not garbage, then login successful.
Quote from: l33t5h@rk on December 28, 2011, 10:21:25 AM
What does the master password do exactly?
Think about the master password like a single sign-on (SS0). You log into the site with the password for your account, and then you have access to various data from other sites using the stored usernames/passwords for each.
Logged
Sec+, eCPPT
l33t5h@rk
Jr. Member
Offline
Posts: 79
Re: Secure Password Storage
«
Reply #9 on:
January 03, 2012, 07:13:19 AM »
Are the other sites similar sites to this or common social networking sites and this is a portal to those? Just curious as to the goal.
Logged
Seen
Full Member
Offline
Posts: 134
Re: Secure Password Storage
«
Reply #10 on:
January 03, 2012, 09:09:02 AM »
Quote from: l33t5h@rk on January 03, 2012, 07:13:19 AM
Are the other sites similar sites to this or common social networking sites and this is a portal to those? Just curious as to the goal.
Social networking sites like twitter, facebook, etc. The idea is instead of having each different site alert you on updates, postings, etc, this site will alert you to all of them. It's somewhat more complex than that but that is the basic idea.
Logged
Sec+, eCPPT
Pages: [
1
]
Go Up
Print
« previous
next »
Jump to:
Please select a destination:
-----------------------------
EH-Net
-----------------------------
=> Calendar Of Events
===> ChicagoCon 2007
===> ChicagoCon 2008s
===> ChicagoCon 2008f
===> ChicagoCon 2009s
=> Ethical Hacktivism
=> News Items and General Discussion About EH-Net
===> Greetings
=> Special Events
-----------------------------
Ethical Hacking Discussions and Related Certifications
-----------------------------
=> General Certification
===> Networking
===> OS
===> Security
=> Compliance, Regulations & Standards
=> Control Systems
=> Cyber Warfare
=> Forensics
===> CCE / MCCE - (Master) Certified Computer Examiner
===> CHFI - Computer Hacking Forensic Investigator
===> EnCE - EnCase® Certified Examiner
===> GCFA - GIAC Certified Forensics Analyst
=> Hardware
=> Incident Response
===> CSIH - Computer Security Incident Handler
===> GCIH - GIAC Certified Incident Handler
=> Malware
===> Advisories
=> Mobile
=> Network Pen Testing
===> CEH - Certified Ethical Hacker
===> CPTC - Certified Penetration Testing Consultant
===> CPTE - Certified Penetration Testing Engineer
===> CSTA - Certified Security Testing Associate
===> eCPPT - eLearnSecurity Certified Professional Penetration Tester
===> ECSA - EC-Council Certified Security Analyst
===> GPEN - GIAC Certified Penetration Tester
===> OSCP - Offensive Security Certified Professional
=> Physical Security
=> Programming
=> Social Engineering
=> Web Applications
=> Wireless
===> CWNP Certs
===> GAWN - GIAC Assessing Wireless Networks
===> OSWP - Offensive Security Wireless Professional
=> Other
-----------------------------
Columns
-----------------------------
=> Editor-In-Chief
=> Andress
=> Gates
=> Haddix
=> Hadnagy
=> Heffner
=> Hoffman
=> Linn
=> RichM
=> Murray
=> J. Peltier
=> Weidman
=> Wilson
-----------------------------
Features
-----------------------------
=> /root
=> Book Reviews
=> Opinions
=> Skillz
===> Examples
===> May 06 - Star Hacks, Episode V: The Empire Hacks Back
===> July 06 - Hack Bill!
===> Sept 06 - Netcat in the Hat
===> Nov 06 - Hitch-Hackers Guide to the Galaxy
===> Dec 06 - A Christmas (Hacking) Story
===> Feb 07 - Charlottes Web Site
===> April 07 - Microsoft Office Space
===> June 07 - Serenity Hack
===> Oct 07 - Worst. Ethical. Hacker. Challenge. Ever.
===> Dec 07 - Frosty the Snow Crash
===> March 2008 - It Happened One Friday
===> Oct 2008 - Scooby Doo and the Crypto Caper
===> Dec 08 - Santa Claus Is Hacking to Town
===> Feb 2009 - Brady Bunch Boondoggle
===> July 2009 - Prison Break
===> October 2009 - SSHliders
===> December 2009 - Miracle on Thirty-Hack Street
===> December 2010 - The Nightmare Before Charlie Browns Christmas
-----------------------------
Resources
-----------------------------
=> Career Central
===> Looking For Work
===> Looking To Hire
=> Links to cool sites.
=> Mass Media
=> News from the Outside World
=> Tools
=> Tutorials
===> Tutorial Requests
Loading...
Exclusive Deal
SANSFIRE 2013
June 15 - 22
5% Off
w/ Code
:
EHN_5
SANS Deals 4 EH-Netters
5% OFF
Any
SANS Course
in Any Format!
Coupon Code:
EHN_5
Including
SANS Rocky Mountain 2013
&
SANS Boston 2013
Polls
Compared to this year, 2013 will be:
Great!
Better.
About the same.
Little worse.
FUBAR!
Recent Forum Topics
News Items and General Discussion About EH-Net
: Change is Coming to EH-Net!!
(30) by
don
Tools
: Symbolic Exploit Assistant project is looking for collaborators
(0) by
galapag0
Greetings
: Hi from the UK
(5) by
prats84
GCIH - GIAC Certified Incident Handler
: Passed my GCIH
(9) by
prats84
Network Pen Testing
: Want a challenge? Want a GXPN practice exam?
(0) by
ajohnson
GCIH - GIAC Certified Incident Handler
: GCIH Free Practice test attempt
(1) by
prats84
EH-Net News Feeds
Latest Additions
Privacy Notice
for TDCC & All Properties
Free Business and Tech Magazines and eBooks
© 2013 The Ethical Hacker Network
Joomla!
is Free Software released under the GNU/GPL License.