1
1

00:00:00,360  -->  00:00:02,910
<v Instructor>Sensitive Data Exposure.</v>
2

2

00:00:02,910  -->  00:00:04,440
In this lesson, we're going to talk
3

3

00:00:04,440  -->  00:00:06,360
about sensitive data exposure,
4

4

00:00:06,360  -->  00:00:08,430
which is when a software vulnerability occurs
5

5

00:00:08,430  -->  00:00:09,750
that allows the attacker to be able
6

6

00:00:09,750  -->  00:00:11,640
to circumvent access controls
7

7

00:00:11,640  -->  00:00:13,830
and retrieve confidential or sensitive data
8

8

00:00:13,830  -->  00:00:16,050
from a file system or a database.
9

9

00:00:16,050  -->  00:00:19,170
Essentially, we're having a breach of confidentiality here
10

10

00:00:19,170  -->  00:00:21,600
so we want to make sure we don't have this happen.
11

11

00:00:21,600  -->  00:00:25,290
So how can we end up preventing sensitive data exposure?
12

12

00:00:25,290  -->  00:00:27,240
Well, we should program our web applications
13

13

00:00:27,240  -->  00:00:29,910
to only send data between authenticated hosts
14

14

00:00:29,910  -->  00:00:33,300
using cryptography and encryption to protect the session.
15

15

00:00:33,300  -->  00:00:36,600
Now, when it comes to encryption, what type should you use?
16

16

00:00:36,600  -->  00:00:38,610
Should you use your own encryption mechanism?
17

17

00:00:38,610  -->  00:00:41,010
Should you make something up because you're just that smart?
18

18

00:00:41,010  -->  00:00:43,500
No, you should use what everybody else is using.
19

19

00:00:43,500  -->  00:00:45,060
You should be using AES.
20

20

00:00:45,060  -->  00:00:46,290
You should be using other things
21

21

00:00:46,290  -->  00:00:48,060
that are widely known and widely tested
22

22

00:00:48,060  -->  00:00:50,400
because those have been proven to be secure.
23

23

00:00:50,400  -->  00:00:52,170
As smart as you may think you are,
24

24

00:00:52,170  -->  00:00:55,320
using your own encryption scheme is a recipe for disaster
25

25

00:00:55,320  -->  00:00:57,510
because our own encryption schemes aren't tested
26

26

00:00:57,510  -->  00:01:01,290
to the level that AES and other worldwide standards are.
27

27

00:01:01,290  -->  00:01:03,420
So we should really be using those worldwide standards
28

28

00:01:03,420  -->  00:01:06,510
as a best practice whenever we're using encryption.
29

29

00:01:06,510  -->  00:01:08,190
Now, another thing you need to avoid
30

30

00:01:08,190  -->  00:01:10,560
inside of your applications is the use
31

31

00:01:10,560  -->  00:01:12,210
of hardcoded credentials.
32

32

00:01:12,210  -->  00:01:14,190
This means you don't want to be able to put in things
33

33

00:01:14,190  -->  00:01:16,980
like your database credentials inside your web app
34

34

00:01:16,980  -->  00:01:19,410
or your usernames or your passwords or things like that.
35

35

00:01:19,410  -->  00:01:22,050
If you're typing them in plain text and hardcoding them in,
36

36

00:01:22,050  -->  00:01:25,290
even as a hash, that is something that could be taken
37

37

00:01:25,290  -->  00:01:26,610
and exploited against you.
38

38

00:01:26,610  -->  00:01:27,930
And this would be another thing that leads
39

39

00:01:27,930  -->  00:01:29,940
to sensitive data exposure.
40

40

00:01:29,940  -->  00:01:31,530
Another thing we always want to make sure we do
41

41

00:01:31,530  -->  00:01:34,890
is disable the use of client password autocomplete features,
42

42

00:01:34,890  -->  00:01:37,830
temporary files and cookies whenever possible.
43

43

00:01:37,830  -->  00:01:39,690
By doing this, we can reduce the risk
44

44

00:01:39,690  -->  00:01:41,580
of sensitive data exposure.
45

45

00:01:41,580  -->  00:01:44,010
Now, speaking of cookies, one more time,
46

46

00:01:44,010  -->  00:01:45,360
let's talk about cookies.
47

47

00:01:45,360  -->  00:01:48,360
There are five key areas inside of your cookies
48

48

00:01:48,360  -->  00:01:50,490
that you need to think about because these five areas
49

49

00:01:50,490  -->  00:01:52,620
and these five attributes are things
50

50

00:01:52,620  -->  00:01:54,510
that may offer client protection
51

51

00:01:54,510  -->  00:01:56,490
depending on how you set them up.
52

52

00:01:56,490  -->  00:01:58,530
First, we have secure.
53

53

00:01:58,530  -->  00:02:00,180
When we talk about the secure attribute,
54

54

00:02:00,180  -->  00:02:01,740
this instructs the client's web browser
55

55

00:02:01,740  -->  00:02:04,080
to only send the cookie if it's being sent
56

56

00:02:04,080  -->  00:02:06,780
over a secure channel like https.
57

57

00:02:06,780  -->  00:02:08,520
Basically, it requires encryption
58

58

00:02:08,520  -->  00:02:10,650
for you to be able to pass the cookie.
59

59

00:02:10,650  -->  00:02:13,320
Second, HttpOnly.
60

60

00:02:13,320  -->  00:02:15,750
This prevents attacks such as cross-site scripting
61

61

00:02:15,750  -->  00:02:18,210
because it disables access from client-side scripting
62

62

00:02:18,210  -->  00:02:19,320
to your cookie.
63

63

00:02:19,320  -->  00:02:20,940
The only way you can access the cookie
64

64

00:02:20,940  -->  00:02:23,070
is over http.
65

65

00:02:23,070  -->  00:02:24,720
Third, domain.
66

66

00:02:24,720  -->  00:02:26,730
This is going to set the domain of the server
67

67

00:02:26,730  -->  00:02:28,410
that the cookie is valid for.
68

68

00:02:28,410  -->  00:02:30,000
Cookies are only going to be able to be accessed
69

69

00:02:30,000  -->  00:02:32,070
from the domain or subdomains specified
70

70

00:02:32,070  -->  00:02:33,750
within this particular attribute
71

71

00:02:33,750  -->  00:02:36,540
so it really limits who can access that cookie.
72

72

00:02:36,540  -->  00:02:38,190
Fourth, path.
73

73

00:02:38,190  -->  00:02:40,200
This is going to specify the URL path
74

74

00:02:40,200  -->  00:02:41,910
for which the cookie is valid.
75

75

00:02:41,910  -->  00:02:43,230
Now, this may be the domain
76

76

00:02:43,230  -->  00:02:45,390
but it also might be a sub-part of the domain.
77

77

00:02:45,390  -->  00:02:48,690
For instance, you might have a cookie for diontrain.com,
78

78

00:02:48,690  -->  00:02:50,400
or it might be set to the path
79

79

00:02:50,400  -->  00:02:54,990
of diontrain.com/account/course/cysa
80

80

00:02:54,990  -->  00:02:56,910
or something like that.
81

81

00:02:56,910  -->  00:02:58,920
And fifth, expires.
82

82

00:02:58,920  -->  00:03:01,590
This is used to set persistent cookies that will expire
83

83

00:03:01,590  -->  00:03:03,810
at a certain date within this attribute.
84

84

00:03:03,810  -->  00:03:06,990
So I might set my cookie to expire after seven days,
85

85

00:03:06,990  -->  00:03:10,620
30 days, 60 days, a year, whatever it is.
86

86

00:03:10,620  -->  00:03:13,020
Just remember, the longer that you keep this,
87

87

00:03:13,020  -->  00:03:15,420
the more chance there is the data inside that cookie
88

88

00:03:15,420  -->  00:03:16,473
could be accessed.
