Repository navigation
feat(dir): verify ans:// identity claims - #2304
Conversation
The ErrFinal doc still told a resolver to mark a failure observed after the caller gave up as a verdict, the rule the ans resolver dropped in b75b45b. A resolver following it would store a failed result on every shutdown mid-lookup. The doc now states the one rule: a verdict is about what the resolver can judge; a failure to reach the network, the caller's own deadline included, is left unmarked. Signed-off-by: kperry <[email protected]> Co-Authored-By: Claude Fable 5.1 <[email protected]>
The ans resolver and the reconciler's identity task each kept their own list of the HTTP statuses that say nothing about the resource (5xx, 408, 429, a redirect), so a change to one would have drifted from the other without a test failing. The rule now lives with the type that carries the code, as StatusError.Transient, and the resolver uses it; the task follows in the wiring change. Signed-off-by: kperry <[email protected]> Co-Authored-By: Claude Fable 5.1 <[email protected]>
An authoritative answer that _ans-badge.<host> does not exist is what the zone says, not a failure to reach it, yet it was left for the task to classify, so the package's contract held only through the task's own rule for a not-found DNS error. It is now a verdict here, like a name that answers without a badge record. The badge-URL host echoed in an error is now bounded like every other text taken from DNS. Signed-off-by: kperry <[email protected]> Co-Authored-By: Claude Fable 5.1 <[email protected]>
A claim waiting on another claim's lookup of the same subject got the leader's error when both callers had given up, so its stored cause could name the leader's cancellation rather than its own deadline. A waiter now reports its own context's error whenever its context is done, and runs the lookup itself only while it is live. The in-flight tests move into a testing/synctest bubble: the waiter is parked before the leader gives up, so the take-over path is the one exercised, fake time replaces the wall-clock deadlines, and a revoked verdict is shown reaching every waiter from one log fetch. Signed-off-by: kperry <[email protected]> Co-Authored-By: Claude Fable 5.1 <[email protected]>
The resolver called resolvers.Final through a local helper that existed only to hold one wrapcheck exception; the linter is now told that Final wraps, and the package calls it directly. The budgets of the two network stages are released with defer, as elsewhere, instead of by hand after each stage. Signed-off-by: kperry <[email protected]> Co-Authored-By: Claude Fable 5.1 <[email protected]>
An ans:// subject, like a spiffe:// one, is proven by the certificate the claim carries rather than by a published key. identity.NeedsCertificate names both schemes and identity.Check applies the rule: those claims need a certificate, every other claim must not carry one, since the certificate sits outside the signed payload and could be grafted on from elsewhere. Client.claim now runs identity.Check after signing instead of repeating the rule, so a claim the reconciler would refuse is never pushed. The dirctl help, the proto comments and the tests cover ans:// alongside spiffe://. Co-Authored-By: Claude Fable 5.1 <[email protected]> Signed-off-by: kperry <[email protected]>
The identity task gains an ans resolver, built when the new reconciler.identity.ans block is enabled and routed to by forSubject; while the block is off an ans:// claim fails as an unsupported scheme. The block carries the resolver's own settings (trusted logs, pinned or fetched root keys, lifetimes, timeout, clock skew) and is checked at startup: a record may carry an ans:// identity claim and an ans:// ownership claim, each taking two of the resolver's timeouts, and all of that must fit the record budget; and the resolver's memo of a subject must expire between runs. isTransient learns two things: a failure the resolver marked with resolvers.Final is never transient, whatever cause it carries; and an HTTP answer that says nothing about the resource is, judged by safefetch's StatusError.Transient so that the task and the resolver share one list. An ans:// result outlives lookups that get no answer (the publisher's DNS, the trusted log) for identity.ans.stale_grace, 24 hours by default, rather than the task's seven days, since the publisher's own DNS is among those lookups: a publisher who breaks their own DNS delays a revocation by at most that. The grace sits in the resolver set beside the scheme dispatch. A run stopped mid-lookup stores no failure for the claim it was on, for every scheme, and reports the interruption. The run summary logs its duration and how many results were kept through transient failures, the startup line names the trusted logs, the pinned keys and the grace, and unpinned mode is called out. The keys take a comma-separated value from the environment, in the reconciler and under dirctl daemon; the samples and Helm values carry the block, off by default. Co-Authored-By: Claude Fable 5.1 <[email protected]> Signed-off-by: kperry <[email protected]>
The identity page gains the ans:// subject: what the claim carries, the shape of the badge record, how the transparency log attests the certificate, what a verified result proves and does not prove, which failures are final and which are transient, how the log's keys are pinned or fetched, the time budget, the configuration keys and the log lines to watch. The CLI reference, the trust-model and Go SDK pages, the publishing skill, the reconciler README and the changelog follow. The word "ans" joins the codespell ignore list. Co-Authored-By: Claude Fable 5.1 <[email protected]> Signed-off-by: kperry <[email protected]>
Signed-off-by: kperry <[email protected]> # Conflicts: # install/docker/reconciler.config.yml
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
The path that leaves stored results alone when the record itself cannot be pulled had no test, and the one line this change touched in it was the patch's only uncovered line. Signed-off-by: kperry <[email protected]> Co-Authored-By: Claude Fable 5.1 <[email protected]>
ramizpolic
left a comment
There was a problem hiding this comment.
Thanks for this. Wiring the resolver into the identity task is clean, and the startup validation, the interrupted-run handling and the docs on what verified does and does not prove are all good. Below are the things I would like to see changed or discussed before merge.
Please change
1. Log key rotation fails every ans:// claim immediately.
An unknown key id under pinned root_keys is marked Final, so results flip to failed with no grace. Keys are only read at startup, so a routine rotation by the log breaks all claims until someone edits the config and restarts. That looks like stale reconciler config rather than a verdict on the claim, which is the same category as our own DNS being down.
Suggestion: either treat it as unmarked so stale_grace applies and log it loudly, or keep it fail-closed but say so explicitly in the docs. Either way, please allow pinning the old and new key together so operators can roll over without a gap.
2. status_cache_ttl < interval does not guarantee the documented revocation bound.
The resolver memo lives across runs. If an entry is created late in a run, it can still be fresh when the next run starts, so a revocation can wait one run longer than "at most status_cache_ttl".
Suggestion: drop the memo at the start of each run, since the task already builds a per-run resolver set. That also removes the need for this validation rule. Otherwise require something like ttl <= interval/2 and document it.
3. stale_grace semantics are hard to use.
0 means "24h", so there is no direct way to ask for no grace. The docs suggest 1s as a workaround, and an explicit 0 cannot override the viper default.
Suggestion: let 0 mean no grace for ans:// and keep the 24h default only in the viper defaults. Alternatively use a pointer, or a separate fail_closed option.
4. Scheme knowledge is spread over several places.
NeedsCertificate, forSubject, graceFor, the ansScheme constant, the bare "spiffe://" literals and the error text all list schemes separately. The new TestForSubjectAgreesWithNeedsCertificate shows the drift risk is real.
Suggestion: one small table or set of constants per scheme (resolver, grace, needs certificate), and build the error message from it.
Worth discussing
5. Stored results are not tied to the claim that produced them.
previous() looks up by record and role only, so a kept verified result can survive after a different claim is attached. This is not new, but ans:// makes it easier to notice.
Question: is that acceptable for the grace window?
6. Turning ans.enabled off flips existing results to failed ("unsupported scheme") on the next run, with no grace.
Question: is that the intended behaviour for a temporary rollback? If so, a line in the operator notes would help.
ramizpolic
left a comment
There was a problem hiding this comment.
The same points as in my earlier summary, now attached to the lines they apply to.
Which scheme a subject is spelled in, whether its claims carry a certificate, which resolver finds its keys and how long a stored result survives lookups that get no answer were each decided by their own list of prefixes, in the client package and in the reconciler, with a test to catch them drifting apart. The client package now owns the schemes: Scheme, SchemeOf and Scheme.NeedsCertificate, with the certificate rule's error text built from the same table. The reconciler keeps one entry per scheme (resolver and grace) keyed by it, so adding a scheme is one line in each place that has something to say about it. Signed-off-by: kperry <[email protected]> Co-Authored-By: Claude Fable 5.1 <[email protected]>
The resolver's memo of a subject's attestation outlived a run: an entry made late in one run was still fresh when the next began, so a revocation could wait a run longer than the documented status_cache_ttl, and the startup rule tying the lifetime to the interval only narrowed the gap. The resolver can now be told to Forget, the task tells every resolver that keeps answers when a run starts, and the lifetime is what it says: how long an answer is reused within a run. The interval rule goes. Signed-off-by: kperry <[email protected]> Co-Authored-By: Claude Fable 5.1 <[email protected]>
An operator who wanted no grace for ans:// results could not ask for it: zero meant the 24-hour default, in the config loaders and again in the task, so the documented workaround was a value of one second. Zero now keeps nothing, and the default lives only where defaults belong, in the reconciler's and the daemon's viper defaults. Signed-off-by: kperry <[email protected]> Co-Authored-By: Claude Fable 5.1 <[email protected]>
A transparency log that rotates its key fails every ans:// claim it attests until the operator pins the new key, and that is the right outcome of pinning, but the only sign of it was a failed result per claim. The resolver now names the cause (ErrUnpinnedRootKey) under the verdict mark, and the identity task warns once per run until the key is pinned. root_keys already takes several keys; the docs now say to pin the next key beside the current one so a rotation has no gap, and a test shows a token signed by either pinned key verifies. Signed-off-by: kperry <[email protected]> Co-Authored-By: Claude Fable 5.1 <[email protected]>
… does Two questions from review: a kept result outlives the claim that produced it, and turning the ans block off fails every ans:// result. Both are intended, and the page now says so: a result is about the record's declared subject, not one claim, and a scheme the task cannot verify does not keep its results. Signed-off-by: kperry <[email protected]> Co-Authored-By: Claude Fable 5.1 <[email protected]>
|
Thanks @ramizpolic. The four changes are in, the two questions are answered in their threads with a doc line each, |
The warning about a signing key root_keys does not hold logged the resolver's error as it came, and that text carries the key id the log's token named. CodeQL (go/log-injection) flagged it: a remote party's text with a line break in it could forge a log entry. The text is now kept on one line before it is logged. Signed-off-by: kperry <[email protected]> Co-Authored-By: Claude Fable 5.1 <[email protected]>
What
Wires the
ans://resolver from #2300 into the reconciler's identity task, which completes #2174.identity.Checkrequires a certificate onspiffe://andans://claims and refuses one on any other subject (identity.NeedsCertificate).Client.claimapplies the same check after signing,dirctl identity claim --certdocuments theans://case, and the proto comments onsubjectandcertificatefollow.resolverSet.ansis built whenidentity.ans.enabledis set, from the resolver's own configuration underidentity.ans.*(trusted_log_hosts,root_keysorallow_unpinned_root_keys,root_keys_ttl,status_cache_ttl,timeout,clock_skew) plus the task'sstale_grace. The block is checked at startup: four resolver timeouts must fitrecord_timeout(an identity and an ownership claim, two stages each) andstale_gracemust not be negative. The resolver's memo is dropped when a run starts, so a revocation takes effect on the next run. While the block is off, anans://claim fails as an unsupported scheme. Startup logs the trusted logs, the pinned key ids, the timeout, the cache lifetime and the grace, and warns when root keys are unpinned.isTransientchecksresolvers.ErrFinalfirst and judges HTTP answers withsafefetch.StatusError.Transient(5xx, 408, 429, redirects), the rule the resolver uses too. Anans://result survives lookups that get no answer foridentity.ans.stale_grace(default 24h) instead of the task's seven days, since the publisher's own DNS is among those lookups: a publisher who breaks their own DNS can delay the effect of a revocation by at most the grace, and an operator who wants to fail closed sets it to0. A run that is stopped mid-lookup stores no failure for any scheme and reports the interruption. The run summary logskeptandduration.RECONCILER_IDENTITY_ANS_*, comma-separated lists),dirctl daemondefaults (DIRECTORY_DAEMON_RECONCILER_IDENTITY_ANS_*), the daemon sample,install/docker/reconciler.env, and both Helm values files (block present, off by default).verifiedresult proves and does not prove, verdicts versus lookups that get no answer and the grace, the log's keys, the time budget, the configuration table and the log lines to watch. The CLI reference, Go SDK page, trust-model page, publishing skill, reconciler README and changelog follow.Resolver follow-ups from the #2300 review
Found while wiring the task and reviewing the result; kept here rather than in another round on #2300.
resolvers.ErrFinal's doc still stated the rule feat(client): add the ans identity key resolver #2300 dropped (a failure observed after the caller gave up is final). It now states the one rule: a verdict is about what the resolver can judge; a failure to reach the network, the caller's own deadline included, is left unmarked.safefetch.StatusError.Transientis the one list of HTTP statuses that say nothing about the resource; the resolver'sfetchErrorand the task'sisTransientboth use it instead of keeping their own copies._ans-badge.<host>is a verdict in the resolver, like a name that answers without a badge record; the badge-URL host echoed in an error is bounded like every other text taken from DNS.testing/synctest, so the take-over path is exercised deterministically and no wall-clock deadlines remain.defer, andresolvers.Finalis called directly, with.golangci.ymltelling wrapcheck that it wraps.Review round 1
ansresolver.ErrUnpinnedRootKey, under theFinalmark), the task warns once per run until the key is pinned,root_keystakes several keys so a rotation has no gap, with a test and a doc paragraph.Resolver.Forgetis called on every resolver that keeps answers when a run starts; thestatus_cache_ttl < intervalrule and its docs are gone.stale_grace: 0keeps nothing; the 24h default lives only in the two viper default sets.client/utils/identityownsScheme,SchemeOfandScheme.NeedsCertificate, the certificate rule's error text is built from it, and the reconciler keeps one entry per scheme (resolver and grace) keyed byScheme, soforSubjectandgraceForread the same table.ans.enabledoff failing results) are answered in their threads and in the docs.Operator notes
identity.ans.stale_graceunset means the loaders' default of24h;0keeps nothing.ans.enabledoff is a rollback, not a pause: it failsans://claims as an unsupported scheme on the next run, with no grace, as does running a reconciler from before this change.root_keys, pin a log's next key beside its current one before it signs with it; a token signed by a key that is not pinned fails its claims and the reconciler warns once per run.Commits
docs(resolvers): state the one rule for a final errorrefactor(safefetch): let a StatusError say whether a retry may helpfix(ans): judge an answer that the badge name does not existfix(ans): give a waiter that gave up its own causerefactor(ans): take the review nits on #2300feat(identity): require a certificate on ans:// claimsfeat(reconciler): verify ans:// claims through the ans resolverdocs(dir): describe the ans identity schemeAfter review:
test(reconciler): cover a record whose annotations cannot be readrefactor(identity): name the subject schemes in one placefix(ans): forget the memo between runsfix(reconciler): let a zero stale_grace keep nothingfeat(ans): name a signing key that is not pinned, once per rundocs(dir): say what a stored result is about and what turning ans off doesfix(reconciler): keep the unpinned-key warning on one line(CodeQL go/log-injection on the new warning)plus two merges of
main.Verification
task lintwith the pinned golangci-lint 2.13.2 overclient,utils,reconcilerandcli: 0 issues.go test -race ./...inclientandreconciler, andcli/cmd/{daemon,identity}: pass.reconciler/tasks/identityis at 97.2% with the new code covered; the resolver package at 100%.helm linton both charts passes and the renderedreconciler.config.ymlcarries the block;task api:genleaves the tree clean; codespell passes.Part of #2170. Closes #2174.
🤖 Generated with Claude Code