Skip to content

plugin/grpc: check proxy list length in policies#7512

Merged
yongtang merged 1 commit into
coredns:masterfrom
thevilledev:fix/grpc-policy-panic
Sep 3, 2025
Merged

plugin/grpc: check proxy list length in policies#7512
yongtang merged 1 commit into
coredns:masterfrom
thevilledev:fix/grpc-policy-panic

Conversation

@thevilledev

@thevilledev thevilledev commented Sep 3, 2025

Copy link
Copy Markdown
Collaborator

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 zero

goroutine 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.

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

codecov Bot commented Sep 3, 2025

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 61.87%. Comparing base (93c57b6) to head (d5c4607).
⚠️ Report is 1612 commits behind head on master.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@yongtang yongtang merged commit 066e516 into coredns:master Sep 3, 2025
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants