SlideShare a Scribd company logo
1 of 33
Download to read offline
Tales of modern day data breaches - a web
security guide for developers
Jaap Karan Singh
jaap@scw.io
Co-Founder & Chief Singh, Secure Code Warrior
> Today’s challenges with software security
Of data breaches caused by software
vulnerability ~ Verizon
21%
Source: Verizon, Data Breach Report, 2018 (but in there the last 10 years)
of newly scanned applications had SQL injections
over the past 5 yrs ~ Cisco
1 in 3
Source: Cybersecurity as a Growth Advantage, Cisco, 2016
> Data Breach #1: US Election Board Systems
Personal data of voters stolen by a teenager
SQL Injection
Understanding the data breach
Was it an Anonymous hacker lurking
in the shadows?
Script kiddie ALERT!
Freely available tools and scripts used for the attack
A user submits his
credentials using
POST parameters.
The parameters are appended
to a database query string that
is submitted to the database.
The session cookie is
returned to the browser;
the user is now logged in.
Client Web
Server
DB Server
John
Doe
Username: John, Password: Doe
SELECT * FROM Users
WHERE Username = “John”
AND Password = “Doe”
Scenario 1: Normal authentication workflow
The credentials are valid and
the appropriate record is
returned to the web server.
Understanding the security vulnerability
A user submits his
credentials using
POST parameters.
The parameters are appended
to a database query string that
is submitted to the database.
The session cookie is
returned to the browser;
the user is now logged in.
Client Web
Server
DB Server
John
Doe
Username: John, Password: Doe
SELECT * FROM Users
WHERE Username = “John”
AND Password = “Doe”
Returned 1 Row
(‘John’, ‘Doe’, ‘Admin’)
Set-cookie: sessionid=
FUHOJFB0I4BW121X7281
Scenario 1: Normal authentication workflow
The credentials are valid and
the appropriate record is
returned to the web server.
Understanding the security vulnerability
Understanding the security vulnerability
SELECT * FROM Users WHERE
Username = ‘admin’ AND
Password = ‘abc’ OR 1=1;Username: admin, Password: abc’ OR 1=1;
Web
Server
DB Server
admin
abc’ OR 1=1;
Scenario 2: Authentication bypass
The submitted input changes the
logic of the query. Because of the
always true condition, the
password condition will be
ignored!
The session cookie is
returned to the browser;
the attacker is now
logged in as
administrator.
The vulnerability is exploited
in order to gain control to an
account without providing a
valid password.
An attacker submits input
values that will take
advantage of the query.
Understanding the security vulnerability
SELECT * FROM Users WHERE
Username = ‘admin’ AND
Password = ‘abc’ OR 1=1;Username: admin, Password: abc’ OR 1=1;
Web
Server
DB Server
admin
Returned 1 Row
(‘admin’, ‘John’, ‘admin’)
Set-cookie: jsessionid=
FUHOJFB0I4BW121X7281
abc’ OR 1=1;
Scenario 2: Authentication bypass
The submitted input changes the
logic of the query. Because of the
always true condition, the
password condition will be
ignored!
The session cookie is
returned to the browser;
the attacker is now
logged in as
administrator.
The vulnerability is exploited
in order to gain control to an
account without providing a
valid password.
An attacker submits input
values that will take
advantage of the query.
Realising the impact
Altered data such as balance and transaction
information could cause repudiation issues.
System unavailability could cause
revenue and reputation loss.
Account and private data theft could
damage reputation and credibility,
causing customer and revenue loss.
Preventing the mistake
Never concatenate user-controllable input with application
SQL to form the query sent to the database.
Consider GET and POST parameters, Cookies and other HTTP headers.
Use parameterized queries.
All of the popular development frameworks provide support for
secure construction of database queries.
insert_user_query = "INSERT INTO users (name, age, gender) VALUES (“
+ request_user_name + “,” + request_user_age
+ “)";
insert_user = db.prepare(insert_user_query)
insert_user.execute()
insert_user = db.prepare "INSERT INTO users (name, age, gender) VALUES (?, ?)"
insert_user.execute(request_user_name, request_user_age)
Preventing the mistake
In addition, apply white-list validation on all user input.
Consider GET and POST parameters, Cookies and other HTTP headers.
Apply the least privilege principle on the database users.
How easy is it to exploit SQL injection?
Follow along on your computer and find out!
> Data Breach #2: Facebook Access Tokens
50,000,000 accounts affected
Access tokens exposed that keep users logged into Facebook
Understanding the data breach
Do you have a login system in your applications?
cookies && sessions
Insecure Session Management
Understanding session management
What are cookies?
HTTP is a stateless protocol.
Cookies can be used to track a
user’s state by storing values
related to the user’s actions.
These cookie values are sent to
and from the server and are
stored in the client’s browser.
When are cookies used?
Cookies can be used to store an
online shopping cart or browsing
activities. Another usage are
authentication cookies, which
store the user’s session
information to determine
whether a user is logged in and
which privileges are assigned to
that user.
Set-cookie: user=johndoe
Cookie: user=johndoe
How are cookies protected?
Certain flags can be added when
setting a cookie to limit its usage:
• Secure – Avoid transmission
over an insecure channel.
• HttpOnly – Don’t let JavaScript
read cookie value.
• Domain – Set the domain for
which the cookie is available.
• Path – Set subfolders and
pages for which the cookie is
available.
• Expires – Determine when the
cookie should be deleted.
Understanding the security vulnerability
An attacker logs into a site.
The site uses a simple
increment to generate
session IDs.
The attacker, noticing the
predictability of the ID
generation, deduces new ID’s,
which he uses to browse back to
the site.
By being able to predict
session ID’s he is able to
impersonate the
authenticated user and is
allowed full access to the
user’s account.
After a few attempts, the attacker
finds a session ID that is associated
with another authenticated user.
Web
Application
Cookie:
sessionID=1234
Weak session token
generation
Authenticated
User
Understanding the security vulnerability
An attacker logs into a site.
The site uses a simple
increment to generate
session IDs.
The attacker, noticing the
predictability of the ID
generation, deduces new ID’s,
which he uses to browse back to
the site.
By being able to predict
session ID’s he is able to
impersonate the
authenticated user and is
allowed full access to the
user’s account.
After a few attempts, the attacker
finds a session ID that is associated
with another authenticated user.
Web
Application
Cookie:
sessionID=1235
Cookie:
sessionID=1234
Weak session token
generation
Authenticated
User
Understanding the security vulnerability
An attacker logs into a site.
The site uses a simple
increment to generate
session IDs.
The attacker, noticing the
predictability of the ID
generation, deduces new ID’s,
which he uses to browse back to
the site.
By being able to predict
session ID’s he is able to
impersonate the
authenticated user and is
allowed full access to the
user’s account.
After a few attempts, the attacker
finds a session ID that is associated
with another authenticated user.
Web
Application
Cookie:
sessionID=1235
Cookie:
sessionID=1234
Weak session token
generation
Cookie: sessionID=1234
Authenticated
User
Welcome ‘User’!
Understanding the security vulnerability
An attacker browses to a
site (without logging in)
and is assigned a session
ID. He wants to trick a
victim into using this same
session ID.
A link to the login page is sent to
the victim. The link contains the
session ID of the attacker. The
victim is tricked into clicking the
link.
The attacker resubmits a
request with the session ID
which is now associated with
the authenticated victim. He has
now access to the victim’s
account.
The victim logs in and,
because of weak session
management, is assigned the
session ID provided by the
attacker!
Web
Application
Session fixation
Set-Cookie: sessionID=E34G0JS
Cookie: sessionID=E34G0JS
Understanding the security vulnerability
Please update your password:
GET /login?SESSIONID=E34G0JS
An attacker browses to a
site (without logging in)
and is assigned a session
ID. He wants to trick a
victim into using this same
session ID.
A link to the login page is sent to
the victim. The link contains the
session ID of the attacker. The
victim is tricked into clicking the
link.
The attacker resubmits a
request with the session ID
which is now associated with
the authenticated victim. He has
now access to the victim’s
account.
The victim logs in and,
because of weak session
management, is assigned the
session ID provided by the
attacker!
Web
Application
Session fixation
Victim
Set-Cookie: sessionID=E34G0JS
Set-Cookie: sessionID=E34G0JS
Cookie: sessionID=E34G0JS
Cookie: sessionID=E34G0JS
Understanding the security vulnerability
Please update your password:
GET /login?SESSIONID=E34G0JS
An attacker browses to a
site (without logging in)
and is assigned a session
ID. He wants to trick a
victim into using this same
session ID.
A link to the login page is sent to
the victim. The link contains the
session ID of the attacker. The
victim is tricked into clicking the
link.
The attacker resubmits a
request with the session ID
which is now associated with
the authenticated victim. He has
now access to the victim’s
account.
The victim logs in and,
because of weak session
management, is assigned the
session ID provided by the
attacker!
Web
Application
Session fixation
Victim
Set-Cookie: sessionID=E34G0JS
Set-Cookie: sessionID=E34G0JS
Cookie: sessionID=E34G0JS
GET /profile?SESSIONID=E34G0JS
Welcome ‘Victim’
Cookie: sessionID=E34G0JS
Realizing the impact
Weak session management allows attacks on
the session ID. Having a user’s session ID is
basically the same as getting that user’s login
and password.
A stolen administrator account could lead to
disruption of the website, causing loss of customers
and revenue.
Due to account theft, sensitive end-user
(customer) data could be stolen, leading to
reputational damage and revenue loss
Preventing the mistake
Session ID properties must be secure.
Unpredictable, time limited, single session.
Use session management features provided by
your development framework.
Store sessions IDs in cookies.
Protect session cookies appropriately.
Expiry timestamp, path, secure flag, invalidate on logout.
Secure the transport layer.
See “Insufficient Transport Layer Protection”
How easy is it to exploit session
management vulnerabilities?
Follow along on your computer and find out!
> Lessons learnt
Secure coding commandments
Uplift your security game
Classroom training
eLearning
Play the long game
Dependency
management
Create secure coding
guidelines
Build relationship with
application security team
01 02 03
Are you ready to be a superhero?

More Related Content

What's hot

Seminar2015Bilic_Nicole
Seminar2015Bilic_NicoleSeminar2015Bilic_Nicole
Seminar2015Bilic_Nicole
Nicole Bili?
 
Stateless authentication with OAuth 2 and JWT - JavaZone 2015
Stateless authentication with OAuth 2 and JWT - JavaZone 2015Stateless authentication with OAuth 2 and JWT - JavaZone 2015
Stateless authentication with OAuth 2 and JWT - JavaZone 2015
Alvaro Sanchez-Mariscal
 

What's hot (19)

OAuth2 & OpenID Connect
OAuth2 & OpenID ConnectOAuth2 & OpenID Connect
OAuth2 & OpenID Connect
 
Protecting web APIs with OAuth 2.0
Protecting web APIs with OAuth 2.0Protecting web APIs with OAuth 2.0
Protecting web APIs with OAuth 2.0
 
Stateless authentication for microservices - GR8Conf 2015
Stateless authentication for microservices - GR8Conf 2015Stateless authentication for microservices - GR8Conf 2015
Stateless authentication for microservices - GR8Conf 2015
 
Stateless authentication for microservices - Spring I/O 2015
Stateless authentication for microservices  - Spring I/O 2015Stateless authentication for microservices  - Spring I/O 2015
Stateless authentication for microservices - Spring I/O 2015
 
Seminar2015Bilic_Nicole
Seminar2015Bilic_NicoleSeminar2015Bilic_Nicole
Seminar2015Bilic_Nicole
 
Owasp top 10 2013
Owasp top 10 2013Owasp top 10 2013
Owasp top 10 2013
 
Authentication techniques
Authentication techniquesAuthentication techniques
Authentication techniques
 
Stateless authentication for microservices
Stateless authentication for microservicesStateless authentication for microservices
Stateless authentication for microservices
 
Hacking the Web
Hacking the WebHacking the Web
Hacking the Web
 
2013 OWASP Top 10
2013 OWASP Top 102013 OWASP Top 10
2013 OWASP Top 10
 
Stateless token-based authentication for pure front-end applications
Stateless token-based authentication for pure front-end applicationsStateless token-based authentication for pure front-end applications
Stateless token-based authentication for pure front-end applications
 
Intrusion detection architecture for different network attacks
Intrusion detection architecture for different network attacksIntrusion detection architecture for different network attacks
Intrusion detection architecture for different network attacks
 
Identity theft blue4it nljug
Identity theft blue4it nljugIdentity theft blue4it nljug
Identity theft blue4it nljug
 
Securing your APIs with OAuth, OpenID, and OpenID Connect
Securing your APIs with OAuth, OpenID, and OpenID ConnectSecuring your APIs with OAuth, OpenID, and OpenID Connect
Securing your APIs with OAuth, OpenID, and OpenID Connect
 
From 0 to Spring Security 4.0
From 0 to Spring Security 4.0From 0 to Spring Security 4.0
From 0 to Spring Security 4.0
 
Stateless authentication with OAuth 2 and JWT - JavaZone 2015
Stateless authentication with OAuth 2 and JWT - JavaZone 2015Stateless authentication with OAuth 2 and JWT - JavaZone 2015
Stateless authentication with OAuth 2 and JWT - JavaZone 2015
 
Modern Security with OAuth 2.0 and JWT and Spring by Dmitry Buzdin
Modern Security with OAuth 2.0 and JWT and Spring by Dmitry BuzdinModern Security with OAuth 2.0 and JWT and Spring by Dmitry Buzdin
Modern Security with OAuth 2.0 and JWT and Spring by Dmitry Buzdin
 
O auth2 with angular js
O auth2 with angular jsO auth2 with angular js
O auth2 with angular js
 
Paul Lammertsma: Account manager & sync
Paul Lammertsma: Account manager & syncPaul Lammertsma: Account manager & sync
Paul Lammertsma: Account manager & sync
 

Similar to Tales of modern day data breaches - a web security guide for developers

Andrews whitakrer lecture18-security.ppt
Andrews whitakrer lecture18-security.pptAndrews whitakrer lecture18-security.ppt
Andrews whitakrer lecture18-security.ppt
SilverGold16
 

Similar to Tales of modern day data breaches - a web security guide for developers (20)

Threat modeling driven security testing
Threat modeling driven security testingThreat modeling driven security testing
Threat modeling driven security testing
 
Secure Code Warrior - Authentication
Secure Code Warrior - AuthenticationSecure Code Warrior - Authentication
Secure Code Warrior - Authentication
 
Session fixation
Session fixationSession fixation
Session fixation
 
Oauth 2.0 Security Considerations for Client Applications
Oauth 2.0 Security Considerations for Client ApplicationsOauth 2.0 Security Considerations for Client Applications
Oauth 2.0 Security Considerations for Client Applications
 
How to Find and Fix Broken Authentication Vulnerability
How to Find and Fix Broken Authentication VulnerabilityHow to Find and Fix Broken Authentication Vulnerability
How to Find and Fix Broken Authentication Vulnerability
 
Secure Code Warrior - NoSQL injection
Secure Code Warrior - NoSQL injectionSecure Code Warrior - NoSQL injection
Secure Code Warrior - NoSQL injection
 
Andrews whitakrer lecture18-security.ppt
Andrews whitakrer lecture18-security.pptAndrews whitakrer lecture18-security.ppt
Andrews whitakrer lecture18-security.ppt
 
Owasp top 10
Owasp top 10Owasp top 10
Owasp top 10
 
Module 4 (enumeration)
Module 4 (enumeration)Module 4 (enumeration)
Module 4 (enumeration)
 
06 application security fundamentals - part 2 - security mechanisms - sessi...
06   application security fundamentals - part 2 - security mechanisms - sessi...06   application security fundamentals - part 2 - security mechanisms - sessi...
06 application security fundamentals - part 2 - security mechanisms - sessi...
 
Secure Code Warrior - Cookies and sessions
Secure Code Warrior - Cookies and sessionsSecure Code Warrior - Cookies and sessions
Secure Code Warrior - Cookies and sessions
 
Security Testing Training With Examples
Security Testing Training With ExamplesSecurity Testing Training With Examples
Security Testing Training With Examples
 
The Immune System of Internet
The Immune System of InternetThe Immune System of Internet
The Immune System of Internet
 
Module 1 - Information Assurance and Security 2.pdf
Module 1 - Information Assurance and Security 2.pdfModule 1 - Information Assurance and Security 2.pdf
Module 1 - Information Assurance and Security 2.pdf
 
OWASP TOP 10 by Team xbios
OWASP TOP 10  by Team xbiosOWASP TOP 10  by Team xbios
OWASP TOP 10 by Team xbios
 
Securing the Web @RivieraDev2016
Securing the Web @RivieraDev2016Securing the Web @RivieraDev2016
Securing the Web @RivieraDev2016
 
a famework for analyzing template security and privacy in biometric authenti...
 a famework for analyzing template security and privacy in biometric authenti... a famework for analyzing template security and privacy in biometric authenti...
a famework for analyzing template security and privacy in biometric authenti...
 
Dynamic watermarking
Dynamic watermarkingDynamic watermarking
Dynamic watermarking
 
Mit 2014 introduction to open id connect and o-auth 2
Mit 2014   introduction to open id connect and o-auth 2Mit 2014   introduction to open id connect and o-auth 2
Mit 2014 introduction to open id connect and o-auth 2
 
encryption ppt
encryption pptencryption ppt
encryption ppt
 

Recently uploaded

TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
mohitmore19
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
VishalKumarJha10
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
Health
 

Recently uploaded (20)

The Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdfThe Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
 
Pharm-D Biostatistics and Research methodology
Pharm-D Biostatistics and Research methodologyPharm-D Biostatistics and Research methodology
Pharm-D Biostatistics and Research methodology
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
BUS PASS MANGEMENT SYSTEM USING PHP.pptx
BUS PASS MANGEMENT SYSTEM USING PHP.pptxBUS PASS MANGEMENT SYSTEM USING PHP.pptx
BUS PASS MANGEMENT SYSTEM USING PHP.pptx
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
Sector 18, Noida Call girls :8448380779 Model Escorts | 100% verified
Sector 18, Noida Call girls :8448380779 Model Escorts | 100% verifiedSector 18, Noida Call girls :8448380779 Model Escorts | 100% verified
Sector 18, Noida Call girls :8448380779 Model Escorts | 100% verified
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 

Tales of modern day data breaches - a web security guide for developers

  • 1. Tales of modern day data breaches - a web security guide for developers Jaap Karan Singh jaap@scw.io Co-Founder & Chief Singh, Secure Code Warrior
  • 2. > Today’s challenges with software security
  • 3. Of data breaches caused by software vulnerability ~ Verizon 21% Source: Verizon, Data Breach Report, 2018 (but in there the last 10 years)
  • 4. of newly scanned applications had SQL injections over the past 5 yrs ~ Cisco 1 in 3 Source: Cybersecurity as a Growth Advantage, Cisco, 2016
  • 5. > Data Breach #1: US Election Board Systems
  • 6. Personal data of voters stolen by a teenager SQL Injection Understanding the data breach
  • 7. Was it an Anonymous hacker lurking in the shadows? Script kiddie ALERT! Freely available tools and scripts used for the attack
  • 8. A user submits his credentials using POST parameters. The parameters are appended to a database query string that is submitted to the database. The session cookie is returned to the browser; the user is now logged in. Client Web Server DB Server John Doe Username: John, Password: Doe SELECT * FROM Users WHERE Username = “John” AND Password = “Doe” Scenario 1: Normal authentication workflow The credentials are valid and the appropriate record is returned to the web server. Understanding the security vulnerability
  • 9. A user submits his credentials using POST parameters. The parameters are appended to a database query string that is submitted to the database. The session cookie is returned to the browser; the user is now logged in. Client Web Server DB Server John Doe Username: John, Password: Doe SELECT * FROM Users WHERE Username = “John” AND Password = “Doe” Returned 1 Row (‘John’, ‘Doe’, ‘Admin’) Set-cookie: sessionid= FUHOJFB0I4BW121X7281 Scenario 1: Normal authentication workflow The credentials are valid and the appropriate record is returned to the web server. Understanding the security vulnerability
  • 10. Understanding the security vulnerability SELECT * FROM Users WHERE Username = ‘admin’ AND Password = ‘abc’ OR 1=1;Username: admin, Password: abc’ OR 1=1; Web Server DB Server admin abc’ OR 1=1; Scenario 2: Authentication bypass The submitted input changes the logic of the query. Because of the always true condition, the password condition will be ignored! The session cookie is returned to the browser; the attacker is now logged in as administrator. The vulnerability is exploited in order to gain control to an account without providing a valid password. An attacker submits input values that will take advantage of the query.
  • 11. Understanding the security vulnerability SELECT * FROM Users WHERE Username = ‘admin’ AND Password = ‘abc’ OR 1=1;Username: admin, Password: abc’ OR 1=1; Web Server DB Server admin Returned 1 Row (‘admin’, ‘John’, ‘admin’) Set-cookie: jsessionid= FUHOJFB0I4BW121X7281 abc’ OR 1=1; Scenario 2: Authentication bypass The submitted input changes the logic of the query. Because of the always true condition, the password condition will be ignored! The session cookie is returned to the browser; the attacker is now logged in as administrator. The vulnerability is exploited in order to gain control to an account without providing a valid password. An attacker submits input values that will take advantage of the query.
  • 12. Realising the impact Altered data such as balance and transaction information could cause repudiation issues. System unavailability could cause revenue and reputation loss. Account and private data theft could damage reputation and credibility, causing customer and revenue loss.
  • 13. Preventing the mistake Never concatenate user-controllable input with application SQL to form the query sent to the database. Consider GET and POST parameters, Cookies and other HTTP headers. Use parameterized queries. All of the popular development frameworks provide support for secure construction of database queries. insert_user_query = "INSERT INTO users (name, age, gender) VALUES (“ + request_user_name + “,” + request_user_age + “)"; insert_user = db.prepare(insert_user_query) insert_user.execute() insert_user = db.prepare "INSERT INTO users (name, age, gender) VALUES (?, ?)" insert_user.execute(request_user_name, request_user_age)
  • 14. Preventing the mistake In addition, apply white-list validation on all user input. Consider GET and POST parameters, Cookies and other HTTP headers. Apply the least privilege principle on the database users.
  • 15. How easy is it to exploit SQL injection? Follow along on your computer and find out!
  • 16. > Data Breach #2: Facebook Access Tokens
  • 17. 50,000,000 accounts affected Access tokens exposed that keep users logged into Facebook Understanding the data breach
  • 18. Do you have a login system in your applications? cookies && sessions Insecure Session Management
  • 19. Understanding session management What are cookies? HTTP is a stateless protocol. Cookies can be used to track a user’s state by storing values related to the user’s actions. These cookie values are sent to and from the server and are stored in the client’s browser. When are cookies used? Cookies can be used to store an online shopping cart or browsing activities. Another usage are authentication cookies, which store the user’s session information to determine whether a user is logged in and which privileges are assigned to that user. Set-cookie: user=johndoe Cookie: user=johndoe How are cookies protected? Certain flags can be added when setting a cookie to limit its usage: • Secure – Avoid transmission over an insecure channel. • HttpOnly – Don’t let JavaScript read cookie value. • Domain – Set the domain for which the cookie is available. • Path – Set subfolders and pages for which the cookie is available. • Expires – Determine when the cookie should be deleted.
  • 20. Understanding the security vulnerability An attacker logs into a site. The site uses a simple increment to generate session IDs. The attacker, noticing the predictability of the ID generation, deduces new ID’s, which he uses to browse back to the site. By being able to predict session ID’s he is able to impersonate the authenticated user and is allowed full access to the user’s account. After a few attempts, the attacker finds a session ID that is associated with another authenticated user. Web Application Cookie: sessionID=1234 Weak session token generation Authenticated User
  • 21. Understanding the security vulnerability An attacker logs into a site. The site uses a simple increment to generate session IDs. The attacker, noticing the predictability of the ID generation, deduces new ID’s, which he uses to browse back to the site. By being able to predict session ID’s he is able to impersonate the authenticated user and is allowed full access to the user’s account. After a few attempts, the attacker finds a session ID that is associated with another authenticated user. Web Application Cookie: sessionID=1235 Cookie: sessionID=1234 Weak session token generation Authenticated User
  • 22. Understanding the security vulnerability An attacker logs into a site. The site uses a simple increment to generate session IDs. The attacker, noticing the predictability of the ID generation, deduces new ID’s, which he uses to browse back to the site. By being able to predict session ID’s he is able to impersonate the authenticated user and is allowed full access to the user’s account. After a few attempts, the attacker finds a session ID that is associated with another authenticated user. Web Application Cookie: sessionID=1235 Cookie: sessionID=1234 Weak session token generation Cookie: sessionID=1234 Authenticated User Welcome ‘User’!
  • 23. Understanding the security vulnerability An attacker browses to a site (without logging in) and is assigned a session ID. He wants to trick a victim into using this same session ID. A link to the login page is sent to the victim. The link contains the session ID of the attacker. The victim is tricked into clicking the link. The attacker resubmits a request with the session ID which is now associated with the authenticated victim. He has now access to the victim’s account. The victim logs in and, because of weak session management, is assigned the session ID provided by the attacker! Web Application Session fixation Set-Cookie: sessionID=E34G0JS Cookie: sessionID=E34G0JS
  • 24. Understanding the security vulnerability Please update your password: GET /login?SESSIONID=E34G0JS An attacker browses to a site (without logging in) and is assigned a session ID. He wants to trick a victim into using this same session ID. A link to the login page is sent to the victim. The link contains the session ID of the attacker. The victim is tricked into clicking the link. The attacker resubmits a request with the session ID which is now associated with the authenticated victim. He has now access to the victim’s account. The victim logs in and, because of weak session management, is assigned the session ID provided by the attacker! Web Application Session fixation Victim Set-Cookie: sessionID=E34G0JS Set-Cookie: sessionID=E34G0JS Cookie: sessionID=E34G0JS Cookie: sessionID=E34G0JS
  • 25. Understanding the security vulnerability Please update your password: GET /login?SESSIONID=E34G0JS An attacker browses to a site (without logging in) and is assigned a session ID. He wants to trick a victim into using this same session ID. A link to the login page is sent to the victim. The link contains the session ID of the attacker. The victim is tricked into clicking the link. The attacker resubmits a request with the session ID which is now associated with the authenticated victim. He has now access to the victim’s account. The victim logs in and, because of weak session management, is assigned the session ID provided by the attacker! Web Application Session fixation Victim Set-Cookie: sessionID=E34G0JS Set-Cookie: sessionID=E34G0JS Cookie: sessionID=E34G0JS GET /profile?SESSIONID=E34G0JS Welcome ‘Victim’ Cookie: sessionID=E34G0JS
  • 26. Realizing the impact Weak session management allows attacks on the session ID. Having a user’s session ID is basically the same as getting that user’s login and password. A stolen administrator account could lead to disruption of the website, causing loss of customers and revenue. Due to account theft, sensitive end-user (customer) data could be stolen, leading to reputational damage and revenue loss
  • 27. Preventing the mistake Session ID properties must be secure. Unpredictable, time limited, single session. Use session management features provided by your development framework. Store sessions IDs in cookies. Protect session cookies appropriately. Expiry timestamp, path, secure flag, invalidate on logout. Secure the transport layer. See “Insufficient Transport Layer Protection”
  • 28. How easy is it to exploit session management vulnerabilities? Follow along on your computer and find out!
  • 31. Uplift your security game Classroom training eLearning
  • 32. Play the long game Dependency management Create secure coding guidelines Build relationship with application security team 01 02 03
  • 33. Are you ready to be a superhero?