SlideShare a Scribd company logo
1 of 49
QUALITY OF LIFEQUALITY OF LIFEMichal ŠpačekMichal Špaček www.michalspacek.comwww.michalspacek.com @spazef0rze@spazef0rze
Yep, that’s me fixing some security issues while on vacation. This talk is about
quality of life, multiple lines of defense, how to implement them in your typical
web app, and why. Explained on passwords and Cross-Site Scripting. This slide
deck contains extra speaker notes not available in the original deck.
In September 2016, Yahoo confirmed a 500 million accounts leak. The breach is
said to have occurred in late 2014. It has changed lives of quite a few people.
Only three months later, in December 2016, Yahoo released a statement saying
that 1 billion accounts were compromised in a different attack in 2013.
I’m not a market expert, but this stock price chart says Yahoo is doing quite fine.
Obviously the breach had no influence on the stock price. But…
In July 2016, before the breaches were disclosed, Verizon announced its intent to
acquire Yahoo’s Internet business for $4.8 billion. On February 21, 2017, Verizon
agreed to lower its purchase price for Yahoo by $350 million, and share liabilities
regarding the investigation into the data breaches. Talk about losing money.
Russian agents were behind Yahoo hack, U.S. said in March 2017. I don’t want to
go into attribution business but let’s focus on the small text below the picture →
Right, that seems quite bad. I’d say Mayer’s quality of life has changed a bit.
Blackmailing
Because
Plaintext passwords
A friend of mine called me some time ago, his voice shaking. He told somebody
has hacked a legacy site his company had built. Unfortunately the site stored
user passwords just like this and the attacker said he’d publish the database
unless the company pays a ransom. That friend and his team had to work 24/7
for a few days to fix the app and some others. Life quality reduced. Eventually
they didn’t pay the ransom, and fortunately database was not released.
In summer 2015 a group or an individual named The Impact Team released 25 GB
of company and user data taken from Ashley Madison, a Canadian dating site
marketed to people who are married or in committed relationships. Not every user of
the site had an affair, but most of the media presented the incident as „database of
cheaters leaked“. Days after the data was published a lot of Ashley Madison users
started to be blackmailed: „send bitcoinz and we will not tell your partner you had an
account with Ashley Madison,“ or „send bitcoinz and we will tell you whether your
partner had an account, or not.“ The hack made a mess of lot of lives.
Supposedly two Ashley Madison users commited suicide because of the hack. One
of them was an american pastor, the other one a man my friend had talked to. Some
other suicides eventually couldn’t be confirmed as events linked to the leak, like the
San Antonio police captain case.
In 2012, LeakedIn, I mean LinkedIn lost 6.5 million usernames and hashed
passwords but in May 2016 it became apparent that the leak was much bigger than
originally thought. It was 167 million credenentials in total. The company discovered
the full extent only after somebody tried to sell the whole database dump.
This is Mark. Mark runs Facebook. Mark used the same password for LinkedIn,
Pinterest, and Twitter. Don’t be like Mark a don’t use the same password for multiple
services. Use strong unique passwords. Use a password manager to generate and
keep your passwords. Have a backup plan in case you forget the master password.
In June 2016 a group called OurMine posted Mark’s password, dadada, on his Twitter.
Da in Russian means Yes. And guess what? This guy, Yevgeny Nikulin, a Russian
national detained in downtown Prague, Czech Republic on October 5, 2016, is
accused by American officials of hacking U.S. targets. Coincidence much, da.
0f158e648228a19cab5f23acfd6c36f716a702a9
SHA-1 hash
Zuckerberg’s password was stored hashed in the LinkedIn dump, this is the hash.
But when passwords are hashed with unsalted SHA-1, it’s quite easy to crack them.
For weak passwords like dadada, you can even Google the unsalted SHA-1 hash.
When a Google search is not enough, or if you want to crack passwords for living,
you’ll need machine full of GPUs, like this one built by Jeremi Gosney and his
company Sagitta HPC. It generates tens of billions of SHA-1 hashes per second.
When even a machine full of GPUs is not fast enough, maybe you’ll more machines.
These Sagitta HPC guys are crazy. Now they’re ordering their GPUs by kilos. So this
is how 300 kg of NVIDIA GeForce GPUs looks like.
https://haveibeenpwned.com
Use Have I been pwned? to see if your account has been compromised in a public
data breach. You can also set up notifications or search across an entire domain.
Variable binding
HTTPS
Firewalls
Security is not just “buy this box and plug it in the network”. When transmitting and
receiving, the data goes through several layers. Each of the layers needs their own
protection. A site using HTTPS to encrypt the traffic can still be hacked and have the
database dumped. Users get phished on sites using HTTPS. But we still HTTPS.❤
Use Observatory by Mozilla to scan some of the layers, it will offer few hints to make
them more secure. It scans HTTP headers, cookies, etc., and optionally includes
results from third-party scanners, like the SSL Labs Server Test.
Password hashing, a second line of defense, protects users and their passwords
when databases leak. Database leaks shouldn’t happen, but they do. Multiple
lines of defense offer protection when something goes wrong. I've actually started
collecting info on how companies store user passwords. The collection is
available at https://pulse.michalspacek.cz/passwords/storages.
Here’s a Czech company using bcrypt. Their disclosure has been rated “A”. They
have also provided historical info and some details in their FAQ. I always link to
a public disclosure, so the site is actually more like a collection of links to who said
what. Disclosure: I worked for Slevomat.cz in 2013-2014.
Slow password hashes + docs
Slow pw hashes + blog, FB, Twitter
SECURE
My scoring system is inspired by the SSL Labs Server Test rating and it works
like this: the better the hashing algorithm is and the better the disclosure is, the
better score the site gets. So if a site uses bcrypt (or PBKDF2, scrypt, or Argon2)
and they tell us in their docs, they score “A”. If they tell us only in a blog post, talk,
or on a social media they score “B”, because a talk or a blog post is quite
invisible. Both “A” and “B” are scores for safe password storage.
Other hashes + salted + iterations
Other hashes + salted
Other hashes, or encrypted
WEAK
A site scores “C” if they use unsuitable hashes like MD5 or SHA-1 with a salt and
multiple iterations. They score “D”, if they hash passwords with one iteration of an
unsuitable hashing function, with a salt. Grade “E” is for when they use plain fast
hashes or encrypt passwords. Users are strongly advised to create unique
passwords for sites with these scores, especially for sites with “D” or “E”.
FAILFAILFAILFAILFAILFAIL
UNSAFE
Last but not least, “F” is for total failure, and that's when the site stores passwords
just like this, in plaintext. When signing up for the service, users should, and I
mean SHOULD use a unique password, not used anywhere else.
XSS
Cross Site Scripting
The concept of multiple lines of defense could also be demonstrated using Cross-
Site Scripting, an attack on users and their browsers. Using XSS, the attacker can
execute their malicious JavaScript downloaded from some other site in the context
of the vulnerable app.
Cross-Site Scripting is not new. According to Open Sourced Vulnerability
Database, the first XSS vulnerability was published in 1999.
$1.2 million
Just in 2014-2016 Google has awarded researchers over $1.2 million for reporting
XSS bugs in their applications via Google’s Vulnerability Reward Program. Not bad.
A man, left, and $1M in $100 bills, right, according to PageTutor. Feels like it fits in
a shoe box, right? This is roughly what Google has paid for XSS for 2 years.
<img src=x onerror=alert(1)>
Cross-Site Scripting happens when a bad guy injects a JavaScript into the page.
They can also inject an img tag with onerror handler, not just a <script> tag.
When XSS is demonstrated or reported, it mostly comes as an alert(1). While this
really is a proof that the attacker is able to run JavaScript, it might not be enough to
convince somebody that Cross-Site Scripting is dangerous and deserves a fix.
< → &lt;
> → &gt;
" → &quot;
' → &apos;
& → &amp;
When developers forget to convert these special characters, mostly the first four
lines, in user input to HTML entities, that’s when bad things (and XSS) happens.
The Browser Exploitation Framework Project
BeEF
But XSS is much more than just alert(1). Meet BeEF, the XSS framework. It
comes with some 300 predefined modules, like fake Flash update notifications,
fake login windows, code to take screenshots of pages, or play an audio file.
2nd
line of
DEFENSEDevelopers quite often forget to escape special characters in input, and will keep
doing so. Because deadlines, bad coffee, or one too many beers. So we need this.
A 2nd
line of defense, like this one, might not work for all cases and/or users, but
when primary defense layer fails it might just save your life. Or cookies.
Speaking of stealing cookies… this is exactly how it works.
To prevent JavaScript from stealing your session cookies, mark them as HTTP-Only
in the app you’ve built. Such cookies will still be sent over the wire, but JavaScript
won’t see them, so an attacker won’t be able to hijack the session using XSS. They
still might be able to sniff the cookie when it’s sent over plain HTTP, though.
XSS
Auditor
Yet another 2nd
line of defense is built right into your browser if you use Chrome or
Internet Explorer, or Edge. It’s not built into Firefox, but again, it’s not a primary
defense layer. The XSS auditor, or XSS filter, prevents the reflected variant of XSS.
WEB
APP1 2
3
This is how reflected XSS works. The attacker sends a link with some evil JavaScript
in the URL to the user (1), user clicks the link and a request is being sent to the web
application (2). The request includes the JavaScript, which in turn gets injected into
the page and is send back to the user (3) and is executed in their browser. The
browser sees what’s coming back from the application and if it looks like the
JavaScript it sent out with the request then the XSS filter gets triggered, if enabled.
X-XSS-Protection: 1; mode=block
You can control the XSS filter by the X-XSS-Protection response header. Using
mode=block is recommended, and will make the browser not display the page at all.
mode=block is also the default setting since Chrome 57. Previously, the browser
tried to clean the page. You can test your browser’s XSS auditor on my demo site.
Content Security Policy is the latest addition to already existing 2nd
lines of defense
against XSS. It’s a response header which provides a list of allowed URLs for the
browser to load images, JavaScript, CSS, etc. from into the page. So even if in the
attacker is able to inject a <script> tag into the HTML the browser will not load the
code from the specified URL provided the host or path is missing from the whitelist.
Content-Security-Policy: default-src 'self'
The Content-Security-Policy response header might look like this basic
example. This will allow JavaScript, images, CSS and some more to be loaded into
the page associated with the header only from 'self', the current origin.
Content-Security-Policy:
default-src 'self';
img-src 'self' https://www.google-analytics.com
The header can be extended by allowing images also from https://www.google-
analytics.com for the Google Analytics tracking script to work properly. The script
itself would need to be loaded from current origin now, and that’s not how it works.
Content-Security-Policy:
default-src 'self';
img-src 'self' https://www.google-analytics.com;
script-src 'self'
https://www.google-analytics.com 'unsafe-inline'
The origin for the Google Analytics script can be added to the whitelist too. The inline
JavaScript is also allowed here by using the 'unsafe-inline' directive. Yes, the JS
code written directly in the HTML using <script> tags or handlers like onclick
might be dangerous so it is called unsafe. But some libraries and/or tools need it.
csp-evaluator.withgoogle.com
Tools like the Google Tag Manager make CSP deployments hard. You need to make
your policy quite open, allow a lot of origins, or hostnames, enable inline JavaScript.
And that’s just making it easier for the attacker to find an opportunity to inject their
code. You can test your policy with CSP Evaluator to see if it can be bypassed. To
make deployments easier, CSP level 3 introduces 'strict-dynamic' which makes
the browser ignore host-based whitelists, and only works with nonces. But enables
the already allowed script to load more scripts without actually extending the policy.
See how 'strict-dynamic' works and test it on my CSP3 demo page.
Michal ŠpačekMichal Špaček www.michalspacek.comwww.michalspacek.com @spazef0rze@spazef0rze
To err is human, obviously, so please think about multiple lines of defense when
building apps because even 20 years old attacks are still hot and dangerous.

More Related Content

What's hot

Cross Site Scripting (XSS)
Cross Site Scripting (XSS)Cross Site Scripting (XSS)
Cross Site Scripting (XSS)
OWASP Khartoum
 
BSides Cleveland: Active Defense - Helping threat actors hack themselves!
BSides Cleveland: Active Defense - Helping threat actors hack themselves!BSides Cleveland: Active Defense - Helping threat actors hack themselves!
BSides Cleveland: Active Defense - Helping threat actors hack themselves!
ThreatReel Podcast
 
NKU Cybersecurity Symposium: Active Defense - Helping threat actors hack them...
NKU Cybersecurity Symposium: Active Defense - Helping threat actors hack them...NKU Cybersecurity Symposium: Active Defense - Helping threat actors hack them...
NKU Cybersecurity Symposium: Active Defense - Helping threat actors hack them...
ThreatReel Podcast
 
OISF Aniversary: Active Defense - Helping threat actors hack themselves!
OISF Aniversary: Active Defense - Helping threat actors hack themselves!OISF Aniversary: Active Defense - Helping threat actors hack themselves!
OISF Aniversary: Active Defense - Helping threat actors hack themselves!
ThreatReel Podcast
 

What's hot (20)

W3 conf hill-html5-security-realities
W3 conf hill-html5-security-realitiesW3 conf hill-html5-security-realities
W3 conf hill-html5-security-realities
 
New Methods in Automated XSS Detection & Dynamic Exploit Creation
New Methods in Automated XSS Detection & Dynamic Exploit CreationNew Methods in Automated XSS Detection & Dynamic Exploit Creation
New Methods in Automated XSS Detection & Dynamic Exploit Creation
 
Cross Site Scripting (XSS)
Cross Site Scripting (XSS)Cross Site Scripting (XSS)
Cross Site Scripting (XSS)
 
XSS - Do you know EVERYTHING?
XSS - Do you know EVERYTHING?XSS - Do you know EVERYTHING?
XSS - Do you know EVERYTHING?
 
Web Application Security in front end
Web Application Security in front endWeb Application Security in front end
Web Application Security in front end
 
WordPress Security Essential Tips & Tricks
WordPress Security Essential Tips & TricksWordPress Security Essential Tips & Tricks
WordPress Security Essential Tips & Tricks
 
Defeating Cross-Site Scripting with Content Security Policy (updated)
Defeating Cross-Site Scripting with Content Security Policy (updated)Defeating Cross-Site Scripting with Content Security Policy (updated)
Defeating Cross-Site Scripting with Content Security Policy (updated)
 
Make profit with UI-Redressing attacks.
Make profit with UI-Redressing attacks.Make profit with UI-Redressing attacks.
Make profit with UI-Redressing attacks.
 
Top Ten Web Hacking Techniques (2008)
Top Ten Web Hacking Techniques (2008)Top Ten Web Hacking Techniques (2008)
Top Ten Web Hacking Techniques (2008)
 
BSides Cleveland: Active Defense - Helping threat actors hack themselves!
BSides Cleveland: Active Defense - Helping threat actors hack themselves!BSides Cleveland: Active Defense - Helping threat actors hack themselves!
BSides Cleveland: Active Defense - Helping threat actors hack themselves!
 
Steve Kosten - Exploiting common web application vulnerabilities
Steve Kosten - Exploiting common web application vulnerabilities Steve Kosten - Exploiting common web application vulnerabilities
Steve Kosten - Exploiting common web application vulnerabilities
 
Modern Web Application Defense
Modern Web Application DefenseModern Web Application Defense
Modern Web Application Defense
 
DOM-based XSS
DOM-based XSSDOM-based XSS
DOM-based XSS
 
XSSmon: A Perl Based IDS for the Detection of Potential XSS Attacks
XSSmon: A Perl Based IDS for the Detection of Potential XSS AttacksXSSmon: A Perl Based IDS for the Detection of Potential XSS Attacks
XSSmon: A Perl Based IDS for the Detection of Potential XSS Attacks
 
Top Ten Web Hacking Techniques (2010)
Top Ten Web Hacking Techniques (2010)Top Ten Web Hacking Techniques (2010)
Top Ten Web Hacking Techniques (2010)
 
P@ssw0rds
P@ssw0rdsP@ssw0rds
P@ssw0rds
 
(In)Security Implication in the JS Universe
(In)Security Implication in the JS Universe(In)Security Implication in the JS Universe
(In)Security Implication in the JS Universe
 
Polyglot payloads in practice by avlidienbrunn at HackPra
Polyglot payloads in practice by avlidienbrunn at HackPraPolyglot payloads in practice by avlidienbrunn at HackPra
Polyglot payloads in practice by avlidienbrunn at HackPra
 
NKU Cybersecurity Symposium: Active Defense - Helping threat actors hack them...
NKU Cybersecurity Symposium: Active Defense - Helping threat actors hack them...NKU Cybersecurity Symposium: Active Defense - Helping threat actors hack them...
NKU Cybersecurity Symposium: Active Defense - Helping threat actors hack them...
 
OISF Aniversary: Active Defense - Helping threat actors hack themselves!
OISF Aniversary: Active Defense - Helping threat actors hack themselves!OISF Aniversary: Active Defense - Helping threat actors hack themselves!
OISF Aniversary: Active Defense - Helping threat actors hack themselves!
 

Viewers also liked

Procesnopravna ochrana eropskeho komunitarneho sutazneho prava
Procesnopravna ochrana eropskeho komunitarneho sutazneho pravaProcesnopravna ochrana eropskeho komunitarneho sutazneho prava
Procesnopravna ochrana eropskeho komunitarneho sutazneho prava
Peter Rizman
 

Viewers also liked (10)

Jak vytrollit hejtra na fejsu
Jak vytrollit hejtra na fejsuJak vytrollit hejtra na fejsu
Jak vytrollit hejtra na fejsu
 
Procesnopravna ochrana eropskeho komunitarneho sutazneho prava
Procesnopravna ochrana eropskeho komunitarneho sutazneho pravaProcesnopravna ochrana eropskeho komunitarneho sutazneho prava
Procesnopravna ochrana eropskeho komunitarneho sutazneho prava
 
Unmanaged Tags - Data Protection in the Age of Mindless Proliferation
Unmanaged Tags - Data Protection in the Age of Mindless Proliferation Unmanaged Tags - Data Protection in the Age of Mindless Proliferation
Unmanaged Tags - Data Protection in the Age of Mindless Proliferation
 
Quality of life
Quality of lifeQuality of life
Quality of life
 
Quality of life in india
Quality of life in indiaQuality of life in india
Quality of life in india
 
Markov model for the online multichannel attribution problem
Markov model for the online multichannel attribution problemMarkov model for the online multichannel attribution problem
Markov model for the online multichannel attribution problem
 
Jak zlepšit zabezpečení čtvrtiny celého webu
Jak zlepšit zabezpečení čtvrtiny celého webuJak zlepšit zabezpečení čtvrtiny celého webu
Jak zlepšit zabezpečení čtvrtiny celého webu
 
Quality of work life ppt
Quality of work life pptQuality of work life ppt
Quality of work life ppt
 
Measuring Quality of Life - Joint Debate Slides
Measuring Quality of Life - Joint Debate SlidesMeasuring Quality of Life - Joint Debate Slides
Measuring Quality of Life - Joint Debate Slides
 
Vašek Purchart - Optimalizace Symfony na devu (2. sraz přátel Symfony v Praze)
Vašek Purchart - Optimalizace Symfony na devu (2. sraz přátel Symfony v Praze)Vašek Purchart - Optimalizace Symfony na devu (2. sraz přátel Symfony v Praze)
Vašek Purchart - Optimalizace Symfony na devu (2. sraz přátel Symfony v Praze)
 

Similar to Quality of Life, Multiple Lines of Defense

Hacking databases
Hacking databasesHacking databases
Hacking databases
sunil kumar
 
Hacking databases
Hacking databasesHacking databases
Hacking databases
sunil kumar
 

Similar to Quality of Life, Multiple Lines of Defense (20)

Disclosing password hashing policies
Disclosing password hashing policiesDisclosing password hashing policies
Disclosing password hashing policies
 
Anatomy of Java Vulnerabilities - NLJug 2018
Anatomy of Java Vulnerabilities - NLJug 2018Anatomy of Java Vulnerabilities - NLJug 2018
Anatomy of Java Vulnerabilities - NLJug 2018
 
Password and Account Management Strategies - April 2019
Password and Account Management Strategies - April 2019Password and Account Management Strategies - April 2019
Password and Account Management Strategies - April 2019
 
Password craking techniques
Password craking techniques Password craking techniques
Password craking techniques
 
Roberto Bicchierai - Defending web applications from attacks
Roberto Bicchierai - Defending web applications from attacksRoberto Bicchierai - Defending web applications from attacks
Roberto Bicchierai - Defending web applications from attacks
 
OlgerHoxha_Thesis_Final
OlgerHoxha_Thesis_FinalOlgerHoxha_Thesis_Final
OlgerHoxha_Thesis_Final
 
Shape Security @ WaffleJS October 16
Shape Security @ WaffleJS October 16Shape Security @ WaffleJS October 16
Shape Security @ WaffleJS October 16
 
Starwest 2008
Starwest 2008Starwest 2008
Starwest 2008
 
Advanced phishing for red team assessments
Advanced phishing for red team assessmentsAdvanced phishing for red team assessments
Advanced phishing for red team assessments
 
Password cracking and brute force tools
Password cracking and brute force toolsPassword cracking and brute force tools
Password cracking and brute force tools
 
Web application security for java (XSS,Session Fixation)
Web application security for java (XSS,Session Fixation)Web application security for java (XSS,Session Fixation)
Web application security for java (XSS,Session Fixation)
 
OWASP Free Training - SF2014 - Keary and Manico
OWASP Free Training - SF2014 - Keary and ManicoOWASP Free Training - SF2014 - Keary and Manico
OWASP Free Training - SF2014 - Keary and Manico
 
Hacking databases
Hacking databasesHacking databases
Hacking databases
 
Hacking databases
Hacking databasesHacking databases
Hacking databases
 
THE GAME OF PHISHING
THE GAME OF PHISHINGTHE GAME OF PHISHING
THE GAME OF PHISHING
 
The Anatomy of Java Vulnerabilities
The Anatomy of Java VulnerabilitiesThe Anatomy of Java Vulnerabilities
The Anatomy of Java Vulnerabilities
 
OpenTechTalks: Ethical hacking with Kali Linux (Tijl Deneut, UGent)
OpenTechTalks: Ethical hacking with Kali Linux (Tijl Deneut, UGent)OpenTechTalks: Ethical hacking with Kali Linux (Tijl Deneut, UGent)
OpenTechTalks: Ethical hacking with Kali Linux (Tijl Deneut, UGent)
 
Believe It Or Not SSL Attacks
Believe It Or Not SSL AttacksBelieve It Or Not SSL Attacks
Believe It Or Not SSL Attacks
 
Top 10 Web Security Vulnerabilities (OWASP Top 10)
Top 10 Web Security Vulnerabilities (OWASP Top 10)Top 10 Web Security Vulnerabilities (OWASP Top 10)
Top 10 Web Security Vulnerabilities (OWASP Top 10)
 
Heartbleed vulnerability
Heartbleed vulnerabilityHeartbleed vulnerability
Heartbleed vulnerability
 

More from Michal Špaček

More from Michal Špaček (20)

Víceúrovňová obrana vysvětlená na Cross-Site Scriptingu
Víceúrovňová obrana vysvětlená na Cross-Site ScriptinguVíceúrovňová obrana vysvětlená na Cross-Site Scriptingu
Víceúrovňová obrana vysvětlená na Cross-Site Scriptingu
 
Lámání a ukládání hesel
Lámání a ukládání heselLámání a ukládání hesel
Lámání a ukládání hesel
 
Fantom Opery, "VPN" a Secure Proxy v Opeře
Fantom Opery, "VPN" a Secure Proxy v OpeřeFantom Opery, "VPN" a Secure Proxy v Opeře
Fantom Opery, "VPN" a Secure Proxy v Opeře
 
Medvědí služba
Medvědí službaMedvědí služba
Medvědí služba
 
XSS PHP CSP ETC OMG WTF BBQ
XSS PHP CSP ETC OMG WTF BBQXSS PHP CSP ETC OMG WTF BBQ
XSS PHP CSP ETC OMG WTF BBQ
 
Bezpečnost e-shopů (HTTPS, XSS, CSP)
Bezpečnost e-shopů (HTTPS, XSS, CSP)Bezpečnost e-shopů (HTTPS, XSS, CSP)
Bezpečnost e-shopů (HTTPS, XSS, CSP)
 
Poučte se z cizích chyb
Poučte se z cizích chybPoučte se z cizích chyb
Poučte se z cizích chyb
 
Minulé století volalo (Cross-Site Scripting + BeEF + CSP demo)
Minulé století volalo (Cross-Site Scripting + BeEF + CSP demo)Minulé století volalo (Cross-Site Scripting + BeEF + CSP demo)
Minulé století volalo (Cross-Site Scripting + BeEF + CSP demo)
 
Password manažeři detailněji – 1Password, LastPass, 2FA, sdílení
Password manažeři detailněji – 1Password, LastPass, 2FA, sdíleníPassword manažeři detailněji – 1Password, LastPass, 2FA, sdílení
Password manažeři detailněji – 1Password, LastPass, 2FA, sdílení
 
HTTPS (a šifrování) všude
HTTPS (a šifrování) všudeHTTPS (a šifrování) všude
HTTPS (a šifrování) všude
 
HTTP Strict Transport Security (HSTS), English version
HTTP Strict Transport Security (HSTS), English versionHTTP Strict Transport Security (HSTS), English version
HTTP Strict Transport Security (HSTS), English version
 
Bezpečnost na mobilních zařízeních
Bezpečnost na mobilních zařízeníchBezpečnost na mobilních zařízeních
Bezpečnost na mobilních zařízeních
 
Základy webové bezpečnosti pro PR a marketing
Základy webové bezpečnosti pro PR a marketingZáklady webové bezpečnosti pro PR a marketing
Základy webové bezpečnosti pro PR a marketing
 
Hlava není na hesla
Hlava není na heslaHlava není na hesla
Hlava není na hesla
 
HTTP Strict Transport Security (HSTS)
HTTP Strict Transport Security (HSTS)HTTP Strict Transport Security (HSTS)
HTTP Strict Transport Security (HSTS)
 
HTTP/2
HTTP/2HTTP/2
HTTP/2
 
Víte, že nevíte, že já vím, že nevíte? (WebTop100 2014)
Víte, že nevíte, že já vím, že nevíte? (WebTop100 2014)Víte, že nevíte, že já vím, že nevíte? (WebTop100 2014)
Víte, že nevíte, že já vím, že nevíte? (WebTop100 2014)
 
Přechod na HTTPS
Přechod na HTTPSPřechod na HTTPS
Přechod na HTTPS
 
Noční můry webového vývojáře
Noční můry webového vývojářeNoční můry webového vývojáře
Noční můry webového vývojáře
 
Zabezpečení Slevomatu
Zabezpečení SlevomatuZabezpečení Slevomatu
Zabezpečení Slevomatu
 

Recently uploaded

一比一原版奥兹学院毕业证如何办理
一比一原版奥兹学院毕业证如何办理一比一原版奥兹学院毕业证如何办理
一比一原版奥兹学院毕业证如何办理
F
 
call girls in Anand Vihar (delhi) call me [🔝9953056974🔝] escort service 24X7
call girls in Anand Vihar (delhi) call me [🔝9953056974🔝] escort service 24X7call girls in Anand Vihar (delhi) call me [🔝9953056974🔝] escort service 24X7
call girls in Anand Vihar (delhi) call me [🔝9953056974🔝] escort service 24X7
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
在线制作约克大学毕业证(yu毕业证)在读证明认证可查
在线制作约克大学毕业证(yu毕业证)在读证明认证可查在线制作约克大学毕业证(yu毕业证)在读证明认证可查
在线制作约克大学毕业证(yu毕业证)在读证明认证可查
ydyuyu
 
一比一原版帝国理工学院毕业证如何办理
一比一原版帝国理工学院毕业证如何办理一比一原版帝国理工学院毕业证如何办理
一比一原版帝国理工学院毕业证如何办理
F
 

Recently uploaded (20)

South Bopal [ (Call Girls) in Ahmedabad ₹7.5k Pick Up & Drop With Cash Paymen...
South Bopal [ (Call Girls) in Ahmedabad ₹7.5k Pick Up & Drop With Cash Paymen...South Bopal [ (Call Girls) in Ahmedabad ₹7.5k Pick Up & Drop With Cash Paymen...
South Bopal [ (Call Girls) in Ahmedabad ₹7.5k Pick Up & Drop With Cash Paymen...
 
一比一原版奥兹学院毕业证如何办理
一比一原版奥兹学院毕业证如何办理一比一原版奥兹学院毕业证如何办理
一比一原版奥兹学院毕业证如何办理
 
Ballia Escorts Service Girl ^ 9332606886, WhatsApp Anytime Ballia
Ballia Escorts Service Girl ^ 9332606886, WhatsApp Anytime BalliaBallia Escorts Service Girl ^ 9332606886, WhatsApp Anytime Ballia
Ballia Escorts Service Girl ^ 9332606886, WhatsApp Anytime Ballia
 
APNIC Updates presented by Paul Wilson at ARIN 53
APNIC Updates presented by Paul Wilson at ARIN 53APNIC Updates presented by Paul Wilson at ARIN 53
APNIC Updates presented by Paul Wilson at ARIN 53
 
2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs
2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs
2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs
 
💚 Call Girls Bahraich 9332606886 High Profile Call Girls You Can Get The S...
💚 Call Girls Bahraich   9332606886  High Profile Call Girls You Can Get The S...💚 Call Girls Bahraich   9332606886  High Profile Call Girls You Can Get The S...
💚 Call Girls Bahraich 9332606886 High Profile Call Girls You Can Get The S...
 
Nagercoil Escorts Service Girl ^ 9332606886, WhatsApp Anytime Nagercoil
Nagercoil Escorts Service Girl ^ 9332606886, WhatsApp Anytime NagercoilNagercoil Escorts Service Girl ^ 9332606886, WhatsApp Anytime Nagercoil
Nagercoil Escorts Service Girl ^ 9332606886, WhatsApp Anytime Nagercoil
 
Meaning of On page SEO & its process in detail.
Meaning of On page SEO & its process in detail.Meaning of On page SEO & its process in detail.
Meaning of On page SEO & its process in detail.
 
best call girls in Hyderabad Finest Escorts Service 📞 9352988975 📞 Available ...
best call girls in Hyderabad Finest Escorts Service 📞 9352988975 📞 Available ...best call girls in Hyderabad Finest Escorts Service 📞 9352988975 📞 Available ...
best call girls in Hyderabad Finest Escorts Service 📞 9352988975 📞 Available ...
 
Best SEO Services Company in Dallas | Best SEO Agency Dallas
Best SEO Services Company in Dallas | Best SEO Agency DallasBest SEO Services Company in Dallas | Best SEO Agency Dallas
Best SEO Services Company in Dallas | Best SEO Agency Dallas
 
Real Men Wear Diapers T Shirts sweatshirt
Real Men Wear Diapers T Shirts sweatshirtReal Men Wear Diapers T Shirts sweatshirt
Real Men Wear Diapers T Shirts sweatshirt
 
Call girls Service Canacona - 8250092165 Our call girls are sure to provide y...
Call girls Service Canacona - 8250092165 Our call girls are sure to provide y...Call girls Service Canacona - 8250092165 Our call girls are sure to provide y...
Call girls Service Canacona - 8250092165 Our call girls are sure to provide y...
 
Leading-edge AI Image Generators of 2024
Leading-edge AI Image Generators of 2024Leading-edge AI Image Generators of 2024
Leading-edge AI Image Generators of 2024
 
call girls in Anand Vihar (delhi) call me [🔝9953056974🔝] escort service 24X7
call girls in Anand Vihar (delhi) call me [🔝9953056974🔝] escort service 24X7call girls in Anand Vihar (delhi) call me [🔝9953056974🔝] escort service 24X7
call girls in Anand Vihar (delhi) call me [🔝9953056974🔝] escort service 24X7
 
在线制作约克大学毕业证(yu毕业证)在读证明认证可查
在线制作约克大学毕业证(yu毕业证)在读证明认证可查在线制作约克大学毕业证(yu毕业证)在读证明认证可查
在线制作约克大学毕业证(yu毕业证)在读证明认证可查
 
一比一原版帝国理工学院毕业证如何办理
一比一原版帝国理工学院毕业证如何办理一比一原版帝国理工学院毕业证如何办理
一比一原版帝国理工学院毕业证如何办理
 
20240507 QFM013 Machine Intelligence Reading List April 2024.pdf
20240507 QFM013 Machine Intelligence Reading List April 2024.pdf20240507 QFM013 Machine Intelligence Reading List April 2024.pdf
20240507 QFM013 Machine Intelligence Reading List April 2024.pdf
 
20240510 QFM016 Irresponsible AI Reading List April 2024.pdf
20240510 QFM016 Irresponsible AI Reading List April 2024.pdf20240510 QFM016 Irresponsible AI Reading List April 2024.pdf
20240510 QFM016 Irresponsible AI Reading List April 2024.pdf
 
"Boost Your Digital Presence: Partner with a Leading SEO Agency"
"Boost Your Digital Presence: Partner with a Leading SEO Agency""Boost Your Digital Presence: Partner with a Leading SEO Agency"
"Boost Your Digital Presence: Partner with a Leading SEO Agency"
 
Research Assignment - NIST SP800 [172 A] - Presentation.pptx
Research Assignment - NIST SP800 [172 A] - Presentation.pptxResearch Assignment - NIST SP800 [172 A] - Presentation.pptx
Research Assignment - NIST SP800 [172 A] - Presentation.pptx
 

Quality of Life, Multiple Lines of Defense

  • 1. QUALITY OF LIFEQUALITY OF LIFEMichal ŠpačekMichal Špaček www.michalspacek.comwww.michalspacek.com @spazef0rze@spazef0rze Yep, that’s me fixing some security issues while on vacation. This talk is about quality of life, multiple lines of defense, how to implement them in your typical web app, and why. Explained on passwords and Cross-Site Scripting. This slide deck contains extra speaker notes not available in the original deck.
  • 2. In September 2016, Yahoo confirmed a 500 million accounts leak. The breach is said to have occurred in late 2014. It has changed lives of quite a few people.
  • 3. Only three months later, in December 2016, Yahoo released a statement saying that 1 billion accounts were compromised in a different attack in 2013.
  • 4. I’m not a market expert, but this stock price chart says Yahoo is doing quite fine. Obviously the breach had no influence on the stock price. But…
  • 5. In July 2016, before the breaches were disclosed, Verizon announced its intent to acquire Yahoo’s Internet business for $4.8 billion. On February 21, 2017, Verizon agreed to lower its purchase price for Yahoo by $350 million, and share liabilities regarding the investigation into the data breaches. Talk about losing money.
  • 6. Russian agents were behind Yahoo hack, U.S. said in March 2017. I don’t want to go into attribution business but let’s focus on the small text below the picture →
  • 7. Right, that seems quite bad. I’d say Mayer’s quality of life has changed a bit.
  • 8. Blackmailing Because Plaintext passwords A friend of mine called me some time ago, his voice shaking. He told somebody has hacked a legacy site his company had built. Unfortunately the site stored user passwords just like this and the attacker said he’d publish the database unless the company pays a ransom. That friend and his team had to work 24/7 for a few days to fix the app and some others. Life quality reduced. Eventually they didn’t pay the ransom, and fortunately database was not released.
  • 9. In summer 2015 a group or an individual named The Impact Team released 25 GB of company and user data taken from Ashley Madison, a Canadian dating site marketed to people who are married or in committed relationships. Not every user of the site had an affair, but most of the media presented the incident as „database of cheaters leaked“. Days after the data was published a lot of Ashley Madison users started to be blackmailed: „send bitcoinz and we will not tell your partner you had an account with Ashley Madison,“ or „send bitcoinz and we will tell you whether your partner had an account, or not.“ The hack made a mess of lot of lives.
  • 10. Supposedly two Ashley Madison users commited suicide because of the hack. One of them was an american pastor, the other one a man my friend had talked to. Some other suicides eventually couldn’t be confirmed as events linked to the leak, like the San Antonio police captain case.
  • 11. In 2012, LeakedIn, I mean LinkedIn lost 6.5 million usernames and hashed passwords but in May 2016 it became apparent that the leak was much bigger than originally thought. It was 167 million credenentials in total. The company discovered the full extent only after somebody tried to sell the whole database dump.
  • 12. This is Mark. Mark runs Facebook. Mark used the same password for LinkedIn, Pinterest, and Twitter. Don’t be like Mark a don’t use the same password for multiple services. Use strong unique passwords. Use a password manager to generate and keep your passwords. Have a backup plan in case you forget the master password.
  • 13. In June 2016 a group called OurMine posted Mark’s password, dadada, on his Twitter.
  • 14. Da in Russian means Yes. And guess what? This guy, Yevgeny Nikulin, a Russian national detained in downtown Prague, Czech Republic on October 5, 2016, is accused by American officials of hacking U.S. targets. Coincidence much, da.
  • 15. 0f158e648228a19cab5f23acfd6c36f716a702a9 SHA-1 hash Zuckerberg’s password was stored hashed in the LinkedIn dump, this is the hash. But when passwords are hashed with unsalted SHA-1, it’s quite easy to crack them.
  • 16. For weak passwords like dadada, you can even Google the unsalted SHA-1 hash.
  • 17. When a Google search is not enough, or if you want to crack passwords for living, you’ll need machine full of GPUs, like this one built by Jeremi Gosney and his company Sagitta HPC. It generates tens of billions of SHA-1 hashes per second.
  • 18. When even a machine full of GPUs is not fast enough, maybe you’ll more machines.
  • 19. These Sagitta HPC guys are crazy. Now they’re ordering their GPUs by kilos. So this is how 300 kg of NVIDIA GeForce GPUs looks like.
  • 20. https://haveibeenpwned.com Use Have I been pwned? to see if your account has been compromised in a public data breach. You can also set up notifications or search across an entire domain.
  • 21. Variable binding HTTPS Firewalls Security is not just “buy this box and plug it in the network”. When transmitting and receiving, the data goes through several layers. Each of the layers needs their own protection. A site using HTTPS to encrypt the traffic can still be hacked and have the database dumped. Users get phished on sites using HTTPS. But we still HTTPS.❤
  • 22. Use Observatory by Mozilla to scan some of the layers, it will offer few hints to make them more secure. It scans HTTP headers, cookies, etc., and optionally includes results from third-party scanners, like the SSL Labs Server Test.
  • 23. Password hashing, a second line of defense, protects users and their passwords when databases leak. Database leaks shouldn’t happen, but they do. Multiple lines of defense offer protection when something goes wrong. I've actually started collecting info on how companies store user passwords. The collection is available at https://pulse.michalspacek.cz/passwords/storages.
  • 24. Here’s a Czech company using bcrypt. Their disclosure has been rated “A”. They have also provided historical info and some details in their FAQ. I always link to a public disclosure, so the site is actually more like a collection of links to who said what. Disclosure: I worked for Slevomat.cz in 2013-2014.
  • 25. Slow password hashes + docs Slow pw hashes + blog, FB, Twitter SECURE My scoring system is inspired by the SSL Labs Server Test rating and it works like this: the better the hashing algorithm is and the better the disclosure is, the better score the site gets. So if a site uses bcrypt (or PBKDF2, scrypt, or Argon2) and they tell us in their docs, they score “A”. If they tell us only in a blog post, talk, or on a social media they score “B”, because a talk or a blog post is quite invisible. Both “A” and “B” are scores for safe password storage.
  • 26. Other hashes + salted + iterations Other hashes + salted Other hashes, or encrypted WEAK A site scores “C” if they use unsuitable hashes like MD5 or SHA-1 with a salt and multiple iterations. They score “D”, if they hash passwords with one iteration of an unsuitable hashing function, with a salt. Grade “E” is for when they use plain fast hashes or encrypt passwords. Users are strongly advised to create unique passwords for sites with these scores, especially for sites with “D” or “E”.
  • 27. FAILFAILFAILFAILFAILFAIL UNSAFE Last but not least, “F” is for total failure, and that's when the site stores passwords just like this, in plaintext. When signing up for the service, users should, and I mean SHOULD use a unique password, not used anywhere else.
  • 28. XSS Cross Site Scripting The concept of multiple lines of defense could also be demonstrated using Cross- Site Scripting, an attack on users and their browsers. Using XSS, the attacker can execute their malicious JavaScript downloaded from some other site in the context of the vulnerable app.
  • 29. Cross-Site Scripting is not new. According to Open Sourced Vulnerability Database, the first XSS vulnerability was published in 1999.
  • 30. $1.2 million Just in 2014-2016 Google has awarded researchers over $1.2 million for reporting XSS bugs in their applications via Google’s Vulnerability Reward Program. Not bad.
  • 31. A man, left, and $1M in $100 bills, right, according to PageTutor. Feels like it fits in a shoe box, right? This is roughly what Google has paid for XSS for 2 years.
  • 32. <img src=x onerror=alert(1)> Cross-Site Scripting happens when a bad guy injects a JavaScript into the page. They can also inject an img tag with onerror handler, not just a <script> tag.
  • 33. When XSS is demonstrated or reported, it mostly comes as an alert(1). While this really is a proof that the attacker is able to run JavaScript, it might not be enough to convince somebody that Cross-Site Scripting is dangerous and deserves a fix.
  • 34. < → &lt; > → &gt; " → &quot; ' → &apos; & → &amp; When developers forget to convert these special characters, mostly the first four lines, in user input to HTML entities, that’s when bad things (and XSS) happens.
  • 35. The Browser Exploitation Framework Project BeEF But XSS is much more than just alert(1). Meet BeEF, the XSS framework. It comes with some 300 predefined modules, like fake Flash update notifications, fake login windows, code to take screenshots of pages, or play an audio file.
  • 36. 2nd line of DEFENSEDevelopers quite often forget to escape special characters in input, and will keep doing so. Because deadlines, bad coffee, or one too many beers. So we need this.
  • 37. A 2nd line of defense, like this one, might not work for all cases and/or users, but when primary defense layer fails it might just save your life. Or cookies.
  • 38. Speaking of stealing cookies… this is exactly how it works.
  • 39. To prevent JavaScript from stealing your session cookies, mark them as HTTP-Only in the app you’ve built. Such cookies will still be sent over the wire, but JavaScript won’t see them, so an attacker won’t be able to hijack the session using XSS. They still might be able to sniff the cookie when it’s sent over plain HTTP, though.
  • 40. XSS Auditor Yet another 2nd line of defense is built right into your browser if you use Chrome or Internet Explorer, or Edge. It’s not built into Firefox, but again, it’s not a primary defense layer. The XSS auditor, or XSS filter, prevents the reflected variant of XSS.
  • 41. WEB APP1 2 3 This is how reflected XSS works. The attacker sends a link with some evil JavaScript in the URL to the user (1), user clicks the link and a request is being sent to the web application (2). The request includes the JavaScript, which in turn gets injected into the page and is send back to the user (3) and is executed in their browser. The browser sees what’s coming back from the application and if it looks like the JavaScript it sent out with the request then the XSS filter gets triggered, if enabled.
  • 42. X-XSS-Protection: 1; mode=block You can control the XSS filter by the X-XSS-Protection response header. Using mode=block is recommended, and will make the browser not display the page at all.
  • 43. mode=block is also the default setting since Chrome 57. Previously, the browser tried to clean the page. You can test your browser’s XSS auditor on my demo site.
  • 44. Content Security Policy is the latest addition to already existing 2nd lines of defense against XSS. It’s a response header which provides a list of allowed URLs for the browser to load images, JavaScript, CSS, etc. from into the page. So even if in the attacker is able to inject a <script> tag into the HTML the browser will not load the code from the specified URL provided the host or path is missing from the whitelist.
  • 45. Content-Security-Policy: default-src 'self' The Content-Security-Policy response header might look like this basic example. This will allow JavaScript, images, CSS and some more to be loaded into the page associated with the header only from 'self', the current origin.
  • 46. Content-Security-Policy: default-src 'self'; img-src 'self' https://www.google-analytics.com The header can be extended by allowing images also from https://www.google- analytics.com for the Google Analytics tracking script to work properly. The script itself would need to be loaded from current origin now, and that’s not how it works.
  • 47. Content-Security-Policy: default-src 'self'; img-src 'self' https://www.google-analytics.com; script-src 'self' https://www.google-analytics.com 'unsafe-inline' The origin for the Google Analytics script can be added to the whitelist too. The inline JavaScript is also allowed here by using the 'unsafe-inline' directive. Yes, the JS code written directly in the HTML using <script> tags or handlers like onclick might be dangerous so it is called unsafe. But some libraries and/or tools need it.
  • 48. csp-evaluator.withgoogle.com Tools like the Google Tag Manager make CSP deployments hard. You need to make your policy quite open, allow a lot of origins, or hostnames, enable inline JavaScript. And that’s just making it easier for the attacker to find an opportunity to inject their code. You can test your policy with CSP Evaluator to see if it can be bypassed. To make deployments easier, CSP level 3 introduces 'strict-dynamic' which makes the browser ignore host-based whitelists, and only works with nonces. But enables the already allowed script to load more scripts without actually extending the policy. See how 'strict-dynamic' works and test it on my CSP3 demo page.
  • 49. Michal ŠpačekMichal Špaček www.michalspacek.comwww.michalspacek.com @spazef0rze@spazef0rze To err is human, obviously, so please think about multiple lines of defense when building apps because even 20 years old attacks are still hot and dangerous.