Let’s get evil – threat
modelling at scale
Jakub Kaluzny
OWASP Poland, 16th Oct 2019
Projects do fail
EffortMoney
Security Scaling
SDLCAutomation
This is about
WHOAMI
JAKUB KALUZNY
• 10 years in IT & Security
• Threat modeling,
DevSecOps, penetration
tests
• Poland, Spain, Australia
• banking, fintech, law, airline,
entertainment, e-commerce
• Speaker at BlackHat,
HackInTheBox, ZeroNights
#whoami
Design Coding Testing Release Maintenance
SDLC process
Weak encryption in web app
Weak encryption in mobile app
Weak encryption in printers
Cost to fix
Cost of a production security bug:
• Incident response = $
• Risk assessment = $
• Fix, test = $
• Ransom, GDPR = $
• Reputation = $
• Stolen data = ?
Cost to fix is not everything
Equifax hack in 2017
Design Coding Testing Release Maintenance
Security testing
• Number of security issues in time
No security testing
• Number of security issues in time
1 round of security testing
PT
• Number of security issues in time
Multiple rounds of security testing
PT PT PT
• Number of security issues in time
Our target - SSDLC
PT PT PT
BUT HOW?
• Number of security issues in time
Isolated round
PT
quality of design
qualityoftesting
Design Coding Testing Release Maintenance
There are tools and services
training
SAST
DAST
SCA VApentesting
IDE plugins
code
review
repo mgrs
checklists
SOE
standards
virtual
patching
WAF
threat
modelling
Design Coding Testing Release Maintenance
What to start with?
training pentesting
threat
modelling
• Quality of coding
• Training
Solution
Training
• Quality of coding
• Secure coding training + onboarding on standards
• Security requirements
• Quality of testing
• Adequate scope / test cases
• Quality of design
• Threat modelling
Waterfall vs Agile – security perspective
Secure
design
Fixing time
Secure
release
Security
testing
Secure
Implementation
Design Coding Testing Release Maintenance
Agile and security
Design Coding Testing Release Maintenance
When does your security team show up?
1 month of a 100-developers company
10
teams
20 sprints
600 user stories
1000+ code changes
3000+ JIRA tickets
Decomposition of user stories
User downloads a list of transactions and their details
Decomposition of user stories
User downloads (a list of transactions) and (their details)
getTransactionsByUser getTransactionDetails
Decomposition of user stories
User downloads (a list of transactions) and (their details)
getTransactionsByUser getTransactionDetails
getTransactionByUser(CONTEXT):
123, 125, 127
getTransactionDetails(123)
getTransactionDetails(124)
Design Coding Testing Release Maintenance
Agile and security
Threat modelling for the rescue
• Factory camera reading license plates
• Setting up physical access control (RFID badges)
• How to detect crawlers?
• Authentication in APIs
Case studies
Threat modeling – evil brainstorming
Threat
actor
Threat
Attack
vector
Who? What? How?
Attack
vector
Security
requirement
Test case
• Generally yes, „secure by design”
Does it work?
Dev/DevOps
Sec
Arch
Functional requirements, design, DFDs
Security requirements
Security testing scope
Risk assessment
Go-live decision
• It ain’t easy
How to make it more Agile
Dev
Sec
Dev
Dev
Dev
Sec DevSecOps
Sec
Which threats to model?
List of user
stories
• Decision
to model
Stories
affecting
security
• Threat
model
Verification
• follow-
up
• Cosmetic changes to report template (colours)
• Add GDPR pop-up
• Update jQuery lib
• Change randomness in reset password link from
rand(1, 1000000) to GUIDv4
• New authentication provider
• Add new report type – list of transactions per user
Examples – decide to model or not
Different wording of user stories
User displays a list of THEIR OWN transactions and details for each of
THEIR OWN transactions.
User downloads a list of transactions and their details
Different wording of recommendation
Update jQuery library to the newest available version with no open
vulnerabilities
Update jQuery library
Threat modeling at scale - Agile
User downloads a list of transactions and their details
Abuser story Security requirement Test cases
Threat modeling at scale - Agile
User downloads a list of transactions and their details
Abuser story Security requirement Test cases
One user downloads
transaction of other
users
Transaction should
belong to the user
from the current
context
Check cross-user data
access control
Threat modeling at scale - Agile
User downloads a list of transactions and their details
Abuser story Security requirement Test cases
One user downloads
transaction of other
users
Transaction should
belong to the user
from the current
context
Check cross-user data
access control
Inject SQL/XML into
ID ???
Execute without auth
???
Threat modeling at scale – base threat models
Abuser story Security requirement Test cases
SOAP API (parent):
User downloads a list of transactions and their details
Threat modeling at scale – base threat models
Abuser story Security requirement Test cases
Execute without auth
Inject XML string
Inject SQL string
Force a cross-site
request
SOAP API (parent):
User downloads a list of transactions and their details
Threat modeling at scale – base threat models
Abuser story Security requirement Test cases
Execute without auth All functions require
auth
Inject XML string External Entities off
Inject SQL string Type casting,
prepared statements
Force a cross-site
request
SameSite cookie flag,
custom request
headers
SOAP API (parent):
User downloads a list of transactions and their details
Threat modeling at scale – base threat models
Abuser story Security requirement Test cases
New RCE CVE Java up-to-date
… Config options: …, …
JAVA APPLICATION (parent):
SOAP API (parent):
User downloads a list of transactions and their details
Adding S to SDLC
Initial
discussions
• Base
threat
models
Stories
affecting
security
• Abuser
stories
Testing
• Security
metric
Responsibilities
Base threat
models
• Security
team
Abuser
stories
• Security
champions
Testing
• Security
team
Threat modeling at scale - examples
User should be able to reset a password.
Abuser story Security requirement Test cases
1. Your e-mail: […]
2. https://example/reset?e-mail=x@y&rnd=12345
3. New pwd: [..], confirm new […]
Threat modeling at scale - examples
Abuser story Security requirement Test cases
Lock other accounts (1) Dictionary attack
Get a copy of e-mail (1) Injection into e-mail
Analyse and guess
contents of reset link
(2)
Use reset link against
another account
(2)
Bypass steps 1, 2 (3)
Change other user’s
password
(3) Injection into pwd
User should be able to reset a password.
Threat modeling at scale - examples
Ad industry. Money withdrawal.
Abuser story Security requirement Test cases
How much do you want to withdraw: […]?
To which of your accounts […] (drop-down list)?
Threat modeling at scale - examples
Ad industry. Money withdrawal.
Abuser story Security requirement Test cases
Withdraw more than
your balance.
Withdraw negative
amount
Select an account
outside the list
Make somebody
withdraw money
CSRF / clickjacking
Threat modeling at scale - examples
VIP airport lounge. Boarding pass QR code reader allowing through
only business class.
Abuser story Security requirement Test cases
Client: (showing boarding pass)
Threat modeling at scale - examples
VIP airport lounge. Boarding pass QR code reader allowing through
only business class.
Abuser story Security requirement Test cases
Use an old business
boarding pass
Use one boarding
pass twice
Use a scan of
boarding pass from
another airport
Modify class in the
QR code
Client: (scans boarding pass)
• Copying invisible code from stackoverflow
• Allowing only trusted dependencies
• We’ve got SAST!
• Regular VA scans
• Presentation clickers
Do abuser stories solve all problems?
• Shift left = testing, coding, design
• Know your enemy
• Automate, centralise
• The earlier you introduce changes, the better
Summary
Thank you!
Jakub.Kaluzny@securing.pl
@j_kaluzny
SecuRing
http://www.securing.pl/en

[OPD 2019] Threat modeling at scale

  • 1.
    Let’s get evil– threat modelling at scale Jakub Kaluzny OWASP Poland, 16th Oct 2019
  • 2.
  • 3.
  • 4.
  • 5.
    JAKUB KALUZNY • 10years in IT & Security • Threat modeling, DevSecOps, penetration tests • Poland, Spain, Australia • banking, fintech, law, airline, entertainment, e-commerce • Speaker at BlackHat, HackInTheBox, ZeroNights #whoami
  • 6.
    Design Coding TestingRelease Maintenance SDLC process
  • 7.
    Weak encryption inweb app Weak encryption in mobile app Weak encryption in printers Cost to fix
  • 8.
    Cost of aproduction security bug: • Incident response = $ • Risk assessment = $ • Fix, test = $ • Ransom, GDPR = $ • Reputation = $ • Stolen data = ? Cost to fix is not everything Equifax hack in 2017
  • 9.
    Design Coding TestingRelease Maintenance Security testing
  • 10.
    • Number ofsecurity issues in time No security testing
  • 11.
    • Number ofsecurity issues in time 1 round of security testing PT
  • 12.
    • Number ofsecurity issues in time Multiple rounds of security testing PT PT PT
  • 13.
    • Number ofsecurity issues in time Our target - SSDLC PT PT PT
  • 14.
  • 15.
    • Number ofsecurity issues in time Isolated round PT quality of design qualityoftesting
  • 16.
    Design Coding TestingRelease Maintenance There are tools and services training SAST DAST SCA VApentesting IDE plugins code review repo mgrs checklists SOE standards virtual patching WAF threat modelling
  • 17.
    Design Coding TestingRelease Maintenance What to start with? training pentesting threat modelling
  • 18.
    • Quality ofcoding • Training Solution
  • 19.
  • 20.
    • Quality ofcoding • Secure coding training + onboarding on standards • Security requirements • Quality of testing • Adequate scope / test cases • Quality of design • Threat modelling
  • 21.
    Waterfall vs Agile– security perspective Secure design Fixing time Secure release Security testing Secure Implementation
  • 22.
    Design Coding TestingRelease Maintenance Agile and security
  • 23.
    Design Coding TestingRelease Maintenance When does your security team show up?
  • 24.
    1 month ofa 100-developers company 10 teams 20 sprints 600 user stories 1000+ code changes 3000+ JIRA tickets
  • 25.
    Decomposition of userstories User downloads a list of transactions and their details
  • 26.
    Decomposition of userstories User downloads (a list of transactions) and (their details) getTransactionsByUser getTransactionDetails
  • 27.
    Decomposition of userstories User downloads (a list of transactions) and (their details) getTransactionsByUser getTransactionDetails getTransactionByUser(CONTEXT): 123, 125, 127 getTransactionDetails(123) getTransactionDetails(124)
  • 28.
    Design Coding TestingRelease Maintenance Agile and security
  • 29.
  • 30.
    • Factory camerareading license plates • Setting up physical access control (RFID badges) • How to detect crawlers? • Authentication in APIs Case studies
  • 31.
    Threat modeling –evil brainstorming Threat actor Threat Attack vector Who? What? How? Attack vector Security requirement Test case
  • 32.
    • Generally yes,„secure by design” Does it work? Dev/DevOps Sec Arch Functional requirements, design, DFDs Security requirements Security testing scope Risk assessment Go-live decision
  • 33.
    • It ain’teasy How to make it more Agile Dev Sec Dev Dev Dev Sec DevSecOps Sec
  • 34.
    Which threats tomodel? List of user stories • Decision to model Stories affecting security • Threat model Verification • follow- up
  • 35.
    • Cosmetic changesto report template (colours) • Add GDPR pop-up • Update jQuery lib • Change randomness in reset password link from rand(1, 1000000) to GUIDv4 • New authentication provider • Add new report type – list of transactions per user Examples – decide to model or not
  • 36.
    Different wording ofuser stories User displays a list of THEIR OWN transactions and details for each of THEIR OWN transactions. User downloads a list of transactions and their details
  • 37.
    Different wording ofrecommendation Update jQuery library to the newest available version with no open vulnerabilities Update jQuery library
  • 38.
    Threat modeling atscale - Agile User downloads a list of transactions and their details Abuser story Security requirement Test cases
  • 39.
    Threat modeling atscale - Agile User downloads a list of transactions and their details Abuser story Security requirement Test cases One user downloads transaction of other users Transaction should belong to the user from the current context Check cross-user data access control
  • 40.
    Threat modeling atscale - Agile User downloads a list of transactions and their details Abuser story Security requirement Test cases One user downloads transaction of other users Transaction should belong to the user from the current context Check cross-user data access control Inject SQL/XML into ID ??? Execute without auth ???
  • 41.
    Threat modeling atscale – base threat models Abuser story Security requirement Test cases SOAP API (parent): User downloads a list of transactions and their details
  • 42.
    Threat modeling atscale – base threat models Abuser story Security requirement Test cases Execute without auth Inject XML string Inject SQL string Force a cross-site request SOAP API (parent): User downloads a list of transactions and their details
  • 43.
    Threat modeling atscale – base threat models Abuser story Security requirement Test cases Execute without auth All functions require auth Inject XML string External Entities off Inject SQL string Type casting, prepared statements Force a cross-site request SameSite cookie flag, custom request headers SOAP API (parent): User downloads a list of transactions and their details
  • 44.
    Threat modeling atscale – base threat models Abuser story Security requirement Test cases New RCE CVE Java up-to-date … Config options: …, … JAVA APPLICATION (parent): SOAP API (parent): User downloads a list of transactions and their details
  • 45.
    Adding S toSDLC Initial discussions • Base threat models Stories affecting security • Abuser stories Testing • Security metric
  • 46.
  • 47.
    Threat modeling atscale - examples User should be able to reset a password. Abuser story Security requirement Test cases 1. Your e-mail: […] 2. https://example/reset?e-mail=x@y&rnd=12345 3. New pwd: [..], confirm new […]
  • 48.
    Threat modeling atscale - examples Abuser story Security requirement Test cases Lock other accounts (1) Dictionary attack Get a copy of e-mail (1) Injection into e-mail Analyse and guess contents of reset link (2) Use reset link against another account (2) Bypass steps 1, 2 (3) Change other user’s password (3) Injection into pwd User should be able to reset a password.
  • 49.
    Threat modeling atscale - examples Ad industry. Money withdrawal. Abuser story Security requirement Test cases How much do you want to withdraw: […]? To which of your accounts […] (drop-down list)?
  • 50.
    Threat modeling atscale - examples Ad industry. Money withdrawal. Abuser story Security requirement Test cases Withdraw more than your balance. Withdraw negative amount Select an account outside the list Make somebody withdraw money CSRF / clickjacking
  • 51.
    Threat modeling atscale - examples VIP airport lounge. Boarding pass QR code reader allowing through only business class. Abuser story Security requirement Test cases Client: (showing boarding pass)
  • 52.
    Threat modeling atscale - examples VIP airport lounge. Boarding pass QR code reader allowing through only business class. Abuser story Security requirement Test cases Use an old business boarding pass Use one boarding pass twice Use a scan of boarding pass from another airport Modify class in the QR code Client: (scans boarding pass)
  • 53.
    • Copying invisiblecode from stackoverflow • Allowing only trusted dependencies • We’ve got SAST! • Regular VA scans • Presentation clickers Do abuser stories solve all problems?
  • 54.
    • Shift left= testing, coding, design • Know your enemy • Automate, centralise • The earlier you introduce changes, the better Summary
  • 55.