SlideShare a Scribd company logo
AStrategic Path from
SecureCode Reviews to
Threat Modeling (101)
- Deepam Kanjani
WhoAreYou
going to listen
for the next 69
minutes?
– Work at Symantec
– Security Researcher and Developer
– IWork on primarily SSDLC implementation but not just limited to it –
– Web ApplicationVulnerability Assessments- Pen-Tests,
– Secure Code Reviews,
– Architecture Risk Assessments,
– Threat Modeling,
– Secured Software Architecture,
– Training,
– Mobile-security assessments,
– Threat telemetry- maintenance & automation,
– Remediation Consulting,
– Security Automation,
– DevOps- Security In the Build,
– Security Automation…
– Java, Python JS, BashS, and PHP
– “Consultant”
– You can reach me @
– Twitter - @deepamkanjani
– mailto:deepamkanjani (at) gmail (dot) com
null/OWASP/G4H meet - August 2017
3
No matter how much care you take during development of any software, security
issues creep in.
What this talk
is not about?
– Learning In-Depth Code Reviews orThreat Modeling
– Getting in to details of how a particular language or an
architecture can lead to security issues.
– To help you confirm on an exploit of an issue
– Improve your code review process
– Ground Breaking Research or a NewTool
– Learning how to fix issues.
– Answering Questions (if any)
null/OWASP/G4H meet - August 2017
SecureCode Reviews --
-Secure Development
Reviews 101
null/OWASP/G4H meet - August 2017
WhyShould
We talk about
it?
– Code is the only advantage for organizations over the hackers and
they need to utilize this fact in a planned way.
– Relying only on penetration testing is definitely not a good
idea.
– When you have the code, use the
code!
null/OWASP/G4H meet - August 2017
6 Bubbles of
Code Review
Observations
null/OWASP/G4H meet - August 2017
Tribal
Knowledge
Configuration
Errors
Stupid
Mistakes
Learning
Opportunities
and Re-
Design
Functional
Leaks
System
Integration –
Miss
(Overlook)
Ref: Independent Research and Excella Results
6 Drops of
Code Review
Observations
null/OWASP/G4H meet - August 2017
Mechanics of
code reviews-
Simplified
– Identify the objectives of review
– Identifying areas / components of interest OR Points of Interest.
– Reviewing the code
null/OWASP/G4H meet - August 2017
So HowCan
you go about
it?
– Identify what are we missing from a SECURITY Standpoint?
– AutomateWhat Can be Automated so that you can concentrate
on manual checks.
null/OWASP/G4H meet - August 2017
See If you
See…
string query = "SELECT * FROM itemsWHERE username = '" +
userName + "' AND password = '" + password.Text + "'";
null/OWASP/G4H meet - August 2017
$command = 'ls -l /home/' . $userName;
system($command);
char buf[24];
printf("Please enter your name n");
gets(buf);
$username = $_GET['username'];
echo '<div class="header">Welcome, ' . $username . '</div>';
BankAccount account = null;
Account = new BankAccount();
return account;
See If you
See…
SELECT * FROM usersWHERE username = ‘Administrator' AND
password = ‘secret'; DELETE FROM users; --';
null/OWASP/G4H meet - August 2017
ls -l /home/; rm -rf /
char buf[24];
printf("Please enter your name n");
gets("xebx1fx5ex89x76x08x31xc0x88x46x07x89x46x0cxb0x
0bx89xf3x8dx4ex08x8dx56x0cxcdx80x31xdbx89xd8x40xcd
x80xe8xdcxffxffxff/bin/sh"
);
$username = $_GET['username'];
echo '<div class="header">Welcome, <script
language="Javascript">alert("You've been attacked!");</script>
'</div>';
BankAccount account = null;
Account = new BankAccount();
return account;
In general
there are 2
approaches
– Control Flow Analysis:
– Reviewer sees through the logical conditions in the code.
null/OWASP/G4H meet - August 2017
In general
there are 2
approaches
– Data Flow Analysis:
– Dataflow analysis is the mechanism used to trace data from the
points of input to the points of output.
– This will help you find bugs associated with poor input handling.
null/OWASP/G4H meet - August 2017
In general
there are 2
approaches:
Then where
did the third
come from?
– Taint Analysis:
– Taint Analysis attempts to identify variables that have been 'tainted'
with user controllable input and traces them to possible vulnerable
functions also known as a 'sink'.
– If the tainted variable gets passed to a sink without first being
sanitized it is flagged as a vulnerability.
null/OWASP/G4H meet - August 2017
There is
another one.
– Lexical Analysis: The Process converts source code syntax into
‘tokens’ of information in an attempt to abstract the source code
and make it easier to manipulate.
null/OWASP/G4H meet - August 2017
There will be
three
Categories of
People after
this…
null/OWASP/G4H meet - August 2017
A Deeper Look in the
code…
request.form
request.querystring
request.url
request.httpmethod
request.headers
request.cookies
TextBox.Text
HiddenField.Value
null/OWASP/G4H meet - August 2017
Accepting User Input [Others]:
InputStream
request.accepttypes
request.browser
request.files
request.item
request.certificate
request.rawurl
request.servervariables
request.urlreferrer
request.useragent
request.userlanguages
request.IsSecureConnection
request.TotalBytes
request.BinaryRead
recordSet
Identify what
are we
missing?
null/OWASP/G4H meet - August 2017
– “The Inspection of Code to identify SecurityWeakness”
– “ Systematic Approach to find SecurityVulnerabilities”
– Code Reviews- Effectiveness of Security Controls, Exercise All
Code Paths, All instances of aVulnerability, Find Design Flaws,
Learn Remediation
null/OWASP/G4H meet - August 2017
Ref: https://www.slideshare.net/skoussa/simplified-security-code-review-process
Strengths
null/OWASP/G4H meet - August 2017
– Scalability
– Code oriented bugs a.k.a mal-coded problems like Buffer
Overflow, SQL Injections can be reported with higher confidence
– All Instances of a particular vulnerability can be discovered (In
most cases)
– Easier RCA’s – Root Cause Analysis (Source – Sink)
– Uncommon Security Flaws
– Discovery of Usage for Existing Security Controls like Global
blacklists
Weaknesses
null/OWASP/G4H meet - August 2017
– Several security vulnerabilities are very difficult to find
automatically, such as authentication problems, access control
issues, insecure use of cryptography, etc.
– High numbers of false positives from tools.
– Could not discover most of the configuration issues as they are not
bundled with the code
– Difficult to 'prove' that an identified security issue is an actual
vulnerability.
– Many of these tools have difficulty analyzing code that can't be
compiled. Analysts frequently can't compile code because they
don't have the right libraries, all the compilation instructions, all
the code, etc.
– Limitations – False Positives and False Negatives
Which Brings us to
Threat Modeling 101
null/OWASP/G4H meet - August 2017
null/OWASP/G4H meet - August 2017
Terms
Threat
Modeling
null/OWASP/G4H meet - August 2017
– The main aim of threat modeling is to identify the important
assets/functionalities of the application and to protect them.
Terms
null/OWASP/G4H meet - August 2017
– Asset. A resource of value, such as the data in a database or on the file
system. A system resource.
– Threat. A potential occurrence, malicious or otherwise, that might
damage or compromise your assets.
– Vulnerability. A weakness in the system that makes a threat possible in
other words aid the attacker to exploit a particular threat.
– Attack (or exploit). An action taken by someone or something that
harms an asset.This could be someone following through on a threat or
exploiting a vulnerability.
– Countermeasure. A safeguard that addresses a threat and mitigates
risk.
STRIDE
null/OWASP/G4H meet - August 2017
– A threat categorization such as STRIDE is
useful in the identification of threats by
classifying attacker goals such as:
– Spoofing
– Tampering
– Repudiation
– Information Disclosure
– Denial of Service
– Elevation of Privilege.
Security
Controls
null/OWASP/G4H meet - August 2017
S
A
D
S
C
A
L
E
C
S
Session Management
Authentication
Data/InputValidation
Secure Code Environment
Cookie Management
Authorization
Logging/Auditing
Error Handling/Exception Handling
Cryptography
Session Management
DefiningTrust
Boundary
null/OWASP/G4H meet - August 2017
Remember
these.
null/OWASP/G4H meet - August 2017
null/OWASP/G4H meet - August 2017
Data Flow Diagram for a College LibraryWebsite
null/OWASP/G4H meet - August 2017
Data Flow Diagram for a College LibraryWebsite – Login Flow
null/OWASP/G4H meet - August 2017
Ref: https://blogs.microsoft.com/microsoftsecure/2014/04/15/introducing-microsoft-threat-modeling-tool-2014/
Reading Material: https://www.slideshare.net/praetorianlabs/praetorian-threat-modelingpresentation for
MicrosoftThreat ModelingTool
MicrosoftThreat ModelingTool
DefiningTrust
Boundary
null/OWASP/G4H meet - August 2017
Threat
Analysis
null/OWASP/G4H meet - August 2017
Risk Ranking
ofThreats
null/OWASP/G4H meet - August 2017
DREAD and
Generic Risk
Model
– For Damage: How big would the damage be if the attack
succeeded?
– For Reproducibility: How easy is it to reproduce an attack to work?
– For Exploitability: How much time, effort, and expertise is needed
to exploit the threat?
– For Affected Users: If a threat were exploited, what percentage of
users would be affected?
– For Discoverability: How easy is it for an attacker to discover this
threat?
– Generic Risk Model: Risk = Likelihood x Impact
null/OWASP/G4H meet - August 2017
Countermeasu
re
Identification -
STRIDE
null/OWASP/G4H meet - August 2017
STRIDEThreat & MitigationTechniques List
ThreatType MitigationTechniques
Spoofing Identity
1.Appropriate authentication
2.Protect secret data
3.Don't store secrets
Tampering with data
1.Appropriate authorization
2.Hashes
3.MACs
4.Digital signatures
5.Tamper resistant protocols
Repudiation
1.Digital signatures
2.Timestamps
3.Audit trails
Information Disclosure
1.Authorization
2.Privacy-enhanced protocols
3.Encryption
4.Protect secrets
5.Don't store secrets
Denial of Service
1.Appropriate authentication
2.Appropriate authorization
3.Filtering
4.Throttling
5.Quality of service
Elevation of privilege 1.Run with least privilege
Categorize
– Non mitigated threats
– Partially mitigated threats
– Fully mitigated threats
null/OWASP/G4H meet - August 2017
Mitigation
Strategies
– Do nothing: for example, hoping for the best
– Inform about the risk: for example, warning user population
about the risk
– Mitigate the risk: for example, by putting countermeasures in
place
– Accept the risk: for example, after evaluating the impact of the
exploitation (business impact)
– Transfer the risk: for example, through contractual agreements
and insurance
– Terminate the risk: for example, shutdown, turn-off, unplug or
decommission the asset
null/OWASP/G4H meet - August 2017
Automate
WhatCan Be
Automated
null/OWASP/G4H meet - August 2017
Automate
WhatCan Be
Automated
null/OWASP/G4H meet - August 2017
– Tests,
– Continuous Integration,
– Static Code Analysis,
– Manual Security Review,
– Manual Secure Code Review,
– Spell Checker,
– etc.
StaticAnalysisTools
null/OWASP/G4H meet - August 2017
Gotta
Wanna
StaticAnalysisTools (waitOWASP
Has listed more of it…)
null/OWASP/G4H meet - August 2017
– OWASPTools
– OWASP Code Crawler (.NET & Java)
– OWASP Orizon Project (Java,PHP,C & JSP)
– OWASP LAPSE Project (Java)
– OWASP O2 Platform
– OWASPWAP-Web Application Protection (PHP)
Open Source/Free
Agnitio (Objective-C, C#, Java & Android)
Brakeman (Rails)
DevBug (PHP)
FindBugs (Java)
FlawFinder (C/C++)
Microsoft FxCop (.NET)
Google CodeSearchDiggity (Multiple)
PMD (Java)
Puma Scan (.NET)
Microsoft PreFast (C/C++)
SonarQube (20+ languages including Java, C#, and JavaScript)
Splint (C)
VisualCodeGrepper (C/C++, C#,VB, PHP, Java & PL/SQL)
RIPS (PHP)
StaticAnalysisTools (waitOWASP
Has listed more of it…)
null/OWASP/G4H meet - August 2017
Commercial
Fortify (OWASP Member)
Veracode (OWASP Member)
GrammaTech
ParaSoft
Armorize CodeSecure (OWASP Member)
Checkmarx Static Code Analysis (OWASP Member)
Rational AppScan Source Edition
Coverity
PVS-Studio
Insight
Polyspace Static Analysis
RIPS NextGen (PHP)
Then,What’s
Next? –Where
is theStrategic
Path
null/OWASP/G4H meet - August 2017
What?
Ref: http://a.espncdn.com/combiner/i?img=/media/motion/2016/0323/dm_160323_wt20_Mar23_India_v_Bangladesh_Dhoni_PC_NRH/dm_160323_wt20_Mar23_India_v_Bangladesh_Dhoni_PC_NRH.jpg
–Model-Security-DevOps
AutomateWhat Can Be
Automated
PerformValidation Exercises like
Secure Development Reviews
Model
null/OWASP/G4H meet - August 2017
Q nA
null/OWASP/G4H meet - August 2017
Q nA
Otherwise…
Rerferences (FromWhere I Did Ctrl+c):
• “2011 CWE/SANSTop 25 Most Dangerous
Software Errors”
• http://cwe.mitre.org/top25/
• https://www.owasp.org/index.php/Applica
tion_Threat_Modeling
• https://msdn.microsoft.com/en-
us/library/aa302419.aspx#c03618429_011
• http://www.hitsinstitute.com/category/sec
urity/physical-security/
• https://www.owasp.org/index.php/Static_
Code_Analysis
• https://www.aspectsecurity.com/secure-
code-review
• https://www.slideshare.net/excellaco/mod
ern-code-review
• http://www.software-
supportability.org/Docs/00-55_Part_2.pdf

More Related Content

What's hot (20)

PDF
AI Security : Machine Learning, Deep Learning and Computer Vision Security
Cihan Özhan
 
PDF
DevSecOps for Developers: How To Start
Patricia Aas
 
PPTX
Finding Zero-Days Before The Attackers: A Fortune 500 Red Team Case Study
DevOps.com
 
KEY
Security Code Review: Magic or Art?
Sherif Koussa
 
PDF
Security and Privacy of Machine Learning
Priyanka Aash
 
PPTX
Secure coding practices
Scott Hurrey
 
PDF
Using Third Party Components for Building an Application Might be More Danger...
Achim D. Brucker
 
PPTX
Student Spring 2021
Denis Zakharov
 
PDF
Blackhat Europe 2009 - Detecting Certified Pre Owned Software
Tyler Shields
 
PDF
Sqlas tool to detect and prevent attacks in php web applications
ijsptm
 
PDF
Threat Modeling: Best Practices
Source Conference
 
PDF
STRIDE Variants and Security Requirements-based Threat Analysis (FFRI Monthly...
FFRI, Inc.
 
PPTX
DevBeat 2013 - Developer-first Security
Coverity
 
PDF
Automatically Repairing Web Application Firewalls based on Successful SQL Inj...
Lionel Briand
 
PPTX
Secure programming with php
Mohmad Feroz
 
PDF
HackInBo2k16 - Threat Intelligence and Malware Analysis
Antonio Parata
 
PPTX
Server Side Template Injection by Mandeep Jadon
Mandeep Jadon
 
PDF
Microsoft threat modeling tool 2016
Rihab Chebbah
 
PPTX
Managing Security in External Software Dependencies
Tharindu Edirisinghe
 
AI Security : Machine Learning, Deep Learning and Computer Vision Security
Cihan Özhan
 
DevSecOps for Developers: How To Start
Patricia Aas
 
Finding Zero-Days Before The Attackers: A Fortune 500 Red Team Case Study
DevOps.com
 
Security Code Review: Magic or Art?
Sherif Koussa
 
Security and Privacy of Machine Learning
Priyanka Aash
 
Secure coding practices
Scott Hurrey
 
Using Third Party Components for Building an Application Might be More Danger...
Achim D. Brucker
 
Student Spring 2021
Denis Zakharov
 
Blackhat Europe 2009 - Detecting Certified Pre Owned Software
Tyler Shields
 
Sqlas tool to detect and prevent attacks in php web applications
ijsptm
 
Threat Modeling: Best Practices
Source Conference
 
STRIDE Variants and Security Requirements-based Threat Analysis (FFRI Monthly...
FFRI, Inc.
 
DevBeat 2013 - Developer-first Security
Coverity
 
Automatically Repairing Web Application Firewalls based on Successful SQL Inj...
Lionel Briand
 
Secure programming with php
Mohmad Feroz
 
HackInBo2k16 - Threat Intelligence and Malware Analysis
Antonio Parata
 
Server Side Template Injection by Mandeep Jadon
Mandeep Jadon
 
Microsoft threat modeling tool 2016
Rihab Chebbah
 
Managing Security in External Software Dependencies
Tharindu Edirisinghe
 

Viewers also liked (7)

PPTX
Metasploit framwork
Deepanshu Gajbhiye
 
PDF
Networking basics by rahul at Null Mumbai
Avkash Kathiriya
 
PPTX
Basics of Cryptography
Sunil Kumar
 
PDF
Yet another talk on bug bounty
vinoth kumar
 
PPTX
Nmap and metasploitable
Mohammed Akbar Shariff
 
PPSX
Bit squatting
Avradeep Bhattacharya
 
PPTX
API Security - Null meet
vinoth kumar
 
Metasploit framwork
Deepanshu Gajbhiye
 
Networking basics by rahul at Null Mumbai
Avkash Kathiriya
 
Basics of Cryptography
Sunil Kumar
 
Yet another talk on bug bounty
vinoth kumar
 
Nmap and metasploitable
Mohammed Akbar Shariff
 
Bit squatting
Avradeep Bhattacharya
 
API Security - Null meet
vinoth kumar
 
Ad

Similar to A Strategic Path from Secure Code Reviews to Threat Modeling (101) (20)

PDF
Shift Left Security
gjdevos
 
PPTX
The bare minimum that you should know about web application security testing ...
Ken DeSouza
 
PPTX
Security Testing by Ken De Souza
QA or the Highway
 
PPT
Security Overview - Updates and Trends In Detail
MohanArumugam24
 
PDF
Application Security - Your Success Depends on it
WSO2
 
PPT
香港六合彩
baoyin
 
PDF
Shift Left Security
gjdevos
 
PPTX
DevSecCon Tel Aviv 2018 - Security learns to sprint by Tanya Janca
DevSecCon
 
PDF
Vulnerability Management In An Application Security World: AppSecDC
Denim Group
 
PPTX
Web security: concepts and tools used by attackers
tomasperezv
 
PPTX
DevSecCon Singapore 2018 - Pushing left like a boss by Tanya Janca
DevSecCon
 
PPTX
Appsec2013 assurance tagging-robert martin
drewz lin
 
PDF
What You Need to Know About Web App Security Testing in 2018
Ken DeSouza
 
PPTX
Threat Modeling - Locking the Door to Vulnerabilities
Security Innovation
 
PDF
Matteo Meucci Software Security in practice - Aiea torino - 30-10-2015
Minded Security
 
PDF
Application Security on a Dime: A Practical Guide to Using Functional Open So...
POSSCON
 
PDF
ISC2: AppSec & OWASP Primer
ThreatReel Podcast
 
PPTX
Altitude SF 2017: Security at the edge
Fastly
 
PPTX
Owasp 2017 oveview
Shreyas N
 
PDF
New Era of Software with modern Application Security v1.0
Dinis Cruz
 
Shift Left Security
gjdevos
 
The bare minimum that you should know about web application security testing ...
Ken DeSouza
 
Security Testing by Ken De Souza
QA or the Highway
 
Security Overview - Updates and Trends In Detail
MohanArumugam24
 
Application Security - Your Success Depends on it
WSO2
 
香港六合彩
baoyin
 
Shift Left Security
gjdevos
 
DevSecCon Tel Aviv 2018 - Security learns to sprint by Tanya Janca
DevSecCon
 
Vulnerability Management In An Application Security World: AppSecDC
Denim Group
 
Web security: concepts and tools used by attackers
tomasperezv
 
DevSecCon Singapore 2018 - Pushing left like a boss by Tanya Janca
DevSecCon
 
Appsec2013 assurance tagging-robert martin
drewz lin
 
What You Need to Know About Web App Security Testing in 2018
Ken DeSouza
 
Threat Modeling - Locking the Door to Vulnerabilities
Security Innovation
 
Matteo Meucci Software Security in practice - Aiea torino - 30-10-2015
Minded Security
 
Application Security on a Dime: A Practical Guide to Using Functional Open So...
POSSCON
 
ISC2: AppSec & OWASP Primer
ThreatReel Podcast
 
Altitude SF 2017: Security at the edge
Fastly
 
Owasp 2017 oveview
Shreyas N
 
New Era of Software with modern Application Security v1.0
Dinis Cruz
 
Ad

Recently uploaded (20)

PPTX
How to Manage Allocation Report for Manufacturing Orders in Odoo 18
Celine George
 
PPTX
Controller Request and Response in Odoo18
Celine George
 
PPTX
How to Create a Customer From Website in Odoo 18.pptx
Celine George
 
PPTX
ENG8_Q1_WEEK2_LESSON1. Presentation pptx
marawehsvinetshe
 
PPTX
ENGlish 8 lesson presentation PowerPoint.pptx
marawehsvinetshe
 
PDF
Workbook de Inglés Completo - English Path.pdf
shityouenglishpath
 
PDF
Android Programming - Basics of Mobile App, App tools and Android Basics
Kavitha P.V
 
PDF
STATEMENT-BY-THE-HON.-MINISTER-FOR-HEALTH-ON-THE-COVID-19-OUTBREAK-AT-UG_revi...
nservice241
 
PDF
Week 2 - Irish Natural Heritage Powerpoint.pdf
swainealan
 
PDF
Stokey: A Jewish Village by Rachel Kolsky
History of Stoke Newington
 
PDF
Council of Chalcedon Re-Examined
Smiling Lungs
 
PPTX
Introduction to Indian Writing in English
Trushali Dodiya
 
PPTX
EDUCATIONAL MEDIA/ TEACHING AUDIO VISUAL AIDS
Sonali Gupta
 
PDF
Reconstruct, Restore, Reimagine: New Perspectives on Stoke Newington’s Histor...
History of Stoke Newington
 
PPTX
How to Send Email From Odoo 18 Website - Odoo Slides
Celine George
 
PPTX
Universal immunization Programme (UIP).pptx
Vishal Chanalia
 
PPTX
Light Reflection and Refraction- Activities - Class X Science
SONU ACADEMY
 
PDF
epi editorial commitee meeting presentation
MIPLM
 
PDF
AI-Powered-Visual-Storytelling-for-Nonprofits.pdf
TechSoup
 
PPTX
Nitrogen rule, ring rule, mc lafferty.pptx
nbisen2001
 
How to Manage Allocation Report for Manufacturing Orders in Odoo 18
Celine George
 
Controller Request and Response in Odoo18
Celine George
 
How to Create a Customer From Website in Odoo 18.pptx
Celine George
 
ENG8_Q1_WEEK2_LESSON1. Presentation pptx
marawehsvinetshe
 
ENGlish 8 lesson presentation PowerPoint.pptx
marawehsvinetshe
 
Workbook de Inglés Completo - English Path.pdf
shityouenglishpath
 
Android Programming - Basics of Mobile App, App tools and Android Basics
Kavitha P.V
 
STATEMENT-BY-THE-HON.-MINISTER-FOR-HEALTH-ON-THE-COVID-19-OUTBREAK-AT-UG_revi...
nservice241
 
Week 2 - Irish Natural Heritage Powerpoint.pdf
swainealan
 
Stokey: A Jewish Village by Rachel Kolsky
History of Stoke Newington
 
Council of Chalcedon Re-Examined
Smiling Lungs
 
Introduction to Indian Writing in English
Trushali Dodiya
 
EDUCATIONAL MEDIA/ TEACHING AUDIO VISUAL AIDS
Sonali Gupta
 
Reconstruct, Restore, Reimagine: New Perspectives on Stoke Newington’s Histor...
History of Stoke Newington
 
How to Send Email From Odoo 18 Website - Odoo Slides
Celine George
 
Universal immunization Programme (UIP).pptx
Vishal Chanalia
 
Light Reflection and Refraction- Activities - Class X Science
SONU ACADEMY
 
epi editorial commitee meeting presentation
MIPLM
 
AI-Powered-Visual-Storytelling-for-Nonprofits.pdf
TechSoup
 
Nitrogen rule, ring rule, mc lafferty.pptx
nbisen2001
 

A Strategic Path from Secure Code Reviews to Threat Modeling (101)

  • 1. AStrategic Path from SecureCode Reviews to Threat Modeling (101) - Deepam Kanjani
  • 2. WhoAreYou going to listen for the next 69 minutes? – Work at Symantec – Security Researcher and Developer – IWork on primarily SSDLC implementation but not just limited to it – – Web ApplicationVulnerability Assessments- Pen-Tests, – Secure Code Reviews, – Architecture Risk Assessments, – Threat Modeling, – Secured Software Architecture, – Training, – Mobile-security assessments, – Threat telemetry- maintenance & automation, – Remediation Consulting, – Security Automation, – DevOps- Security In the Build, – Security Automation… – Java, Python JS, BashS, and PHP – “Consultant” – You can reach me @ – Twitter - @deepamkanjani – mailto:deepamkanjani (at) gmail (dot) com null/OWASP/G4H meet - August 2017
  • 3. 3 No matter how much care you take during development of any software, security issues creep in.
  • 4. What this talk is not about? – Learning In-Depth Code Reviews orThreat Modeling – Getting in to details of how a particular language or an architecture can lead to security issues. – To help you confirm on an exploit of an issue – Improve your code review process – Ground Breaking Research or a NewTool – Learning how to fix issues. – Answering Questions (if any) null/OWASP/G4H meet - August 2017
  • 5. SecureCode Reviews -- -Secure Development Reviews 101 null/OWASP/G4H meet - August 2017
  • 6. WhyShould We talk about it? – Code is the only advantage for organizations over the hackers and they need to utilize this fact in a planned way. – Relying only on penetration testing is definitely not a good idea. – When you have the code, use the code! null/OWASP/G4H meet - August 2017
  • 7. 6 Bubbles of Code Review Observations null/OWASP/G4H meet - August 2017 Tribal Knowledge Configuration Errors Stupid Mistakes Learning Opportunities and Re- Design Functional Leaks System Integration – Miss (Overlook) Ref: Independent Research and Excella Results
  • 8. 6 Drops of Code Review Observations null/OWASP/G4H meet - August 2017
  • 9. Mechanics of code reviews- Simplified – Identify the objectives of review – Identifying areas / components of interest OR Points of Interest. – Reviewing the code null/OWASP/G4H meet - August 2017
  • 10. So HowCan you go about it? – Identify what are we missing from a SECURITY Standpoint? – AutomateWhat Can be Automated so that you can concentrate on manual checks. null/OWASP/G4H meet - August 2017
  • 11. See If you See… string query = "SELECT * FROM itemsWHERE username = '" + userName + "' AND password = '" + password.Text + "'"; null/OWASP/G4H meet - August 2017 $command = 'ls -l /home/' . $userName; system($command); char buf[24]; printf("Please enter your name n"); gets(buf); $username = $_GET['username']; echo '<div class="header">Welcome, ' . $username . '</div>'; BankAccount account = null; Account = new BankAccount(); return account;
  • 12. See If you See… SELECT * FROM usersWHERE username = ‘Administrator' AND password = ‘secret'; DELETE FROM users; --'; null/OWASP/G4H meet - August 2017 ls -l /home/; rm -rf / char buf[24]; printf("Please enter your name n"); gets("xebx1fx5ex89x76x08x31xc0x88x46x07x89x46x0cxb0x 0bx89xf3x8dx4ex08x8dx56x0cxcdx80x31xdbx89xd8x40xcd x80xe8xdcxffxffxff/bin/sh" ); $username = $_GET['username']; echo '<div class="header">Welcome, <script language="Javascript">alert("You've been attacked!");</script> '</div>'; BankAccount account = null; Account = new BankAccount(); return account;
  • 13. In general there are 2 approaches – Control Flow Analysis: – Reviewer sees through the logical conditions in the code. null/OWASP/G4H meet - August 2017
  • 14. In general there are 2 approaches – Data Flow Analysis: – Dataflow analysis is the mechanism used to trace data from the points of input to the points of output. – This will help you find bugs associated with poor input handling. null/OWASP/G4H meet - August 2017
  • 15. In general there are 2 approaches: Then where did the third come from? – Taint Analysis: – Taint Analysis attempts to identify variables that have been 'tainted' with user controllable input and traces them to possible vulnerable functions also known as a 'sink'. – If the tainted variable gets passed to a sink without first being sanitized it is flagged as a vulnerability. null/OWASP/G4H meet - August 2017
  • 16. There is another one. – Lexical Analysis: The Process converts source code syntax into ‘tokens’ of information in an attempt to abstract the source code and make it easier to manipulate. null/OWASP/G4H meet - August 2017
  • 17. There will be three Categories of People after this… null/OWASP/G4H meet - August 2017
  • 18. A Deeper Look in the code… request.form request.querystring request.url request.httpmethod request.headers request.cookies TextBox.Text HiddenField.Value null/OWASP/G4H meet - August 2017 Accepting User Input [Others]: InputStream request.accepttypes request.browser request.files request.item request.certificate request.rawurl request.servervariables request.urlreferrer request.useragent request.userlanguages request.IsSecureConnection request.TotalBytes request.BinaryRead recordSet
  • 19. Identify what are we missing? null/OWASP/G4H meet - August 2017 – “The Inspection of Code to identify SecurityWeakness” – “ Systematic Approach to find SecurityVulnerabilities” – Code Reviews- Effectiveness of Security Controls, Exercise All Code Paths, All instances of aVulnerability, Find Design Flaws, Learn Remediation
  • 20. null/OWASP/G4H meet - August 2017 Ref: https://www.slideshare.net/skoussa/simplified-security-code-review-process
  • 21. Strengths null/OWASP/G4H meet - August 2017 – Scalability – Code oriented bugs a.k.a mal-coded problems like Buffer Overflow, SQL Injections can be reported with higher confidence – All Instances of a particular vulnerability can be discovered (In most cases) – Easier RCA’s – Root Cause Analysis (Source – Sink) – Uncommon Security Flaws – Discovery of Usage for Existing Security Controls like Global blacklists
  • 22. Weaknesses null/OWASP/G4H meet - August 2017 – Several security vulnerabilities are very difficult to find automatically, such as authentication problems, access control issues, insecure use of cryptography, etc. – High numbers of false positives from tools. – Could not discover most of the configuration issues as they are not bundled with the code – Difficult to 'prove' that an identified security issue is an actual vulnerability. – Many of these tools have difficulty analyzing code that can't be compiled. Analysts frequently can't compile code because they don't have the right libraries, all the compilation instructions, all the code, etc. – Limitations – False Positives and False Negatives
  • 23. Which Brings us to Threat Modeling 101 null/OWASP/G4H meet - August 2017
  • 24. null/OWASP/G4H meet - August 2017 Terms
  • 25. Threat Modeling null/OWASP/G4H meet - August 2017 – The main aim of threat modeling is to identify the important assets/functionalities of the application and to protect them.
  • 26. Terms null/OWASP/G4H meet - August 2017 – Asset. A resource of value, such as the data in a database or on the file system. A system resource. – Threat. A potential occurrence, malicious or otherwise, that might damage or compromise your assets. – Vulnerability. A weakness in the system that makes a threat possible in other words aid the attacker to exploit a particular threat. – Attack (or exploit). An action taken by someone or something that harms an asset.This could be someone following through on a threat or exploiting a vulnerability. – Countermeasure. A safeguard that addresses a threat and mitigates risk.
  • 27. STRIDE null/OWASP/G4H meet - August 2017 – A threat categorization such as STRIDE is useful in the identification of threats by classifying attacker goals such as: – Spoofing – Tampering – Repudiation – Information Disclosure – Denial of Service – Elevation of Privilege.
  • 28. Security Controls null/OWASP/G4H meet - August 2017 S A D S C A L E C S Session Management Authentication Data/InputValidation Secure Code Environment Cookie Management Authorization Logging/Auditing Error Handling/Exception Handling Cryptography Session Management
  • 31. null/OWASP/G4H meet - August 2017 Data Flow Diagram for a College LibraryWebsite
  • 32. null/OWASP/G4H meet - August 2017 Data Flow Diagram for a College LibraryWebsite – Login Flow
  • 33. null/OWASP/G4H meet - August 2017 Ref: https://blogs.microsoft.com/microsoftsecure/2014/04/15/introducing-microsoft-threat-modeling-tool-2014/ Reading Material: https://www.slideshare.net/praetorianlabs/praetorian-threat-modelingpresentation for MicrosoftThreat ModelingTool MicrosoftThreat ModelingTool
  • 37. DREAD and Generic Risk Model – For Damage: How big would the damage be if the attack succeeded? – For Reproducibility: How easy is it to reproduce an attack to work? – For Exploitability: How much time, effort, and expertise is needed to exploit the threat? – For Affected Users: If a threat were exploited, what percentage of users would be affected? – For Discoverability: How easy is it for an attacker to discover this threat? – Generic Risk Model: Risk = Likelihood x Impact null/OWASP/G4H meet - August 2017
  • 38. Countermeasu re Identification - STRIDE null/OWASP/G4H meet - August 2017 STRIDEThreat & MitigationTechniques List ThreatType MitigationTechniques Spoofing Identity 1.Appropriate authentication 2.Protect secret data 3.Don't store secrets Tampering with data 1.Appropriate authorization 2.Hashes 3.MACs 4.Digital signatures 5.Tamper resistant protocols Repudiation 1.Digital signatures 2.Timestamps 3.Audit trails Information Disclosure 1.Authorization 2.Privacy-enhanced protocols 3.Encryption 4.Protect secrets 5.Don't store secrets Denial of Service 1.Appropriate authentication 2.Appropriate authorization 3.Filtering 4.Throttling 5.Quality of service Elevation of privilege 1.Run with least privilege
  • 39. Categorize – Non mitigated threats – Partially mitigated threats – Fully mitigated threats null/OWASP/G4H meet - August 2017
  • 40. Mitigation Strategies – Do nothing: for example, hoping for the best – Inform about the risk: for example, warning user population about the risk – Mitigate the risk: for example, by putting countermeasures in place – Accept the risk: for example, after evaluating the impact of the exploitation (business impact) – Transfer the risk: for example, through contractual agreements and insurance – Terminate the risk: for example, shutdown, turn-off, unplug or decommission the asset null/OWASP/G4H meet - August 2017
  • 42. Automate WhatCan Be Automated null/OWASP/G4H meet - August 2017 – Tests, – Continuous Integration, – Static Code Analysis, – Manual Security Review, – Manual Secure Code Review, – Spell Checker, – etc.
  • 45. StaticAnalysisTools (waitOWASP Has listed more of it…) null/OWASP/G4H meet - August 2017 – OWASPTools – OWASP Code Crawler (.NET & Java) – OWASP Orizon Project (Java,PHP,C & JSP) – OWASP LAPSE Project (Java) – OWASP O2 Platform – OWASPWAP-Web Application Protection (PHP) Open Source/Free Agnitio (Objective-C, C#, Java & Android) Brakeman (Rails) DevBug (PHP) FindBugs (Java) FlawFinder (C/C++) Microsoft FxCop (.NET) Google CodeSearchDiggity (Multiple) PMD (Java) Puma Scan (.NET) Microsoft PreFast (C/C++) SonarQube (20+ languages including Java, C#, and JavaScript) Splint (C) VisualCodeGrepper (C/C++, C#,VB, PHP, Java & PL/SQL) RIPS (PHP)
  • 46. StaticAnalysisTools (waitOWASP Has listed more of it…) null/OWASP/G4H meet - August 2017 Commercial Fortify (OWASP Member) Veracode (OWASP Member) GrammaTech ParaSoft Armorize CodeSecure (OWASP Member) Checkmarx Static Code Analysis (OWASP Member) Rational AppScan Source Edition Coverity PVS-Studio Insight Polyspace Static Analysis RIPS NextGen (PHP)
  • 47. Then,What’s Next? –Where is theStrategic Path null/OWASP/G4H meet - August 2017 What? Ref: http://a.espncdn.com/combiner/i?img=/media/motion/2016/0323/dm_160323_wt20_Mar23_India_v_Bangladesh_Dhoni_PC_NRH/dm_160323_wt20_Mar23_India_v_Bangladesh_Dhoni_PC_NRH.jpg –Model-Security-DevOps AutomateWhat Can Be Automated PerformValidation Exercises like Secure Development Reviews Model
  • 48. null/OWASP/G4H meet - August 2017 Q nA
  • 49. null/OWASP/G4H meet - August 2017 Q nA Otherwise… Rerferences (FromWhere I Did Ctrl+c): • “2011 CWE/SANSTop 25 Most Dangerous Software Errors” • http://cwe.mitre.org/top25/ • https://www.owasp.org/index.php/Applica tion_Threat_Modeling • https://msdn.microsoft.com/en- us/library/aa302419.aspx#c03618429_011 • http://www.hitsinstitute.com/category/sec urity/physical-security/ • https://www.owasp.org/index.php/Static_ Code_Analysis • https://www.aspectsecurity.com/secure- code-review • https://www.slideshare.net/excellaco/mod ern-code-review • http://www.software- supportability.org/Docs/00-55_Part_2.pdf