Repository navigation
Stop counting refused private addresses toward alerts - #143
Conversation
When a lookup's target resolves to a private or reserved address, safenet refuses the connection and the lookup fails with a BlockedError. That error was deliberately left out of IsExpectedError, so every refusal counted toward the throttle and spike alerts, on the reasoning that it might be someone probing for SSRF. Two things were wrong with that. The alert names a lookup and a count, never the host or the customer, so there was nothing in it to investigate; the log line written for the same failure has the host. And the trigger is a hostname the caller chooses. Names that point at private addresses are ordinary in public DNS, so a customer checking a list of subdomains would raise alerts by accident, and anyone could raise them on purpose. The encryption endpoint made it sharper, because all three of its lookups resolve the host and fail together. The refusal itself is unchanged: nothing connects, the caller gets the same error, and it is still logged at warn level with the host. It just no longer reaches the alerter. docs/decisions.md records the reversal and where the signal belongs if it is wanted back: a counter in the metrics, not the pager. Assisted-by: Claude Fable 5.2
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
What
A lookup whose target resolves to a private or reserved address is refused by
safenet(BlockedError). That error is now an expected one inIsExpectedError, so it no longer counts toward the throttle and spike alerts. This applies on every endpoint.Nothing else about the refusal changes: no connection is made, the caller gets the same error message, and the failure is still logged at warn level with the host.
Why
It was deliberately unexpected, as a possible SSRF probe worth a look. Two problems:
docs/decisions.mdrecords the reversal. If the attack signal is wanted back, a counter of blocked dials ininternal/metricsis the place for it, not the pager.In this PR
internal/domain/errors.go: one more case inIsExpectedError.TestIsExpectedError_BlockedError_Expected), two cases added to the expected table (refused before dialing, and refused at dial time inside anet.OpError), and a service-level test that an encryption lookup against such a host records no alert.docs/decisions.md,.claude/rules/lookups.md, and one internal line in the unreleased v1.3.0 changelog block.Verification
make verifypasses: gofmt, vet, golangci-lint (0 new findings), unit tests with-race, integration tests.Assisted-by: Claude Fable 5.2
Summary by CodeRabbit