Secure code review

Auditing coverage of security-relevant application events

Trusted records: terminal, document, eye arranged to illustrate auditing coverage of security-relevant application events.

Security records and error handling should support investigation while preserving confidentiality and safe application state. Understanding coverage of security-relevant application events helps establish which security property the feature needs and where that property is actually enforced.

What does this involve?

Useful security records describe important actors, resources and state changes without becoming another source of secrets. Their value depends on reliable event coverage, correlation and access protection as well as the volume of information collected.

This section defines requirements for logging security-relevant events within the application. Capturing these events is critical for detecting suspicious behaviour, supporting investigations, and fulfilling compliance obligations.

This section outlines the types of events that should be logged but does not attempt to provide exhaustive detail. Each application has unique risk factors and operational context.

Why it matters

Consider a realistic failure: an error both exposes internal information and leaves too little trustworthy context to reconstruct the affected operation.

Missing or misleading records can delay detection and make an incident harder to reconstruct. Excessive capture can expose credentials or confidential content to people and systems that did not otherwise need it.

A code audit connects a stated requirement to the implementation responsible for enforcing it. Source review and targeted behavioural checks should explain the same boundary and any relevant exceptions.

How penetration testers check for it

Review the specific control expectations below against the code, deployment and observable application behaviour.

  • Confirm that all authentication operations are logged, including successful and unsuccessful attempts. Additional metadata, such as the type of authentication or factors used, should also be collected.
  • Confirm that failed authorisation attempts are logged. For L3, this must include logging all authorisation decisions, including logging when sensitive data is accessed (without logging the sensitive data itself).
  • Confirm that the application logs the security events that are defined in the documentation and also logs attempts to bypass the security controls, such as input validation, business logic, and anti-automation.
  • Confirm that the application logs unexpected errors and security control failures such as backend TLS failures.
  • Review redaction and resistance to misleading event content.
  • Assess access, integrity and retention.

How to fix it

Implement the required boundary in the component that actually performs the sensitive operation and retain focused regression coverage.

  • Define meaningful events and consistent fields.
  • Exclude unnecessary secrets and personal information.
  • Protect log access and important audit records.
  • Verify that monitoring and investigation workflows can use the retained evidence.

A complete request or response is rarely necessary for every event. Capture should be justified by an operational purpose and protected according to the information it contains.

Recheck the changed behaviour against the original failure conditions and the legitimate user journey. Keep enough evidence to show which release and configuration were verified, and include related entry points that depend on the same security decision.

Read about our methodology or contact pentested.com to discuss the security of your application code.

See your first test report this week.

Book a 30 minute demo. We will verify one of your targets with you and run a test against it, so you can judge the results on your own systems.

Book a demo