plugin/grpc: check proxy list length in policies#7512
Merged
Conversation
While the gRPC plugin setup requires at least one upstream, the missing proxy list length check in the policy implementation currently causes Go panics with a fuzzer. This commit adds a zero-length check as a defensive measure to affected policies. Also includes a set of unit tests, increasing the plugin test coverage from 74.5% to 79.1%. Signed-off-by: Ville Vesilehto <ville@vesilehto.fi>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #7512 +/- ##
==========================================
+ Coverage 55.70% 61.87% +6.17%
==========================================
Files 224 274 +50
Lines 10016 18165 +8149
==========================================
+ Hits 5579 11240 +5661
- Misses 3978 6262 +2284
- Partials 459 663 +204 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
yongtang
approved these changes
Sep 3, 2025
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.
1. Why is this pull request needed and what does it do?
While the gRPC plugin setup requires at least one upstream, the missing proxy list length check in the policy implementation currently causes Go panics with a fuzzer.
Details
panic: runtime error: integer divide by zerogoroutine 1 [running]:
github.com/coredns/coredns/plugin/grpc.(*roundRobin).List(0x101953708?, {0x0?, 0x140000d2180?, 0x0?})
/git/coredns/plugin/grpc/policy.go:50 +0x1f4
github.com/coredns/coredns/plugin/grpc.(*GRPC).list(...)
/git/coredns/plugin/grpc/grpc.go:159
github.com/coredns/coredns/plugin/grpc.(*GRPC).ServeDNS(0x140000b62d0, {0x101953708, 0x102045b60}, {0x101957f90, 0x140000d2180}, 0x140000b6360)
/git/coredns/plugin/grpc/grpc.go:52 +0x158
github.com/coredns/coredns/plugin/pkg/fuzz.Do({0x10194f838, 0x140000b62d0}, {0x128e38001, 0xd, 0xd})
/git/coredns/plugin/pkg/fuzz/do.go:26 +0x154
github.com/coredns/coredns/plugin/grpc.Fuzz({0x128e38000?, 0xe, 0x140001eded8?})
/git/coredns/plugin/grpc/fuzz.go:154 +0x620
go-fuzz-dep.Main({0x140001edf30, 0x1, 0x101fa58c8?})
go-fuzz-dep/main.go:36 +0x10c
main.main()
github.com/coredns/coredns/plugin/grpc/go.fuzz.main/main.go:15 +0x34
exit status 2%
This commit adds a zero-length check as a defensive measure to affected policies. Also includes a set of unit tests, increasing the plugin test coverage from 74.5% to 79.1%.
2. Which issues (if any) are related?
None.
3. Which documentation changes (if any) need to be made?
None. No user facing changes.
4. Does this introduce a backward incompatible change or deprecation?
No, internal improvement.