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

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Recently uploaded (20)

Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
AI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by AnitarajAI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by Anitaraj
 
API Governance and Monetization - The evolution of API governance
API Governance and Monetization -  The evolution of API governanceAPI Governance and Monetization -  The evolution of API governance
API Governance and Monetization - The evolution of API governance
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Decarbonising Commercial Real Estate: The Role of Operational Performance
Decarbonising Commercial Real Estate: The Role of Operational PerformanceDecarbonising Commercial Real Estate: The Role of Operational Performance
Decarbonising Commercial Real Estate: The Role of Operational Performance
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
 
Choreo: Empowering the Future of Enterprise Software Engineering
Choreo: Empowering the Future of Enterprise Software EngineeringChoreo: Empowering the Future of Enterprise Software Engineering
Choreo: Empowering the Future of Enterprise Software Engineering
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Stronger Together: Developing an Organizational Strategy for Accessible Desig...
Stronger Together: Developing an Organizational Strategy for Accessible Desig...Stronger Together: Developing an Organizational Strategy for Accessible Desig...
Stronger Together: Developing an Organizational Strategy for Accessible Desig...
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
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
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 

Crafting Secure Software - DDDEU 2019