Luyện nói tiếng Anh bằng Shadowing qua video: Password Storage Tier List: encryption, hashing, salting, bcrypt, and beyond

Đang tạo bài học...
1
If you're building a product that requires logging in, you probably have to deal with storing passwords.
2
But storing passwords opens you up to security risks, like someone breaking into your database, stealing all your passwords, and dealing immense reputational damage to your product.
3
So how do you store passwords in a secure fashion?
4
Let's start from the worst way, and steadily work our way up to something a little more secure.
5
I'm going to assume you have a little bit of software engineering knowledge.
6
Let's go.
7
The F tier way to store your passwords is like normal data.
8
a normal column perhaps with the rest of your user data.
9
Sometimes this is called storing passwords in plain text.
10
This is pretty bad because if a hacker gains access to your database, they can steal all the passwords effortlessly.
11
Security is all about multiple lines of defense, and storing passwords in plain text is not a defense.
12
If your database is breached, you're done, and database breaches happen quite often.
13
That's why this is F tier.
14
But how can we do better?
15
If you watched my encryption video, you might think that we should encrypt these passwords.
16
That's definitely an improvement, because if they break into your database, they get gibberish instead of useful information.
17
However, if they do get access to the key, then they can decrypt all the passwords, and you're unfortunately right back to F tier.
18
It's definitely nicer that the passwords aren't just sitting out there in the open, but if a hacker has access to your database already,
19
it may not be much more effort for them to steal the decryption key too from an adjacent server or config file.
20
So storing passwords in a way that makes it possible to retrieve the password increases the risk of an inside job,
21
where an employee with privileged access to the key decrypts people's passwords for nefarious purposes.
22
The Xword protection certainly helps, but this is D tier.
23
How do we get to C?
24
The key insight is that we only need to know
25
when the user types in the same password as when they signed up.
26
We don't actually need to know the password itself.
27
You might think the two are one and the same, but they actually aren't.
28
It's possible to take a password and generate a fingerprint from it, which will let us know if we encounter the same password in the future, but still be unable to recover the password directly from the fingerprint.
29
This is a technique known as hashing.
30
How do we use hashing?
31
When the user signs up, we take the password they provide, generate a small fingerprint or hash, and store it instead of the actual password.
32
In the future, when the user tries to log in, we take the password they typed in, we're the same hashing process and see if the output hashes compare.
33
If the hashes are the same, it's overwhelmingly likely that they typed in the correct password.
34
Thanks to the power of hashing, we're able to verify someone's password without storing the actual password.
35
Hashing might sound a little magical at the moment.
36
How does hashing prevent someone from recovering their original password from the output hash?
37
And how does it prevent two strings from hashing to the same thing
38
and allowing someone to log in with the wrong password?
39
For the first one, how to prevent someone from recovering their original password, the process of hashing involves a lot of aggressive mixing of the data in the original input to produce the output.
40
It's like taking three paints of different colors and mixing them together which probably results in some weird shade of brown.
41
With just the brown, you'd probably be unable to guess the original three colors that made the brown.
42
In the same way, you can't figure out the original password from the hash
43
because the bits in the data have all been thoroughly mixed and scrambled.
44
This property is known as being a one-way function, like a one-way street.
45
Once you hash, you can't unhash.
46
For the second, which is how hashing makes it hard for two strings to hash to the same value known as a hash collision, the answer is similar to what I just said.
47
That hash function mixes the data in such a way that even small tweaks in the input result in totally different hashes.
48
As a result, for good hash functions, there is no publicly known way to generate two strings whose hashes collide without just trying many many many strings.
49
No luck with these ten!
50
This property is called collision resistance.
51
Picking the right hash function is important.
52
We used to think that older hash functions that you may have heard about, like md5 and SHA-1 had collision resistance,
53
but cryptographic progress marches on and they've been proved insecure.
54
For example, about a decade ago, researchers published a method for generating a collision, two strings that have the same MD5 hash that you can run in about a second on your laptop.
55
So we've moved on to stronger hash functions like SHA-2, which is the one I've been using in this video.
56
With our new hashing technique under our belt, let's hash all the passwords in our database instead of encrypting them to arrive at C tier password storage.
57
Now, we don't have a key that effortlessly unlocks the password table like before, which is definitely an improvement.
58
However, we need to talk about dictionary attacks.
59
As it turns out, many people use extremely weak passwords like password or 123456.
60
If a hacker has access to your database, they can just run your hash function on password or 123456 to get the hash, and then find all the hashes that match in your database.
61
Voila, they've broken those people's passwords.
62
This is called a dictionary attack because you could run through the dictionary, hashing words as you go and seeing if any of them match the hash.
63
Remember that it's not possible to directly turn a hash back into a password, in general.
64
However, because the hacker knows the hash came from a password, they can use their knowledge of human nature to narrow down the possible guesses, which makes guessing feasible.
65
Furthermore, they can use lists of the most common passwords to pre-generate a huge database of hashes.
66
So all they need to do is to compare their huge database to your database to find matches.
67
These databases are known as rainbow tables.
68
How can we defend against this?
69
Let's go to B tier for a technique that protects against rainbow tables but not against dictionary attacks.
70
It's a technique called salting.
71
When the user signs up, rather than directly hashing each password, we can first generate a short random string called the salt.
72
Then we prepenn it to the string before running the hash.
73
We then store the salt next to the hashed password.
74
When the user logs in, we can prepenn the remembered salt to the password they entered and hash to see if it matches the stored password.
75
It's important to use the same salt at login that was generated during signup, which is why we want to store it in the database.
76
Otherwise the user wouldn't be able to log in even with the right password because the hashes wouldn't match.
77
This makes Rainbow Tables useless because their databases only contain non-salted hashes.
78
For example, these users have the password QWERTY but the table doesn't match anymore.
79
This has the added benefit of decorrelating users who have the same password.
80
Previously if two users used the same password their hashes would be the same, which is not ideal because you can see
81
that they have the same password even if you don't know what the password actually is.
82
Now, even though their passwords are the same, their salts are different, so the hashes are different.
83
But why is this still B-tier?
84
Remember the other issue we talked about, which is dictionary attacks.
85
An attacker with a list of common passwords can still try all of them against a hash using the salt.
86
They don't get the benefit of pre-computation, but they can still start from scratch.
87
Furthermore, specialized hardware like GPUs have made it possible for people to compute billions of hashes per second, which translates into billions of guesses per second.
88
How on earth do we stop this one?
89
Let's see what A-tier has to say.
90
An A-tier is using a specialized password hashing function that is deliberately slow.
91
The previous hash functions we discussed are designed to be fast because they're used for other applications besides passwords.
92
Password hashing functions like bcrypt, scrypt, and argon2 come with salting for free and more importantly are designed to be really really really slow,
93
to consume lots of power and to take lots of memory.
94
This sounds weird, but this is actually on purpose, to defend against the overwhelming power of hardware.
95
The billions of hashes per second we saw a moment ago can be slowed down to mere thousands per second, if not even slower, because you can actually choose the level of slowness you want.
96
This is known as the work factor.
97
With only thousands of guesses per second, that's still enough to easily go through the most common passwords, but it's not enough to break tougher or more obscure passwords.
98
With a high enough work factor, hackers might be able to break some of the passwords in your system, but not all of them.
99
After all, the goal of security is not to be immune to attacks which is impossible, but to hinder attackers enough that they turn their attention to other places.
100
As a concrete example, let's look at bcrypt.
101
The output of bcrypt looks like this.
102
It has a prefix that identifies the output as a bcrypted thing, a work factor, a 22 character salt, and a 31 character hash.
103
The most interesting thing about this is that the work factor is exponential.
104
When you increase the work factor by 1, the function becomes twice as slow.
105
Here's a graph of bcrypt hash time by work factor on my laptop.
106
The exponential increase is quite clear.
107
Most folks recommend setting it to around 15 for real use cases, which takes 1.3 seconds on my laptop.
108
Fun fact, when it was first published, the recommended work factor was just 6, which would take just 2 milliseconds on my modern laptop.
109
So is that it?
110
Are we done?
111
Is there an even higher tier?
112
S tier?
113
It's kind of a trick answer, but there is.
114
S tier is not storing passwords at all.
115
As we've learned in this video, storing passwords is quite tricky, so consider ways to avoid doing it at all.
116
For example, you can use other authentication services like sign in with Google
117
or sign in with Facebook and others so that users can log into your product using an established authentication platform.
118
Not only is it more convenient for users, you get to sleep better at night knowing that your system doesn't have any passwords at all in it.
119
That's all I have for today.
120
Let's recap.
121
First, we looked at storing passwords in plain text which means anyone can easily access them.
122
So we considered encrypting them, which is not ideal because their original form can still be recovered.
123
We introduced hashing to make that impossible, but we saw that people can pre-compute huge rainbow tables to quickly break passwords.
124
To counteract that, we introduced salting, which individualizes each password with a random string called the salt, so that pre-computed databases don't work anymore.
125
Unfortunately, hardware is so fast that even without pre-computed databases, attackers can still try billions of guesses per second,
126
so we need to switch to deliberately slow password hashing functions that greatly decrease the rate of guesses.
127
Finally, we bypassed the whole problem by considering how to not store passwords at all.
128
I hope this was helpful.
129
If you enjoyed this video, please consider sharing it with somebody else who might also enjoy it.
130
Thanks again!

Tại sao nên luyện nói với video này?

Việc luyện nói qua video không chỉ giúp bạn cải thiện khả năng ngôn ngữ mà còn mang đến cơ hội hiểu rõ hơn về ngữ điệu và cách diễn đạt tự nhiên trong tiếng Anh. Video này, với chủ đề "Cách lưu trữ mật khẩu và bảo mật," sẽ giúp bạn làm quen với cả những khái niệm công nghệ khó hiểu lẫn từ vựng chuyên ngành. Khi xem video, bạn có thể thực hành shadow speak để cải thiện phát âm và gia tăng độ tự tin khi giao tiếp tiếng Anh. Hãy chú ý đến cách diễn đạt của người nói để nắm vững hơn các cấu trúc ngữ pháp và từ vựng trong bối cảnh thực tế.

Ngữ pháp & Cụm từ trong bối cảnh

  • Cấu trúc so sánh: Khi người nói nhấn mạnh sự khác biệt giữa các cách lưu trữ mật khẩu, từ "better" và "worse" xuất hiện nhiều lần. Câu này sẽ giúp bạn thực hành cách sử dụng tính từ so sánh trong tiếng Anh.
  • Câu điều kiện: "If a hacker gains access to your database…" là cấu trúc điều kiện phổ biến, giúp bạn cách diễn tả các tình huống giả định. Đây là một kỹ năng quan trọng trong giao tiếp dựa vào các nguyên tắc an ninh công nghệ.
  • Cụm danh từ: "passwords in plain text" là một ví dụ điển hình cho việc sử dụng cụm danh từ để mô tả các vấn đề cụ thể mà video đề cập. Hiểu cách sử dụng cụm danh từ sẽ giúp bạn diễn đạt ý tưởng một cách rõ ràng và súc tích.

Những cạm bẫy phát âm phổ biến

Khi nghe video, bạn có thể gặp khó khăn với một số từ ngữ như "encryption" và "hashing." Đây là những từ khá mới mẻ đối với nhiều người học, vì vậy hãy chú ý đến cách người nói phát âm từng âm tiết. Thực hành luyện nghe nói qua video sẽ giúp bạn cải thiện cách phát âm những từ này. Ngoài ra, giọng của người nói có thể có những điểm nhấn khác nhau, vì vậy hãy luyện tập với các đoạn hội thoại ngắn, tập trung vào việc tiếp nhận âm điệu và ngữ điệu để nói theo một cách tự nhiên hơn. Điều này đặc biệt hữu ích trong việc luyện tập shadowspeak, giúp bạn trở nên tự tin hơn khi giao tiếp thực tế.

Phương Pháp Shadowing Là Gì?

Shadowing là kỹ thuật học ngôn ngữ có cơ sở khoa học, ban đầu được phát triển cho chương trình đào tạo phiên dịch viên chuyên nghiệp và được phổ biến rộng rãi bởi nhà đa ngôn ngữ học Dr. Alexander Arguelles. Nguyên lý cốt lõi đơn giản nhưng cực kỳ hiệu quả: bạn nghe tiếng Anh của người bản xứ và lặp lại to ngay lập tức — như một "cái bóng" (shadow) đuổi theo người nói với độ trễ chỉ 1–2 giây. Khác với luyện ngữ pháp hay học từ vựng bị động, Shadowing buộc não bộ và cơ miệng phải đồng thời xử lý và tái tạo ngôn ngữ thực tế. Các nghiên cứu khoa học xác nhận phương pháp này cải thiện đáng kể phát âm, ngữ điệu, nhịp điệu, nối âm, kỹ năng nghe và độ lưu loát khi nói — đặc biệt hiệu quả cho người luyện IELTS Speaking và muốn giao tiếp tiếng Anh tự nhiên như người bản ngữ.