SlideShare a Scribd company logo
SECURE CODE
TRAINING
Error Handling and Logging
DAVID CERVIGNI
IT SECURITY CONSULTANT AND
PCI CODE REVIEWER
Bad Error Handling Risks
• Information disclosure
• Lack of Availability (DoS)
• Unhandled status leads to malicious behavior being
unnoticed
INSTEAD:
– Not Just catching exception
– Not Just logging exception/errors
Handle all failures securely and return the system to a proper
state!
Avoid information disclosure…
• Do not disclose sensitive information in error
responses, including system details, session
identifiers or account information
• Use error handlers that do not display debugging
or stack trace information
• Implement generic error messages and use
custom error pages
…and fail safely
• The application should handle application
errors and not rely on the server configuration
• Properly free allocated memory(resources)
when error conditions occur
• Error handling logic associated with security
controls should deny access by default
Server Error pages
web.xml:
<error-page> <error-code>500</error-code> <location>/app/error</location>
</error-page>
<error-page> <exception-type>java.lang.Exception</exception-type>
<location>/app/error</location> </error-page>
<error-page> <error-code>400</error-code>
<location>/index.jsp</location>
</error-page>
<error-page> <error-code>403</error-code>
<location>/app/403</location>
</error-page>
May be never enough: one solution is to configure WAF/reverse proxy
interceptor.
Stacktraces monsters
ERR00-J. Do not suppress or ignore checked
exceptions
NON COMPLIANT
COMPLIANT
LOGS
Checklist & Examples
Why we log?
Many industries are required by legal and regulatory requirements to be:
• Auditable – all activities that affect user state or balances are formally
tracked
• Traceable – it’s possible to determine where an activity occurs in all tiers
of the application
• High integrity – logs cannot be overwritten or tampered with by local or
remote users
Well-written applications will dual-purpose logs and activity traces for audit
and monitoring, and make it easy to track a transaction without excessive
effort or access to the system. They should possess the ability to easily track
or identify potential fraud or anomalies end-to-end.
Proper logging checklist
• All logging controls should be implemented on a trusted system (e.g., The server)
• Logging controls should support both success and failure of specified security events
• Ensure logs contain important log event data: Log Event Data, This should include the following:
– 1. Time stamp from a trusted system component
– 2. Severity rating for each event
– 3. Tagging of security relevant events, if they are mixed with other log entries
– 4. Identity of the account/user that caused the event
– 5. Source IP address associated with the request
– 6. Event outcome (success or failure)
– 7. Description of the event
• Restrict access to logs to only authorized individuals
• Utilize a master routine for all logging operations
• Do not store sensitive information in logs, including unnecessary system details, session identifiers
or passwords
• Ensure that a mechanism exists to conduct log analysis
Proper logging checklist
• Log all input validation failures
• Log all authentication attempts, especially failures
• Log all access control failures
• Log all apparent tampering events, including unexpected changes to state
data
• Log attempts to connect with invalid or expired session tokens
• Log all system exceptions
• Log all administrative functions, including changes to the security
configuration settings
• Log all backend TLS connection failures
• Log cryptographic module failures
Log forging
Log forging vulnerabilities occur when:
• Data enters an application from an untrusted source.
• The data is written to an application or system log file.
Log forging
If a user submits the string "twenty-one" for val, the following entry is logged:
INFO: Failed to parse val=twenty-one
However, if an attacker submits the string
"twenty-one%0a%0aINFO:+User+logged+out%3dbadguy",
the following entry is logged:
INFO: Failed to parse val=twenty-one
INFO: User logged out=badguy
Log injection & blind XSS example
• Impacting through downstream systems (log monitoring, analysis, feeds)
Contextual logging libraries
• Log4j MDC (Mapped Diagnostic Context)
• Is part of Log4j 2 API
Log correlation and aggregation
• WAF/PROXY/LB/WEBAPP/DB
Cryptographic log integrity
Audit trails are legally protected in many countries, and should be
logged into high integrity destinations to prevent casual and motivated
tampering and destruction.
How to determine if you are vulnerable
• Do the logs transit in the clear between the logging host and the
destination?
• Do the logs have a HMAC or similar tamper proofing mechanism to
prevent change from the time of the logging activity to when it is
reviewed?
• Can relevant logs be easily extracted in a legally sound fashion to
assist with prosecutions?
SECURE CODE
TRAINING
INTENSIVE COURSE
DAVID CERVIGNI
IT SECURITY CONSULTANT AND
PCI CODE REVIEWER
References:
https://www.owasp.org/index.php/Log_Injection
https://www.securecoding.cert.org/confluence/pages/viewp
age.action?pageId=18581047
https://logging.apache.org/log4j/2.x/manual/thread-
context.html
https://www.owasp.org/index.php/Error_Handling,_Auditing
_and_Logging
https://www.loggly.com/ultimate-guide/java-logging-basics/

More Related Content

What's hot

Determining Scope for PCI DSS Compliance
Determining Scope for PCI DSS ComplianceDetermining Scope for PCI DSS Compliance
Determining Scope for PCI DSS Compliance
Schellman & Company
 
OWASP Top 10 2017 - New Vulnerabilities
OWASP Top 10 2017 - New VulnerabilitiesOWASP Top 10 2017 - New Vulnerabilities
OWASP Top 10 2017 - New Vulnerabilities
Dilum Bandara
 
Firewall Analyzer - Middle East Workshop
Firewall Analyzer - Middle East WorkshopFirewall Analyzer - Middle East Workshop
Firewall Analyzer - Middle East Workshop
ManageEngine, Zoho Corporation
 
Anatomy Web Attack
Anatomy Web AttackAnatomy Web Attack
Anatomy Web Attack
Kelly Speiser
 
Taking the Pain out of PCI Compliance
Taking the Pain out of PCI ComplianceTaking the Pain out of PCI Compliance
Taking the Pain out of PCI Compliance
Tripwire
 
OWASP Top Ten in Practice
OWASP Top Ten in PracticeOWASP Top Ten in Practice
OWASP Top Ten in Practice
Security Innovation
 
Data security authorization and access control
Data security  authorization and access controlData security  authorization and access control
Data security authorization and access control
Leo Mark Villar
 
Data/File Security & Control
Data/File Security & ControlData/File Security & Control
Data/File Security & Control
Adetula Bunmi
 
Secure coding guidelines
Secure coding guidelinesSecure coding guidelines
Secure coding guidelines
Sathyanarayana Panduranga
 
NetGains Infrastructure Security
NetGains Infrastructure SecurityNetGains Infrastructure Security
NetGains Infrastructure Security
NetGains Technologies Pvt. Ltd.
 
Introduction to Gravitational Teleport
Introduction to Gravitational TeleportIntroduction to Gravitational Teleport
Introduction to Gravitational Teleport
Teleport
 
OWASP TOP 10
OWASP TOP 10OWASP TOP 10
OWASP TOP 10
Robert MacLean
 
IT security : Keep calm and monitor PowerShell
IT security : Keep calm and monitor PowerShellIT security : Keep calm and monitor PowerShell
IT security : Keep calm and monitor PowerShell
ManageEngine
 
8 must dos for a perfect privileged account management strategy
8 must dos for a perfect privileged account management strategy8 must dos for a perfect privileged account management strategy
8 must dos for a perfect privileged account management strategy
ManageEngine
 
Web attacks
Web attacksWeb attacks
Web attacks
husnara mohammad
 
Java zone ASVS 2015
Java zone ASVS 2015Java zone ASVS 2015
Java zone ASVS 2015
Joachim Van der Auwera
 
Virtual Web Application Firewall (vAWF) Data Sheet - Array Networks
Virtual Web Application Firewall (vAWF) Data Sheet - Array NetworksVirtual Web Application Firewall (vAWF) Data Sheet - Array Networks
Virtual Web Application Firewall (vAWF) Data Sheet - Array Networks
Array Networks
 
Firewall log and network security management - Mumbai Seminar
Firewall log and network security management - Mumbai SeminarFirewall log and network security management - Mumbai Seminar
Firewall log and network security management - Mumbai Seminar
ManageEngine, Zoho Corporation
 
MBESDatasheet
MBESDatasheetMBESDatasheet
MBESDatasheet
Wiveka O'Sullivan
 
Splunk for ibtrm
Splunk for ibtrmSplunk for ibtrm
Splunk for ibtrm
Greg Hanchin
 

What's hot (20)

Determining Scope for PCI DSS Compliance
Determining Scope for PCI DSS ComplianceDetermining Scope for PCI DSS Compliance
Determining Scope for PCI DSS Compliance
 
OWASP Top 10 2017 - New Vulnerabilities
OWASP Top 10 2017 - New VulnerabilitiesOWASP Top 10 2017 - New Vulnerabilities
OWASP Top 10 2017 - New Vulnerabilities
 
Firewall Analyzer - Middle East Workshop
Firewall Analyzer - Middle East WorkshopFirewall Analyzer - Middle East Workshop
Firewall Analyzer - Middle East Workshop
 
Anatomy Web Attack
Anatomy Web AttackAnatomy Web Attack
Anatomy Web Attack
 
Taking the Pain out of PCI Compliance
Taking the Pain out of PCI ComplianceTaking the Pain out of PCI Compliance
Taking the Pain out of PCI Compliance
 
OWASP Top Ten in Practice
OWASP Top Ten in PracticeOWASP Top Ten in Practice
OWASP Top Ten in Practice
 
Data security authorization and access control
Data security  authorization and access controlData security  authorization and access control
Data security authorization and access control
 
Data/File Security & Control
Data/File Security & ControlData/File Security & Control
Data/File Security & Control
 
Secure coding guidelines
Secure coding guidelinesSecure coding guidelines
Secure coding guidelines
 
NetGains Infrastructure Security
NetGains Infrastructure SecurityNetGains Infrastructure Security
NetGains Infrastructure Security
 
Introduction to Gravitational Teleport
Introduction to Gravitational TeleportIntroduction to Gravitational Teleport
Introduction to Gravitational Teleport
 
OWASP TOP 10
OWASP TOP 10OWASP TOP 10
OWASP TOP 10
 
IT security : Keep calm and monitor PowerShell
IT security : Keep calm and monitor PowerShellIT security : Keep calm and monitor PowerShell
IT security : Keep calm and monitor PowerShell
 
8 must dos for a perfect privileged account management strategy
8 must dos for a perfect privileged account management strategy8 must dos for a perfect privileged account management strategy
8 must dos for a perfect privileged account management strategy
 
Web attacks
Web attacksWeb attacks
Web attacks
 
Java zone ASVS 2015
Java zone ASVS 2015Java zone ASVS 2015
Java zone ASVS 2015
 
Virtual Web Application Firewall (vAWF) Data Sheet - Array Networks
Virtual Web Application Firewall (vAWF) Data Sheet - Array NetworksVirtual Web Application Firewall (vAWF) Data Sheet - Array Networks
Virtual Web Application Firewall (vAWF) Data Sheet - Array Networks
 
Firewall log and network security management - Mumbai Seminar
Firewall log and network security management - Mumbai SeminarFirewall log and network security management - Mumbai Seminar
Firewall log and network security management - Mumbai Seminar
 
MBESDatasheet
MBESDatasheetMBESDatasheet
MBESDatasheet
 
Splunk for ibtrm
Splunk for ibtrmSplunk for ibtrm
Splunk for ibtrm
 

Similar to Cm4 secure code_training_1day_error handling and logging

How to Test for The OWASP Top Ten
 How to Test for The OWASP Top Ten How to Test for The OWASP Top Ten
How to Test for The OWASP Top Ten
Security Innovation
 
Security Practices - Logging.pptx
Security Practices - Logging.pptxSecurity Practices - Logging.pptx
Security Practices - Logging.pptx
Alireza Vafi
 
Security testing
Security testingSecurity testing
Security testing
Rihab Chebbah
 
The 5 Layers of Security Testing by Alan Koch
The 5 Layers of Security Testing by Alan KochThe 5 Layers of Security Testing by Alan Koch
The 5 Layers of Security Testing by Alan Koch
QA or the Highway
 
The 5 Layers of Security Testing by Alan Koch
The 5 Layers of Security Testing by Alan KochThe 5 Layers of Security Testing by Alan Koch
The 5 Layers of Security Testing by Alan Koch
QA or the Highway
 
Secure code practices
Secure code practicesSecure code practices
Secure code practices
Hina Rawal
 
Web security uploadv1
Web security uploadv1Web security uploadv1
Web security uploadv1
Setia Juli Irzal Ismail
 
2013 OWASP Top 10
2013 OWASP Top 102013 OWASP Top 10
2013 OWASP Top 10
bilcorry
 
Monitoring and Reporting on IBM i Compliance and Security
Monitoring and Reporting on IBM i Compliance and SecurityMonitoring and Reporting on IBM i Compliance and Security
Monitoring and Reporting on IBM i Compliance and Security
Precisely
 
5 Things Your Security Administrator Should Tell You
5 Things Your Security Administrator Should Tell You5 Things Your Security Administrator Should Tell You
5 Things Your Security Administrator Should Tell You
HelpSystems
 
Owasp Proactive Controls for Web developer
Owasp  Proactive Controls for Web developerOwasp  Proactive Controls for Web developer
Owasp Proactive Controls for Web developer
Sameer Paradia
 
09 application security fundamentals - part 2 - security mechanisms - logging
09   application security fundamentals - part 2 - security mechanisms - logging09   application security fundamentals - part 2 - security mechanisms - logging
09 application security fundamentals - part 2 - security mechanisms - logging
appsec
 
Wc4
Wc4Wc4
IBM i Security: Identifying the Events That Matter Most
IBM i Security: Identifying the Events That Matter MostIBM i Security: Identifying the Events That Matter Most
IBM i Security: Identifying the Events That Matter Most
Precisely
 
IBM i Security SIEM Integration
IBM i Security SIEM IntegrationIBM i Security SIEM Integration
IBM i Security SIEM Integration
Precisely
 
Controlling Access to IBM i Systems and Data
Controlling Access to IBM i Systems and DataControlling Access to IBM i Systems and Data
Controlling Access to IBM i Systems and Data
Precisely
 
Exploitation techniques and fuzzing
Exploitation techniques and fuzzingExploitation techniques and fuzzing
Exploitation techniques and fuzzing
G Prachi
 
Web Security Overview
Web Security OverviewWeb Security Overview
Web Security Overview
Noah Jaehnert
 
Secure coding guidelines
Secure coding guidelinesSecure coding guidelines
Secure coding guidelines
Zakaria SMAHI
 
Six Mistakes of Log Management 2008
Six Mistakes of Log Management 2008Six Mistakes of Log Management 2008
Six Mistakes of Log Management 2008
Anton Chuvakin
 

Similar to Cm4 secure code_training_1day_error handling and logging (20)

How to Test for The OWASP Top Ten
 How to Test for The OWASP Top Ten How to Test for The OWASP Top Ten
How to Test for The OWASP Top Ten
 
Security Practices - Logging.pptx
Security Practices - Logging.pptxSecurity Practices - Logging.pptx
Security Practices - Logging.pptx
 
Security testing
Security testingSecurity testing
Security testing
 
The 5 Layers of Security Testing by Alan Koch
The 5 Layers of Security Testing by Alan KochThe 5 Layers of Security Testing by Alan Koch
The 5 Layers of Security Testing by Alan Koch
 
The 5 Layers of Security Testing by Alan Koch
The 5 Layers of Security Testing by Alan KochThe 5 Layers of Security Testing by Alan Koch
The 5 Layers of Security Testing by Alan Koch
 
Secure code practices
Secure code practicesSecure code practices
Secure code practices
 
Web security uploadv1
Web security uploadv1Web security uploadv1
Web security uploadv1
 
2013 OWASP Top 10
2013 OWASP Top 102013 OWASP Top 10
2013 OWASP Top 10
 
Monitoring and Reporting on IBM i Compliance and Security
Monitoring and Reporting on IBM i Compliance and SecurityMonitoring and Reporting on IBM i Compliance and Security
Monitoring and Reporting on IBM i Compliance and Security
 
5 Things Your Security Administrator Should Tell You
5 Things Your Security Administrator Should Tell You5 Things Your Security Administrator Should Tell You
5 Things Your Security Administrator Should Tell You
 
Owasp Proactive Controls for Web developer
Owasp  Proactive Controls for Web developerOwasp  Proactive Controls for Web developer
Owasp Proactive Controls for Web developer
 
09 application security fundamentals - part 2 - security mechanisms - logging
09   application security fundamentals - part 2 - security mechanisms - logging09   application security fundamentals - part 2 - security mechanisms - logging
09 application security fundamentals - part 2 - security mechanisms - logging
 
Wc4
Wc4Wc4
Wc4
 
IBM i Security: Identifying the Events That Matter Most
IBM i Security: Identifying the Events That Matter MostIBM i Security: Identifying the Events That Matter Most
IBM i Security: Identifying the Events That Matter Most
 
IBM i Security SIEM Integration
IBM i Security SIEM IntegrationIBM i Security SIEM Integration
IBM i Security SIEM Integration
 
Controlling Access to IBM i Systems and Data
Controlling Access to IBM i Systems and DataControlling Access to IBM i Systems and Data
Controlling Access to IBM i Systems and Data
 
Exploitation techniques and fuzzing
Exploitation techniques and fuzzingExploitation techniques and fuzzing
Exploitation techniques and fuzzing
 
Web Security Overview
Web Security OverviewWeb Security Overview
Web Security Overview
 
Secure coding guidelines
Secure coding guidelinesSecure coding guidelines
Secure coding guidelines
 
Six Mistakes of Log Management 2008
Six Mistakes of Log Management 2008Six Mistakes of Log Management 2008
Six Mistakes of Log Management 2008
 

More from dcervigni

Cm9 secure code_training_1day_input sanitization
Cm9 secure code_training_1day_input sanitizationCm9 secure code_training_1day_input sanitization
Cm9 secure code_training_1day_input sanitization
dcervigni
 
Cm2 secure code_training_1day_data_protection
Cm2 secure code_training_1day_data_protectionCm2 secure code_training_1day_data_protection
Cm2 secure code_training_1day_data_protection
dcervigni
 
Cm1 secure code_training_1day_intro
Cm1 secure code_training_1day_introCm1 secure code_training_1day_intro
Cm1 secure code_training_1day_intro
dcervigni
 
Cm8 secure code_training_1day_security libraries
Cm8 secure code_training_1day_security librariesCm8 secure code_training_1day_security libraries
Cm8 secure code_training_1day_security libraries
dcervigni
 
Cm3 secure code_training_1day_access_control
Cm3 secure code_training_1day_access_controlCm3 secure code_training_1day_access_control
Cm3 secure code_training_1day_access_control
dcervigni
 
Cm5 secure code_training_1day_system configuration
Cm5 secure code_training_1day_system configurationCm5 secure code_training_1day_system configuration
Cm5 secure code_training_1day_system configuration
dcervigni
 
Cm6 secure code_training_1day_file management
Cm6 secure code_training_1day_file managementCm6 secure code_training_1day_file management
Cm6 secure code_training_1day_file management
dcervigni
 
Cm7 secure code_training_1day_xss
Cm7 secure code_training_1day_xssCm7 secure code_training_1day_xss
Cm7 secure code_training_1day_xss
dcervigni
 
JavaScript security and tools evolution at 2017 OWASP Taiwan Week
JavaScript security and tools evolution at 2017 OWASP Taiwan WeekJavaScript security and tools evolution at 2017 OWASP Taiwan Week
JavaScript security and tools evolution at 2017 OWASP Taiwan Week
dcervigni
 

More from dcervigni (9)

Cm9 secure code_training_1day_input sanitization
Cm9 secure code_training_1day_input sanitizationCm9 secure code_training_1day_input sanitization
Cm9 secure code_training_1day_input sanitization
 
Cm2 secure code_training_1day_data_protection
Cm2 secure code_training_1day_data_protectionCm2 secure code_training_1day_data_protection
Cm2 secure code_training_1day_data_protection
 
Cm1 secure code_training_1day_intro
Cm1 secure code_training_1day_introCm1 secure code_training_1day_intro
Cm1 secure code_training_1day_intro
 
Cm8 secure code_training_1day_security libraries
Cm8 secure code_training_1day_security librariesCm8 secure code_training_1day_security libraries
Cm8 secure code_training_1day_security libraries
 
Cm3 secure code_training_1day_access_control
Cm3 secure code_training_1day_access_controlCm3 secure code_training_1day_access_control
Cm3 secure code_training_1day_access_control
 
Cm5 secure code_training_1day_system configuration
Cm5 secure code_training_1day_system configurationCm5 secure code_training_1day_system configuration
Cm5 secure code_training_1day_system configuration
 
Cm6 secure code_training_1day_file management
Cm6 secure code_training_1day_file managementCm6 secure code_training_1day_file management
Cm6 secure code_training_1day_file management
 
Cm7 secure code_training_1day_xss
Cm7 secure code_training_1day_xssCm7 secure code_training_1day_xss
Cm7 secure code_training_1day_xss
 
JavaScript security and tools evolution at 2017 OWASP Taiwan Week
JavaScript security and tools evolution at 2017 OWASP Taiwan WeekJavaScript security and tools evolution at 2017 OWASP Taiwan Week
JavaScript security and tools evolution at 2017 OWASP Taiwan Week
 

Recently uploaded

20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
Matthew Sinclair
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
SOFTTECHHUB
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
Neo4j
 
Introducing Milvus Lite: Easy-to-Install, Easy-to-Use vector database for you...
Introducing Milvus Lite: Easy-to-Install, Easy-to-Use vector database for you...Introducing Milvus Lite: Easy-to-Install, Easy-to-Use vector database for you...
Introducing Milvus Lite: Easy-to-Install, Easy-to-Use vector database for you...
Zilliz
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
James Anderson
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
Uni Systems S.M.S.A.
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
Kari Kakkonen
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
danishmna97
 
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
Neo4j
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
Alpen-Adria-Universität
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdfUni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems S.M.S.A.
 
20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
Matthew Sinclair
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
Octavian Nadolu
 
20 Comprehensive Checklist of Designing and Developing a Website
20 Comprehensive Checklist of Designing and Developing a Website20 Comprehensive Checklist of Designing and Developing a Website
20 Comprehensive Checklist of Designing and Developing a Website
Pixlogix Infotech
 
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
shyamraj55
 
Mind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AIMind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AI
Kumud Singh
 

Recently uploaded (20)

20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
 
Introducing Milvus Lite: Easy-to-Install, Easy-to-Use vector database for you...
Introducing Milvus Lite: Easy-to-Install, Easy-to-Use vector database for you...Introducing Milvus Lite: Easy-to-Install, Easy-to-Use vector database for you...
Introducing Milvus Lite: Easy-to-Install, Easy-to-Use vector database for you...
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
 
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
 
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdfUni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdf
 
20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
 
20 Comprehensive Checklist of Designing and Developing a Website
20 Comprehensive Checklist of Designing and Developing a Website20 Comprehensive Checklist of Designing and Developing a Website
20 Comprehensive Checklist of Designing and Developing a Website
 
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
 
Mind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AIMind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AI
 

Cm4 secure code_training_1day_error handling and logging

  • 1. SECURE CODE TRAINING Error Handling and Logging DAVID CERVIGNI IT SECURITY CONSULTANT AND PCI CODE REVIEWER
  • 2. Bad Error Handling Risks • Information disclosure • Lack of Availability (DoS) • Unhandled status leads to malicious behavior being unnoticed INSTEAD: – Not Just catching exception – Not Just logging exception/errors Handle all failures securely and return the system to a proper state!
  • 3. Avoid information disclosure… • Do not disclose sensitive information in error responses, including system details, session identifiers or account information • Use error handlers that do not display debugging or stack trace information • Implement generic error messages and use custom error pages
  • 4. …and fail safely • The application should handle application errors and not rely on the server configuration • Properly free allocated memory(resources) when error conditions occur • Error handling logic associated with security controls should deny access by default
  • 5. Server Error pages web.xml: <error-page> <error-code>500</error-code> <location>/app/error</location> </error-page> <error-page> <exception-type>java.lang.Exception</exception-type> <location>/app/error</location> </error-page> <error-page> <error-code>400</error-code> <location>/index.jsp</location> </error-page> <error-page> <error-code>403</error-code> <location>/app/403</location> </error-page> May be never enough: one solution is to configure WAF/reverse proxy interceptor.
  • 7. ERR00-J. Do not suppress or ignore checked exceptions NON COMPLIANT COMPLIANT
  • 9. Why we log? Many industries are required by legal and regulatory requirements to be: • Auditable – all activities that affect user state or balances are formally tracked • Traceable – it’s possible to determine where an activity occurs in all tiers of the application • High integrity – logs cannot be overwritten or tampered with by local or remote users Well-written applications will dual-purpose logs and activity traces for audit and monitoring, and make it easy to track a transaction without excessive effort or access to the system. They should possess the ability to easily track or identify potential fraud or anomalies end-to-end.
  • 10. Proper logging checklist • All logging controls should be implemented on a trusted system (e.g., The server) • Logging controls should support both success and failure of specified security events • Ensure logs contain important log event data: Log Event Data, This should include the following: – 1. Time stamp from a trusted system component – 2. Severity rating for each event – 3. Tagging of security relevant events, if they are mixed with other log entries – 4. Identity of the account/user that caused the event – 5. Source IP address associated with the request – 6. Event outcome (success or failure) – 7. Description of the event • Restrict access to logs to only authorized individuals • Utilize a master routine for all logging operations • Do not store sensitive information in logs, including unnecessary system details, session identifiers or passwords • Ensure that a mechanism exists to conduct log analysis
  • 11. Proper logging checklist • Log all input validation failures • Log all authentication attempts, especially failures • Log all access control failures • Log all apparent tampering events, including unexpected changes to state data • Log attempts to connect with invalid or expired session tokens • Log all system exceptions • Log all administrative functions, including changes to the security configuration settings • Log all backend TLS connection failures • Log cryptographic module failures
  • 12. Log forging Log forging vulnerabilities occur when: • Data enters an application from an untrusted source. • The data is written to an application or system log file.
  • 13. Log forging If a user submits the string "twenty-one" for val, the following entry is logged: INFO: Failed to parse val=twenty-one However, if an attacker submits the string "twenty-one%0a%0aINFO:+User+logged+out%3dbadguy", the following entry is logged: INFO: Failed to parse val=twenty-one INFO: User logged out=badguy
  • 14. Log injection & blind XSS example • Impacting through downstream systems (log monitoring, analysis, feeds)
  • 15. Contextual logging libraries • Log4j MDC (Mapped Diagnostic Context) • Is part of Log4j 2 API
  • 16. Log correlation and aggregation • WAF/PROXY/LB/WEBAPP/DB
  • 17. Cryptographic log integrity Audit trails are legally protected in many countries, and should be logged into high integrity destinations to prevent casual and motivated tampering and destruction. How to determine if you are vulnerable • Do the logs transit in the clear between the logging host and the destination? • Do the logs have a HMAC or similar tamper proofing mechanism to prevent change from the time of the logging activity to when it is reviewed? • Can relevant logs be easily extracted in a legally sound fashion to assist with prosecutions?
  • 18. SECURE CODE TRAINING INTENSIVE COURSE DAVID CERVIGNI IT SECURITY CONSULTANT AND PCI CODE REVIEWER References: https://www.owasp.org/index.php/Log_Injection https://www.securecoding.cert.org/confluence/pages/viewp age.action?pageId=18581047 https://logging.apache.org/log4j/2.x/manual/thread- context.html https://www.owasp.org/index.php/Error_Handling,_Auditing _and_Logging https://www.loggly.com/ultimate-guide/java-logging-basics/

Editor's Notes

  1. http://www.masterzen.fr/2013/01/13/the-10-commandments-of-logging/ Auditing: this is sometimes a business requirement. The idea is to capture significant events that matter to the management or legal people. These are statements that describe usually what users of the system are doing (like who signed-in, who edited that, etc…). Profiling: as logs are timestamped (sometimes to the millisecond level), it can become a good tool to profile sections of a program, for instance by logging the start and end of an operation, you can either automatically (by parsing the log) or during troubleshooting infer some performance metrics without adding those metrics to the program itself. Statistics: if you log each time a certain event happens (like a certain kind of error or event) you can compute interesting statistics about the running program (or the user behaviors). It’s also possible to hook this to an alert system that can detect too many errors in a row.