-
Notifications
You must be signed in to change notification settings - Fork 11
/
index.html
1072 lines (903 loc) · 53.4 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html>
<head>
<title>Web Security 101 | William Durand</title>
<link rel="stylesheet" href="reveal.js/css/reveal.min.css">
<link rel="stylesheet" href="reveal.js/css/theme/beige.css" id="theme">
<link rel="stylesheet" href="reveal.js/lib/css/zenburn.css">
<link rel="stylesheet" href="font-awesome/css/font-awesome.min.css">
<link rel="stylesheet" href="css/fix-fontawesome-reveal-js.css">
<link rel="stylesheet" href="css/custom.css">
<script>
if (window.location.search.match(/print-pdf/gi)) {
document.write('<link rel="stylesheet" href="css/pdf.css" type="text/css">');
}
</script>
</head>
<body>
<div class="reveal">
<div class="slides">
<section>
<h1 class="title">Web Security 101</h1>
<em>William Durand</em>
</section>
<section>
<section data-markdown>
<script type="text/template">
# Open Web Application Security Project
</script>
</section>
<section data-markdown>
<script type="text/template">
# OWASP
* **Not-for-profit** organization focused on **improving the<br>security**
of software;
* **Documentation** and **tools** to help learn about security,
<br>and protect your applications.
<br>
<i class="fa-globe"></i> [https://www.owasp.org](https://www.owasp.org)
</script>
</section>
<section data-markdown>
<script type="text/template">
# OWASP Top 10 (2013)
1. Injection
2. Broken Authentication and Session Management
3. Cross-Site Scripting (XSS)
4. Insecure Direct Object References
5. Security Misconfiguration
6. Sensitive Data Exposure
7. Missing Function Level Access Control
8. Cross-Site Request Forgery (CSRF)
9. Using Components with Known Vulnerabilities
10. Unvalidated Redirects and Forwards
</script>
</section>
</section>
<section>
<section data-markdown data-background="images/injection.jpg">
<script type="text/template">
# 1. Injection
</script>
</section>
<section data-markdown>
<script type="text/template">
## In A Nutshell
* When an application **sends untrusted data to an interpreter**;
* Attacker sends simple **text-based attacks** that exploit the syntax
of the targeted interpreter;
* Almost **any source of data can be an attack vector**:
- `GET`/`POST` parameters
- `PATH_INFO`
- HTTP headers
- uploaded **files**
* Can result in **data loss or corruption** or denial of access.
</script>
</section>
<section data-markdown>
<script type="text/template">
## SQL Injection
Unescaped user input causes the **premature end of a SQL query**,
and allows a malicious query to be executed:
<br>
<br>
$query = 'SELECT * FROM foo WHERE bar = "' . $_GET['bar'] . '"';
// example.org?bar=nope" OR 1 = 1 --
</script>
</section>
<section data-markdown>
<script type="text/template">
## Directory traversal attack
Filesystem access combined to unvalidated user input
<br>allows attackers to **access private files**:
<br>
<br>
echo file_get_contents($_GET['file']);
// example.org?file=../private.conf
</script>
</section>
<section data-markdown>
<script type="text/template">
## Remote Code Execution
Unsafe input is **dynamically executed**:
<br>
<br>
exec('rm -rf web/upload/' . $_GET['file']);
// example.org?file=*; rm -rf /;
</script>
</section>
<section data-markdown>
<script type="text/template">
## How To Prevent Injections?
### Escape, escape, escape!
* SQL: **Prepared Statements** (PDO);
* Input/Output: `basename()`, `realpath()`;
* System calls: `shell_escape_args()`;
* Cookies: make sure they contain what you expect;
* Validate **all** user input;
* Positive or **white-list** input validation;
* Avoid `eval()` or `exec()` functions.
</script>
</section>
</section>
<section>
<section data-markdown data-background="images/broken-padlock.jpg" class="invert-color">
<script type="text/template">
# 2. Broken Authentication and Session Management
</script>
</section>
<section data-markdown>
<script type="text/template">
## In A Nutshell
* Attackers **use leaks or flaws in the authentication** or **session
management functions** to impersonate users;
* May allows **some or even all accounts to be attacked**. Once successful,
the **attacker can do anything the victim could do**.
* Privileged accounts are frequently targeted!
</script>
</section>
<section data-markdown>
<script type="text/template">
## How To Prevent This?
* **Hash** passwords properly (**bcrypt**/**Blowfish** please);
* **Salt** passwords;
* Use the [Password Hashing API](http://www.php.net/manual/en/book.password.php) in PHP;
* **Never** ever **store passwords in clear text**;
* Don't put session IDs in URLs;
* Regenerate IDs when authentication changes;
* Allow session IDs to timeout/expire;
* Use HTTPS.
</script>
</section>
<section data-markdown>
<script type="text/template">
## PHP Session Configuration
; Helps mitigate XSS by telling the browser not to expose the cookie to
; client side scripting such as JavaScript
session.cookie_httponly = 1
; Prevents session fixation by making sure that PHP only uses cookies for
; sessions and disallow session ID passing as a GET parameter
session.use_only_cookies = 1
; Better entropy source
; Evades insufficient entropy vulnerabilities
session.entropy_file = "/dev/urandom"
; Might help against brut-force attacks too!
session.entropy_length=32
; Smaller exploitation window for XSS/CSRF/Clickjacking...
session.cookie_lifetime = 0
; Ensures session cookies are only sent over secure connections
; (it requires a valid SSL certificate)
; Related to OWASP 2013-A6-Sensitive Data Exposure
session.cookie_secure = 1
</script>
</section>
</section>
<section>
<section data-markdown>
<script type="text/template">
# 3. Cross-Site Scripting (XSS)
</script>
</section>
<section data-markdown>
<script type="text/template">
## In A Nutshell
* The most prevalent web application security flaw!
* When an **application includes user supplied
data** in a page sent to the browser **without
properly validating or escaping that content**;
* Attacker sends **text-based attack scripts** that
exploit the interpreter in the browser;
* Almost any source of data can be an attack
vector, including internal sources such as **data
from the database**, but also **URLs**, **form
fields**;
* Can result in **session hijacking**, malicious
scripts execution, website **defacement**.
</script>
</section>
<section data-markdown>
<script type="text/template">
## How To Prevent XSS?
### Do not trust anyone!
* **Escape** all untrusted data based on the HTML context the data
will be placed into: `htmlspecialchars()`;
* **Whitelist** input validation;
* Consider **auto-sanitization libraries** ([HTML Purifier](http://htmlpurifier.org/));
* Don't even trust admins;
* Secure your cookies (encrypt or sign them).
</script>
</section>
<section data-markdown>
<script type="text/template">
## Content Security Policy (CSP)
Defines the `Content-Security-Policy` HTTP header
<br>that allows you to create a **whitelist of sources of
trusted content**, and **instructs the browser** to only
execute or<br>render resources from those sources.
<br>
<br>
Content-Security-Policy: script-src 'self' https://apis.google.com
<img src="images/csp.png" class="no-border" />
<i class="fa fa-book"></i> [An Introduction to Content Security Policy](http://www.html5rocks.com/en/tutorials/security/content-security-policy/)
<br>
<i class="fa fa-bookmark"></i> [Using Content-Security-Policy for Evil](http://homakov.blogspot.fr/2014/01/using-content-security-policy-for-evil.html)
</script>
</section>
<section data-markdown>
<script type="text/template">
## X-XSS-Protection
The `X-XSS-Protection` header allows to configure a
user-agent's built in reflective XSS protection.
<br>
<br>
X-XSS-Protection: 1
<br>
* `0` - Disables the XSS Protections offered by the user-agent
* `1` - Enables the XSS Protection
* `1; mode=block` - Prevents browser (IE8+ and
Webkit browsers) to render pages (instead of
sanitizing)
<br>
<i class="fa fa-book"></i> [Controlling the XSS Filter](http://blogs.msdn.com/b/ieinternals/archive/2011/01/31/controlling-the-internet-explorer-xss-filter-with-the-x-xss-protection-http-header.aspx)
<br>
<i class="fa fa-warning"></i> `mode=block` creates a [vulnerability in IE8](http://hackademix.net/2009/11/21/ies-xss-filter-creates-xss-vulnerabilities/)
</script>
</section>
</section>
<section>
<section data-markdown>
<script type="text/template">
# 4. Insecure Direct Object References
</script>
</section>
<section data-markdown>
<script type="text/template">
## In A Nutshell
* Expose a reference to an internal implementation
object **without verifying authorization**;
* Attacker, who is an **authorized system user**,
changes a parameter value (URL, `GET`/`POST`
parameters, cookies) that directly refers to a
system object to another object the user is not
authorized for;
* Can **compromise all the data** that can be
referenced by the vulnerable parameter;
* Unless object references are unpredictable, it is
easy for an attacker to access the available data
of that type.
</script>
</section>
<section data-markdown>
<script type="text/template">
## How To Prevent This?
* Use **per user or session indirect object references**;
* Always **check the user credentials before
allowing<br>access** to restricted content.
</script>
</section>
</section>
<section>
<section data-markdown>
<script type="text/template">
# 5. Security Misconfiguration
</script>
</section>
<section data-markdown>
<script type="text/template">
## In A Nutshell
* Attacker accesses **default accounts**, **unused pages**,
**unpatched flaws**, **unprotected files** and directories,
etc.<br>to gain unauthorized access to or knowledge of the
system;
* Can completely **compromise the system without you knowing it**.
**All of your data can be stolen** or modified<br>slowly over time;
* Recovery costs can be expensive!
</script>
</section>
<section data-markdown>
<script type="text/template">
## How To Prevent This?
* Have a repeatable **hardening process** that makes it fast and easy
to deploy another environment that is properly locked down;
* Have a process for **keeping on top of updates and patches**;
* Build a **strong application architecture** that
provides **effective** and **secure** separation
between components;
* Consider running **scans** and doing **audits** periodically;
* **Disable** or fix **default accounts**;
* **Disable unnecessary services**.
* Let your webserver process run by a user with restricted permission. **Never** as root!
</script>
</section>
</section>
<section>
<section data-markdown data-background="images/sensitive-data-exposure.jpg" class="invert-color">
<script type="text/template">
# 6. Sensitive Data Exposure
</script>
</section>
<section data-markdown>
<script type="text/template">
## In A Nutshell
* Failure frequently compromises all data that
should have been protected. Typically, this
information includes sensitive data such as health
records, credentials, personal data, credit cards;
* Attackers **don't break crypto directly**, but
rather break something else, such as **steal keys**,
or do **Man-In-The-Middle attacks**;
* Attackers **monitor network traffic** of your users,
maybe in public places (Starbucks!!), maybe backend
connections, maybe inside your network!
* **Sensitive data deserves extra protection** such as
**encryption** at rest or in transit, and special
**precautions when exchanged with the browser**!
</script>
</section>
<section data-markdown>
<script type="text/template">
## Insecure Cryptographic Storage
* **Encrypt** sensitive data;
* **Encrypt** offsite backups;
* Use **strong standard encryption algorithms**;
* Change your (strong) encryption key regularly;
* Don't store sensitive data unnecessarily;
* **Salt** your passwords (yep, again);
* **Disable autocomplete on forms** collecting
sensitive data;
* **Disable caching for pages that contain
sensitive data**;
* Check with a crypto expert.
</script>
</section>
<section data-markdown>
<script type="text/template">
## Insufficient Transport<br>Layer Protection
* **Require** SSL/**TLS**;
* At least, force the password to be sent encrypted;
* Ideally any page using the session should have SSL/TLS.
</script>
</section>
<section data-markdown>
<script type="text/template">
## HTTP Strict Transport Security (HSTS)
**HTTP Strict Transport Security** is a security
feature that **lets a web site tell browsers that it
should only be communicated with using HTTPS**,
instead of using HTTP.
<br>
<br>
Strict-Transport-Security: max-age=expireTime [; includeSubdomains]
<br>
<i class="fa fa-book"></i> [HTTP Strict Transport Security](https://developer.mozilla.org/en-US/docs/Security/HTTP_Strict_Transport_Security)
</script>
</section>
<section data-markdown>
<script type="text/template">
## Public Key Pinning (PKP)
Public Key Pinning **prevents Man-In-The-Middle
attacks** due to rogue CAs not on the site's list,
by **binding a set of hashes public keys to domain
names**. It is a mechanism:
* **for sites** to **specify which certificate
authorities have issued valid certs for that
site**,
* and **for user-agents** to **reject TLS connections**
to those sites **if** the **certificate is not issued by
a known-good CA**.
<br>
<i class="fa fa-book"></i> [SecurityEngineering/Public Key Pinning](https://wiki.mozilla.org/SecurityEngineering/Public_Key_Pinning)
</script>
</section>
</section>
<section>
<section data-markdown data-background="images/missing-function-level-ac.jpg" class="invert-color">
<script type="text/template">
# 7. Missing Function Level Access Control
</script>
</section>
<section data-markdown>
<script type="text/template">
## In A Nutshell
* Applications do not always protect application functions properly;
* Attackers **access unauthorized functionality by
changing<br>the URL or a parameter to a privileged
function**;
* **Anonymous users can access private functions
that aren't protected**;
* **Misconfiguration** and **lack of checks** are the main issues;
* Can **compromise user accounts**, administrative
accounts,<br>and **allow the unauthorized use of
privileged functionalities**.
</script>
</section>
<section data-markdown>
<script type="text/template">
## How To Prevent This?
* Consider every page: public or private?
* Make sure you **check credentials** when you
serve a page, picture or anything;
* Make sure checks are in place when authentication
is required;
* **Deny all** by default, explicitly grant access
to users or roles.
<br>
<br>
<i class="fa fa-book"></i> [Never Blacklist; Only Whitelist](http://phpsecurity.readthedocs.org/en/latest/Input-Validation.html#never-blacklist-only-whitelist)
</script>
</section>
<section data-markdown>
<script type="text/template">
## Hackers Gonna Hack!
![](images/hackers-gonna-hack.jpg)
</script>
</section>
</section>
<section>
<section data-markdown data-background="images/csrf.jpg" class="invert-color">
<script type="text/template">
# 8. Cross-Site Request Forgery (CSRF)
</script>
</section>
<section data-markdown>
<script type="text/template">
## In A Nutshell
* Attacker creates **forged HTTP requests and tricks
a victim into submitting them** via image tags, XSS,
Form POSTs, or numerous other techniques. If the
user is authenticated, the attack succeeds;
* Attackers **can create malicious web pages** which
generate **forged requests that are indistinguishable
from legitimate ones**;
* Causes victim to **change any data the victim is
allowed to change**, but also to **perform any function
the victim is authorized to use**.
<i class="fa fa-bookmark"></i> [Facebook CSRF worth USD 5000 ](http://amolnaik4.blogspot.fr/2012/08/facebook-csrf-worth-usd-5000.html)
<br>
<i class="fa fa-bookmark"></i> [Does Google Understand CSRF? ](http://cryptogasm.com/2012/02/does-google-understand-csrf/)
<br>
<i class="fa fa-bookmark"></i> [A few CSRF-like vulnerable examples.](http://homakov.blogspot.fr/2012/03/hacking-skrillformer-moneybookers.html)
</script>
</section>
<section data-markdown>
<script type="text/template">
## CSRF With GET
Using a zero-byte image attack:
<img src="https://bank.com/transfer.do?acct=BOB&amount=100"
height="0" width="0" />
Using a link, asking the victim to click on it:
<a href="http://bank.com/transfer.do?acct=BOB&amount=100">
View my Pictures!
</a>
</script>
</section>
<section data-markdown>
<script type="text/template">
## CSRF With POST
A malicious page can issue a POST request to any domain:
<form method="POST" action="http://example.org/form">
<input type="text" name="name" value="Will">
<input type="text" name="message" value="Hello, World!">
<!-- ... -->
</form>
With a few lines of JavaScript:
$(document).ready(function() {
$('form').submit();
});
</script>
</section>
<section data-markdown>
<script type="text/template">
## CSRF Against RESTful Web Services
You can change the encoding of HTML forms to `text/plain`,
and do some tricks to produce parseable JSON:
<form method="POST" action="http://example.org/form"
style="visibility: hidden" enctype="text/plain">
<input type="text"
name='{"id": 0,
"name": "Will",
"message": "Hello, World!",
"timestamp": "20140219"}//'
value="dummy" />
<input type="submit" value="Send" />
</form>
The above form produces a request body looking like this:
{
"id": 0,
"name": "Will",
"message": "Hello, World!",
"timestamp": "20140219"
}//=dummy
</script>
</section>
<section data-markdown>
<script type="text/template">
## How To Prevent This?
* Don't do "things" using the `GET` method;
* Create **one unique token per user** (at least once per session);
* Include/verify it in every sensitive form;
* Avoid putting this token in the query string.
</script>
</section>
<section data-markdown>
<script type="text/template">
## Stateless vs Stateful
Technique seen before uses **tokens issued by the
server that the client has to post back**. The server
**validates the request by comparing the incoming
token with its copy**. This is **stateful!**
<br>
<br>
![](images/csrf.png)
<br>
**Stateless** protection needed!
</script>
</section>
<section data-markdown>
<script type="text/template">
## CSRF Protection With Double Submit
**Double submit** technique is a variation of the
token scheme where **the client is required to
submit the token both as a request parameter and as
a cookie**.
<br>
<br>
A malicious page on another domain **cannot read the
<br>anti-CSRF cookie** before its request and thus cannot
<br> include it as a request parameter.
<br>
<br>
<p class="left">
<i class="fa fa-book"></i> [Stateless CSRF Protection](http://appsandsecurity.blogspot.fr/2012/01/stateless-csrf-protection.html)
<br>
<i class="fa fa-book"></i> [Triple Submit CSRF Protection](http://www.slideshare.net/johnwilander/stateless-anticsrf)
<br>
<i class="fa fa-book"></i> [Stateful vs Stateless CSRF Defences: Know The Difference](http://blog.astrumfutura.com/2013/08/stateful-vs-stateless-csrf-defences-know-the-difference/)
</p>
</script>
</section>
<section data-markdown>
<script type="text/template">
## Same-Origin Policy (1/5)
The same-origin policy **restricts how** a document
or **script** loaded from one origin **can
interact** with a resource from another origin.
<br>
<img src="images/sameorigin.jpg" class="no-border" />
</script>
</section>
<section data-markdown>
<script type="text/template">
## Same-Origin Policy (2/5)
<br>
### `document.domain`
document.domain = "example.org";
<br>
You would be allowed to execute JavaScript from an
**iframe** sourced on a subdomain, on a page sourced
on the main domain.
<br>
This method is **not suited for cross-domain
resources** as browsers (e.g. Firefox) will not
allow you to change the `document.domain` to a
different domain.
</script>
</section>
<section data-markdown>
<script type="text/template">
## Same-Origin Policy (3/5)
<br>
### `window.postMessage`
The `window.postMessage` method, when called,
causes a `MessageEvent` (containing a `origin`
property) to be dispatched at the target window
when any pending script that must be executed
completes.
<br>
Any window may access this method on any other
window, at any time, regardless of the location of
the document in the window, to send it a message.
**Check the identity of the sender of the message!**
</script>
</section>
<section>
<h2>Same-Origin Policy (4/5)</h2>
<br>
<h3>JSON With Padding (JSONP)</h3>
<p>It is a communication technique used in JavaScript
applications to request data from a server in a
different domain:</p>
<pre><code class="html"><!-- Request sent via a `script` tag -->
<script src="https://example.com/status.json?callback=apiStatus"></script></code></pre>
<pre><code class="html"><!-- Data received as an execution of the predefined function -->
<script>function apiStatus(data) { console.log(data.status); }</script></code></pre>
</section>
<section data-markdown>
<script type="text/template">
## Same-Origin Policy (5/5)
<br>
### Cross-Origin Resource Sharing (CORS)
[CORS](http://www.w3.org/TR/access-control/)
defines how the browser and server<br>must communicate
when accessing sources across<br>origins by means of
custom HTTP headers:
``` bash
# Client sends a request with this extra header:
Origin: http://williamdurand.fr
# Server sends this header along with the response:
# `*` is a valid value and stands for "public resource"
Access-Control-Allow-Origin: http://williamdurand.fr
```
If this header is missing, or the origins don't
match,<br>then the browser disallows the request.
</script>
</section>
</section>
<section>
<section data-markdown>
<script type="text/template">
# 9. Using Components with Known Vulnerabilities
</script>
</section>
<section data-markdown>
<script type="text/template">
## In A Nutshell
* Attacker identifies **a weak component through
scanning or manual analysis**. He customizes the
exploit as needed and executes the attack;
* Virtually **every application has these issues**
because most development teams don't focus on
ensuring their libraries<br>are up to date;
* In many cases, the developers don't even know all
the components they are using, never mind their
versions. **Component dependencies make things even
worse**;
* The impact could range **from minimal to complete
host takeover and data compromise**.
</script>
</section>
<section data-markdown>
<script type="text/template">
## How To Prevent This?
* **Keep** components **up to date**;
* Identify all components and versions;
* Monitor security of these components;
* Subscribe to security mailing-lists, twitter accounts
<br>(e.g. [@debian_security](https://twitter.com/debian_security));
* SensioLabs [Security Advisories Checker](https://security.sensiolabs.org/) in PHP.
* Make sure your components aren't verbose.
<br>(e.g. Webserver tellings its name and version)
* Require [`roave/security-advisories:dev-master`](https://github.com/Roave/SecurityAdvisories)
in your `composer.json`
</script>
</section>
</section>
<section>
<section data-markdown data-background="images/redirect.jpg" class="invert-color">
<script type="text/template">
# 10. Unvalidated Redirects and Forwards
</script>
</section>
<section data-markdown>
<script type="text/template">
## In A Nutshell
* Attacker **links to unvalidated redirect and tricks
victims<br>into clicking it**;
* Attacker targets unsafe forward to bypass
security checks;
* Victims are more likely to click on it since the
link is to a valid website;
* Such redirects may attempt to **install malware or
trick victims into disclosing passwords or other
sensitive information**. Unsafe forwards may allow
access control bypass.
</script>
</section>
<section data-markdown>
<script type="text/template">
## How To Prevent This?
* **Avoid using redirects and forwards**;
* If used, don't involve user parameters in
calculating the destination;
* If destination parameters can't be avoided,
ensure that the supplied value is valid, and
authorized for the user.
<br>It is recommended that any such destination
parameters be a **mapping value**, rather than the
actual URL or portion of the URL, and that server
side code translate this mapping to the target URL.
<br>
<i class="fa fa-bookmark"></i> [How I hacked Github again.](http://homakov.blogspot.fr/2014/02/how-i-hacked-github-again.html)
</script>
</section>
<section data-markdown>
<script type="text/template">
## Clickjacking
A malicious technique of **tricking a user into
clicking on something different from what the user
perceives<br>they are clicking on**.
<br>
<br>
Stop clickjacking with one simple header:
X-Frame-Options: DENY|SAMEORIGIN
<br>
This will cause browsers to **refuse requests for
framing in<br>that page**. Most websites do not use
frames, and do not<br>need to be frame-able anyway.
<br>
<i class="fa fa-bookmark"></i> [X-Frame-Options (XFO) Detection from JavaScript](http://blog.whitehatsec.com/x-frame-options-xfo-detection-from-javascript/)
</script>
</section>
<section data-markdown>
<script type="text/template">
## Pastejacking
Browsers now allow developers to automatically add
content to a user's clipboard, following certain
conditions.
<br>
Pastejacking exploits this to **trick a
user into running commands they didn't want to get
ran, and gain code execution**.
<br>
TL;DR: **Do not (directly) copy/paste code!**
<br>
<i class="fa fa-bookmark"></i> [On Pastejacking](https://github.com/dxa4481/Pastejacking)
</script>
</section>
</section>
<section>
<section data-markdown>
<script type="text/template">
# But Also...
</script>
</section>
<section data-markdown>
<script type="text/template">
## Avoid Mime Sniffing
Browsers usually guess `Content-Type` of what you are serving by doing [Mime
Sniffing](http://mimesniff.spec.whatwg.org/). In order to **force browsers to
treat content in accordance with the `Content-Type` header you send**,
you can use the `X-Content-Type-Options` header.
<br>
<br>
X-Content-Type-Options: nosniff
<br>
It also protects against **hotlinking**.
<br>
<br>
<i class="fa fa-bookmark"></i> [nosniff header support coming to Chrome and Firefox](https://github.com/blog/1482-heads-up-nosniff-header-support-coming-to-chrome-and-firefox)
</script>
</section>
<section data-markdown>
<script type="text/template">
## Cookie Security
<i class="fa fa-book"></i> [Understanding Cookie Security](http://kuza55.blogspot.fr/2008/02/understanding-cookie-security.html)
<br>
<br>
<ul class="no-bullets">
<li><i class="fa fa-bookmark"></i> [Cookie Bomb or let's break the Internet.](http://homakov.blogspot.fr/2014/01/cookie-bomb-or-lets-break-internet.html)</li>
<li><i class="fa fa-bookmark"></i> [Rethinking Cookies: originOnly ](http://homakov.blogspot.fr/2013/02/rethinking-cookies-originonly.html)</li>
</ul>
</script>
</section>
<section data-markdown class="justified">
<script type="text/template">
## JSON Hijacking
A script that contains a JSON array is a valid
JavaScript script,<br>and can thus be executed.
By **overriding the global array constructor or
accessor methods**, then including a JSON URL
via a `<script>` tag,<br>a malicious third-party
website could steal the data from the<br>JSON
response (that must be a JSON array).
By putting a `while(1);` at the start, the script
will hang instead.
<br>
<p class="left">
<i class="fa fa-bookmark"></i> [Re-Securing JSON](http://ejohn.org/blog/re-securing-json/)
<br>
<i class="fa fa-bookmark"></i> [JSON Hijacking](http://haacked.com/archive/2009/06/25/json-hijacking.aspx/)
<br>
<i class="fa fa-bookmark"></i> [Why does Google prepend while(1); to their JSON responses?](http://stackoverflow.com/questions/2669690/why-does-google-prepend-while1-to-their-json-responses)
</p>
</script>
</section>
<section data-markdown>
<script type="text/template">
## JSONP
Always sanitize the `callback` parameter.
<br>
JsonpCallbackValidator allows you to validate a
<br>JSONP callback in order to prevent XSS attacks:
<i class="fa fa-github"></i> [willdurand/JsonpCallbackValidator](https://github.com/willdurand/JsonpCallbackValidator)
<br>
<br>
<i class="fa fa-bookmark"></i> [Are you sure you use JSONP properly?](http://homakov.blogspot.fr/2013/02/are-you-sure-you-use-jsonp-properly.html)
</script>
</section>
<section data-markdown>
<script type="text/template">
## Basic Security Thinking
1. Trust nobody and nothing;
2. Assume a worse-case scenario;
3. Apply Defense-In-Depth;
4. Keep It Simple Stupid (KISS);
5. Principle of Least Privilege;
6. Attackers can smell obscurity;
7. RTFM but never trust it;
8. If it is not tested, it does not work;
9. It is always your fault!
<br>
<i class="fa fa-book"></i> [Survive The Deep End: PHP Security](http://phpsecurity.readthedocs.org/en/latest/index.html)
</script>
</section>
</section>
<section data-markdown>
<script type="text/template">
# Symfony