System Design: How to store passwords in the database?

  Рет қаралды 186,324

ByteByteGo

ByteByteGo

Күн бұрын

Weekly system design newsletter: bit.ly/3tfAlYD
Checkout our bestselling System Design Interview books:
Volume 1: amzn.to/3Ou7gkd
Volume 2: amzn.to/3HqGozy
Other things we made:
Digital version of System Design Interview books: bit.ly/3mlDSk9
Twitter: bit.ly/3HqEz5G
LinkedIn: bit.ly/39h22JK
ABOUT US:
Covering topics and trends in large-scale system design, from the authors of the best-selling System Design Interview series.

Пікірлер: 271
@nemeziz_prime
@nemeziz_prime Жыл бұрын
Man this guy is brilliant. He keeps uploading videos about stuff which has always left me perplexed. Plus these animations and short crisp videos are the perfect icing on the cake ❤️
@NonTwinBrothers
@NonTwinBrothers Жыл бұрын
Bro when's your next movie coming out
@jfolz
@jfolz Жыл бұрын
In addition to a per-password salt you can also add a random, application-specific "pepper". It's hashed along with the password and the salt, but unlike the salt the pepper is not stored in the DB. A dump is useless without the pepper and an attacker would often need multiple vectors to obtain both.
@danielschmider5069
@danielschmider5069 Жыл бұрын
Yes, I personally find a pepper even better, because the DB is usually the primary attack vector. The pepper can be completely separate from the DB.
@jfolz
@jfolz Жыл бұрын
@Cristiano Morgado unlike a salt the pepper should be considered a secret. Storing it on the machine (hardcoding, config file, ...) is an option if a bit risky. Since you probably don't want an admin to type it in on startup, a central key server would be the next most secure option.
@juliansoto2651
@juliansoto2651 Жыл бұрын
@Cristiano Morgado you treat a pepper the same way you handle any admin password. Unique and secretly stored.
@jfolz
@jfolz Жыл бұрын
@@juliansoto2651 peppers are secrets, though I wouldn't say they're on the level of an admin password. Since you should always use a salt as well the impact of a leak is very limited. Storing it locally in a file is probably fine, though a key server has some advantages when it comes to maintenance.
@mhombach3035
@mhombach3035 Жыл бұрын
I think you misunderstood how a "pepper" is supposed to work :) A "pepper" is some short string that is added to the password while the hash is created, but that pepper is never stored anywhere. This way, your own server has to do a "tiny-bruteforce" on the users password when he tries to login. Since it's "tiny", it will only take a few ms, but for an attacker this will blow the timescale off. It's also more secure because for the pepper there can/should be used a small but very exotic pool of characters to choose from on the random generation. So you can take a few exotic ascii/unicode symbols for the pepper's character-pool and most attackers will "never" reveal the password if "only" the database was breached and not the server-code. Even if the server-code was also breached, the pepper would still force an attacker to waste more ms computation per iteration.
@NguyenTuan-ek1pv
@NguyenTuan-ek1pv Жыл бұрын
Short, concise, very straight forward You guys are so amazing.
@riddhishchakraborty8529
@riddhishchakraborty8529 23 күн бұрын
Explained in simple style. Informative.
@singhabhay1810
@singhabhay1810 Жыл бұрын
Binged watched all the videos.. though I knew about these concepts watching the simple yet accurate explanation was a pleasure. The graphics were simple and effective , my only complaint is I wish the video was longer with more content.
@RS-vu5um
@RS-vu5um Жыл бұрын
Very Clear and Crisp explanation. These videos are very helpful. Appreciate your work for the community.
@robbmanes
@robbmanes Жыл бұрын
Okay, this video is the perfect length and perfect explanation to send to my junior-level engineers. You do this perfectly to get someone started in like 1/10th of the time I could have explained it, so bravo. 👏👏👏
@JeremyChone
@JeremyChone Жыл бұрын
Very nice explanation. On top of password individual hash (stored in the DB), we also use an additional system wide salt, usually stored as a kubernetes secret property. This add another level of security. Also, we also use similar salt technic for the web token signature. Web Tokens embed their expiration, which is updated at each web request (typically as a http only cookie), and the third element is the signature using: ash(user_uuid + user_tsalt + global_tsalt). Also, we do NOT store credentials/access in the token, which is a longer conversation. So, a user row has a psalt column, for the password hash, and a tsalt for the token salt. Anyway, great vide, this is great to find this level of content on KZfaq.
@ksuhdilla
@ksuhdilla Жыл бұрын
I love this man's voice. It's like a soft lullaby but he is feeding me information
@yahayaoyinkansola8258
@yahayaoyinkansola8258 Жыл бұрын
This is so wonderful!, i never understood why people always salted their passwords and thought it was never important, now i do thanks to you!
@manojamrutharaj9071
@manojamrutharaj9071 Жыл бұрын
Glad to see one of the Authors of the book making these excellent videos for us to understand. Thanks for your effort...
@gauravkumarmnnit
@gauravkumarmnnit Жыл бұрын
Short and sweet yet to the point explanation, eagerly waiting for your new videos.
@nanotichorizon9644
@nanotichorizon9644 Жыл бұрын
Elegantly explained. You are top class brother! The design of inputs as well as the representation of logic is concise and clear.
@RossiMurilo
@RossiMurilo Жыл бұрын
Great content! Super clean and straight forward. Well done!
@Sanatanlif
@Sanatanlif Жыл бұрын
Learned again something new , Thank you Alex!! More power to you !! Keep helping as you are !!
@achintha8963
@achintha8963 8 ай бұрын
I am really thankful to the KZfaq algorithm for recommending this brilliant channel. Man, your content is to the point👌. Keep it up❤.
@skhapijulhossen6499
@skhapijulhossen6499 Жыл бұрын
Easy peasy explaination. Brilliant Man! 🙌 We need more system design videos 🙏
@emmanuelespinoza2634
@emmanuelespinoza2634 Жыл бұрын
I just discover your channel, it is pure gold man keep it going 🥰
@zoomzoom1889
@zoomzoom1889 Жыл бұрын
Excellent, well written scripts in easy to understand language. Keep doing these videos
@risingdamp220gaming6
@risingdamp220gaming6 Жыл бұрын
Such a great video! Amazing Delivery and top notch visuals!!
@RameshJothimani
@RameshJothimani Жыл бұрын
Thanks a lot for this video! Simple, clear & excellent demonstration
@AlexRoxjar
@AlexRoxjar Жыл бұрын
Some of the best videos I've watched on the topic!
@towb0at
@towb0at Жыл бұрын
Really great videos on this channel, I enjoyed them very much even though I didn't look them up with the intent of learning something new
@tvm73836
@tvm73836 Жыл бұрын
I love your short and highly informative videos. Here’s a suggestion for a video. How are passwords stored in a password manager or an application that accesses other password protected applications like a database?
@RahulHasija39
@RahulHasija39 8 ай бұрын
You have amazing set of tutorials. Two things I would like to mention - What if someone steal the HDD containing this user database. They will have access to salt and bcrypt hash, they can start doing bruteforce attack. To address this issue - Should we also have bitlocker enabled on machine managing these passwords/sensitive information or Shouldn't we encrypt the hash by some common DB key for all the users or unique key of each user. Those keys then can be managed by some other service.
@drakezen
@drakezen Жыл бұрын
I didn't know that you are the author of the system design book; I had bought it months ago. Great book!
@Julien-hg8jh
@Julien-hg8jh Жыл бұрын
i love how you explain ! it can not be more clean and simple :D
@pobodjjd
@pobodjjd 3 ай бұрын
Precise and accurate! Thank you very much!
@sakthikumar4721
@sakthikumar4721 Жыл бұрын
One of the best tutorials. I love your videos awaiting for more.
@anhquocnguyen1578
@anhquocnguyen1578 Жыл бұрын
amazing explanation and illustration. thank you
@zerocool4360
@zerocool4360 Жыл бұрын
Amazing explanation. Everything makes much more sense now. What tool are you using to create such great animations?
@bazoo513
@bazoo513 Жыл бұрын
Very clear. A pointer or two to common attacks to which unsalted hashed passwords are vulnerable would be useful, just to shock a naive viewer a bit. BTW, I appreciate the fact that you never call an attack "impossible", not even "infeasible", but merely "unattractive".
@ClipHiveCentral
@ClipHiveCentral Жыл бұрын
Without his linkedin post i wont be able to figure this brilliant and easy-catch presentation
@Lucas-ne8xu
@Lucas-ne8xu Жыл бұрын
Clear explanation. Please keep making these amazing videos.
@SayanInMoves
@SayanInMoves Жыл бұрын
very nice content. I love it. Just praying for more videos to publish soon.
@Qwertzym0onsif
@Qwertzym0onsif Жыл бұрын
Wow ! Thats really good explanation to such a complex thing ! Keep it up
@sahibvirk
@sahibvirk Жыл бұрын
Sir you are so brilliant and a very good teacher. Please, make more videos.
@yacoubasawadogo8225
@yacoubasawadogo8225 Жыл бұрын
Very well explained in a short video ❤
@parkershaw8529
@parkershaw8529 Жыл бұрын
Thanks for sharing the knowledge! I learned something new today!
@nathantorquato9777
@nathantorquato9777 Жыл бұрын
Please release a course on system design! Your content is amazing!
@soundhermm5514
@soundhermm5514 Жыл бұрын
Their system design books are available in the market go for it.
@rishabhmaheshwari7788
@rishabhmaheshwari7788 Жыл бұрын
Very good and interactive session. And it felt great to see you saying thank you while doing namaste.
@18something
@18something Жыл бұрын
Great content, you got me with the Kafka one. Pls do more system design vids
@manuelnovella39
@manuelnovella39 Жыл бұрын
These videos really are amazing
@SanjeeviRajRC
@SanjeeviRajRC Жыл бұрын
simple and clean explanation.
@codegreenie3429
@codegreenie3429 11 ай бұрын
I am super happy because this is exactly how i store my customer passwords in my app database. Guess I am a good CS student afterall
@gpt_forever
@gpt_forever Жыл бұрын
Thanks a lot! Very helpful information
@manieshsh
@manieshsh Жыл бұрын
Thanks for such crisp video. One question though. How will one store a password for a database in the same DB. ?
@icesallowcome
@icesallowcome Жыл бұрын
Just found this channel, it's dope. That's my dawg.
@sheikhAbdelrahman
@sheikhAbdelrahman Жыл бұрын
Nice and simple .. Thank you!
@Nathan17B
@Nathan17B Жыл бұрын
Quality Content. Thanks my friend.
@neroamayo6345
@neroamayo6345 Жыл бұрын
Brilliant. Please keep uploading videos.
@Alan_Dler
@Alan_Dler Жыл бұрын
Great video mate. thanks for the web101 review.
@pratikchavan3603
@pratikchavan3603 Ай бұрын
Pretty Good explanation 👏
@mhombach3035
@mhombach3035 Жыл бұрын
It would have been nice if you had mentioned and explained "pepper" in addition to the "salt", which is the most modern and secure way of securing passwords :) Also, MD5 is not only "too fast", it's officially broken in way where mathematical collisions exist to narrow extract the original password pretty quick.
@upulba
@upulba Жыл бұрын
Very nice explanation, quick question: why do we use salt when storing a password in the DB?
@joydey1794
@joydey1794 Жыл бұрын
❤️ just what I was looking for
@AungBaw
@AungBaw Жыл бұрын
Animation, quality & content improved video by video.
@juloko
@juloko Жыл бұрын
Learned and subscribed.
@DvACtOid
@DvACtOid Жыл бұрын
Great content and animation, concise and easy to grapes. I couldn't complain anything. If ask for any improvement can be made is keep produce more content and make voice sound more energetic .
@vasanthkorada4802
@vasanthkorada4802 Жыл бұрын
thank you. waiting for more videos
@ashishagupta
@ashishagupta Жыл бұрын
Another advantage of using salt is that.. internal person who has access to db cannot identify if there are same hashes stored in database, that means two user have same password.
@juliansoto2651
@juliansoto2651 Жыл бұрын
Wow that's brilliant. That's a more convincing argument in favor of salts. They never made sense to me until now.
@atabhatti6010
@atabhatti6010 Жыл бұрын
@@juliansoto2651 Yes. The same is true if a user repeated passwords across apps. If the attacker brings an old file of stolen password hashes to compare, the stolen hashes are useless against the new file made with different salts, even if the passwords are repeated.
@angel54268
@angel54268 Жыл бұрын
Amazing video Thanks
@digvijaychauhan7312
@digvijaychauhan7312 Жыл бұрын
Wow great simple.Can you please tell what for we use pepper?
@TylerTriesTech
@TylerTriesTech Жыл бұрын
What are you using to make the animated diagrams?
@burnbabie
@burnbabie Жыл бұрын
instant sub. Well articulated.
@vishi83
@vishi83 Жыл бұрын
Good video, thanks 👍. In my work, I avoided Storing Salt in db and used pepper which is like a symmetric key embedded in code to do 2nd level hash. What do you think of this approach?
@subee128
@subee128 3 ай бұрын
Thank you very much
@TricoliciSerghei
@TricoliciSerghei Жыл бұрын
Great video!
@godlymajins
@godlymajins Жыл бұрын
Love the content!!
@benmp4094
@benmp4094 Жыл бұрын
This is top stuff, thanks for sharing
@Na4Ge4
@Na4Ge4 Жыл бұрын
wish identity server 4 tutorials can be this easy to understand
@000bulit000
@000bulit000 Жыл бұрын
With hashed password with salt in the DB, in DB leak case - attackers has hashed password and salt on one dish. Then, the thing is to try different algorithms to decode it... I think it's like a house with locked door, but without one wall 🙂.
@liang3163
@liang3163 Жыл бұрын
Excatly, using only salts stored in db is actually unsafe, we need global level pepper anyway.
@TheHarimir
@TheHarimir Жыл бұрын
nice explanation. it does leave me with one question: how abaut password recovery?
@rbelatamas
@rbelatamas Жыл бұрын
cool, thank you!
@shivamgupta5476
@shivamgupta5476 Жыл бұрын
Nice can you explain in videos on backend best practices with solutions like password saving , you discussed in this video. Why we use Vault if in Database we can use security
@cryptomania3553
@cryptomania3553 Жыл бұрын
Amazing sir
@shahul41u
@shahul41u Жыл бұрын
Awesome content
@Borkolini
@Borkolini Жыл бұрын
Great content, thank you! What software do you use to create animations? They are so clean and smooth, greatly adds to clarity of your explanations!
@robbmanes
@robbmanes Жыл бұрын
Seriously, the animations are smoother than anything most marketing coming out of big shops.
@Julien-hg8jh
@Julien-hg8jh Жыл бұрын
I think he master Powerpoint :D
@peterstedman6140
@peterstedman6140 Жыл бұрын
He's said that they (it's not a solo venture), use a mix of products including photoshop and illustrator
@kunliliu1875
@kunliliu1875 Жыл бұрын
Very useful
@shreerangakv7183
@shreerangakv7183 Жыл бұрын
Please do complete course on these topics.
@JamesJansson
@JamesJansson Жыл бұрын
The easiest way to do this is Bcrypt. It stores all the information (password hash and salting information) in a single string in the DB. Lots of implementations across lots of programming languages.
@danalex2991
@danalex2991 Жыл бұрын
Amazing
@plashless3406
@plashless3406 Жыл бұрын
Amazing.
@zixuanzhao6043
@zixuanzhao6043 Ай бұрын
so the validation process when first fetch the salt then hash the combination of pwd+salt, does this happen at the client side or server side?
@panos9186
@panos9186 Жыл бұрын
That is concise and brief explanation indeed so thanks. But then, how do you overcome a "pass-the-hash" attack where an attacker already has access to a DB (does not matter how) and then he/she can use hashed passwords from other accounts for a possible privilege escalation?
@syedfaiqhaidernaqvi1031
@syedfaiqhaidernaqvi1031 Ай бұрын
How does the encyption algorithm match the hash stored in database and the one entered by the user, as algorithms like bcrypt, argon2 etc generate different hash values for the same input each time???
@JAYPATEL-pt5fu
@JAYPATEL-pt5fu Жыл бұрын
thank you!!! video liked and u got a well deserved sub from me!!!!
@notreallyme425
@notreallyme425 Жыл бұрын
When logging into a website is the hash computed on the client or the server? In other words is the password sent over the Network to the server and the server computes the hash, or does the client computer accept the password, compute the hash, and then transmit the hash to the client?
@eric19xx
@eric19xx Жыл бұрын
brilliant
@daniel860305
@daniel860305 Жыл бұрын
Can you elaborate on the precomputation attack? Thanks a lot!
@theghostwhowalk
@theghostwhowalk Жыл бұрын
Great series… N00b question: When the database gets compromised won’t salt be exposed as well? If so then p/w can be recovered ?
@ashishjha9262
@ashishjha9262 Жыл бұрын
This is used to prevent precomputation attack. Suppose attacker knows that SHA256 has been used in DB. He will compute SHA256 of all common word in dictionary and voila! User who used simple dictionary word as password are compromised. Now suppose DB administrator used salt for each row. Now attacker has to comuter SHA256 of all common dictionary word against each salt. Imagine 10M user or 10 million salt. He/she has to computer the SHA of all dictionary items 10 million times(As opposed to single time previously)
@CyberMew
@CyberMew Жыл бұрын
My understanding is this (please correct me if I am wrong, not security expert): The salted hashed value result (of salt and plain password) is stored along with the salt. Yes the salt is visible in plain text. However it is made much harder to crack the password since probably no rainbow table exists for it that can be used as the salt is random and unique per password (unless the attacker build their own table but it’s just further deterrence), so attacker has no way to easily look it up and instead has to try attacking it manually, password by password, restarting the crack each time per user, making it harder and deter efforts to crack it. Imagine your password is “1234”. It hashed to “ABCD”. Easily crackable. Now the backend does the salting for you behind the scene. So maybe it becomes hash(“ABCDrand0mSaltHeRe”). It’s harder to crack. The hash value is stored in the hash column along with the salt in the salt column. Again this is unique salt per user password. During login, client sends backend the password say “EFGH”. Backend will take it and together with the salt prestored for the username, does the hash check, if hash(“EFGHrand0mSaltHeRe”) == hashed_value_in_db. If you have the same salt for all passwords. Then it’s as good as as not using any salt. Any experts please feel free to correct me.
@theghostwhowalk
@theghostwhowalk Жыл бұрын
@@ashishjha9262 awesome makes sense. Thanks!!
@theghostwhowalk
@theghostwhowalk Жыл бұрын
@@CyberMew agree to both of you, but when database is compromised, since we storing salt on the dB, won’t that be exposed per user too along with pw? So even if salt is unique per user, getPw for user I’d will give salt too?
@CyberMew
@CyberMew Жыл бұрын
@@theghostwhowalk I guess there is no foolproof prevention. You want to make life harder for attackers. The video mentioned bcrypt which is a slow hashing function which helps to waste attacker time. Rainbow tables are not readily available for each of the password+hash combinations (wiki has a good explanation on what rainbow table is). As Ashish Jha mentioned the computation is a lot when you try to crack it. Password by password. “a”+”salt”, “aa”+”salt”, etc. I guess it’s mainly to prevent easy cracking of password. It does not prevent the cracking of password. This is why you use a long and complicated password and that is always advised. Otherwise hackers can still crack it easily.
@MegaSascuach
@MegaSascuach Жыл бұрын
More videos please!!!!!
@stackunderflow5951
@stackunderflow5951 Жыл бұрын
We can also store the hash algorithm used in the database, which makes adapting to new algorithm easier.
@kandisaganesh
@kandisaganesh Жыл бұрын
Bad idea, in case db is compromised you are exposing hash algorithm which can help attacker?
@stackunderflow5951
@stackunderflow5951 Жыл бұрын
@@kandisaganesh Even if the attacker knows the hash algorithm, it's still impossible for them to calculate the original value based on hashed value.
@lawrencedoliveiro9104
@lawrencedoliveiro9104 Жыл бұрын
The *nix shadow file does exactly that -- the password hash begins with a prefix indicating which algorithm was used.
@deverasjk
@deverasjk Жыл бұрын
awesome video!!! if you it ok, could you make a video big O notation?? tyvm anyway!!
@multiwebinc
@multiwebinc Жыл бұрын
Great explanation. One thing I would like to add is that modern programming languages have hashing libraries available (e.g. for Argon2 and Bcrypt) and the salt is generated by the library and outputted as part of the hash, so you don't need to worry about trying to manually generate or store the salt.
@Hauketal
@Hauketal Жыл бұрын
You will have to store the salt in the database, because only then you can have enough entropy to make rainbow tables unfeasable.
@multiwebinc
@multiwebinc Жыл бұрын
@@Hauketal The point is that the hash, along with any other parameters used to calculate the hash, are part of the output string that these libraries generate. You don't need to specifically worry about or store the salt separately.
@peresola3885
@peresola3885 Жыл бұрын
Thanks for the video! I can't quite understand slide in 2:15. Can someone help me understand? Thanks
@VishnuKumar-fq1zo
@VishnuKumar-fq1zo Жыл бұрын
Can we use same salt for going for all password?
@ssarkar2996
@ssarkar2996 Жыл бұрын
On a cloud system, I need to store the connection info of each tenant somewhere. This info includes the database password. I need the database password in clear text as I have to request the database for a connection. What is the best way to store the tenant info in such a scenario?
@RajeshSharmaIndia
@RajeshSharmaIndia 10 ай бұрын
During login, the scenario you described, where the communication between the client and server can potentially be intercepted by a third party, sending the password in plain text is not secure.
@mishuman
@mishuman Жыл бұрын
How do you generate the salt for each user? Is there another hash function in play?
Password Storage Tier List: encryption, hashing, salting, bcrypt, and beyond
10:16
狼来了的故事你们听过吗?#天使 #小丑 #超人不会飞
00:42
超人不会飞
Рет қаралды 57 МЛН
1❤️
00:20
すしらーめん《りく》
Рет қаралды 32 МЛН
What Is Single Sign-on (SSO)? How It Works
4:54
ByteByteGo
Рет қаралды 533 М.
Top 5 Redis Use Cases
6:28
ByteByteGo
Рет қаралды 162 М.
Basic System Design for Uber or Lyft | System Design Interview Prep
16:18
System Design: Why is Kafka fast?
5:02
ByteByteGo
Рет қаралды 1 МЛН
System Design Interview: A Step-By-Step Guide
9:54
ByteByteGo
Рет қаралды 581 М.
Top 7 Most-Used Distributed System Patterns
6:14
ByteByteGo
Рет қаралды 228 М.
Google system design interview: Design Spotify (with ex-Google EM)
42:13
IGotAnOffer: Engineering
Рет қаралды 973 М.
Design a High-Throughput Logging System | System Design
8:23
Interview Pen
Рет қаралды 40 М.
How Discord Stores TRILLIONS of Messages
7:11
ByteByteGo
Рет қаралды 152 М.
Good APIs Vs Bad APIs: 7 Tips for API Design
5:48
ByteByteGo
Рет қаралды 201 М.