High School AdvancedA11.6Secure Software Architecture
Lesson A11.6
Secure Error Handling and Logging
Software will fail sometimes. Secure architecture does not pretend every error can be prevented. Instead, it designs how failures are contained, communicated, recorded, investigated, and learned from.
This lesson teaches you to separate user-facing errors from operational diagnostics, security audit events, and protected debugging evidence while keeping secrets and unnecessary private data out of logs.
High School Advanced • A11: Secure Software Architecture • Lesson 6 of 10
60% complete
Readiness Check
A11.6 Entry Readiness
0/4 ready
Professional Hook
One Failure, Four Different Audiences
Imagine the fictional Northbridge portal fails while saving a privileged account change. The end user needs to know that the action did not complete. The operator needs to know which service failed. The security team needs an auditable record of the attempted privileged action. A developer may need deeper diagnostic context.
Those audiences should not all receive the same message.
End user
Explain what the user needs to know and what safe action they can take next.
Include: Simple outcome, retry guidance, support reference, neutral error code when useful.
Analyze deeper implementation failures in a tightly controlled diagnostic context.
Include: Sanitized exception class, component, operation, stack location or trace reference when approved, correlation ID.
Avoid: Anything broader than needed for troubleshooting; secret or private values should remain redacted.
Learning Objectives
Five Capabilities for This Lesson
1
Explain how secure error handling protects users while still giving defenders and engineers enough evidence to understand what happened.
2
Separate user-facing messages, operational diagnostics, security telemetry, and protected debugging evidence by audience and purpose.
3
Design logging requirements that capture useful context without exposing secrets, unnecessary private data, or sensitive implementation details.
4
Evaluate fictional logging evidence for coverage, redaction, source health, retention, access, correlation, and auditability.
5
Build an error-handling and logging design that becomes the sixth artifact in the A11 Secure Software Design Assessment.
Why It Matters
Errors Can Leak, Hide, or Preserve Evidence
Poor error handling can expose implementation details, private data, or secrets. Poor logging can hide important security decisions or create huge amounts of noisy data. Good design balances privacy, usability, operations, investigation, and accountability.
Protect the user
Give understandable guidance without exposing protected technical details.
Protect the evidence
Record important decisions and outcomes with enough context to investigate later.
Protect the data
Minimize what gets logged and keep secret or private values out of telemetry.
Core Framework
Eight Steps for Secure Failure Handling
01
Detect the failure
What condition occurred and which component recognized it?
Distinguish validation failures, authorization denials, dependency failures, internal faults, rate or capacity conditions, and expected business-rule outcomes.
Source ID, last-seen time, ingestion status, parser status, expected/actual volume.
Avoid
Assuming no alerts means the source is healthy.
User vs. Defender
One Event Can Produce Different Outputs
Strong error handling creates different outputs from the same underlying event depending on the audience.
Authorization denied
User
You do not have permission to perform this action. Reference: NB-403.
Operator
Action denied by authorization policy; correlation ID links to audit event.
Security
Actor ref, target ref, action, decision=deny, policy ref, correlation ID.
Dependency unavailable
User
This feature is temporarily unavailable. Your main record was not changed. Please try again later.
Operator
Scheduling dependency unavailable; retry queue active; correlation ID recorded.
Security
Only if the failure is security-relevant; otherwise operational evidence may be sufficient.
Unexpected internal error
User
We could not complete the request. Reference: NB-500-7F2.
Operator
Service and operation failed; sanitized exception category and correlation ID available.
Security
Escalate if the event pattern or affected workflow meets a defined security-monitoring rule.
Validation error
User
One or more fields need attention. Review the highlighted entries.
Operator
Usually low-level operational evidence only unless repeated patterns matter to service health.
Security
Do not log full private field values merely because validation failed.
Fake Dashboard
Northbridge Logging Assurance Dashboard
Fictional telemetry-health data
Critical audit sources
12
11 healthy, 1 degraded
Redaction compliance
98.7%
One diagnostic schema requires remediation
Events with correlation IDs
96%
Legacy reporting workflow remains incomplete
Source freshness
99.4%
Authorization source delayed for 7 minutes earlier today
Fake SOC Alert
Authorization Audit Source Freshness Degraded
Source: Fictional Source Health Monitor • Time: 09:19
Medium Severity
The authorization audit source has not delivered new events for seven minutes. Parser state is healthy, but expected event volume is above zero.
Defensive recommendation: Treat event absence as an evidence-quality issue until source freshness recovers. Do not assume no authorization activity occurred.
Event Register
Six Fictional Logging Requirements
LOG-01Security auditConfirmed
Counselor record access decision
Fields
Actor ref, student ref, action, decision, assignment-policy ref, timestamp, correlation ID
Redaction
No counseling-note content, passwords, tokens, or unnecessary profile data
Training note: this is fake data for defensive analysis practice only.
Review Questions
Eighteen Questions for Error and Logging Design
1
Who is the audience for this error or event?
2
What decision should this evidence support?
3
Which fields are required?
4
Which sensitive values are forbidden?
5
Does the user-facing message expose internal implementation detail?
6
Does the event identify service and environment?
7
Is actor or workload identity needed?
8
Is target reference needed?
9
Is a correlation ID present?
10
Is the result or policy decision explicit?
11
Is the event schema stable and documented?
12
Who owns the source?
13
Who can access the evidence?
14
How long should it be retained?
15
How is source health measured?
16
What happens if the logging destination is unavailable?
17
Which events should become alerts?
18
What change triggers require schema or privacy re-review?
Analyze the Evidence
Evidence Analysis: Missing Correlation ID
The legacy reporting workflow records job reference, component reference, result, duration, and environment.
The event does not contain a correlation ID.
The workflow spans the application, reporting service, and storage service.
No alternative cross-service linkage is documented.
What is the strongest conclusion about LOG-06?
Source Health
No Logs Is Not the Same as No Activity
Security teams depend on logging pipelines. If a source stops sending events, dashboards may look quiet even while the software is active. That is why source-health evidence belongs in the architecture.
Freshness
When was the last expected event or heartbeat received?
Volume
Is current event volume within an expected range?
Parsing
Are events being interpreted by the expected schema?
Ingestion
Are events arriving at the intended destination?
Retention
Are required events still available for the approved period?
Ownership
Who responds when the source becomes stale or degraded?
Common Mistakes
Eight Ways Error and Logging Design Fails
1
Showing stack traces to users
Why it fails: Internal component names, paths, line references, dependency details, and implementation context can leak unnecessarily.
Better approach: Give users a bounded message and correlation reference; keep deeper diagnostics in restricted channels.
2
Logging everything
Why it fails: Excess data increases privacy, access, retention, storage, and investigation burden.
Better approach: Record the minimum fields needed for the operational or security purpose.
3
Logging secrets
Why it fails: Logs often have broader access and longer retention than secret stores.
Better approach: Use secret metadata or record IDs, never secret values.
4
No correlation ID
Why it fails: Multi-service workflows become difficult to reconstruct without a safe way to connect related events.
Better approach: Use a non-secret correlation identifier across the workflow.
5
No source-health monitoring
Why it fails: A silent logging pipeline can make defenders believe nothing happened when evidence is simply missing.
Why it fails: Users, operators, defenders, and diagnostic reviewers need different levels of detail.
Better approach: Separate user messages, operational logs, security audit events, and restricted diagnostics.
7
Permanent verbose debugging
Why it fails: Temporary diagnostic detail can become long-term sensitive telemetry.
Better approach: Time-bound diagnostic settings, restrict access, review retention, and return to the approved baseline.
8
Treating every error as a security incident
Why it fails: Ordinary validation and dependency failures can overwhelm monitoring if they are not classified by purpose and impact.
Better approach: Define which events are operational, which are security-relevant, and which need escalation.
Scenario Decision Lab
Scenario Decision Lab 1 — Internal Error During Privileged Change
A fictional privileged account change fails because the record service returns an unexpected internal exception. The user is waiting, operators need to troubleshoot, and the security team must preserve the audit trail.
The authorization dashboard shows no events for seven minutes, but the source-health monitor reports degraded freshness while parser health remains normal.
Safe Fictional Lab
Design an Error and Logging Matrix
Use only fictional events and synthetic identifiers. Do not include real private records, credentials, tokens, internal production endpoints, or confidential logs.
1
Choose at least eight fictional error or audit events.
2
Identify the audience for each event.
3
Write a safe user-facing message where applicable.
4
Define the operational fields needed.
5
Define the security audit fields needed.
6
List forbidden sensitive values.
7
Add a correlation ID requirement for multi-service workflows.
8
Define event owner and source owner.
9
Define access and retention class.
10
Add source-health expectations.
11
Define alert or escalation conditions.
12
Assign status: Confirmed, Conditional, Unknown, or Blocked.
13
Add validation evidence.
14
Add change triggers for schema, privacy, or architecture changes.
Analyze the Evidence
Evidence Analysis: Quiet Authorization Dashboard
No authorization events are visible for seven minutes.
The source-health monitor reports freshness=DEGRADED.
Parser status is healthy.
Expected event volume for this time period is above zero.
The source later recovers and reports backlog=0.
What is the strongest evidence-based conclusion?
Advanced Challenge
Design a Privileged Audit Event Schema
Create a fictional audit schema for a high-impact account-recovery workflow that is useful to defenders without exposing secrets or unnecessary private information.
1
Event ID
2
Timestamp
3
Environment
4
Actor reference
5
Approver reference
6
Target account reference
7
Action
8
Result
9
Policy or approval reference
10
Correlation ID
11
Service source
12
Reason category
13
Forbidden fields
14
Retention class
15
Access owner
16
Source-health owner
The best schema is not the one with the most fields. It is the one that captures the evidence needed for accountability and investigation while minimizing sensitive data.
Defender Habits
A11.6 Defender Checklist
Skill Check
Seven Questions
Check Your Understanding
A11.6 Mini Quiz: Secure Error Handling and Logging
Choose your answers first. Explanations appear only after submission.
1. What is the strongest goal of secure error handling?
2. Why is a correlation ID useful?
3. Which value should never be recorded in an ordinary security log?
4. What does source-health monitoring protect against?
5. Which is the strongest user-facing message for an unexpected internal error?
6. Why should logs use data minimization?
7. A security dashboard shows no authorization events, but source freshness is degraded. What is the strongest conclusion?
Portfolio Prompt
Portfolio Build — Error Handling and Logging Design
Create the sixth artifact for your A11 Secure Software Design Assessment: a fictional error-handling and logging matrix with at least eight events. Include audience, safe user message, operational fields, security audit fields, forbidden fields, correlation requirement, owner, source owner, access class, retention class, source-health expectation, validation evidence, status, escalation rule, and change trigger.
Use synthetic identifiers and fictional events only.
Include at least one authorization decision and one privileged action.
Include one dependency failure and one source-health event.
Show how user-facing messages differ from protected diagnostics.
Include at least one event with an explicit redaction requirement.
Explain how the design supports investigations without collecting unnecessary private data.
Confidence / Readiness Reflection
Are You Ready for A11.7?
A11.7 moves to Code Review for Security. Before continuing, make sure you can identify what secure implementation reviewers should look for in error handling, logging, and evidence.
1
I can separate user-facing errors, operational logs, security audit events, and protected diagnostics.
2
I can define useful event fields without logging secrets or unnecessary private data.
3
I can explain why correlation IDs improve multi-service traceability.
4
I can evaluate source health before drawing conclusions from missing events.
5
I can define access, retention, ownership, and change triggers for logging evidence.
Portfolio Build Guide
How to Make the Logging Design Look Professional
Use event IDs
Give each important event a stable ID so requirements, code review, testing, alerts, and retention can reference it.
Separate audiences
Show the user response, operational evidence, security evidence, and diagnostic evidence separately.
Show forbidden fields
Make redaction rules explicit rather than assuming developers will know what not to log.
Use synthetic references
Use fictional actor, target, service, and correlation identifiers rather than real user data.
Show source health
Document freshness, volume, parsing, ingestion, and ownership expectations.
Show access and retention
Explain who can view the evidence and how long it should remain.
Show validation
Record how the team confirms required fields are present and forbidden values are absent.
Connect to A11
Link events back to requirements, threat-model concerns, secrets governance, and dependency workflows.
Key Takeaways
What You Should Remember
1.Secure error handling is about giving the right audience the right amount of information.
2.User messages should be useful but should not reveal unnecessary internal detail.
3.Operational logs, security audit events, and protected diagnostics serve different purposes.
4.Correlation IDs help connect distributed evidence without exposing secrets.
5.Logs should minimize sensitive data and exclude secret values entirely.
6.Source-health monitoring is necessary because missing logs can reflect a broken pipeline rather than absence of activity.
7.Authorization, privileged actions, configuration changes, and important security decisions should be auditable.
8.Retention and access are part of logging architecture, not afterthoughts.
9.The A11 logging design becomes a direct input to code review, testing, deployment, and incident response.
Lesson Safety Boundary
Use synthetic logging evidence only
Do not collect, expose, or request real credentials, tokens, private records, confidential logs, production endpoints, or other sensitive operational data. All examples in this lesson are fictional and defensive.
Lesson Complete
A11.6 Secure Error Handling and Logging Complete
You now have an error-handling and logging architecture that balances user safety, operational troubleshooting, auditability, privacy, redaction, correlation, retention, access, and source health. Next, A11.7 focuses on Code Review for Security.