SlideShare a Scribd company logo
1 of 66
Download to read offline
Crafting
Secure
Software
WhoamI?
Craftsman at Arolla
Session by : Yvan Phélizot (yvan.phelizot@arolla.fr)
@cotonne / cotonne.github.io
BBL : http://www.brownbaglunch.fr/baggers.html#yvan-phelizot
Download
https://goo.gl/ryc8NB
Who are you?
A promising business!
The VHS is back!!
Netflipster
Registration
DB
Booking
Basic functionalities
Registration ----
Name:
tom
Password:
pouce
Connection ---
Name:
tom
Password:
pouce
You are connected as tom
Films:
1) Harry Potter and the
Philosopher's Stone
...
Selection:
1
Quantity:
1
Your command of 1 VHS ( Harry
Potter and the Philosopher's
Stone ) will be sent soon
Errors (example)
Registration ----
Name:
tom
Utilisateur existant
Connection ---
Name:
tom
Password:
pouce
Mot de passe invalide
Films:
1) Harry Potter and the
Philosopher's Stone
...
Selection:
10
Le VHS 10 a été trouvé 0 fois
Time to deploy
Netflipster!
Hey! Wait a
minute...
We need you!
What if....
I used tom^1B[41m as a login?
XSS
Rule #1...
Almost...
Rule #1 : Validate all inputs
// read username
if(!username.matches("<un format>")) {
throw new Error();
}
// do something with username
// read username
// do something with username
Never happens before
What if....
I used 1’ or ‘1’=’1 as a password?
Sensitive
Data
Exposure
Rule #2 : Fail securely
// read password
try {
// use password in SQL query
} catch (e) {
// Sorry, smth went wrong!
}
// read password
// use password in SQL
query
What if....
I used 1’ or ‘1’=’1 as a password?
SQL
injection
Rule #3 : Sanitize output
// read password
String password = "";
password = password.replaceAll("'", "");
// use sanitized password in SQL query
// read password
// use password in SQL query
An easy one...
Let’s fix Netflipster
Let’s fix security holes
1) login = tom^1B[41m ⇒ Validate all inputs (only letters)
2) password: ‘ or ‘1‘=‘1 ⇒ Fail Securely (no exception)
3) password: ‘ or ‘1‘=‘1 ⇒ Sanitize data (remove quote)
This is secure coding
Hey ...
- Why not testing that we correctly enforce those
requirements?
- Why not trying to reduce our code to the minimum?
- Why not keeping track of those exchanges?
Any idea?
Secure TDD
Test-Driven Security
Recommended
reading
Is it secure?
What if....
I used
1||char(39)||or||char(39)1char(39)=ch
ar(39)1 as a password?
Don’t build your own tool!
Use best practices!
For SQL : Prepared Statement
Others : Sanitize functions
Is it secure?
What if....
I used -1 as a quantity ?
Fix it!
We are losing money!
What if....
I used 2147483647 as a quantity ?
Why ?
We lost business rules
Hey, wait!
Who is absolutely sure
that the code always complies with those
rules?
Step 1 : make implicit concept explicit
class User {
final String username;
}
String username
Step 2 : ensure compliance with rules… ALWAYS
class User {
final Username username;
final Password password;
}
class Username {
// Validation control here!
// Immutability ⇒ checking
state at creation/modification
}
Step 2 : Let’s continue with...
1) Extract behaviors into separate classes
2) Wrap primitives into meaningful classes
3) Combine them into entities
4) Ensure
a) Immutability
b) Consistency
5) Define domains and trusted boundaries
Let’s reinforce
Netflipster
Define
QUANTITY
Add
ADVERSARIAL
UNIT TESTS
Recommended
reading
Boundaries
BANK BILLING
PAYMENT
CONFIRM
PAYMENT
DDD
+
Security
Explicit elements of
the domain
Enforcing business
rules
Clear definition of
boundaries
Is it secure?
Is this normal?
Booking(string userId, int quantity,
string vhsId)
Booking(string vhsId, int quantity, string
userId)
Invalid<String> ⇒ Valid<String> ⇒
Valid<Result>
bug zero kata
Is it secure?
What if....
I enter 0 as a VHS ID?
Insecure
Direct Object
References
Rule #4 : Fail fast
// read id
if(!identifiers.contains(vhsId)){
return;
}
// book a VHS
// read id
// book a VHS
Complete Mediation
Hidden != Secure
Security by Obscurity
Can we design
our application in
a secure way?
10 rules of Secure by Design
1) Trust with caution/Check
everything
2) Protect others
3) KISS
4) Default Deny
5) Learn to learn
6) Fail Securely/Fast
7) Least privilege
8) Separation of duties
9) Fix security holes
10) Practices defense in
depth
Levels to security
● Level -1: Nope
● Level 0: Craft
● Level 1: Security guidelines
● Level 2: Secure Coding
● Level 3: Crafting Secure Software (TDS, Strongly Typed)
● Level 4: Secure by (DD-)Design
● Level 5: Secure by Design
You can’t have
SECURITY
without
QUALITY
Clean Code Secure Code
Remember, even the most secure
design is rendered by a low-quality and
insecure implementation, regardless of
the number of security features the
product employs
Crafting software
…
helps security
Merci!
Questions?
Session by : Yvan Phélizot
(yvan.phelizot@arolla.fr)
@yoda044 / cotonne.github.io
BBL :
http://www.brownbaglunch.fr/baggers.html#
yvan-phelizot

More Related Content

Similar to Crafting Secure Software - DDDEU 2019

Threat stack aws
Threat stack awsThreat stack aws
Threat stack aws
Jen Andre
 
Dylan Butler & Oliver Hager - Building a cross platform cryptocurrency app
Dylan Butler & Oliver Hager - Building a cross platform cryptocurrency appDylan Butler & Oliver Hager - Building a cross platform cryptocurrency app
Dylan Butler & Oliver Hager - Building a cross platform cryptocurrency app
DevCamp Campinas
 
支撐英雄聯盟戰績網的那條巨蟒
支撐英雄聯盟戰績網的那條巨蟒支撐英雄聯盟戰績網的那條巨蟒
支撐英雄聯盟戰績網的那條巨蟒
Toki Kanno
 
Post esst slides v18
Post esst slides v18Post esst slides v18
Post esst slides v18
Scott Carrey
 
Изучаем миллиард состояний программы на уровне профи. Как разработать быстрый...
Изучаем миллиард состояний программы на уровне профи. Как разработать быстрый...Изучаем миллиард состояний программы на уровне профи. Как разработать быстрый...
Изучаем миллиард состояний программы на уровне профи. Как разработать быстрый...
Positive Hack Days
 

Similar to Crafting Secure Software - DDDEU 2019 (20)

DEFCON 23 - Ian Latter - remote access the apt
DEFCON 23 - Ian Latter - remote access the aptDEFCON 23 - Ian Latter - remote access the apt
DEFCON 23 - Ian Latter - remote access the apt
 
Pre-Quiz Symantec Endpoint Encryption
Pre-Quiz Symantec Endpoint EncryptionPre-Quiz Symantec Endpoint Encryption
Pre-Quiz Symantec Endpoint Encryption
 
Threat stack aws
Threat stack awsThreat stack aws
Threat stack aws
 
Dylan Butler & Oliver Hager - Building a cross platform cryptocurrency app
Dylan Butler & Oliver Hager - Building a cross platform cryptocurrency appDylan Butler & Oliver Hager - Building a cross platform cryptocurrency app
Dylan Butler & Oliver Hager - Building a cross platform cryptocurrency app
 
⛳️ Votre API passe-t-elle le contrôle technique ?
⛳️ Votre API passe-t-elle le contrôle technique ?⛳️ Votre API passe-t-elle le contrôle technique ?
⛳️ Votre API passe-t-elle le contrôle technique ?
 
Ppsp icassp17v10
Ppsp icassp17v10Ppsp icassp17v10
Ppsp icassp17v10
 
支撐英雄聯盟戰績網的那條巨蟒
支撐英雄聯盟戰績網的那條巨蟒支撐英雄聯盟戰績網的那條巨蟒
支撐英雄聯盟戰績網的那條巨蟒
 
Post esst slides v18
Post esst slides v18Post esst slides v18
Post esst slides v18
 
Unleashing Real-World Simulations: A Python Tutorial by Avjinder Kaler
Unleashing Real-World Simulations: A Python Tutorial by Avjinder KalerUnleashing Real-World Simulations: A Python Tutorial by Avjinder Kaler
Unleashing Real-World Simulations: A Python Tutorial by Avjinder Kaler
 
Sensepost assessment automation
Sensepost assessment automationSensepost assessment automation
Sensepost assessment automation
 
Web3 + scams = It's a match
Web3 + scams = It's a matchWeb3 + scams = It's a match
Web3 + scams = It's a match
 
Destruction, Decapods and Doughnuts: Continuous Delivery for Audio & Video Fa...
Destruction, Decapods and Doughnuts: Continuous Delivery for Audio & Video Fa...Destruction, Decapods and Doughnuts: Continuous Delivery for Audio & Video Fa...
Destruction, Decapods and Doughnuts: Continuous Delivery for Audio & Video Fa...
 
Real-World WebAppSec Flaws - Examples and Countermeasues
Real-World WebAppSec Flaws - Examples and CountermeasuesReal-World WebAppSec Flaws - Examples and Countermeasues
Real-World WebAppSec Flaws - Examples and Countermeasues
 
Timeshift Everything, Miss Nothing - Mashup your PVR with Kamaelia
Timeshift Everything, Miss Nothing - Mashup your PVR with KamaeliaTimeshift Everything, Miss Nothing - Mashup your PVR with Kamaelia
Timeshift Everything, Miss Nothing - Mashup your PVR with Kamaelia
 
Passwords & security
Passwords & securityPasswords & security
Passwords & security
 
nullcon 2011 - Chupa Rustam
nullcon 2011 - Chupa Rustamnullcon 2011 - Chupa Rustam
nullcon 2011 - Chupa Rustam
 
Exploring billion states of a program like a pro. How to cook your own fast a...
Exploring billion states of a program like a pro. How to cook your own fast a...Exploring billion states of a program like a pro. How to cook your own fast a...
Exploring billion states of a program like a pro. How to cook your own fast a...
 
Изучаем миллиард состояний программы на уровне профи. Как разработать быстрый...
Изучаем миллиард состояний программы на уровне профи. Как разработать быстрый...Изучаем миллиард состояний программы на уровне профи. Как разработать быстрый...
Изучаем миллиард состояний программы на уровне профи. Как разработать быстрый...
 
Thai Text processing by Transfer Learning using Transformer (Bert)
Thai Text processing by Transfer Learning using Transformer (Bert)Thai Text processing by Transfer Learning using Transformer (Bert)
Thai Text processing by Transfer Learning using Transformer (Bert)
 
Bypassing Secure Boot using Fault Injection
Bypassing Secure Boot using Fault InjectionBypassing Secure Boot using Fault Injection
Bypassing Secure Boot using Fault Injection
 

More from Yvan PHELIZOT (6)

REX CraftConf 2022 / Supply Chain Attack
REX CraftConf 2022 / Supply Chain AttackREX CraftConf 2022 / Supply Chain Attack
REX CraftConf 2022 / Supply Chain Attack
 
Smart XSS fuzzer
Smart XSS fuzzerSmart XSS fuzzer
Smart XSS fuzzer
 
2019 meetup web_sec_crafting_securesoftware
2019 meetup web_sec_crafting_securesoftware2019 meetup web_sec_crafting_securesoftware
2019 meetup web_sec_crafting_securesoftware
 
Arrêtons de perdre du temps #NoEstimates
Arrêtons de perdre du temps #NoEstimatesArrêtons de perdre du temps #NoEstimates
Arrêtons de perdre du temps #NoEstimates
 
50 shades of fizzbuzz v2 - share
50 shades of fizzbuzz   v2 - share50 shades of fizzbuzz   v2 - share
50 shades of fizzbuzz v2 - share
 
How to become a domain expert in no time?
How to become a domain expert in no time?How to become a domain expert in no time?
How to become a domain expert in no time?
 

Recently uploaded

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 

Recently uploaded (20)

Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 

Crafting Secure Software - DDDEU 2019