Logs are most valuable during a security incident, exactly when the system producing them may no longer be trustworthy. If an attacker gains administrative control of an application server and its only audit trail is stored on that same server, the attacker may be able to alter or remove both the activity and the evidence of it.
The defensive problem is therefore not just what to log. It is also who can change the log after it is created.
A useful design separates the system being observed from the system that preserves its security records. This article explains that trust boundary, shows a small logging model, and develops practical rules for permissions, failure handling, verification, and residual risk.
A log is evidence only within its trust assumptions
Consider an application that writes authentication events to a local file:
application
|
+--> /var/log/application/security.logThis is useful for debugging and routine monitoring. But suppose the application host is compromised and the attacker obtains an operating-system privilege that can modify that file. The same authority that permits harmful actions may also permit deletion or editing of the evidence.
The important mental model is:
security evidence is only as independent as the authority needed to change itMoving a file to another directory does not create meaningful independence if the same administrator, service account, or compromised host can still rewrite it.
The defensive goal is to make the authority for producing an event different from the authority for changing preserved history.
Separate producers from preserved history
A stronger design sends security events to a separate logging service or collector:
application host ---> log collector ---> protected log storage
send events ingest retainThe application host needs permission to submit new events. It should not automatically receive permission to edit or delete events that the logging system has already accepted.
This changes the attacker’s problem. Compromising the application may still allow the attacker to control future behavior on that host, but it does not necessarily grant equivalent control over previously collected evidence.
That distinction is the core control. The logging system becomes a separate trust boundary rather than another directory owned by the monitored machine.
Use the smallest useful permission model
A simplified permission model can be written as:
application identity:
may submit events
may not read all historical logs
may not edit accepted events
may not delete accepted events
logging operator:
may search retained events
may manage retention under controlled procedures
logging service:
may append and store accepted eventsThe exact mechanisms depend on the logging platform, but the security property is portable: a producer should receive only the authority required to deliver its records.
This is an application of least privilege. If a web server needs to send authentication events, giving it a credential that can also purge the central log store increases the impact of a web-server compromise without helping normal operation.
Read access deserves similar attention. Security logs often contain user identifiers, network addresses, resource names, and operational details. Centralizing them can create a valuable source of evidence, but also a concentrated source of sensitive information. Limit search and export permissions to roles that need them.
Preserve useful context without trusting every field
Remote storage protects accepted records from some forms of later modification, but it does not make every record truthful.
A compromised application can often generate false application-level events because it controls the code or process that reports them. It may claim that an operation succeeded when it failed, omit an event, or supply misleading values in fields it controls.
For that reason, distinguish between fields supplied by the producer and metadata added by the receiving system. A collector may be able to record facts such as:
received_at: collector's receipt time
source_identity: authenticated producer identity
source_channel: connection or transport metadata
reported_event_time: timestamp supplied by producer
reported_user: user identifier supplied by applicationThe collector-added fields do not prove that the application’s account of an event is correct. They do, however, help investigators distinguish what the collector observed from what the producer claimed.
This is especially important for timestamps. Clock synchronization improves correlation, but a timestamp generated on a compromised host should not be treated as stronger evidence than it is. Keeping both producer time and collector receipt time can make that limitation visible.
Protect the path to the collector
Separating storage is useful only if the application can reliably reach the intended collector and the collector can identify the producer under the assumptions of the deployment.
Use an authenticated transport supported by the logging platform when events cross a network or other untrusted boundary. The purpose is to reduce the risk that another party can impersonate a producer or silently alter records in transit. Encryption can additionally protect log contents from passive observers on that path.
Do not treat transport protection as a substitute for storage permissions. A correctly authenticated connection can deliver an event to a log store that the producer is later allowed to erase. These controls address different parts of the path.
Likewise, a shared credential used by every service weakens source attribution. If one service is compromised and possesses the common credential, the collector may be unable to distinguish that service from the others. Where the platform supports it, use separate producer identities and manage their credentials with the same care as other service credentials.
Decide what happens when logging fails
Remote logging introduces a real operational trade-off: the collector or network can become unavailable.
An application generally has three broad choices when it cannot deliver an event:
- stop the protected operation;
- continue the operation and buffer the event for later delivery;
- continue without preserving that event.
No single choice is correct for every event.
For a routine page view, failing the user request because the log collector is temporarily unavailable may cause unnecessary outages. Local buffering with bounded storage may be reasonable.
For a highly sensitive administrative action, the organization may decide that proceeding without a durable audit record creates too much risk. In that case, failing closed can be justified if the availability consequence is understood and tested.
The key is to make this decision deliberately. An unbounded local queue can exhaust disk space. A memory-only buffer disappears on restart. Silent dropping hides monitoring gaps. A fail-closed design can turn a logging outage into an application outage.
Choose behavior according to the value of the event, the application’s availability requirements, and the failure modes you can operate safely.
Detect gaps as well as suspicious events
A central log store is not useful if teams assume delivery is working but never verify it.
Monitor the logging pipeline itself. Useful checks include whether expected producers are still sending events, whether ingestion is delayed, whether queues are growing, whether storage is approaching capacity, and whether retention jobs are behaving as intended.
For important event streams, a sudden absence can be a security signal. If an application normally sends authentication events continuously and then stops while the application remains active, investigate the gap rather than interpreting silence as proof that nothing happened.
Testing should include failure cases, not only successful ingestion. Disconnect a non-production producer from the collector and confirm the application follows the intended buffering or failure policy. Verify that the producer credential cannot modify historical records. Confirm that operators can retrieve events needed for an investigation and that access to those logs is itself controlled and recorded where appropriate.
Understand what separation does not solve
A separate log store reduces the risk that compromise of a monitored host automatically destroys previously collected evidence. It does not make the logging system universally trustworthy.
Several important risks remain:
- A compromised producer may suppress events before they are sent.
- A compromised producer may submit misleading application-level data.
- An attacker who also compromises the logging environment may be able to alter or delete retained records.
- Excessive logging can expose secrets or personal data that should never have been recorded.
- Incorrect retention or capacity settings can remove evidence through ordinary operations.
- A collector outage can create gaps if buffering and recovery are inadequate.
These limits explain why high-value environments often use defense in depth. Restricted producer permissions can be combined with tightly controlled administrative access, retention controls, backups or archival copies, monitoring of the logging infrastructure, and independent telemetry from other layers such as identity systems or network controls.
The stronger controls should match the threat model. A small internal application may need a central collector with sensible access control and retention. A system facing stronger insider or infrastructure-compromise threats may justify storage mechanisms that provide additional immutability or independently protected copies.
Avoid confusing centralization with independence
Central logging can still fail its security purpose if every administrator of the application also has unrestricted administration over the logging platform.
The physical or network location of the logs is less important than the authority model. Ask concrete questions:
If the application host is fully compromised, can it delete old logs?
If the application credential is stolen, can it rewrite history?
Who can change retention settings?
Who can delete the log store?
Would those actions themselves be visible somewhere the same actor cannot erase?These questions expose shared privileges that diagrams often hide.
Complete separation of duties is not practical for every team. The objective is not organizational complexity for its own sake. It is to avoid giving a routine application identity unnecessary control over the evidence used to investigate that application.
Conclusion
Security logging is not only an event-format problem. It is a trust-boundary problem.
When important logs exist only inside the system they describe, compromise of that system can also compromise the evidence. Sending records to a separately controlled collector, restricting producers to the minimum submission permissions, and monitoring the delivery path reduces that risk.
The practical test is simple: assume the monitored application is compromised, then ask what authority the attacker gains over logs that were already accepted. If the answer is “complete control,” the logging design has not yet created an independent source of evidence.