Тёмный

System Design: How to store passwords in the database? 

ByteByteGo
Подписаться 964 тыс.
Просмотров 198 тыс.
50% 1

Опубликовано:

 

3 окт 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 274   
@nemeziz_prime
@nemeziz_prime 2 года назад
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 2 года назад
Bro when's your next movie coming out
@NguyenTuan-ek1pv
@NguyenTuan-ek1pv 2 года назад
Short, concise, very straight forward You guys are so amazing.
@jfolz
@jfolz 2 года назад
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 2 года назад
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 2 года назад
@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 2 года назад
@Cristiano Morgado you treat a pepper the same way you handle any admin password. Unique and secretly stored.
@jfolz
@jfolz 2 года назад
@@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 2 года назад
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.
@singhabhay1810
@singhabhay1810 2 года назад
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.
@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!
@ksuhdilla
@ksuhdilla 2 года назад
I love this man's voice. It's like a soft lullaby but he is feeding me information
@simple-stack-by-ed
@simple-stack-by-ed 2 месяца назад
Simple quality. This channel is one of my role models.
@JeremyChone
@JeremyChone 2 года назад
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 RU-vid.
@ClipHiveCentral
@ClipHiveCentral 2 года назад
Without his linkedin post i wont be able to figure this brilliant and easy-catch presentation
@codegreenie3429
@codegreenie3429 Год назад
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
@zoomzoom1889
@zoomzoom1889 Год назад
Excellent, well written scripts in easy to understand language. Keep doing these videos
@RahulHasija39
@RahulHasija39 Год назад
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.
@riddhishchakraborty8529
@riddhishchakraborty8529 4 месяца назад
Explained in simple style. Informative.
@achintha8963
@achintha8963 Год назад
I am really thankful to the RU-vid algorithm for recommending this brilliant channel. Man, your content is to the point👌. Keep it up❤.
@gauravkumarmnnit
@gauravkumarmnnit 2 года назад
Short and sweet yet to the point explanation, eagerly waiting for your new videos.
@bazoo513
@bazoo513 2 года назад
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".
@nathantorquato9777
@nathantorquato9777 2 года назад
Please release a course on system design! Your content is amazing!
@soundhermm5514
@soundhermm5514 2 года назад
Their system design books are available in the market go for it.
@Na4Ge4
@Na4Ge4 2 года назад
wish identity server 4 tutorials can be this easy to understand
@manojamrutharaj9071
@manojamrutharaj9071 2 года назад
Glad to see one of the Authors of the book making these excellent videos for us to understand. Thanks for your effort...
@tigana
@tigana 3 месяца назад
Great video I appreciate how concise this was. Why isn't the salt hashed too for extra security?
@rishabhmaheshwari7788
@rishabhmaheshwari7788 2 года назад
Very good and interactive session. And it felt great to see you saying thank you while doing namaste.
@emmanuelespinoza2634
@emmanuelespinoza2634 2 года назад
I just discover your channel, it is pure gold man keep it going 🥰
@icesallowcome
@icesallowcome 2 года назад
Just found this channel, it's dope. That's my dawg.
@sahibvirk
@sahibvirk 2 года назад
Sir you are so brilliant and a very good teacher. Please, make more videos.
@joydey1794
@joydey1794 2 года назад
❤️ just what I was looking for
@yacoubasawadogo8225
@yacoubasawadogo8225 Год назад
Very well explained in a short video ❤
@nanotichorizon9644
@nanotichorizon9644 2 года назад
Elegantly explained. You are top class brother! The design of inputs as well as the representation of logic is concise and clear.
@anhquocnguyen1578
@anhquocnguyen1578 2 года назад
amazing explanation and illustration. thank you
@Alan_Dler
@Alan_Dler 2 года назад
Great video mate. thanks for the web101 review.
@manuelnovella39
@manuelnovella39 2 года назад
These videos really are amazing
@pobodjjd
@pobodjjd 8 месяцев назад
Precise and accurate! Thank you very much!
@parkershaw8529
@parkershaw8529 2 года назад
Thanks for sharing the knowledge! I learned something new today!
@RS-vu5um
@RS-vu5um 2 года назад
Very Clear and Crisp explanation. These videos are very helpful. Appreciate your work for the community.
@AlexRoxjar
@AlexRoxjar 2 года назад
Some of the best videos I've watched on the topic!
@SanjeeviRajRC
@SanjeeviRajRC 2 года назад
simple and clean explanation.
@skhapijulhossen6499
@skhapijulhossen6499 2 года назад
Easy peasy explaination. Brilliant Man! 🙌 We need more system design videos 🙏
@Sanatanlif
@Sanatanlif 2 года назад
Learned again something new , Thank you Alex!! More power to you !! Keep helping as you are !!
@risingdamp220gaming6
@risingdamp220gaming6 2 года назад
Such a great video! Amazing Delivery and top notch visuals!!
@pratikchavan3603
@pratikchavan3603 5 месяцев назад
Pretty Good explanation 👏
@drakezen
@drakezen 2 года назад
I didn't know that you are the author of the system design book; I had bought it months ago. Great book!
@Lucas-ne8xu
@Lucas-ne8xu 2 года назад
Clear explanation. Please keep making these amazing videos.
@SayanInMoves
@SayanInMoves 2 года назад
very nice content. I love it. Just praying for more videos to publish soon.
@AungBaw
@AungBaw 2 года назад
Animation, quality & content improved video by video.
@juloko
@juloko 2 года назад
Learned and subscribed.
@towb0at
@towb0at 2 года назад
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
@18something
@18something 2 года назад
Great content, you got me with the Kafka one. Pls do more system design vids
@Julien-hg8jh
@Julien-hg8jh 2 года назад
i love how you explain ! it can not be more clean and simple :D
@neroamayo6345
@neroamayo6345 2 года назад
Brilliant. Please keep uploading videos.
@ashishagupta
@ashishagupta 2 года назад
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 2 года назад
Wow that's brilliant. That's a more convincing argument in favor of salts. They never made sense to me until now.
@atabhatti6010
@atabhatti6010 2 года назад
@@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.
@mhombach3035
@mhombach3035 2 года назад
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.
@shreerangakv7183
@shreerangakv7183 2 года назад
Please do complete course on these topics.
@angel54268
@angel54268 2 года назад
Amazing video Thanks
@RameshJothimani
@RameshJothimani 2 года назад
Thanks a lot for this video! Simple, clear & excellent demonstration
@gpt_forever
@gpt_forever 2 года назад
Thanks a lot! Very helpful information
@sakthikumar4721
@sakthikumar4721 2 года назад
One of the best tutorials. I love your videos awaiting for more.
@sheikhAbdelrahman
@sheikhAbdelrahman 2 года назад
Nice and simple .. Thank you!
@RossiMurilo
@RossiMurilo 2 года назад
Great content! Super clean and straight forward. Well done!
@tvm73827
@tvm73827 Год назад
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?
@Qwertzym0onsif
@Qwertzym0onsif 2 года назад
Wow ! Thats really good explanation to such a complex thing ! Keep it up
@subee128
@subee128 8 месяцев назад
Thank you very much
@DvACtOid
@DvACtOid 2 года назад
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 .
@000bulit000
@000bulit000 2 года назад
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 2 года назад
Excatly, using only salts stored in db is actually unsafe, we need global level pepper anyway.
@multiwebinc
@multiwebinc 2 года назад
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 2 года назад
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 2 года назад
@@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.
@manieshsh
@manieshsh 2 года назад
Thanks for such crisp video. One question though. How will one store a password for a database in the same DB. ?
@JamesJansson
@JamesJansson 2 года назад
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.
@TheHarimir
@TheHarimir 2 года назад
nice explanation. it does leave me with one question: how abaut password recovery?
@cryptomania3553
@cryptomania3553 2 года назад
Amazing sir
@theghostwhowalk
@theghostwhowalk 2 года назад
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 2 года назад
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 2 года назад
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 2 года назад
@@ashishjha9262 awesome makes sense. Thanks!!
@theghostwhowalk
@theghostwhowalk 2 года назад
@@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 2 года назад
@@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.
@Nathan17B
@Nathan17B 2 года назад
Quality Content. Thanks my friend.
@kunliliu1875
@kunliliu1875 2 года назад
Very useful
@benmp4094
@benmp4094 2 года назад
This is top stuff, thanks for sharing
@rbelatamas
@rbelatamas 2 года назад
cool, thank you!
@digvijaychauhan7312
@digvijaychauhan7312 Год назад
Wow great simple.Can you please tell what for we use pepper?
@vasanthkorada4802
@vasanthkorada4802 2 года назад
thank you. waiting for more videos
@upulba
@upulba 2 года назад
Very nice explanation, quick question: why do we use salt when storing a password in the DB?
@noredine
@noredine 2 года назад
"password1" is a very commons pass, that's why I use "password2"
@deepakdiipu6572
@deepakdiipu6572 10 месяцев назад
bcrypt automatically adds salt to the password. We don't have to store the salt separately in database, it will be taken care by bcrypt in general
@borkomne
@borkomne 2 года назад
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!
@Julien-hg8jh
@Julien-hg8jh 2 года назад
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
@MegaSascuach
@MegaSascuach 2 года назад
More videos please!!!!!
@stackunderflow5951
@stackunderflow5951 2 года назад
We can also store the hash algorithm used in the database, which makes adapting to new algorithm easier.
@kandisaganesh
@kandisaganesh 2 года назад
Bad idea, in case db is compromised you are exposing hash algorithm which can help attacker?
@stackunderflow5951
@stackunderflow5951 2 года назад
@@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 2 года назад
The *nix shadow file does exactly that -- the password hash begins with a prefix indicating which algorithm was used.
@daniel860305
@daniel860305 Год назад
Can you elaborate on the precomputation attack? Thanks a lot!
@burnbabie
@burnbabie 2 года назад
instant sub. Well articulated.
@igor9silva
@igor9silva Год назад
This design implies that the password will go as plain text through the network, before being hashed at the server. The technique I'm used to is: hash at the front-end (for both sign up and login), then re-hash it at the backend, including the salt and pepper. Very few milliseconds are added, and the password is never transfer as plain text.
@nikhilneela
@nikhilneela Год назад
Wouldn't using https, already encrypt the contents in signup and login flow ?
@igor9silva
@igor9silva Год назад
@@nikhilneela yes but on a different layer. HTTPS is fairly easy to decrypt when on the same network (using any regular sniffing software).
@TricoliciSerghei
@TricoliciSerghei 2 года назад
Great video!
@godlymajins
@godlymajins 2 года назад
Love the content!!
@TylerTriesTech
@TylerTriesTech 2 года назад
What are you using to make the animated diagrams?
@deverasjk
@deverasjk 2 года назад
awesome video!!! if you it ok, could you make a video big O notation?? tyvm anyway!!
@zerocool4360
@zerocool4360 2 года назад
Amazing explanation. Everything makes much more sense now. What tool are you using to create such great animations?
@RajeshSharmaIndia
@RajeshSharmaIndia Год назад
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.
@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?
@JAYPATEL-pt5fu
@JAYPATEL-pt5fu 2 года назад
thank you!!! video liked and u got a well deserved sub from me!!!!
@shivamgupta5476
@shivamgupta5476 2 года назад
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
@aviksarkar8673
@aviksarkar8673 2 года назад
Just to clarify myself.. that "Salt" is a randomly generated string that also stores in the db after hashing corresponding to the user. Correct me if I am wrong.
@singhsandeep
@singhsandeep 2 года назад
yes
@Icmex70
@Icmex70 2 года назад
Yeah, but you need to concatenate password and salt before hashing.
@eric19xx
@eric19xx 2 года назад
brilliant
@ProshnoKoutuhol
@ProshnoKoutuhol 2 года назад
If the salt is stored in the database, what is the value in adding it to the password? The hacker can get the salt from the database (if it is compromised), and using pre-computation attacks they can hack the password and the salt?
@andreaspettersson3258
@andreaspettersson3258 2 года назад
It would still be quite safe to store it there as a pre-computation attack is based on known pairs. For instance, the md5 of "apple" is 1f3870be274f6c49b3e31a0c6728957f so an attacker would just do a lookup if the hashed password in the database matches 1f3870be274f6c49b3e31a0c6728957f and if it does, they know that the password is "apple". Adding a salt would make that table of known pairs useless as the salt is unique and would generate a unique hash that doesn't exist in any pre-computed table.
@liquidpebbles
@liquidpebbles 2 года назад
@@andreaspettersson3258 I see. So it prevents an attacker from scanning an entire table to find records with known hashes. But, if an attacker had the hash and the salt for each record, they could conceivable try to brute force each record's password by hashing common passwords appended with the salt from the record until they find a match or move onto the next record?
@GDScriptDude
@GDScriptDude 2 года назад
@@liquidpebbles Yes, if the data has any value to the hacker then they are surely going to spend a few minutes looking at the field names to look for a salt value field and try to spot a well known fingerprint of a data storage schema.
@danalex2991
@danalex2991 2 года назад
Amazing
@liang3163
@liang3163 2 года назад
I have to say some points of the author are somehow misleading: 1. a global field pepper is enough for rainbow table attack(or any other brutal force attack) 2. unique salts for every user is for preventing extreme cases when two users set the same password, since you need to make every user's hash unique. This can ensure the hacker can at most decode only one user's real password even if he break the first layer security(the global field salt). Normally, you cannot just use "unique salts for every user" to prevent attack, because if the database is hacked, the hacker can generate the rainbow table to attack one user by using "his unique salt from database" + "a list of commonly used password from online". So the best way is using pepper + salt, an not-bad way is using pepper alone, while using salt alone is unsafe!
@9415868687
@9415868687 2 года назад
Question: if user's password is weak and can be found in a common passwords DB? does salting still help? if yes, how?
@evancombs5159
@evancombs5159 2 года назад
The salt is there to protect against a compromised database so the hacker can't just compare the hash in the database against known hashes to figure out the password. It doesn't protect against a compromised password.
@shahul41u
@shahul41u 2 года назад
Awesome content
@peresola3885
@peresola3885 2 года назад
Thanks for the video! I can't quite understand slide in 2:15. Can someone help me understand? Thanks
Далее
小路飞嫁祸姐姐搞破坏 #路飞#海贼王
00:45
HTTP 1 Vs HTTP 2 Vs HTTP 3!
7:37
Просмотров 191 тыс.
Top 6 Most Popular API Architecture Styles
4:21
Просмотров 917 тыс.
Consistent Hashing | Algorithms You Should Know #1
8:04
Session Vs JWT: The Differences You May Not Know!
7:00
Microservices with Databases can be challenging...
20:52