Chapter 19 — Quantum and post-quantum security: monitoring
Lesson map
Lesson 19 published. Map, example, EX037.
flowchart TD
N0["Learning outcomes"]
N1["19.1 What to log"]
N2["19.2 Dashboards and alerts"]
N3["19.3 Practical activity — Lab K"]
N4["19.4 Lag and coverage"]
N5["19.7 Privacy of logs"]
N6["Synthesis"]
N0 --> N1 --> N2 --> N3 --> N4 --> N5 --> N6
N6 --> EX["Worked example"]
EX --> Q["Exercise EX037"]
Logical drawing
flowchart LR
N0["Learning outcomes"]
N1["19.1 What to log"]
N2["19.2 Dashboards and alerts"]
N3["19.3 Practical activity — Lab K"]
N4["19.4 Lag and coverage"]
N5["19.7 Privacy of logs"]
N6["Synthesis"]
N0 --> N1 --> N2 --> N3 --> N4 --> N5 --> N6 --> Q["EX037"]
[Learning outcomes]
|
v
[19.1 What to log]
|
v
[19.2 Dashboards and alerts]
|
v
[19.3 Practical activity — Lab K]
|
v
[19.4 Lag and coverage]
|
v
[19.7 Privacy of logs]
|
v
[Synthesis]
|
v
[Worked example] --> [Exercise EX037]
Learning outcomes
You will (1) log negotiated algorithms in TLS, SSH and VPN services; (2) build dashboards and alerts for hybrid share and fallback; (3) use confidence bounds in canary decisions; and (4) handle measurement lag.
19.1 What to log
TLS: negotiated group, protocol version, cipher suite, certificate signature algorithm (server-side), client library hints if available. SSH: KEX algorithm and host-key algorithm. VPN: key-exchange methods per tunnel. Many servers can log these with configuration changes; add fields to access logs rather than enabling verbose debug logs in production.
KLS's ingress access log gained three fields: negotiated group, TLS version and cipher suite. The sshd hosts log the KEX algorithm per session at the default level after a small configuration change, and the VPN appliance exports tunnel parameters to the log platform. Together they feed the hybrid-share dashboard without any debug logging in production.
19.2 Dashboards and alerts
Per service and site: hybrid share, fallback share, handshake failure rate by cause. Alerts: hybrid share drops by more than five points in an hour (rollback or misconfiguration); failure rate exceeds budget during rollout.
KLS chose the five-point rule after looking at a month of normal variation: the hourly hybrid share on the gateway moved by at most two points without a change. A drop of five therefore signals a real event, while the absolute floor of 90 % catches slow drift. Each alert links to the runbook for a hybrid-share drop.
19.3 Practical activity — Lab K
# Lab K (ch 19): canary gate for enabling a hybrid group - promote only if failures stay within budget.
import math
def upper95(k, n): # Wilson upper bound
z = 1.96; p = k / n; d = 1 + z*z/n
return ((p + z*z/(2*n)) + z*math.sqrt(p*(1-p)/n + z*z/(4*n*n))) / d
baseline, budget = 5e-4, 4e-4 # baseline failure rate, allowed increase
for stage, k, n in [("1% canary", 3, 5000), ("10% canary", 28, 50000), ("10% canary (proxy site)", 96, 50000)]:
ub = upper95(k, n); ok = ub <= baseline + budget
print(f"{stage:24s} {k}/{n} upper95={ub:.5f} {'PROMOTE' if ok else 'HOLD'}")
Expected output:
1% canary 3/5000 upper95=0.00176 HOLD
10% canary 28/50000 upper95=0.00081 PROMOTE
10% canary (proxy site) 96/50000 upper95=0.00234 HOLD
The gate compares the 95 % Wilson upper bound of the observed failure rate with the baseline of 0.05 % plus a budget of 0.04 %, a ceiling of 0.09 %. The 1 % canary saw only 3 failures in 5,000 handshakes, a rate of 0.06 %, but with so few trials the upper bound is 0.176 %, so the gate says HOLD: not evidence of harm, just not enough evidence of safety. At 10 %, 28 in 50,000 gives a bound of 0.081 % and the gate promotes. The proxy site's 96 in 50,000 is a real elevation, 0.19 % observed, and holds for investigation.
19.4 Lag and coverage
Logs may arrive minutes or days late; partner-side changes are visible only when partners connect. Annotate dashboards with coverage and lag so that decisions use the right time window.
For KLS, ingress logs arrive within two minutes, VPN appliance exports hourly and partner SFTP evidence only when each partner's nightly job runs. The dashboard shows each panel's last data time, and canary decisions on SFTP wait at least a full week so every partner has connected.
Two KLS partners upload only at month end, so a one-week SFTP window would report them as untested rather than as failing; the dashboard lists them separately with their last connection date.
19.5 Worked example
KLS adds $ssl_curve (or the product's equivalent) to ingress logs and builds a dashboard. A week later the alert fires: hybrid share on the customer portal dropped from 93 % to 4 % after a release. Cause: the release restored an old ingress annotation. Rollback of the annotation restored the share within an hour.
Two details made the recovery quick. The alert linked to a runbook that started with "compare the live profile hash with the approved one", which pointed directly at the annotation. And because the profile was versioned separately, the fix restored the annotation without rolling back the release. The CI gate in Chapter 22 was added afterwards so the same annotation could not ship again.
19.6 Common errors and limits
- Debug logging in production.
- Monitoring failures but not fallback.
- Ignoring lag in decisions.
KLS considered turning on full TLS debug logging to see negotiations and rejected it: the volume would have overwhelmed the log platform and recorded more client detail than needed. Its first dashboard showed only failures, so the portal's silent drop from 93 % to 4 % hybrid would have been invisible. And a canary was nearly promoted on the basis of one hour of VPN data that, because of hourly export, actually described the previous hour.
19.7 Privacy of logs
Negotiation logs contain client addresses and timestamps. Log only what monitoring needs — algorithm fields, service, site and coarse client identifiers — and apply the same retention and access rules as other operational logs. Aggregated metrics can be kept longer than raw logs. This keeps monitoring consistent with privacy obligations and reduces the value of the logs to an attacker.
When sharing dashboards with vendors or partners during joint troubleshooting, export aggregated views rather than raw log extracts, and remove client identifiers.
Exercises
- EX037 — Alert rule. Write an alert rule for hybrid share on the API gateway. Rubric: 3 = metric, threshold, window, action.
- EX038 — Canary reading. Using Lab K, decide what to do with the 10 % canary at the proxy site and why. Rubric: 3 = hold, investigate proxy, exclude/fix.
Synthesis
Logging negotiated algorithms enables dashboards and alerts that catch fallback and failures; canary gates use confidence bounds, with lag and coverage visible.
Continue studying — chapter 19 of 30
← Chapter 18 (draft) · Course chapter index · Chapter 20 (draft) →