Secure Software Development / Intermediate: implementation boundaries and verification / Lesson 14
Verify safe diagnostics with synthetic markers
Design and test diagnostic events that retain useful context while excluding sensitive values.
On this page
Lesson goals
- Choose minimal diagnostic fields.
- Test normal and error paths using synthetic markers.
- Trace logs through relevant downstream boundaries.
Define useful diagnostic evidence
A service needs enough diagnostic information to investigate failures without collecting credentials or unnecessary personal data. Start by naming the decisions an operator must make and the minimum safe fields needed for them. In this fictional isolated lab, a denied request and a processing error each receive a safe correlation reference, time and outcome. Agree retention and access with the responsible owner. The exercise uses synthetic markers and never requires a real credential or user record.
Select fields before logging
Use a structured allowlist of fields rather than dumping a complete request, exception object or environment. A safe event may include an action, category, outcome and correlation reference while omitting authorization headers, passwords and session tokens. The first table illustrates the chosen lab fields, not a universal logging policy. Review how exception formatting and framework defaults behave: a field removed from normal logging may still appear in an error path or a downstream collector.
Event | Safe fields
request denied | action, outcome, time, correlation reference
processing error | category, time, correlation reference
The table describes expected fields and checks, not a real log or execution result.
Exercise success and error paths
In a disposable environment send a benign synthetic marker through the relevant input and trigger both a normal decision and an agreed error path. Inspect the resulting event through an approved restricted observation path. The marker should be absent from fields where the policy forbids it, while the expected safe event remains. The second table lists expected outcomes and does not claim that a test has run. Do not paste real secrets into the test, issue report or screenshot.
Case | Expected
synthetic marker in request | absent from log
known event | safe context remains
The table describes expected fields and checks, not a real log or execution result.
Trace downstream copies
Follow the event from the application to its collector, storage and any authorized diagnostic view. Masking only at a dashboard can leave the original value in another destination. Record safe references, retention and inaccessible boundaries without copying the marker into further production systems. If a real secret is suspected in existing logs, follow the organization’s incident and rotation procedure; changing code cannot remove historical copies automatically. Keep the exposure response distinct from the synthetic regression test.
Verify both privacy and usefulness
After the repair, repeat success and error cases using fresh markers and verify both absence of the prohibited value and presence of useful safe context. Test a neighboring allowed field so a disabled logger cannot make the privacy assertion pass accidentally. Record the artifact, configuration and paths inspected. These checks support the selected diagnostic flow; they do not prove that every dependency, historical export or untested exception path is free of sensitive data.
Common errors and fixes
Logging a complete request for convenience
- Why it happens
- The request can contain credentials and personal data.
- How to fix it
- Replace the dump with reviewed safe fields.
- Prevent it next time
- Use structured allowlists and negative tests.
Masking a secret only in the dashboard
- Why it happens
- Collectors or storage may retain the original value.
- How to fix it
- Omit it before emission and assess existing copies.
- Prevent it next time
- Trace events through the whole logging path.
Disabling all logging to pass a privacy test
- Why it happens
- The test checks absence but not diagnostic usefulness.
- How to fix it
- Verify a safe event and required context remain.
- Prevent it next time
- Pair privacy assertions with a positive event check.
2 practice exercises
1. A synthetic marker is absent from the dashboard but present in the collector. Is the repair complete?
Show worked solution
No. Remove the prohibited field before emission and verify the collector and downstream destinations; track existing real exposure separately.
2. The privacy test passes because no event was emitted. What additional assertion is needed?
Show worked solution
Verify that the expected event and safe action, outcome and correlation context remain available without the marker.
Key takeaways
- Select safe diagnostic fields before emitting events.
- Verify both privacy and usefulness across the logging path.