Commit afc9fc3
committed
Fix: Gate TLS-bridge leaf cache on wall-clock validity, not monotonic TTL
The minter cached forged leaves on a TTL compared with time.Now(), which
carries Go's monotonic clock. Across a host suspend / VM pause the
monotonic clock freezes while wall time — and the leaf's x509 NotAfter —
keeps advancing, so the cache kept serving a leaf the client already
rejected as expired ("certificate has expired"). The bridge then read the
rejection as a forged-cert failure, auto-skipped the host, and fell back
to undecrypted passthrough — silently disabling interception (and any
inference/MCP parsing) for that host until the proxy was restarted.
- mint: populate tls.Certificate.Leaf so the cache can gate on the cert's
real NotAfter (and the TLS stack avoids re-parsing each handshake). Leaf
validity is now now+ttl+renewBefore.
- cache: store the renewal deadline monotonic-stripped (.Round(0)) so the
freshness check uses the wall clock, plus a backstop that never serves a
leaf whose real NotAfter has already passed.
- SkipSet: same .Round(0) treatment so auto-skip entries expire on real
time across a suspend instead of lingering.
Add a regression test that ages a cached leaf past its NotAfter while the
monotonic deadline still reads fresh, and asserts a re-mint.
Primarily a dev-environment robustness fix (laptop sleep / VM pause) —
production nodes do not suspend — but wall-clock gating is the correct
invariant regardless.
Assisted-By: Claude (Anthropic AI) <noreply@anthropic.com>
Signed-off-by: Hai Huang <huang195@gmail.com>1 parent 160f917 commit afc9fc3
3 files changed
Lines changed: 70 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
114 | 114 | | |
115 | 115 | | |
116 | 116 | | |
117 | | - | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
118 | 122 | | |
119 | 123 | | |
120 | 124 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
41 | 47 | | |
42 | 48 | | |
43 | 49 | | |
| |||
71 | 77 | | |
72 | 78 | | |
73 | 79 | | |
74 | | - | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
75 | 89 | | |
76 | 90 | | |
77 | 91 | | |
| |||
82 | 96 | | |
83 | 97 | | |
84 | 98 | | |
85 | | - | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
86 | 103 | | |
87 | 104 | | |
88 | 105 | | |
| |||
101 | 118 | | |
102 | 119 | | |
103 | 120 | | |
104 | | - | |
105 | | - | |
106 | | - | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
107 | 125 | | |
108 | 126 | | |
109 | 127 | | |
| |||
116 | 134 | | |
117 | 135 | | |
118 | 136 | | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
119 | 141 | | |
120 | 142 | | |
121 | 143 | | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
122 | 147 | | |
123 | 148 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
123 | 123 | | |
124 | 124 | | |
125 | 125 | | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
0 commit comments