Repository navigation
Rate limiting, audit and metrics for the osctrld endpoints - #1098
Merged
Merged
Conversation
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.
Rate limiting, audit and metrics for the osctrld endpoints
Follow-up to extensions delivery (#1096).
Problem
osctrl-tls's osctrld routes (
osctrld-flags,-cert,-verify,-script,-extensions,-extension) authenticate with the shared environment secret, and they had:Anyone who knew an environment's UUID could guess secrets without limit or trace. The secret now unlocks flags, certificates and root-run extension binaries.
What changes
Three new limits under
rateLimits, with the same fields asenroll(burst,period,evictAfter,retryAfter,maxBuckets), CLI flags (--rate-limit-osctrld-auth-*,--rate-limit-osctrld-*,--rate-limit-osctrld-download-*) and env vars. They are validated at startup.osctrldAuthosctrldosctrldDownloadRetry-Afteron that environment's osctrld routes, even with the right secret, until the budget refills.ratelimit.Limiter.Attempt), so slow parallel requests can't get extra guesses.utils.GetIPis used for limiter keys and audit. It is the TCP peer, or the right-most untrusted forwarding hop when the peer is in--trusted-proxies.trustedProxiesmust be set; otherwise every client shares the proxy's budgets.maxBucketstracked keys, new keys share one overflow budget and are blocked collectively.auditlog.FailedOsctrld).<unknown>environment, sharing one cap and one metric label.osctrld_auth_failures_total{environment}, the alert signal for secret guessing;osctrld_rate_limited_total{route,limit};osctrld_auth_audit_dropped_total{environment};CertHandler: its 403 body is now empty, previously "uh oh...".Configuration compatibility
tls.ymlwithout the new entries still loads: the defaults are filled in before the YAML is read.ConfigVersion4 → 5. This only affects the startup notice and the generated samples. Sampletls.yml/api.yml, the service-config help text and ARCHITECTURE.md are updated.Security and operational impact
trustedProxies, or all hosts share one budget.Validation
go test ./... -count=1: 57 packages pass (new tests also with-race)go vet ./...;gofmt -l pkg cmd(empty);golangci-lint run ./...: 0 issuesmake openapi-checkcleanRetry-After.X-Forwarded-Fordoesn't change the key; without trusted proxies, the TCP peer is the key.<unknown>cap;