Log Entity Actions Security Pattern
Records entity actions to create an audit trail, enabling accountability, non-repudiation, incident investigation, and security monitoring.
Problem Addressed
Entity repudiates action request: An entity denies having performed an action, or there's no way to determine what actions occurred, who performed them, or when.
Core Components
| Role |
Type |
Responsibility |
| Entity |
Entity |
Performs actions that should be logged |
| System |
Entity |
Processes entity requests |
| Logger |
Entity |
Records actions to log store |
| Log Store |
Storage |
Persists log entries |
| Log Monitor |
Entity |
Analyzes logs for anomalies |
Data Elements
- action: The operation performed
- principal: Identity of entity performing action
- timestamp: When action occurred
- outcome: Success/failure status
- context: Additional relevant information
What to Log
Security-Relevant Events
- Authentication attempts (success and failure)
- Authorization decisions (grants and denials)
- Access to sensitive data
- Administrative operations
- Security configuration changes
- Session events (creation, termination)
Per-Event Information
- Who: Principal/user identifier
- What: Action performed
- When: Timestamp (synchronized, preferably UTC)
- Where: Source (IP, location, system)
- Outcome: Success, failure, error
- Context: Relevant parameters (without sensitive data)
What NOT to Log
Never log:
- Passwords or credentials
- Session tokens
- Encryption keys
- Full credit card numbers
- Personal data beyond necessity
- Sensitive business data
Security Considerations
Log Integrity
- Protect logs from tampering
- Detect unauthorized modifications
- Consider append-only storage
- Sign or hash log entries
Log Confidentiality
- Logs may contain sensitive information
- Restrict access to authorized personnel
- Encrypt logs at rest and in transit
Log Availability
- Ensure logging system resilience
- Handle logging failures gracefully
- Don't let logging failures stop business operations
- Alert on logging system issues
Centralized Logging
- Aggregate logs from multiple sources
- Enables correlation and analysis
- Protects against local log tampering
- Use secure transmission to central store
Log Retention
- Define retention periods
- Meet compliance requirements
- Secure deletion when expired
- Archive for long-term storage if needed
Time Synchronization
- Use NTP for consistent timestamps
- Critical for correlating events across systems
- Include timezone information (prefer UTC)
Logging Flow
Entity → [action] → System
System → [log(action, principal, timestamp, outcome)] → Logger
Logger → [store] → Log Store
Log Monitor → [analyze] → Log Store
Log Monitor → [alert] → Security Team (if anomaly)
Implementation Guidelines
Log Format
- Use structured format (JSON, key-value)
- Consistent schema across systems
- Include correlation IDs for request tracing
Log Levels
- ERROR: Security failures requiring attention
- WARN: Suspicious but not definitively malicious
- INFO: Normal security events
- DEBUG: Detailed troubleshooting (not in production)
Performance
- Asynchronous logging to avoid blocking
- Buffer and batch writes
- Monitor logging overhead
Monitoring and Alerting
- Real-time analysis for critical events
- Threshold-based alerts (e.g., failed logins)
- Pattern detection for attack identification
Common Security Events to Log
| Event |
Log Level |
Details to Include |
| Login success |
INFO |
principal, source IP, timestamp |
| Login failure |
WARN |
attempted user, source IP, failure reason |
| Authorization denied |
WARN |
principal, action, resource |
| Admin action |
INFO |
principal, action, target, parameters |
| Security config change |
INFO |
principal, what changed, old/new values |
| Session timeout |
INFO |
principal, session duration |
Implementation Checklist
Related Patterns
- Authentication (events to log)
- Authorisation (events to log)
- Data validation (events to log)
References
1---2name: log-entity-actions-pattern3description: Security pattern for implementing security logging and audit trails. Use when designing logging systems for security events, implementing non-repudiation, creating audit trails, or addressing security monitoring and incident response needs. Addresses "Entity repudiates action request" problem.4---56# Log Entity Actions Security Pattern78Records entity actions to create an audit trail, enabling accountability, non-repudiation, incident investigation, and security monitoring.910## Problem Addressed1112**Entity repudiates action request**: An entity denies having performed an action, or there's no way to determine what actions occurred, who performed them, or when.1314## Core Components1516| Role | Type | Responsibility |17|------|------|----------------|18| **Entity** | Entity | Performs actions that should be logged |19| **System** | Entity | Processes entity requests |20| **Logger** | Entity | Records actions to log store |21| **Log Store** | Storage | Persists log entries |22| **Log Monitor** | Entity | Analyzes logs for anomalies |2324### Data Elements2526- **action**: The operation performed27- **principal**: Identity of entity performing action28- **timestamp**: When action occurred29- **outcome**: Success/failure status30- **context**: Additional relevant information3132## What to Log3334### Security-Relevant Events35- Authentication attempts (success and failure)36- Authorization decisions (grants and denials)37- Access to sensitive data38- Administrative operations39- Security configuration changes40- Session events (creation, termination)4142### Per-Event Information43- **Who**: Principal/user identifier44- **What**: Action performed45- **When**: Timestamp (synchronized, preferably UTC)46- **Where**: Source (IP, location, system)47- **Outcome**: Success, failure, error48- **Context**: Relevant parameters (without sensitive data)4950## What NOT to Log5152**Never log:**53- Passwords or credentials54- Session tokens55- Encryption keys56- Full credit card numbers57- Personal data beyond necessity58- Sensitive business data5960## Security Considerations6162### Log Integrity63- Protect logs from tampering64- Detect unauthorized modifications65- Consider append-only storage66- Sign or hash log entries6768### Log Confidentiality69- Logs may contain sensitive information70- Restrict access to authorized personnel71- Encrypt logs at rest and in transit7273### Log Availability74- Ensure logging system resilience75- Handle logging failures gracefully76- Don't let logging failures stop business operations77- Alert on logging system issues7879### Centralized Logging80- Aggregate logs from multiple sources81- Enables correlation and analysis82- Protects against local log tampering83- Use secure transmission to central store8485### Log Retention86- Define retention periods87- Meet compliance requirements88- Secure deletion when expired89- Archive for long-term storage if needed9091### Time Synchronization92- Use NTP for consistent timestamps93- Critical for correlating events across systems94- Include timezone information (prefer UTC)9596## Logging Flow9798```99Entity → [action] → System100System → [log(action, principal, timestamp, outcome)] → Logger101Logger → [store] → Log Store102Log Monitor → [analyze] → Log Store103Log Monitor → [alert] → Security Team (if anomaly)104```105106## Implementation Guidelines107108### Log Format109- Use structured format (JSON, key-value)110- Consistent schema across systems111- Include correlation IDs for request tracing112113### Log Levels114- ERROR: Security failures requiring attention115- WARN: Suspicious but not definitively malicious116- INFO: Normal security events117- DEBUG: Detailed troubleshooting (not in production)118119### Performance120- Asynchronous logging to avoid blocking121- Buffer and batch writes122- Monitor logging overhead123124### Monitoring and Alerting125- Real-time analysis for critical events126- Threshold-based alerts (e.g., failed logins)127- Pattern detection for attack identification128129## Common Security Events to Log130131| Event | Log Level | Details to Include |132|-------|-----------|-------------------|133| Login success | INFO | principal, source IP, timestamp |134| Login failure | WARN | attempted user, source IP, failure reason |135| Authorization denied | WARN | principal, action, resource |136| Admin action | INFO | principal, action, target, parameters |137| Security config change | INFO | principal, what changed, old/new values |138| Session timeout | INFO | principal, session duration |139140## Implementation Checklist141142- [ ] All authentication events logged143- [ ] All authorization denials logged144- [ ] Sensitive operations logged145- [ ] No credentials in logs146- [ ] Timestamps synchronized (NTP)147- [ ] Logs protected from tampering148- [ ] Log access restricted149- [ ] Retention policy defined150- [ ] Monitoring/alerting configured151- [ ] Secure transmission to central store152153## Related Patterns154155- Authentication (events to log)156- Authorisation (events to log)157- Data validation (events to log)158159## References160161- Source: https://securitypatterns.distrinet-research.be/patterns/02_02_001__log_entity_actions/162- OWASP Logging Cheat Sheet163- OWASP Security Logging Vocabulary