쉐도잉 연습: Password Storage Tier List: encryption, hashing, salting, bcrypt, and beyond - 영상으로 영어 말하기 배우기

레슨 만드는 중...
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!

이 수업에 대해

이번 수업에서는 비밀번호 저장과 관련된 다양한 기술과 보안 위험성에 대해 배울 것입니다. 여러분은 해싱, 암호화, 솔팅 등의 개념을 이해하고, 이러한 기술들이 어떻게 안전한 비밀번호 관리를 가능하게 하는지를 학습하게 됩니다. 수업의 진행 방식은 실제 상황에 적용할 수 있는 예제와 함께 설명될 것입니다. 이 과정에서 영어 회화 능력을 향상시키기 위해 영어 쉐도잉 기법을 적극 활용할 것입니다.

주요 어휘 및 구문

  • 비밀번호 저장 (Password Storage)
  • 암호화 (Encryption)
  • 해싱 (Hashing)
  • 솔팅 (Salting)
  • 데이터베이스 (Database)
  • 해독 키 (Decryption Key)
  • 해시 충돌 (Hash Collision)
  • 원방향 함수 (One-way Function)

연습 팁

비디오의 속도와 어조에 맞춰 영어 쉐도잉 연습을 할 때, 다음과 같은 팁을 따르면 좋습니다. 먼저, 비디오를 한번 시청한 후, 각 문장을 듣고 따라 말해보세요. 이때 중요한 점은 그 문장의 리듬과 억양을 그대로 유지하는 것입니다. 각 문장을 반복해서 들을 때는 조금씩 속도를 높여가며 연습해보세요. 이를 통해 여러분의 발음과 유창성을 동시에 향상시킬 수 있습니다. 또 한 가지 중요한 점은 shadowspeak 기술을 활용하여 녹음 기능을 통해 자신의 목소리를 들어봄으로써 발음의 정확성을 체크하는 것입니다. 이렇게 반복 연습을 통해 영어 회화를 자연스럽게 익힐 수 있습니다.

쉐도잉이란? 영어 실력을 빠르게 키우는 과학적 방법

쉐도잉(Shadowing)은 원래 전문 통역사 훈련을 위해 개발된 언어 학습 기법으로, 다언어 학자인 Dr. Alexander Arguelles에 의해 대중화된 방법입니다. 핵심 원리는 간단하지만 매우 강력합니다: 원어민의 영어를 들으면서 1~2초의 짧은 지연으로 즉시 소리 내어 따라 말하는 것——마치 '그림자(shadow)'처럼 화자를 따라가는 것입니다. 문법 공부나 수동적인 청취와 달리, 쉐도잉은 뇌와 입 근육이 동시에 실시간으로 영어를 처리하고 재현하도록 훈련합니다. 연구에 따르면 이 방법은 발음 정확도, 억양, 리듬, 연음, 청취력, 말하기 유창성을 크게 향상시킵니다. IELTS 스피킹 준비와 자연스러운 영어 소통을 원하는 분들에게 특히 효과적입니다.