docs(spec): audit and throttle authentication failures - #24
Draft
antstanley wants to merge 1 commit into
Draft
Conversation
This was referenced Aug 5, 2026
antstanley
force-pushed
the
spec/audit-and-throttle-auth-failures
branch
2 times, most recently
from
August 5, 2026 08:22
149741e to
99fc4e4
Compare
antstanley
changed the base branch from
main
to
spec/fail-closed-config-and-adapters
August 5, 2026 08:22
antstanley
marked this pull request as draft
August 5, 2026 08:25
This was referenced Aug 5, 2026
antstanley
force-pushed
the
spec/audit-and-throttle-auth-failures
branch
from
August 5, 2026 09:00
99fc4e4 to
6f258a9
Compare
antstanley
force-pushed
the
spec/audit-and-throttle-auth-failures
branch
from
August 5, 2026 11:29
6f258a9 to
2f9ace8
Compare
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
antstanley
force-pushed
the
spec/audit-and-throttle-auth-failures
branch
from
August 5, 2026 12:01
2f9ace8 to
aee02c0
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Note
Stacked PR 4 of 16 — part of stack #35, which targets
main.Base: #25 (
spec/fail-closed-config-and-adapters) · Followed by: #19This PR's diff shows only its own change. Merge the stack bottom-up; do not merge this before its base.
Why it sits at position 4: Introduces the mandatory
SecurityEventchannel, theRateLimiterport,ClientAddrand theTooManyRequestsmapping. #19, #26 and #31 all build on this machinery.Scope of this PR
This PR currently carries the change spec. It will also carry the implementation plan and the build work for that spec — plan and code land as later commits on this same branch, so the spec, its plan, and its implementation review and merge as one unit.
Review order within the PR: spec first, then plan, then implementation.
Change spec proposing that authentication failures be recorded and throttled.
Problem. Four defects that combine so that a brute-force campaign against
/tokenis invisible:ValidationFailedis emitted atDebug(7) against a defaultInfo(6) floor, so the shipped defaults discard every failed-authentication event before any adapter sees it.exchangevia?before any event is emitted, so those paths record nothing at any level. There is no access log either.UserCreated,TokenExchange,TokenRefresh,AllSessionsRevoked,TokenRevocation).Proposed delta. Split audit emission into a mandatory
SecurityEventchannel whose severity derives from a closed enum and which no configured threshold can filter, leavingemit_threshold/blocking_thresholdto govern a best-effort channel only. Move terminal-outcome emission to a single exit point per flow so no failure can leaveexchange/refreshunrecorded.Make a mandatory-channel write failure fail the operation (
audit.durability, shippingobservethen flipping toenforce) and flip the shippedaudit.adapterdefault fromnooptostdout. The cost is named plainly: a remote-sink outage becomes an availability event for/tokenand/revoke.Add a
RateLimiterport with per-IP / per-IP-failures / per-subject / per-provider limits plus a global concurrency bound on the public routes, returning429 slow_downwithRetry-After, keyed only on aClientAddrthe server established viainto_make_service_with_connect_infoandserver.trusted_proxies/trusted_proxy_hops— never on an unvalidatedX-Forwarded-For.Notes.
crates/server/src/main.rscallsaxum::serve(listener, app)with noConnectInfo, so no peer address exists today — the per-IP fix cannot be middleware-only. This is a structural prerequisite the finding did not name.changes/merged/2026-07-01-wire_audit_event_emission.md(which putValidationFailedatdebugbehindemit_threshold) and argues why that reasoning was wrong, rather than quietly overriding it.reasonmust be a fixed classification string, becauseProviderError'sDisplayembeds the upstream response body verbatim.Drafted with the
spec-creatorplugin from a deep security scan of the repository at53cbdec9. Spec only — no source changes.