SlideShare a Scribd company logo
Secure Code Review 101Secure Code Review 101
Narudom Roongsiriwong, CISSPNarudom Roongsiriwong, CISSP
MiSSConf(SP2) Nov 19, 2016MiSSConf(SP2) Nov 19, 2016
Secure Code Review 101Secure Code Review 101
Narudom Roongsiriwong, CISSPNarudom Roongsiriwong, CISSP
MiSSConf(SP2) Nov 19, 2016MiSSConf(SP2) Nov 19, 2016
WhoAmI
● Lazy Blogger
– Japan, Security, FOSS, Politics, Christian
– http://narudomr.blogspot.com
● Information Security since 1995
● Web Application Development since 1998
● Head of IT Security and Solution Architecture, Kiatnakin
Bank PLC (KKP)
● Consultant for OWASP Thailand Chapter
● Committee Member of Cloud Security Alliance (CSA),
Thailand Chapter
● Consulting Team Member for National e-Payment project
● Contact: narudom.roongsiriwong@owasp.org
Security controls cannot
deal with broken business
logic such as A2, A4 and A7
Security controls cannot
deal with broken business
logic such as A2, A4 and A7
Software weaknesses
reduction down to zero is
possible
Software weaknesses
reduction down to zero is
possible
Reduce Security Weaknesses vs
Increase Security Controls
What is Secure Code Review?
● Aim to identify security flaws in the application
related to its features and design, along with the
exact root causes.
● Verify that the proper security and logical controls
are present, work as intended, and have been
invoked in the right places.
● Assure application developers are following secure
development techniques.
● Combine human effort and advanced static analysis
tools.
Code Review and Secure Code Review
● Secure Code Review enhances the standard Code
Review practice with security considerations.
– Security standards
– Security risks in the code base
– Security context
● Reviewers must have the necessary skills and secure
coding knowledge to effectively evaluate the code.
Code Review in Secure SDLC
Code Review
How Code Review Reduces Costs on Bug Fixes
Relative cost of security fixes, based on time of detection
Source: The National Institute of Standards and Technology (NIST)
Code Review
Penetration
Testing
Method Comparison to Cover High Level Topics
Good
Some
None
Source: Code Review Guide 2.0 (Alpha Release)
Method Comparison Against OWASP Top 10 Risks
Good
Some
None
Source: Code Review Guide 2.0 (Alpha Release)
Factors to Consider in Code Review Process
● Risks
● Purpose & Context
– A payment web application will have higher security
standards than a promotional website.
● Lines of Code: the more lines, the more bugs
● Programming Language
– Unmanaged code → Chances of buffer overflow
– PHP → Remote code execution
● Resources, Time & Deadlines
Code Review Preparation
● Application Features and Business Rules
– BR, SRS, etc
● Context
● Sensitive Data
● User Roles and Access Rights
● Application Type
– Web, Desktop, Web Service, Mobile, Hybrid
● Language and Its Security Features and Issues
● Design / Framework
– MVC, Strut, Spring, Hibernate, YII, CakePHP
● Company Standards and Guidelines
Code Review Checklist
● Data Validation
● Authentication
● Session Management
● Authorization
● Cryptography
● Error Handling
● Logging
● Security Configuration
● Network Architecture
Advantage & Disadvantage of Source Code Scanner
● Advantage
– Reduction in manual
efforts
– Find all the instances of
the vulnerabilities
– Source to sink analysis
– Elaborate reporting
format
● Disadvantage
– Business logic flaws
remain untouched
– Limited scope
– Design flaws
– False positives
Name
Programming Language Support
OS
Java PHP .NET C C++ Python Other
CodePro X W L M
FindBugs X W L
FxCop X W
Flawfinder X X L
Milk X X W L
MOPS X L
OWASP Code Crawler X X W
OWASP ORIZON X X X L
OWASP O2 Platform X X Javascript W
OWASP LAPSE X W L M
PMD X X X Javascript, XML,
XSL W L
PREfast X X W L
RIPS-Scanner X
SonarQube X X X X Delphi, Javascript,
XML W L M
Sprint X W L
StypeCop X W
Yasca X X X X X HTML, , Javascript,
Cobol, Coldfusion W L
Free Source Code Scanners
Example: SonarQube with OWASP Plugin
Let’s Go Back to Basic without Code Scanner
● Use your favorite text editor or IDE.
● “Find in Files” feature with RegEx is recommended.
● In this presentation will show you “Geany”, cross
platform text editor. https://www.geany.org
Review SQL Injection
● Cause of SQL injection vulnerability is from an SQL
command that constructs from the untrusted input.
● Common actions to interact with data are Create
(INSERT), Read (SELECT), Update, Delete.
● SELECT/UPDATE/DELETE are usually filtered only
some records, using WHERE.
● Some bad code use dynamic fields or tables, it’s also
able to be injected.
Sting custQuery =
“SELECT custName, address1, address2,
city, postalCode WHERE custID= ‘“ +
request.GetParameter(“id”) + “’“
Code
Data
Example: Find in Files for INSERT or WHERE
Example: Find in Files for INSERT or WHERE
1) Suspect
2) Is this an input
parameter?
3) Vulnerable from calling?
Review Remote Code Injection
● Both client side (JavaScript) and
server side (ex. PHP) scripting
● Search for data from untrusted
sources could be inputs of
– eval (most of scripting language)
– include, require (PHP)
eva1
Review Hard-Coded Password/Encryption Key
● Hard-coded passwords or
key may compromise
system security in a way
that cannot be easily
remedied.
● Developers may create a
backdoor with hard-coded
username and password
for special credential.
● Forms of password for
databases and application
are likely to be “password”,
“pass”, “passwd” or “pwd”.
→ RegEx: pass|pwd
● Borland Interbase 4.0, 5.0, 6.0 was
discovered a special credentials,
username “politically” and
password “correct”, were inserted
into the credential table at
program startup.
dpb = dpb_string;
*dpb++ = gds__dpb_version1;
*dpb++ = gds__dpb_user_name;
*dpb++ = strlen (LOCKSMITH_USER);
q = LOCKSMITH_USER;
while (*q) *dpb++ = *q++;
*dpb++ = gds__dpb_password_enc;
strcpy (password_enc, (char
*)ENC_crypt(LOCKSMITH_PASSWORD,
PASSWORD_SALT));
q = password_enc + 2;
*dpb++ = strlen (q);
while (*q) *dpb++ = *q++;
dpb_length = dpb – dpb_string;
isc_attach_database (status_vector, 0,
GDS_VAL(name), &DB, dpb_length,
dpb_string);
Review Poor Logging Practices
● Use of a System Output Stream
– Using System.out or System.err rather than a dedicated logging.
– Log messages may accidentally be returned to the end users and
expose sensitive information
public class MyClass
public void debug(Object message) {
System.out.println(message);
}
}
● Logger Not Declared Static Final
– Loggers should be declared to be static and final.
– Use the same logger for the duration of the program.
– The following statement errantly declares a non-static logger.
private final Logger logger = Logger.getLogger(MyClass.class);
Review Session Management
● .Net ASPX web.config
<authentication mode=”Forms”>
<forms loginUrl=”member_login.aspx”
cookieless=”UseCookies”
requireSSL=”true”
path=”/MyApplication” />
</authentication>
● Java web.xml
<session-config>
<cookie-config>
<secure>true</secure>
</cookie-config>
</session-config>
● PHP.ini
session.cookie_lifetime=0
session.use_cookies=On
session.use_only_cookies=On
session.use_strict_mode=On
session.cookie_httponly=On
session.cookie_secure=On
session.gc_maxlifetime=[choose smallest possible]
session.use_trans_sid=Off
Conclusion
● Code scanner absolutely helps code reviewers but
they are lacks of capabilities and usually create false
positive.
● Code reviewers should know the specific language
and framework of codes they reviews
● The justification must rely on the context and
requirements of the application together with
standards and guidelines
Secure Code Review 101
Ad

More Related Content

What's hot (20)

Application Security
Application SecurityApplication Security
Application Security
Reggie Niccolo Santos
 
Secure coding practices
Secure coding practicesSecure coding practices
Secure coding practices
Mohammed Danish Amber
 
CSSLP & OWASP & WebGoat
CSSLP & OWASP & WebGoatCSSLP & OWASP & WebGoat
CSSLP & OWASP & WebGoat
Surachai Chatchalermpun
 
Penetration Testing Basics
Penetration Testing BasicsPenetration Testing Basics
Penetration Testing Basics
Rick Wanner
 
Introduction to penetration testing
Introduction to penetration testingIntroduction to penetration testing
Introduction to penetration testing
Nezar Alazzabi
 
The Security Code Review Guide
The Security Code Review GuideThe Security Code Review Guide
The Security Code Review Guide
Nicola Pietroluongo
 
Introduction to Web Application Penetration Testing
Introduction to Web Application Penetration TestingIntroduction to Web Application Penetration Testing
Introduction to Web Application Penetration Testing
Anurag Srivastava
 
Penetration Testing Tutorial | Penetration Testing Tools | Cyber Security Tra...
Penetration Testing Tutorial | Penetration Testing Tools | Cyber Security Tra...Penetration Testing Tutorial | Penetration Testing Tools | Cyber Security Tra...
Penetration Testing Tutorial | Penetration Testing Tools | Cyber Security Tra...
Edureka!
 
Security testing fundamentals
Security testing fundamentalsSecurity testing fundamentals
Security testing fundamentals
Cygnet Infotech
 
Understanding Cross-site Request Forgery
Understanding Cross-site Request ForgeryUnderstanding Cross-site Request Forgery
Understanding Cross-site Request Forgery
Daniel Miessler
 
OWASP Top 10 Web Application Vulnerabilities
OWASP Top 10 Web Application VulnerabilitiesOWASP Top 10 Web Application Vulnerabilities
OWASP Top 10 Web Application Vulnerabilities
Software Guru
 
Vulnerability assessment and penetration testing
Vulnerability assessment and penetration testingVulnerability assessment and penetration testing
Vulnerability assessment and penetration testing
Abu Sadat Mohammed Yasin
 
Application Security - Your Success Depends on it
Application Security - Your Success Depends on itApplication Security - Your Success Depends on it
Application Security - Your Success Depends on it
WSO2
 
API Security Fundamentals
API Security FundamentalsAPI Security Fundamentals
API Security Fundamentals
José Haro Peralta
 
What is Penetration Testing?
What is Penetration Testing?What is Penetration Testing?
What is Penetration Testing?
btpsec
 
Simplified Security Code Review Process
Simplified Security Code Review ProcessSimplified Security Code Review Process
Simplified Security Code Review Process
Sherif Koussa
 
Security testing
Security testingSecurity testing
Security testing
Tabăra de Testare
 
Practical Malware Analysis: Ch 0: Malware Analysis Primer & 1: Basic Static T...
Practical Malware Analysis: Ch 0: Malware Analysis Primer & 1: Basic Static T...Practical Malware Analysis: Ch 0: Malware Analysis Primer & 1: Basic Static T...
Practical Malware Analysis: Ch 0: Malware Analysis Primer & 1: Basic Static T...
Sam Bowne
 
Vulnerability and Assessment Penetration Testing
Vulnerability and Assessment Penetration TestingVulnerability and Assessment Penetration Testing
Vulnerability and Assessment Penetration Testing
Yvonne Marambanyika
 
Application Security Architecture and Threat Modelling
Application Security Architecture and Threat ModellingApplication Security Architecture and Threat Modelling
Application Security Architecture and Threat Modelling
Priyanka Aash
 
Penetration Testing Basics
Penetration Testing BasicsPenetration Testing Basics
Penetration Testing Basics
Rick Wanner
 
Introduction to penetration testing
Introduction to penetration testingIntroduction to penetration testing
Introduction to penetration testing
Nezar Alazzabi
 
Introduction to Web Application Penetration Testing
Introduction to Web Application Penetration TestingIntroduction to Web Application Penetration Testing
Introduction to Web Application Penetration Testing
Anurag Srivastava
 
Penetration Testing Tutorial | Penetration Testing Tools | Cyber Security Tra...
Penetration Testing Tutorial | Penetration Testing Tools | Cyber Security Tra...Penetration Testing Tutorial | Penetration Testing Tools | Cyber Security Tra...
Penetration Testing Tutorial | Penetration Testing Tools | Cyber Security Tra...
Edureka!
 
Security testing fundamentals
Security testing fundamentalsSecurity testing fundamentals
Security testing fundamentals
Cygnet Infotech
 
Understanding Cross-site Request Forgery
Understanding Cross-site Request ForgeryUnderstanding Cross-site Request Forgery
Understanding Cross-site Request Forgery
Daniel Miessler
 
OWASP Top 10 Web Application Vulnerabilities
OWASP Top 10 Web Application VulnerabilitiesOWASP Top 10 Web Application Vulnerabilities
OWASP Top 10 Web Application Vulnerabilities
Software Guru
 
Vulnerability assessment and penetration testing
Vulnerability assessment and penetration testingVulnerability assessment and penetration testing
Vulnerability assessment and penetration testing
Abu Sadat Mohammed Yasin
 
Application Security - Your Success Depends on it
Application Security - Your Success Depends on itApplication Security - Your Success Depends on it
Application Security - Your Success Depends on it
WSO2
 
What is Penetration Testing?
What is Penetration Testing?What is Penetration Testing?
What is Penetration Testing?
btpsec
 
Simplified Security Code Review Process
Simplified Security Code Review ProcessSimplified Security Code Review Process
Simplified Security Code Review Process
Sherif Koussa
 
Practical Malware Analysis: Ch 0: Malware Analysis Primer & 1: Basic Static T...
Practical Malware Analysis: Ch 0: Malware Analysis Primer & 1: Basic Static T...Practical Malware Analysis: Ch 0: Malware Analysis Primer & 1: Basic Static T...
Practical Malware Analysis: Ch 0: Malware Analysis Primer & 1: Basic Static T...
Sam Bowne
 
Vulnerability and Assessment Penetration Testing
Vulnerability and Assessment Penetration TestingVulnerability and Assessment Penetration Testing
Vulnerability and Assessment Penetration Testing
Yvonne Marambanyika
 
Application Security Architecture and Threat Modelling
Application Security Architecture and Threat ModellingApplication Security Architecture and Threat Modelling
Application Security Architecture and Threat Modelling
Priyanka Aash
 

Similar to Secure Code Review 101 (20)

Shift Left Security
Shift Left SecurityShift Left Security
Shift Left Security
gjdevos
 
Security in open source projects
Security in open source projectsSecurity in open source projects
Security in open source projects
Jose Manuel Ortega Candel
 
Demystify Information Security & Threats for Data-Driven Platforms With Cheta...
Demystify Information Security & Threats for Data-Driven Platforms With Cheta...Demystify Information Security & Threats for Data-Driven Platforms With Cheta...
Demystify Information Security & Threats for Data-Driven Platforms With Cheta...
Chetan Khatri
 
DevSecOps: What Why and How : Blackhat 2019
DevSecOps: What Why and How : Blackhat 2019DevSecOps: What Why and How : Blackhat 2019
DevSecOps: What Why and How : Blackhat 2019
NotSoSecure Global Services
 
Agile Secure Development
Agile Secure DevelopmentAgile Secure Development
Agile Secure Development
Bosnia Agile
 
Shift Left Security
Shift Left SecurityShift Left Security
Shift Left Security
gjdevos
 
Course_Presentation cyber --------------.pptx
Course_Presentation cyber --------------.pptxCourse_Presentation cyber --------------.pptx
Course_Presentation cyber --------------.pptx
ssuser020436
 
Coding Security: Code Mania 101
Coding Security: Code Mania 101Coding Security: Code Mania 101
Coding Security: Code Mania 101
Narudom Roongsiriwong, CISSP
 
BroadStrong Software Room Profile
BroadStrong Software Room ProfileBroadStrong Software Room Profile
BroadStrong Software Room Profile
Henry Li
 
Serverless survival kit
Serverless survival kitServerless survival kit
Serverless survival kit
Steve Houël
 
MongoDB .local Bengaluru 2019: New Encryption Capabilities in MongoDB 4.2: A ...
MongoDB .local Bengaluru 2019: New Encryption Capabilities in MongoDB 4.2: A ...MongoDB .local Bengaluru 2019: New Encryption Capabilities in MongoDB 4.2: A ...
MongoDB .local Bengaluru 2019: New Encryption Capabilities in MongoDB 4.2: A ...
MongoDB
 
OWASP ZAP Workshop for QA Testers
OWASP ZAP Workshop for QA TestersOWASP ZAP Workshop for QA Testers
OWASP ZAP Workshop for QA Testers
Javan Rasokat
 
Resume ram-krishna
Resume ram-krishnaResume ram-krishna
Resume ram-krishna
Ram Krishna | BitHostIn
 
Introduction to Backend Development (1).pptx
Introduction to Backend Development (1).pptxIntroduction to Backend Development (1).pptx
Introduction to Backend Development (1).pptx
OsuGodbless
 
Webinar: Scaling MongoDB
Webinar: Scaling MongoDBWebinar: Scaling MongoDB
Webinar: Scaling MongoDB
MongoDB
 
WebGoat.SDWAN.Net in Depth
WebGoat.SDWAN.Net in DepthWebGoat.SDWAN.Net in Depth
WebGoat.SDWAN.Net in Depth
yalegko
 
WebGoat.SDWAN.Net in Depth: SD-WAN Security Assessment
WebGoat.SDWAN.Net in Depth: SD-WAN Security Assessment WebGoat.SDWAN.Net in Depth: SD-WAN Security Assessment
WebGoat.SDWAN.Net in Depth: SD-WAN Security Assessment
Sergey Gordeychik
 
MongoDB SoCal 2020: Migrate Anything* to MongoDB Atlas
MongoDB SoCal 2020: Migrate Anything* to MongoDB AtlasMongoDB SoCal 2020: Migrate Anything* to MongoDB Atlas
MongoDB SoCal 2020: Migrate Anything* to MongoDB Atlas
MongoDB
 
Backend Developer Roadmap PDF By ScholarHat
Backend Developer Roadmap PDF By ScholarHatBackend Developer Roadmap PDF By ScholarHat
Backend Developer Roadmap PDF By ScholarHat
Scholarhat
 
OWASP_Top_Ten_Proactive_Controls_v32.pptx
OWASP_Top_Ten_Proactive_Controls_v32.pptxOWASP_Top_Ten_Proactive_Controls_v32.pptx
OWASP_Top_Ten_Proactive_Controls_v32.pptx
nmk42194
 
Shift Left Security
Shift Left SecurityShift Left Security
Shift Left Security
gjdevos
 
Demystify Information Security & Threats for Data-Driven Platforms With Cheta...
Demystify Information Security & Threats for Data-Driven Platforms With Cheta...Demystify Information Security & Threats for Data-Driven Platforms With Cheta...
Demystify Information Security & Threats for Data-Driven Platforms With Cheta...
Chetan Khatri
 
Agile Secure Development
Agile Secure DevelopmentAgile Secure Development
Agile Secure Development
Bosnia Agile
 
Shift Left Security
Shift Left SecurityShift Left Security
Shift Left Security
gjdevos
 
Course_Presentation cyber --------------.pptx
Course_Presentation cyber --------------.pptxCourse_Presentation cyber --------------.pptx
Course_Presentation cyber --------------.pptx
ssuser020436
 
BroadStrong Software Room Profile
BroadStrong Software Room ProfileBroadStrong Software Room Profile
BroadStrong Software Room Profile
Henry Li
 
Serverless survival kit
Serverless survival kitServerless survival kit
Serverless survival kit
Steve Houël
 
MongoDB .local Bengaluru 2019: New Encryption Capabilities in MongoDB 4.2: A ...
MongoDB .local Bengaluru 2019: New Encryption Capabilities in MongoDB 4.2: A ...MongoDB .local Bengaluru 2019: New Encryption Capabilities in MongoDB 4.2: A ...
MongoDB .local Bengaluru 2019: New Encryption Capabilities in MongoDB 4.2: A ...
MongoDB
 
OWASP ZAP Workshop for QA Testers
OWASP ZAP Workshop for QA TestersOWASP ZAP Workshop for QA Testers
OWASP ZAP Workshop for QA Testers
Javan Rasokat
 
Introduction to Backend Development (1).pptx
Introduction to Backend Development (1).pptxIntroduction to Backend Development (1).pptx
Introduction to Backend Development (1).pptx
OsuGodbless
 
Webinar: Scaling MongoDB
Webinar: Scaling MongoDBWebinar: Scaling MongoDB
Webinar: Scaling MongoDB
MongoDB
 
WebGoat.SDWAN.Net in Depth
WebGoat.SDWAN.Net in DepthWebGoat.SDWAN.Net in Depth
WebGoat.SDWAN.Net in Depth
yalegko
 
WebGoat.SDWAN.Net in Depth: SD-WAN Security Assessment
WebGoat.SDWAN.Net in Depth: SD-WAN Security Assessment WebGoat.SDWAN.Net in Depth: SD-WAN Security Assessment
WebGoat.SDWAN.Net in Depth: SD-WAN Security Assessment
Sergey Gordeychik
 
MongoDB SoCal 2020: Migrate Anything* to MongoDB Atlas
MongoDB SoCal 2020: Migrate Anything* to MongoDB AtlasMongoDB SoCal 2020: Migrate Anything* to MongoDB Atlas
MongoDB SoCal 2020: Migrate Anything* to MongoDB Atlas
MongoDB
 
Backend Developer Roadmap PDF By ScholarHat
Backend Developer Roadmap PDF By ScholarHatBackend Developer Roadmap PDF By ScholarHat
Backend Developer Roadmap PDF By ScholarHat
Scholarhat
 
OWASP_Top_Ten_Proactive_Controls_v32.pptx
OWASP_Top_Ten_Proactive_Controls_v32.pptxOWASP_Top_Ten_Proactive_Controls_v32.pptx
OWASP_Top_Ten_Proactive_Controls_v32.pptx
nmk42194
 
Ad

More from Narudom Roongsiriwong, CISSP (20)

Biometric Authentication.pdf
Biometric Authentication.pdfBiometric Authentication.pdf
Biometric Authentication.pdf
Narudom Roongsiriwong, CISSP
 
Security Shift Leftmost - Secure Architecture.pdf
Security Shift Leftmost - Secure Architecture.pdfSecurity Shift Leftmost - Secure Architecture.pdf
Security Shift Leftmost - Secure Architecture.pdf
Narudom Roongsiriwong, CISSP
 
Secure Design: Threat Modeling
Secure Design: Threat ModelingSecure Design: Threat Modeling
Secure Design: Threat Modeling
Narudom Roongsiriwong, CISSP
 
Security Patterns for Software Development
Security Patterns for Software DevelopmentSecurity Patterns for Software Development
Security Patterns for Software Development
Narudom Roongsiriwong, CISSP
 
How Good Security Architecture Saves Corporate Workers from COVID-19
How Good Security Architecture Saves Corporate Workers from COVID-19How Good Security Architecture Saves Corporate Workers from COVID-19
How Good Security Architecture Saves Corporate Workers from COVID-19
Narudom Roongsiriwong, CISSP
 
Secure Software Design for Data Privacy
Secure Software Design for Data PrivacySecure Software Design for Data Privacy
Secure Software Design for Data Privacy
Narudom Roongsiriwong, CISSP
 
Blockchain and Cryptocurrency for Dummies
Blockchain and Cryptocurrency for DummiesBlockchain and Cryptocurrency for Dummies
Blockchain and Cryptocurrency for Dummies
Narudom Roongsiriwong, CISSP
 
DevSecOps 101
DevSecOps 101DevSecOps 101
DevSecOps 101
Narudom Roongsiriwong, CISSP
 
National Digital ID Platform Technical Forum
National Digital ID Platform Technical ForumNational Digital ID Platform Technical Forum
National Digital ID Platform Technical Forum
Narudom Roongsiriwong, CISSP
 
IoT Security
IoT SecurityIoT Security
IoT Security
Narudom Roongsiriwong, CISSP
 
Embedded System Security: Learning from Banking and Payment Industry
Embedded System Security: Learning from Banking and Payment IndustryEmbedded System Security: Learning from Banking and Payment Industry
Embedded System Security: Learning from Banking and Payment Industry
Narudom Roongsiriwong, CISSP
 
Secure Your Encryption with HSM
Secure Your Encryption with HSMSecure Your Encryption with HSM
Secure Your Encryption with HSM
Narudom Roongsiriwong, CISSP
 
Top 10 Bad Coding Practices Lead to Security Problems
Top 10 Bad Coding Practices Lead to Security ProblemsTop 10 Bad Coding Practices Lead to Security Problems
Top 10 Bad Coding Practices Lead to Security Problems
Narudom Roongsiriwong, CISSP
 
OWASP Top 10 Proactive Control 2016 (C5-C10)
OWASP Top 10 Proactive Control 2016 (C5-C10)OWASP Top 10 Proactive Control 2016 (C5-C10)
OWASP Top 10 Proactive Control 2016 (C5-C10)
Narudom Roongsiriwong, CISSP
 
Securing the Internet from Cyber Criminals
Securing the Internet from Cyber CriminalsSecuring the Internet from Cyber Criminals
Securing the Internet from Cyber Criminals
Narudom Roongsiriwong, CISSP
 
Secure Software Development Adoption Strategy
Secure Software Development Adoption StrategySecure Software Development Adoption Strategy
Secure Software Development Adoption Strategy
Narudom Roongsiriwong, CISSP
 
Secure PHP Coding
Secure PHP CodingSecure PHP Coding
Secure PHP Coding
Narudom Roongsiriwong, CISSP
 
Application Security: Last Line of Defense
Application Security: Last Line of DefenseApplication Security: Last Line of Defense
Application Security: Last Line of Defense
Narudom Roongsiriwong, CISSP
 
AnyID and Privacy
AnyID and PrivacyAnyID and Privacy
AnyID and Privacy
Narudom Roongsiriwong, CISSP
 
OWASP Top 10 A4 – Insecure Direct Object Reference
OWASP Top 10 A4 – Insecure Direct Object ReferenceOWASP Top 10 A4 – Insecure Direct Object Reference
OWASP Top 10 A4 – Insecure Direct Object Reference
Narudom Roongsiriwong, CISSP
 
How Good Security Architecture Saves Corporate Workers from COVID-19
How Good Security Architecture Saves Corporate Workers from COVID-19How Good Security Architecture Saves Corporate Workers from COVID-19
How Good Security Architecture Saves Corporate Workers from COVID-19
Narudom Roongsiriwong, CISSP
 
Embedded System Security: Learning from Banking and Payment Industry
Embedded System Security: Learning from Banking and Payment IndustryEmbedded System Security: Learning from Banking and Payment Industry
Embedded System Security: Learning from Banking and Payment Industry
Narudom Roongsiriwong, CISSP
 
Top 10 Bad Coding Practices Lead to Security Problems
Top 10 Bad Coding Practices Lead to Security ProblemsTop 10 Bad Coding Practices Lead to Security Problems
Top 10 Bad Coding Practices Lead to Security Problems
Narudom Roongsiriwong, CISSP
 
OWASP Top 10 A4 – Insecure Direct Object Reference
OWASP Top 10 A4 – Insecure Direct Object ReferenceOWASP Top 10 A4 – Insecure Direct Object Reference
OWASP Top 10 A4 – Insecure Direct Object Reference
Narudom Roongsiriwong, CISSP
 
Ad

Recently uploaded (20)

Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul
 
Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025
Splunk
 
Role of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered ManufacturingRole of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered Manufacturing
Andrew Leo
 
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes
 
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Aqusag Technologies
 
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptxSpecial Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
shyamraj55
 
HCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser EnvironmentsHCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser Environments
panagenda
 
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
Alan Dix
 
Generative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in BusinessGenerative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in Business
Dr. Tathagat Varma
 
Procurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptxProcurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptx
Jon Hansen
 
What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...
Vishnu Singh Chundawat
 
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath MaestroDev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
UiPathCommunity
 
TrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business ConsultingTrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business Consulting
Trs Labs
 
tecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdftecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdf
fjgm517
 
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager APIUiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPathCommunity
 
Technology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data AnalyticsTechnology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data Analytics
InData Labs
 
Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.
hpbmnnxrvb
 
How analogue intelligence complements AI
How analogue intelligence complements AIHow analogue intelligence complements AI
How analogue intelligence complements AI
Paul Rowe
 
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-UmgebungenHCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
panagenda
 
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptxIncreasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Anoop Ashok
 
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul
 
Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025
Splunk
 
Role of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered ManufacturingRole of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered Manufacturing
Andrew Leo
 
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes
 
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Aqusag Technologies
 
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptxSpecial Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
shyamraj55
 
HCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser EnvironmentsHCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser Environments
panagenda
 
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
Alan Dix
 
Generative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in BusinessGenerative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in Business
Dr. Tathagat Varma
 
Procurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptxProcurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptx
Jon Hansen
 
What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...
Vishnu Singh Chundawat
 
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath MaestroDev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
UiPathCommunity
 
TrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business ConsultingTrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business Consulting
Trs Labs
 
tecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdftecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdf
fjgm517
 
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager APIUiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPathCommunity
 
Technology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data AnalyticsTechnology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data Analytics
InData Labs
 
Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.
hpbmnnxrvb
 
How analogue intelligence complements AI
How analogue intelligence complements AIHow analogue intelligence complements AI
How analogue intelligence complements AI
Paul Rowe
 
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-UmgebungenHCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
panagenda
 
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptxIncreasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Anoop Ashok
 

Secure Code Review 101

  • 1. Secure Code Review 101Secure Code Review 101 Narudom Roongsiriwong, CISSPNarudom Roongsiriwong, CISSP MiSSConf(SP2) Nov 19, 2016MiSSConf(SP2) Nov 19, 2016 Secure Code Review 101Secure Code Review 101 Narudom Roongsiriwong, CISSPNarudom Roongsiriwong, CISSP MiSSConf(SP2) Nov 19, 2016MiSSConf(SP2) Nov 19, 2016
  • 2. WhoAmI ● Lazy Blogger – Japan, Security, FOSS, Politics, Christian – http://narudomr.blogspot.com ● Information Security since 1995 ● Web Application Development since 1998 ● Head of IT Security and Solution Architecture, Kiatnakin Bank PLC (KKP) ● Consultant for OWASP Thailand Chapter ● Committee Member of Cloud Security Alliance (CSA), Thailand Chapter ● Consulting Team Member for National e-Payment project ● Contact: [email protected]
  • 3. Security controls cannot deal with broken business logic such as A2, A4 and A7 Security controls cannot deal with broken business logic such as A2, A4 and A7 Software weaknesses reduction down to zero is possible Software weaknesses reduction down to zero is possible Reduce Security Weaknesses vs Increase Security Controls
  • 4. What is Secure Code Review? ● Aim to identify security flaws in the application related to its features and design, along with the exact root causes. ● Verify that the proper security and logical controls are present, work as intended, and have been invoked in the right places. ● Assure application developers are following secure development techniques. ● Combine human effort and advanced static analysis tools.
  • 5. Code Review and Secure Code Review ● Secure Code Review enhances the standard Code Review practice with security considerations. – Security standards – Security risks in the code base – Security context ● Reviewers must have the necessary skills and secure coding knowledge to effectively evaluate the code.
  • 6. Code Review in Secure SDLC Code Review
  • 7. How Code Review Reduces Costs on Bug Fixes Relative cost of security fixes, based on time of detection Source: The National Institute of Standards and Technology (NIST) Code Review Penetration Testing
  • 8. Method Comparison to Cover High Level Topics Good Some None Source: Code Review Guide 2.0 (Alpha Release)
  • 9. Method Comparison Against OWASP Top 10 Risks Good Some None Source: Code Review Guide 2.0 (Alpha Release)
  • 10. Factors to Consider in Code Review Process ● Risks ● Purpose & Context – A payment web application will have higher security standards than a promotional website. ● Lines of Code: the more lines, the more bugs ● Programming Language – Unmanaged code → Chances of buffer overflow – PHP → Remote code execution ● Resources, Time & Deadlines
  • 11. Code Review Preparation ● Application Features and Business Rules – BR, SRS, etc ● Context ● Sensitive Data ● User Roles and Access Rights ● Application Type – Web, Desktop, Web Service, Mobile, Hybrid ● Language and Its Security Features and Issues ● Design / Framework – MVC, Strut, Spring, Hibernate, YII, CakePHP ● Company Standards and Guidelines
  • 12. Code Review Checklist ● Data Validation ● Authentication ● Session Management ● Authorization ● Cryptography ● Error Handling ● Logging ● Security Configuration ● Network Architecture
  • 13. Advantage & Disadvantage of Source Code Scanner ● Advantage – Reduction in manual efforts – Find all the instances of the vulnerabilities – Source to sink analysis – Elaborate reporting format ● Disadvantage – Business logic flaws remain untouched – Limited scope – Design flaws – False positives
  • 14. Name Programming Language Support OS Java PHP .NET C C++ Python Other CodePro X W L M FindBugs X W L FxCop X W Flawfinder X X L Milk X X W L MOPS X L OWASP Code Crawler X X W OWASP ORIZON X X X L OWASP O2 Platform X X Javascript W OWASP LAPSE X W L M PMD X X X Javascript, XML, XSL W L PREfast X X W L RIPS-Scanner X SonarQube X X X X Delphi, Javascript, XML W L M Sprint X W L StypeCop X W Yasca X X X X X HTML, , Javascript, Cobol, Coldfusion W L Free Source Code Scanners
  • 15. Example: SonarQube with OWASP Plugin
  • 16. Let’s Go Back to Basic without Code Scanner ● Use your favorite text editor or IDE. ● “Find in Files” feature with RegEx is recommended. ● In this presentation will show you “Geany”, cross platform text editor. https://www.geany.org
  • 17. Review SQL Injection ● Cause of SQL injection vulnerability is from an SQL command that constructs from the untrusted input. ● Common actions to interact with data are Create (INSERT), Read (SELECT), Update, Delete. ● SELECT/UPDATE/DELETE are usually filtered only some records, using WHERE. ● Some bad code use dynamic fields or tables, it’s also able to be injected. Sting custQuery = “SELECT custName, address1, address2, city, postalCode WHERE custID= ‘“ + request.GetParameter(“id”) + “’“ Code Data
  • 18. Example: Find in Files for INSERT or WHERE
  • 19. Example: Find in Files for INSERT or WHERE 1) Suspect 2) Is this an input parameter? 3) Vulnerable from calling?
  • 20. Review Remote Code Injection ● Both client side (JavaScript) and server side (ex. PHP) scripting ● Search for data from untrusted sources could be inputs of – eval (most of scripting language) – include, require (PHP) eva1
  • 21. Review Hard-Coded Password/Encryption Key ● Hard-coded passwords or key may compromise system security in a way that cannot be easily remedied. ● Developers may create a backdoor with hard-coded username and password for special credential. ● Forms of password for databases and application are likely to be “password”, “pass”, “passwd” or “pwd”. → RegEx: pass|pwd ● Borland Interbase 4.0, 5.0, 6.0 was discovered a special credentials, username “politically” and password “correct”, were inserted into the credential table at program startup. dpb = dpb_string; *dpb++ = gds__dpb_version1; *dpb++ = gds__dpb_user_name; *dpb++ = strlen (LOCKSMITH_USER); q = LOCKSMITH_USER; while (*q) *dpb++ = *q++; *dpb++ = gds__dpb_password_enc; strcpy (password_enc, (char *)ENC_crypt(LOCKSMITH_PASSWORD, PASSWORD_SALT)); q = password_enc + 2; *dpb++ = strlen (q); while (*q) *dpb++ = *q++; dpb_length = dpb – dpb_string; isc_attach_database (status_vector, 0, GDS_VAL(name), &DB, dpb_length, dpb_string);
  • 22. Review Poor Logging Practices ● Use of a System Output Stream – Using System.out or System.err rather than a dedicated logging. – Log messages may accidentally be returned to the end users and expose sensitive information public class MyClass public void debug(Object message) { System.out.println(message); } } ● Logger Not Declared Static Final – Loggers should be declared to be static and final. – Use the same logger for the duration of the program. – The following statement errantly declares a non-static logger. private final Logger logger = Logger.getLogger(MyClass.class);
  • 23. Review Session Management ● .Net ASPX web.config <authentication mode=”Forms”> <forms loginUrl=”member_login.aspx” cookieless=”UseCookies” requireSSL=”true” path=”/MyApplication” /> </authentication> ● Java web.xml <session-config> <cookie-config> <secure>true</secure> </cookie-config> </session-config> ● PHP.ini session.cookie_lifetime=0 session.use_cookies=On session.use_only_cookies=On session.use_strict_mode=On session.cookie_httponly=On session.cookie_secure=On session.gc_maxlifetime=[choose smallest possible] session.use_trans_sid=Off
  • 24. Conclusion ● Code scanner absolutely helps code reviewers but they are lacks of capabilities and usually create false positive. ● Code reviewers should know the specific language and framework of codes they reviews ● The justification must rely on the context and requirements of the application together with standards and guidelines