Skip to content

fix(ct_monitor): keep scanning after a log fails its check - #1349

Merged
kvinwang merged 1 commit into
nextfrom
fix/ct-monitor-unwedge
Sep 24, 2026
Merged

kvinwang merged 1 commit into
nextfrom
fix/ct-monitor-unwedge

Conversation

@kvinwang

Copy link
Copy Markdown
Collaborator

Problem

check_new_logs returned on the first failing log with ?, before last_checked was advanced. Every following pass re-fetched the same page and stopped at the same entry, while run only logged the error — the monitor looked healthy but checked nothing. A single crt.sh 429 whose body fails to parse as PEM is enough to trigger it.

Fix

A failing log is reported and the pass continues; the watermark advances and failures are summarised into one error. The loop is extracted into scan so it can be tested without a network.

Trade-off: a failing certificate is now alerted on once per appearance instead of every minute forever.

Verification

cargo test -p ct_monitor: 6 passed (the crate had no tests before).

Split out of #1281.

The scan loop propagated the first failure with `?`, which returned before
`last_checked` was ever assigned. Sixty seconds later the same page of up to
10 000 logs was re-fetched and the pass stopped at the same entry -- forever.
`run` only logs the error, so the monitor went on looking healthy while
checking nothing.

The trigger does not have to be a real mis-issuance. `check_one_log` fetches
each certificate from crt.sh and parses it as PEM, so a single 429 whose HTML
body fails to parse wedges the monitor just as effectively. On a first run
`last_checked` is `None`, so a domain with any certificate history issues up to
10 000 sequential crt.sh fetches, which will itself provoke the rate limiting
that causes the wedge. It is also a detection-evasion primitive: one benign
unknown key -- a rotated gateway key, say -- masks every log recorded after it.

So a failing log is now reported and the pass continues, the watermark advances,
and the failures are summarised into one error at the end. The trade is that a
certificate that genuinely should not exist is alerted on once instead of every
minute; the alternative was alerting forever about one certificate and never
looking at another.

Extract the loop into `scan`, away from the HTTP calls, so it can be tested
without a network -- the crate had no tests at all. Stopping at the previous
watermark and reporting one that fell off the page are unchanged, and both are
now covered.
@kvinwang
kvinwang merged commit 7ed734b into next Sep 24, 2026
11 checks passed
@kvinwang
kvinwang deleted the fix/ct-monitor-unwedge branch September 24, 2026 05:19
kvinwang added a commit that referenced this pull request Sep 25, 2026
…d ct_monitor

tc-kms-build-001 now requires --locked on every dstack cargo build in the
builder images (#1403), a versioned, integrity-checked Vue script on the
onboarding page (#1396), and the ct_monitor scan tests (#1349), whose binary
talks to crt.sh directly and cannot run hermetically.

Signed-off-by: Kevin Wang <wy721@qq.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant