This site is the archived OWASP Foundation Wiki and is no longer accepting Account Requests.
To view the new OWASP Foundation website, please visit https://owasp.org
Difference between revisions of "Logging Cheat Sheet"
m (→Other Cheatsheets) |
(→Related articles) (Tag: Visual edit) |
||
Line 3: | Line 3: | ||
{| style="padding: 0;margin:0;margin-top:10px;text-align:left;" |- | {| style="padding: 0;margin:0;margin-top:10px;text-align:left;" |- | ||
− | | valign="top" | + | | valign="top" style="border-right: 1px dotted gray;padding-right:25px;" | |
Last revision (mm/dd/yy): '''{{REVISIONMONTH}}/{{REVISIONDAY}}/{{REVISIONYEAR}}''' | Last revision (mm/dd/yy): '''{{REVISIONMONTH}}/{{REVISIONDAY}}/{{REVISIONYEAR}}''' | ||
= Introduction = | = Introduction = | ||
Line 281: | Line 281: | ||
Other [http://www.arcsight.com/solutions/solutions-cef/ Common Event Format (CEF), Arcsight] | Other [http://www.arcsight.com/solutions/solutions-cef/ Common Event Format (CEF), Arcsight] | ||
+ | |||
+ | Other [https://www.ibm.com/developerworks/community/wikis/form/anonymous/api/wiki/9989d3d7-02c1-444e-92be-576b33d2f2be/page/3dc63f46-4a33-4e0b-98bf-4e55b74e556b/attachment/a19b9122-5940-4c89-ba3e-4b4fc25e2328/media/QRadar_LEEF_Format_Guide.pdf Log Event Extended Format ('''LEEF'''), IBM] | ||
Other [http://www.clerkendweller.com/2010/8/17/Application-Security-Logging Application Security Logging, Colin Watson, Web Security Usability and Design Blog] | Other [http://www.clerkendweller.com/2010/8/17/Application-Security-Logging Application Security Logging, Colin Watson, Web Security Usability and Design Blog] | ||
Line 293: | Line 295: | ||
Most of the information included is based on content in the articles referenced in the text and listed above, but the following people have provided their ideas, knowledge and practical experience: | Most of the information included is based on content in the articles referenced in the text and listed above, but the following people have provided their ideas, knowledge and practical experience: | ||
− | Colin Watson - colin.watson[at]owasp.org<br/> | + | Colin Watson - colin.watson[at]owasp.org<br /> |
− | Eoin Keary - eoin.keary[at]owasp.org<br/> | + | Eoin Keary - eoin.keary[at]owasp.org<br /> |
Alexis Fitzgerald - alexis.fitzgerald[at]owasp.org | Alexis Fitzgerald - alexis.fitzgerald[at]owasp.org | ||
Revision as of 07:27, 20 October 2017
Last revision (mm/dd/yy): 10/20/2017 IntroductionThis cheat sheet is focused on providing developers with concentrated guidance on building application logging mechanisms, especially related to security logging. Many systems enable network device, operating system, web server, mail server and database server logging, but often custom application event logging is missing, disabled or poorly configured. It provides much greater insight than infrastructure logging alone. Web application (e.g. web site or web service) logging is much more than having web server logs enabled (e.g. using Extended Log File Format). Application logging should be consistent within the application, consistent across an organization's application portfolio and use industry standards where relevant, so the logged event data can be consumed, correlated, analyzed and managed by a wide variety of systems. PurposeApplication logging should be always be included for security events. Application logs are invaluable data for:
Application logging might also be used to record other types of events too such as:
Process monitoring, audit and transaction logs/trails etc are usually collected for different purposes than security event logging, and this often means they should be kept separate. The types of events and details collected will tend to be different. For example a PCIDSS audit log will contain a chronological record of activities to provide an independently verifiable trail that permits reconstruction, review and examination to determine the original sequence of attributable transactions. It is important not to log too much, or too little. Use knowledge of the intended purposes to guide what, when and how much. The remainder of this cheat sheet primarily discusses security event logging. Design, implementation and testingEvent data sourcesThe application itself has access to a wide range of information events that should be used to generate log entries. Thus, the primary event data source is the application code itself. The application has the most information about the user (e.g. identity, roles, permissions) and the context of the event (target, action, outcomes), and often this data is not available to either infrastructure devices, or even closely-related applications. Other sources of information about application usage that could also be considered are:
The degree of confidence in the event information has to be considered when including event data from systems in a different trust zone. Data may be missing, modified, forged, replayed and could be malicious – it must always be treated as untrusted data. Consider how the source can be verified, and how integrity and non-repudiation can be enforced. Where to record event dataApplications commonly write event log data to the file system or a database (SQL or NoSQL). Applications installed on desktops and on mobile devices may use local storage and local databases, as well as sending data to remote storage. Your selected framework may limit the available choices. All types of applications may send event data to remote systems (instead of or as well as more local storage). This could be a centralized log collection and management system (e.g. SIEM or SEM) or another application elsewhere. Consider whether the application can simply send its event stream, unbuffered, to stdout, for management by the execution environment.
Consider separate files/tables for extended event information such as error stack traces or a record of HTTP request and response headers and bodies. Which events to logThe level and content of security monitoring, alerting and reporting needs to be set during the requirements and design stage of projects, and should be proportionate to the information security risks. This can then be used to define what should be logged. There is no one size fits all solution, and a blind checklist approach can lead to unnecessary "alarm fog" that means real problems go undetected. Where possible, always log:
Optionally consider if the following events can be logged and whether it is desirable information:
Event attributesEach log entry needs to include sufficient information for the intended subsequent monitoring and analysis. It could be full content data, but is more likely to be an extract or just summary properties. The application logs must record "when, where, who and what" for each event. The properties for these will be different depending on the architecture, class of application and host system/device, but often include the following:
Additionally consider recording:
For more information on these, see the "other" related articles listed at the end, especially the comprehensive article by Anton Chuvakin and Gunnar Peterson. Note A: The "Interaction identifier" is a method of linking all (relevant) events for a single user interaction (e.g. desktop application form submission, web page request, mobile app button click, web service call). The application knows all these events relate to the same interaction, and this should be recorded instead of losing the information and forcing subsequent correlation techniques to re-construct the separate events. For example a single SOAP request may have multiple input validation failures and they may span a small range of times. As another example, an output validation failure may occur much later than the input submission for a long-running "saga request" submitted by the application to a database server. Note B: Each organisation should ensure it has a consistent, and documented, approach to classification of events (type, confidence, severity), the syntax of descriptions, and field lengths & data types including the format used for dates/times. Data to excludeNever log data unless it is legally sanctioned. For example intercepting some communications, monitoring employees, and collecting some data without consent may all be illegal. Never exclude any events from "known" users such as other internal systems, "trusted" third parties, search engine robots, uptime/process and other remote monitoring systems, pen testers, auditors. However, you may want to include a classification flag for each of these in the recorded data. The following should not usually be recorded directly in the logs, but instead should be removed, masked, sanitized, hashed or encrypted:
Sometimes the following data can also exist, and whilst useful for subsequent investigation, it may also need to be treated in some special manner before the event is recorded:
Consider using personal data de-identification techniques such as deletion, scrambling or pseudonymization of direct and indirect identifiers where the individual's identity is not required, or the risk is considered too great. In some systems, sanitization can be undertaken post log collection, and prior to log display. Customizable loggingIt may be desirable to be able to alter the level of logging (type of events based on severity or threat level, amount of detail recorded). If this is implemented, ensure that:
Event collectionIf your development framework supports suitable logging mechanisms use, or build upon that. Otherwise, implement an application-wide log handler which can be called from other modules/components. Document the interface referencing the organisation-specific event classification and description syntax requirements. If possible create this log handler as a standard module that can is thoroughly tested, deployed in multiple application, and added to a list of approved & recommended modules.
Note C: This is not always possible where the application is running on a device under some other party's control (e.g. on an individual's mobile phone, on a remote customer's workstation which is on another corporate network). In these cases attempt to measure the time offset, or record a confidence level in the event time stamp. Where possible record data in a standard format, or at least ensure it can be exported/broadcast using an industry-standard format. In some cases, events may be relayed or collected together in intermediate points. In the latter some data may be aggregated or summarized before forwarding on to a central repository and analysis system. VerificationLogging functionality and systems must be included in code review, application testing and security verification processes:
Deployment and operationRelease
OperationEnable processes to detect whether logging has stopped, and to identify tampering or unauthorized access and deletion (see protection below). ProtectionThe logging mechanisms and collected event data must be protected from mis-use such as tampering in transit, and unauthorized access, modification and deletion once stored. Logs may contain personal and other sensitive information, or the data may contain information regarding the application's code and logic. In addition, the collected information in the logs may itself have business value (to competitors, gossip-mongers, journalists and activists) such as allowing the estimate of revenues, or providing performance information about employees. This data may be held on end devices, at intermediate points, in centralized repositories and in archives and backups. Consider whether parts of the data may need to be excluded, masked, sanitized, hashed or encrypted during examination or extraction. At rest:
In transit:
See NIST SP 800-92 Guide to Computer Security Log Management for more guidance. Monitoring of eventsThe logged event data needs to be available to review and there are processes in place for appropriate monitoring, alerting and reporting:
Disposal of logsLog data, temporary debug logs, and backups/copies/extractions, must not be destroyed before the duration of the required data retention period, and must not be kept beyond this time. Legal, regulatory and contractual obligations may impact on these periods.
Related articlesOWASP ESAPI Documentation OWASP Logging Project IETF syslog protocol Mitre Common Event Expression (CEE) NIST SP 800-92 Guide to Computer Security Log Management PCISSC PCI DSS v2.0 Requirement 10 and PA-DSS v2.0 Requirement 4 Other Build Visibility In, Richard Bejtlich, TaoSecurity blog Other Common Event Format (CEF), Arcsight Other Log Event Extended Format (LEEF), IBM Other Application Security Logging, Colin Watson, Web Security Usability and Design Blog Other Common Log File System (CLFS), Microsoft Other Building Secure Applications: Consistent Logging, Rohit Sethi & Nish Bhalla, Symantec Connect
Authors and Primary ContributorsMost of the information included is based on content in the articles referenced in the text and listed above, but the following people have provided their ideas, knowledge and practical experience: Colin Watson - colin.watson[at]owasp.org Other Cheatsheets |