WEBVTT

1
00:00:00.450 --> 00:00:02.720
Two classic web bugs: XSS,

2
00:00:02.720 --> 00:00:04.350
and broken login.

3
00:00:04.520 --> 00:00:05.830
One steals sessions.

4
00:00:05.830 --> 00:00:07.940
The other hands over accounts.

5
00:00:08.790 --> 00:00:10.860
Cross-site scripting, or XSS,

6
00:00:10.860 --> 00:00:13.360
happens when a page takes text from

7
00:00:13.360 --> 00:00:15.280
a user and puts it into the

8
00:00:15.280 --> 00:00:17.220
page without cleaning it.

9
00:00:17.390 --> 00:00:19.640
The browser cannot tell it from the

10
00:00:19.640 --> 00:00:20.670
site's own code.

11
00:00:20.670 --> 00:00:21.720
So it runs it.

12
00:00:22.570 --> 00:00:24.970
A script running in someone's page can

13
00:00:24.970 --> 00:00:27.390
read their session, and act as them.

14
00:00:27.560 --> 00:00:29.920
In DOM XSS, the unsafe step is

15
00:00:29.920 --> 00:00:32.190
in the page's own JavaScript,

16
00:00:32.190 --> 00:00:35.480
so nothing even has to reach the server.

17
00:00:36.330 --> 00:00:38.870
Broken login is lesson four again.

18
00:00:39.040 --> 00:00:41.550
If the login form glues your email

19
00:00:41.550 --> 00:00:44.060
into a SQL query, injected SQL can

20
00:00:44.060 --> 00:00:46.210
cut off the password check.

21
00:00:46.380 --> 00:00:48.830
The database returns the first user,

22
00:00:48.830 --> 00:00:50.070
often the admin.

23
00:00:50.240 --> 00:00:52.390
You are in, without a password.

24
00:00:53.240 --> 00:00:54.050
The fixes.

25
00:00:54.050 --> 00:00:57.050
For XSS: encode anything a user typed

26
00:00:57.050 --> 00:00:59.230
before it goes into a page,

27
00:00:59.230 --> 00:01:02.140
and add a content security policy.

28
00:01:02.310 --> 00:01:04.150
For login: prepared statements,

29
00:01:04.150 --> 00:01:06.250
rate limits, and a second factor.

30
00:01:07.100 --> 00:01:08.540
So: never trust input.

31
00:01:08.540 --> 00:01:10.310
Not in the page, and not in

32
00:01:10.310 --> 00:01:11.110
the query.

33
00:01:11.280 --> 00:01:13.630
In the lab, on the training app

34
00:01:13.630 --> 00:01:16.440
Juice Shop, you solve two challenges:

35
00:01:16.440 --> 00:01:18.570
a DOM XSS, and logging in as

36
00:01:18.570 --> 00:01:19.470
the admin.

37
00:01:19.640 --> 00:01:22.190
Only on training apps, or systems you

38
00:01:22.190 --> 00:01:23.720
are allowed to test.
