SlideShare a Scribd company logo
1 of 49
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

Security Code Review: Magic or Art?
Security Code Review: Magic or Art?Security Code Review: Magic or Art?
Security Code Review: Magic or Art?
Sherif Koussa
 
Using Third Party Components for Building an Application Might be More Danger...
Using Third Party Components for Building an Application Might be More Danger...Using Third Party Components for Building an Application Might be More Danger...
Using Third Party Components for Building an Application Might be More Danger...
Achim D. Brucker
 
Blackhat Europe 2009 - Detecting Certified Pre Owned Software
Blackhat Europe 2009 - Detecting Certified Pre Owned SoftwareBlackhat Europe 2009 - Detecting Certified Pre Owned Software
Blackhat Europe 2009 - Detecting Certified Pre Owned Software
Tyler Shields
 

What's hot (20)

AI Security : Machine Learning, Deep Learning and Computer Vision Security
AI Security : Machine Learning, Deep Learning and Computer Vision SecurityAI Security : Machine Learning, Deep Learning and Computer Vision Security
AI Security : Machine Learning, Deep Learning and Computer Vision Security
 
DevSecOps for Developers: How To Start
DevSecOps for Developers: How To StartDevSecOps for Developers: How To Start
DevSecOps for Developers: How To Start
 
Finding Zero-Days Before The Attackers: A Fortune 500 Red Team Case Study
Finding Zero-Days Before The Attackers: A Fortune 500 Red Team Case StudyFinding Zero-Days Before The Attackers: A Fortune 500 Red Team Case Study
Finding Zero-Days Before The Attackers: A Fortune 500 Red Team Case Study
 
Security Code Review: Magic or Art?
Security Code Review: Magic or Art?Security Code Review: Magic or Art?
Security Code Review: Magic or Art?
 
Security and Privacy of Machine Learning
Security and Privacy of Machine LearningSecurity and Privacy of Machine Learning
Security and Privacy of Machine Learning
 
Secure coding practices
Secure coding practicesSecure coding practices
Secure coding practices
 
Using Third Party Components for Building an Application Might be More Danger...
Using Third Party Components for Building an Application Might be More Danger...Using Third Party Components for Building an Application Might be More Danger...
Using Third Party Components for Building an Application Might be More Danger...
 
Student Spring 2021
Student Spring 2021Student Spring 2021
Student Spring 2021
 
Blackhat Europe 2009 - Detecting Certified Pre Owned Software
Blackhat Europe 2009 - Detecting Certified Pre Owned SoftwareBlackhat Europe 2009 - Detecting Certified Pre Owned Software
Blackhat Europe 2009 - Detecting Certified Pre Owned Software
 
Sqlas tool to detect and prevent attacks in php web applications
Sqlas tool to detect and prevent attacks in php web applicationsSqlas tool to detect and prevent attacks in php web applications
Sqlas tool to detect and prevent attacks in php web applications
 
Threat Modeling: Best Practices
Threat Modeling: Best PracticesThreat Modeling: Best Practices
Threat Modeling: Best Practices
 
Threat Modelling
Threat ModellingThreat Modelling
Threat Modelling
 
STRIDE Variants and Security Requirements-based Threat Analysis (FFRI Monthly...
STRIDE Variants and Security Requirements-based Threat Analysis (FFRI Monthly...STRIDE Variants and Security Requirements-based Threat Analysis (FFRI Monthly...
STRIDE Variants and Security Requirements-based Threat Analysis (FFRI Monthly...
 
DevBeat 2013 - Developer-first Security
DevBeat 2013 - Developer-first SecurityDevBeat 2013 - Developer-first Security
DevBeat 2013 - Developer-first Security
 
Automatically Repairing Web Application Firewalls based on Successful SQL Inj...
Automatically Repairing Web Application Firewalls based on Successful SQL Inj...Automatically Repairing Web Application Firewalls based on Successful SQL Inj...
Automatically Repairing Web Application Firewalls based on Successful SQL Inj...
 
Secure programming with php
Secure programming with phpSecure programming with php
Secure programming with php
 
HackInBo2k16 - Threat Intelligence and Malware Analysis
HackInBo2k16 - Threat Intelligence and Malware AnalysisHackInBo2k16 - Threat Intelligence and Malware Analysis
HackInBo2k16 - Threat Intelligence and Malware Analysis
 
Server Side Template Injection by Mandeep Jadon
Server Side Template Injection by Mandeep JadonServer Side Template Injection by Mandeep Jadon
Server Side Template Injection by Mandeep Jadon
 
Microsoft threat modeling tool 2016
Microsoft threat modeling tool 2016Microsoft threat modeling tool 2016
Microsoft threat modeling tool 2016
 
Managing Security in External Software Dependencies
Managing Security in External Software DependenciesManaging Security in External Software Dependencies
Managing Security in External Software Dependencies
 

Viewers also liked (7)

Metasploit framwork
Metasploit framworkMetasploit framwork
Metasploit framwork
 
Networking basics by rahul at Null Mumbai
Networking basics by rahul at Null MumbaiNetworking basics by rahul at Null Mumbai
Networking basics by rahul at Null Mumbai
 
Basics of Cryptography
Basics of CryptographyBasics of Cryptography
Basics of Cryptography
 
Yet another talk on bug bounty
Yet another talk on bug bountyYet another talk on bug bounty
Yet another talk on bug bounty
 
Nmap and metasploitable
Nmap and metasploitableNmap and metasploitable
Nmap and metasploitable
 
Bit squatting
Bit squattingBit squatting
Bit squatting
 
API Security - Null meet
API Security - Null meetAPI Security - Null meet
API Security - Null meet
 

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

Security engineering 101 when good design & security work together
Security engineering 101  when good design & security work togetherSecurity engineering 101  when good design & security work together
Security engineering 101 when good design & security work together
Wendy Knox Everette
 
Addressing Web Application Security Vulnerabilities.pdf
Addressing Web Application Security Vulnerabilities.pdfAddressing Web Application Security Vulnerabilities.pdf
Addressing Web Application Security Vulnerabilities.pdf
CecilSu
 
So... you want to be a security consultant
So... you want to be a security consultant So... you want to be a security consultant
So... you want to be a security consultant
abnmi
 
Break it while you make it: writing (more) secure software
Break it while you make it: writing (more) secure softwareBreak it while you make it: writing (more) secure software
Break it while you make it: writing (more) secure software
Leigh Honeywell
 
4.Security Assessment And Testing
4.Security Assessment And Testing4.Security Assessment And Testing
4.Security Assessment And Testing
phanleson
 

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

apidays LIVE New York 2021 - Why Software Teams Struggle with API Security Te...
apidays LIVE New York 2021 - Why Software Teams Struggle with API Security Te...apidays LIVE New York 2021 - Why Software Teams Struggle with API Security Te...
apidays LIVE New York 2021 - Why Software Teams Struggle with API Security Te...
 
Security engineering 101 when good design & security work together
Security engineering 101  when good design & security work togetherSecurity engineering 101  when good design & security work together
Security engineering 101 when good design & security work together
 
Security assessment with a hint of CISSP Prep
Security assessment with a hint of CISSP PrepSecurity assessment with a hint of CISSP Prep
Security assessment with a hint of CISSP Prep
 
Penetration testing dont just leave it to chance
Penetration testing dont just leave it to chancePenetration testing dont just leave it to chance
Penetration testing dont just leave it to chance
 
WhiteHat 2014 Website Security Statistics Report
WhiteHat 2014 Website Security Statistics ReportWhiteHat 2014 Website Security Statistics Report
WhiteHat 2014 Website Security Statistics Report
 
Addressing Web Application Security Vulnerabilities.pdf
Addressing Web Application Security Vulnerabilities.pdfAddressing Web Application Security Vulnerabilities.pdf
Addressing Web Application Security Vulnerabilities.pdf
 
Dev{sec}ops
Dev{sec}opsDev{sec}ops
Dev{sec}ops
 
Software Analytics: Towards Software Mining that Matters (2014)
Software Analytics:Towards Software Mining that Matters (2014)Software Analytics:Towards Software Mining that Matters (2014)
Software Analytics: Towards Software Mining that Matters (2014)
 
So... you want to be a security consultant
So... you want to be a security consultant So... you want to be a security consultant
So... you want to be a security consultant
 
Break it while you make it: writing (more) secure software
Break it while you make it: writing (more) secure softwareBreak it while you make it: writing (more) secure software
Break it while you make it: writing (more) secure software
 
Agnitio: its static analysis, but not as we know it
Agnitio: its static analysis, but not as we know itAgnitio: its static analysis, but not as we know it
Agnitio: its static analysis, but not as we know it
 
OWASP Secure Coding Quick Reference Guide
OWASP Secure Coding Quick Reference GuideOWASP Secure Coding Quick Reference Guide
OWASP Secure Coding Quick Reference Guide
 
Static analysis for security
Static analysis for securityStatic analysis for security
Static analysis for security
 
Security Metrics Rehab: Breaking Free from Top ‘X’ Lists, Cultivating Organic...
Security Metrics Rehab: Breaking Free from Top ‘X’ Lists, Cultivating Organic...Security Metrics Rehab: Breaking Free from Top ‘X’ Lists, Cultivating Organic...
Security Metrics Rehab: Breaking Free from Top ‘X’ Lists, Cultivating Organic...
 
OISF - AppSec Presentation
OISF - AppSec PresentationOISF - AppSec Presentation
OISF - AppSec Presentation
 
4.Security Assessment And Testing
4.Security Assessment And Testing4.Security Assessment And Testing
4.Security Assessment And Testing
 
8 Patterns For Continuous Code Security by Veracode CTO Chris Wysopal
8 Patterns For Continuous Code Security by Veracode CTO Chris Wysopal8 Patterns For Continuous Code Security by Veracode CTO Chris Wysopal
8 Patterns For Continuous Code Security by Veracode CTO Chris Wysopal
 
(In)security in Open Source
(In)security in Open Source(In)security in Open Source
(In)security in Open Source
 
The Principles of Secure Development - David Rook
The Principles of Secure Development - David RookThe Principles of Secure Development - David Rook
The Principles of Secure Development - David Rook
 
Open Source Insight: 2017 Top 10 IT Security Stories, Breaches, and Predictio...
Open Source Insight:2017 Top 10 IT Security Stories, Breaches, and Predictio...Open Source Insight:2017 Top 10 IT Security Stories, Breaches, and Predictio...
Open Source Insight: 2017 Top 10 IT Security Stories, Breaches, and Predictio...
 

Recently uploaded

The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
heathfieldcps1
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
QucHHunhnh
 

Recently uploaded (20)

UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the Classroom
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptx
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptx
 

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