Control Objective
The primary objective of error handling and logging is to provide useful information for the user, administrators, and incident response teams. The objective is not to create massive amounts of logs, but high quality logs, with more signal than discarded noise.
High quality logs will often contain sensitive data, and must be protected as per local data privacy laws or directives. This should include:
- Not collecting or logging sensitive information unless specifically required.
- Ensuring all logged information is handled securely and protected as per its data classification.
- Ensuring that logs are not stored forever, but have an absolute lifetime that is as short as possible.
If logs contain private or sensitive data, the definition of which varies from country to country, the logs become some of the most sensitive information held by the application and thus very attractive to attackers in their own right.
It is also important to ensure that the application fails securely and that errors do not disclose unnecessary information.
V7.1 Log Content Requirements
Logging sensitive information is dangerous – the logs become classified themselves, which means they need to be encrypted, become subject to retention policies, and must be disclosed in security audits. Ensure only necessary information is kept in logs, and certainly no payment, credentials (including session tokens), sensitive or personally identifiable information.
V7.1 covers OWASP Top 10 2017:A10. As 2017:A10 and this section are not penetration testable, it’s important for:
- Developers to ensure full compliance with this section, as if all items were marked as L1
- Penetration testers to validate full compliance of all items in V7.1 via interview, screenshots, or assertion
| # | Description | L1 | L2 | L3 | CWE |
| 7.1.1 | Verify that the application does not log credentials or payment details. Session tokens should only be stored in logs in an irreversible, hashed form. (C9, C10) | ✓ | ✓ | ✓ | 532 |
| 7.1.2 | Verify that the application does not log other sensitive data as defined under local privacy laws or relevant security policy. (C9) | ✓ | ✓ | ✓ | 532 |
| 7.1.3 | Verify that the application logs security relevant events including successful and failed authentication events, access control failures, deserialization failures and input validation failures. (C5, C7) | ✓ | ✓ | 778 | |
| 7.1.4 | Verify that each log event includes necessary information that would allow for a detailed investigation of the timeline when an event happens. (C9) | ✓ | ✓ | 778 |
V7.2 Log Processing Requirements
Timely logging is critical for audit events, triage, and escalation. Ensure that the application’s logs are clear and can be easily monitored and analyzed either locally or log shipped to a remote monitoring system.
V7.2 covers OWASP Top 10 2017:A10. As 2017:A10 and this section are not penetration testable, it’s important for:
- Developers to ensure full compliance with this section, as if all items were marked as L1
- Penetration testers to validate full compliance of all items in V7.2 via interview, screenshots, or assertion
| # | Description | L1 | L2 | L3 | CWE |
| 7.2.1 | Verify that all authentication decisions are logged, without storing sensitive session tokens or passwords. This should include requests with relevant metadata needed for security investigations. | ✓ | ✓ | 778 | |
| 7.2.2 | Verify that all access control decisions can be logged and all failed decisions are logged. This should include requests with relevant metadata needed for security investigations. | ✓ | ✓ | 285 |
V7.3 Log Protection Requirements
Logs that can be trivially modified or deleted are useless for investigations and prosecutions. Disclosure of logs can expose inner details about the application or the data it contains. Care must be taken when protecting logs from unauthorized disclosure, modification or deletion.
| # | Description | L1 | L2 | L3 | CWE |
| 7.3.1 | Verify that the application appropriately encodes user-supplied data to prevent log injection. (C9) | ✓ | ✓ | 117 | |
| 7.3.2 | Verify that all events are protected from injection when viewed in log viewing software. (C9) | ✓ | ✓ | 117 | |
| 7.3.3 | Verify that security logs are protected from unauthorized access and modification. (C9) | ✓ | ✓ | 200 | |
| 7.3.4 | Verify that time sources are synchronized to the correct time and time zone. Strongly consider logging only in UTC if systems are global to assist with post-incident forensic analysis. (C9) | ✓ | ✓ |
Note: Log encoding (7.3.1) is difficult to test and review using automated dynamic tools and penetration tests, but architects, developers, and source code reviewers should consider it an L1 requirement.
V7.4 Error Handling
The purpose of error handling is to allow the application to provide security relevant events for monitoring, triage and escalation. The purpose is not to create logs. When logging security related events, ensure that there is a purpose to the log, and that it can be distinguished by SIEM or analysis software.
| # | Description | L1 | L2 | L3 | CWE |
| 7.4.1 | Verify that a generic message is shown when an unexpected or security sensitive error occurs, potentially with a unique ID which support personnel can use to investigate. (C10) | ✓ | ✓ | ✓ | 210 |
| 7.4.2 | Verify that exception handling (or a functional equivalent) is used across the codebase to account for expected and unexpected error conditions. (C10) | ✓ | ✓ | 544 | |
| 7.4.3 | Verify that a “last resort” error handler is defined which will catch all unhandled exceptions. (C10) | ✓ | ✓ | 431 |
Note: Certain languages, such as Swift and Go – and through common design practice – many functional languages, do not support exceptions or last resort event handlers. In this case, architects and developers should use a pattern, language, or framework friendly way to ensure that applications can securely handle exceptional, unexpected, or security-related events.
References
For more information, see also:
OWASP Authentication Cheat Sheet section about error messages
Control Objective
The primary objective of error handling and logging is to provide useful information for the user, administrators, and incident response teams. The objective is not to create massive amounts of logs, but high quality logs, with more signal than discarded noise.
High quality logs will often contain sensitive data, and must be protected as per local data privacy laws or directives. This should include:
- Not collecting or logging sensitive information unless specifically required.
- Ensuring all logged information is handled securely and protected as per its data classification.
- Ensuring that logs are not stored forever, but have an absolute lifetime that is as short as possible.
If logs contain private or sensitive data, the definition of which varies from country to country, the logs become some of the most sensitive information held by the application and thus very attractive to attackers in their own right.
It is also important to ensure that the application fails securely and that errors do not disclose unnecessary information.
V7.1 Log Content Requirements
Logging sensitive information is dangerous – the logs become classified themselves, which means they need to be encrypted, become subject to retention policies, and must be disclosed in security audits. Ensure only necessary information is kept in logs, and certainly no payment, credentials (including session tokens), sensitive or personally identifiable information.
V7.1 covers OWASP Top 10 2017:A10. As 2017:A10 and this section are not penetration testable, it’s important for:
- Developers to ensure full compliance with this section, as if all items were marked as L1
- Penetration testers to validate full compliance of all items in V7.1 via interview, screenshots, or assertion
| # | Description | L1 | L2 | L3 | CWE |
| 7.1.1 | Verify that the application does not log credentials or payment details. Session tokens should only be stored in logs in an irreversible, hashed form. (C9, C10) | ✓ | ✓ | ✓ | 532 |
| 7.1.2 | Verify that the application does not log other sensitive data as defined under local privacy laws or relevant security policy. (C9) | ✓ | ✓ | ✓ | 532 |
| 7.1.3 | Verify that the application logs security relevant events including successful and failed authentication events, access control failures, deserialization failures and input validation failures. (C5, C7) | ✓ | ✓ | 778 | |
| 7.1.4 | Verify that each log event includes necessary information that would allow for a detailed investigation of the timeline when an event happens. (C9) | ✓ | ✓ | 778 |
V7.2 Log Processing Requirements
Timely logging is critical for audit events, triage, and escalation. Ensure that the application’s logs are clear and can be easily monitored and analyzed either locally or log shipped to a remote monitoring system.
V7.2 covers OWASP Top 10 2017:A10. As 2017:A10 and this section are not penetration testable, it’s important for:
- Developers to ensure full compliance with this section, as if all items were marked as L1
- Penetration testers to validate full compliance of all items in V7.2 via interview, screenshots, or assertion
| # | Description | L1 | L2 | L3 | CWE |
| 7.2.1 | Verify that all authentication decisions are logged, without storing sensitive session tokens or passwords. This should include requests with relevant metadata needed for security investigations. | ✓ | ✓ | 778 | |
| 7.2.2 | Verify that all access control decisions can be logged and all failed decisions are logged. This should include requests with relevant metadata needed for security investigations. | ✓ | ✓ | 285 |
V7.3 Log Protection Requirements
Logs that can be trivially modified or deleted are useless for investigations and prosecutions. Disclosure of logs can expose inner details about the application or the data it contains. Care must be taken when protecting logs from unauthorized disclosure, modification or deletion.
| # | Description | L1 | L2 | L3 | CWE |
| 7.3.1 | Verify that the application appropriately encodes user-supplied data to prevent log injection. (C9) | ✓ | ✓ | 117 | |
| 7.3.2 | Verify that all events are protected from injection when viewed in log viewing software. (C9) | ✓ | ✓ | 117 | |
| 7.3.3 | Verify that security logs are protected from unauthorized access and modification. (C9) | ✓ | ✓ | 200 | |
| 7.3.4 | Verify that time sources are synchronized to the correct time and time zone. Strongly consider logging only in UTC if systems are global to assist with post-incident forensic analysis. (C9) | ✓ | ✓ |
Note: Log encoding (7.3.1) is difficult to test and review using automated dynamic tools and penetration tests, but architects, developers, and source code reviewers should consider it an L1 requirement.
V7.4 Error Handling
The purpose of error handling is to allow the application to provide security relevant events for monitoring, triage and escalation. The purpose is not to create logs. When logging security related events, ensure that there is a purpose to the log, and that it can be distinguished by SIEM or analysis software.
| # | Description | L1 | L2 | L3 | CWE |
| 7.4.1 | Verify that a generic message is shown when an unexpected or security sensitive error occurs, potentially with a unique ID which support personnel can use to investigate. (C10) | ✓ | ✓ | ✓ | 210 |
| 7.4.2 | Verify that exception handling (or a functional equivalent) is used across the codebase to account for expected and unexpected error conditions. (C10) | ✓ | ✓ | 544 | |
| 7.4.3 | Verify that a “last resort” error handler is defined which will catch all unhandled exceptions. (C10) | ✓ | ✓ | 431 |
Note: Certain languages, such as Swift and Go – and through common design practice – many functional languages, do not support exceptions or last resort event handlers. In this case, architects and developers should use a pattern, language, or framework friendly way to ensure that applications can securely handle exceptional, unexpected, or security-related events.
References
For more information, see also:
- OWASP Testing Guide 4.0 content: Testing for Error Handling
- OWASP Authentication Cheat Sheet section about error messages
What is the ASVS?
The OWASP Application Security Verification Standard (ASVS) Project provides a basis for testing web application technical security controls and also provides developers with a list of requirements for secure development.
The primary aim of the OWASP Application Security Verification Standard (ASVS) Project is to normalize the range in the coverage and level of rigor available in the market when it comes to performing Web application security verification using a commercially-workable open standard. The standard provides a basis for testing application technical security controls, as well as any technical security controls in the environment, that are relied on to protect against vulnerabilities such as Cross-Site Scripting (XSS) and SQL injection. This standard can be used to establish a level of confidence in the security of Web applications. The requirements were developed with the following objectives in mind:
- Use as a metric – Provide application developers and application owners with a yardstick with which to assess the degree of trust that can be placed in their Web applications,
- Use as guidance – Provide guidance to security control developers as to what to build into security controls in order to satisfy application security requirements, and
- Use during procurement – Provide a basis for specifying application security verification requirements in contracts.
Using the OWASP ASVS
OWASP ASVS has two main goals:
- to help organizations develop and maintain secure applications.
- to allow security service vendors, security tools vendors, and consumers to align their requirements and offerings.
Application Security Verification Levels
The Application Security Verification Standard defines three security verification levels, with each level increasing in depth.
- ASVS Level 1 is for low assurance levels, and is completely penetration testable
- ASVS Level 2 is for applications that contain sensitive data, which requires protection and is the recommended level for most apps
- ASVS Level 3 is for the most critical applications – applications that perform high value transactions, contain sensitive medical data, or any application that requires the highest level of trust.
Each ASVS level contains a list of security requirements. Each of these requirements can also be mapped to security-specific features and capabilities that must be built into software by developers.
Level 1 is the only level that is completely penetration testable using humans. All others require access to documentation, source code, configuration, and the people involved in the development process. However, even if L1 allows “black box” (no documentation and no source) testing to occur, it is not an effective assurance activity and should be actively discouraged. Malicious attackers have a great deal of time, most penetration tests are over within a couple of weeks. Defenders need to build in security controls, protect, find and resolve all weaknesses, and detect and respond to malicious actors in a reasonable time. Malicious actors have essentially infinite time and only require a single porous defense, a single weakness, or missing detection to succeed. Black box testing, often performed at the end of development, quickly, or not at all, is completely unable to cope with that asymmetry.
Over the last 30+ years, black box testing has proven over and over again to miss critical security issues that led directly to ever more massive breaches. We strongly encourage the use of a wide range of security assurance and verification, including replacing penetration tests with source code led (hybrid) penetration tests at Level 1, with full access to developers and documentation throughout the development process. Financial regulators do not tolerate external financial audits with no access to the books, sample transactions, or the people performing the controls. Industry and governments must demand the same standard of transparency in the software engineering field.
We strongly encourage the use of security tools within the development process itself. DAST and SAST tools can be used continuously by the build pipeline to find easy to find security issues that should never be present.
Automated tools and online scans are unable to complete more than half of the ASVS without human assistance. If comprehensive test automation for each build is required, then a combination of custom unit and integration tests, along with build initiated online scans are used. Business logic flaws and access control testing is only possible using human assistance. These should be turned into unit and integration tests.
How to use this standard
One of the best ways to use the Application Security Verification Standard is to use it as a blueprint to create a Secure Coding Checklist specific to your application, platform or organization. Tailoring the ASVS to your use cases will increase the focus on the security requirements that are most important to your projects and environments.
Level 1 – First steps, automated, or whole of portfolio view
An application achieves ASVS Level 1 if it adequately defends against application security vulnerabilities that are easy to discover, and included in the OWASP Top 10 and other similar checklists.
Level 1 is the bare minimum that all applications should strive for. It is also useful as a first step in a multi-phase effort or when applications do not store or handle sensitive data and therefore do not need the more rigorous controls of Level 2 or 3. Level 1 controls can be checked either automatically by tools or simply manually without access to source code. We consider Level 1 the minimum required for all applications.
Threats to the application will most likely be from attackers who are using simple and low effort techniques to identify easy-to-find and easy-to-exploit vulnerabilities. This is in contrast to a determined attacker who will spend focused energy to specifically target the application. If data processed by your application has high value, you would rarely want to stop at a Level 1 review.
Level 2 – Most applications
An application achieves ASVS Level 2 (or Standard) if it adequately defends against most of the risks associated with software today.
Level 2 ensures that security controls are in place, effective, and used within the application. Level 2 is typically appropriate for applications that handle significant business-to-business transactions, including those that process healthcare information, implement business-critical or sensitive functions, or process other sensitive assets, or industries where integrity is a critical facet to protect their business, such as the game industry to thwart cheaters and game hacks.
Threats to Level 2 applications will typically be skilled and motivated attackers focusing on specific targets using tools and techniques that are highly practiced and effective at discovering and exploiting weaknesses within applications.
Level 3 – High value, high assurance, or high safety
ASVS Level 3 is the highest level of verification within the ASVS. This level is typically reserved for applications that require significant levels of security verification, such as those that may be found within areas of military, health and safety, critical infrastructure, etc.
Organizations may require ASVS Level 3 for applications that perform critical functions, where failure could significantly impact the organization’s operations, and even its survivability. Example guidance on the application of ASVS Level 3 is provided below. An application achieves ASVS Level 3 (or Advanced) if it adequately defends against advanced application security vulnerabilities and also demonstrates principles of good security design.
An application at ASVS Level 3 requires more in depth analysis of architecture, coding, and testing than all the other levels. A secure application is modularized in a meaningful way (to facilitate resiliency, scalability, and most of all, layers of security), and each module (separated by network connection and/or physical instance) takes care of its own security responsibilities (defense in depth), that need to be properly documented. Responsibilities include controls for ensuring confidentiality (e.g. encryption), integrity (e.g. transactions, input validation), availability (e.g. handling load gracefully), authentication (including between systems), non-repudiation, authorization, and auditing (logging).
Source: https://owasp.org/www-project-application-security-verification-standard/
Note: The OWASP ASVS, related copyright and trademarks belong to its owner OWASP. This guide is for educational purposes only and will be expanded beyond the original version provided by OWASP.