Secure code review

Reviewing log integrity, access control and retention

Trusted records: terminal, document, eye arranged to illustrate reviewing log integrity, access control and retention.

Security records and error handling should support investigation while preserving confidentiality and safe application state. Understanding log integrity and access control and retention helps establish which security property the feature needs and where that property is actually enforced.

What does this involve?

Authorisation determines which resources and operations an established identity may use. It must be enforced where protected data is read or changed. User interface restrictions, obscure identifiers and documentation can help usability, but they do not replace the service's own permission decision.

Logs are valuable forensic artifacts and must be protected. If logs can be easily modified or deleted, they lose their integrity and become unreliable for incident investigations or legal proceedings. Logs may expose internal application behaviour or sensitive metadata, making them an attractive target for attackers.

This section defines requirements to ensure that logs are protected from unauthorised access, tampering, and disclosure, and that they are safely transmitted and stored in secure, isolated systems.

Why it matters

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

A missing check can expose another account's information or let an ordinary user perform a privileged action. The result should be described by the actual records and operations reached, including whether access crosses a customer or organisational boundary.

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 logging components appropriately encode data to prevent log injection.
  • Confirm that logs are protected from unauthorised access and cannot be modified.
  • Confirm that logs are securely transmitted to a logically separate system for analysis, detection, alerting, and escalation. The aim is to ensure that if the application is breached, the logs are not compromised.
  • Test nested resources, background processing and state changes.
  • Confirm rejection as well as the legitimate successful journey.

How to fix it

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

  • Define explicit access rules and default-deny behaviour.
  • Bind resource selection to trusted ownership and tenant context.
  • Enforce permission checks at each protected operation.
  • Maintain regression cases for unauthorised users and changed permissions.

A successful response alone does not prove unauthorised access. Establish whose resource was affected and what the caller was legitimately entitled to do.

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