Lcos-000 opened a new issue, #3679:
URL: https://github.com/apache/dubbo-go/issues/3679
### Description
`RPCInvocation.ActualMethodName()`
(`protocol/invocation/rpcinvocation.go:85-91`) performs an unguarded type
assertion on the first generic-call argument:
```go
func (r *RPCInvocation) ActualMethodName() string {
if r.IsGenericInvocation() {
return r.Arguments()[0].(string) // panics if arg[0] is not a
string
} else {
return r.MethodName()
}
}
```
`IsGenericInvocation()` (`rpcinvocation.go:94-99`) only checks that
`MethodName` is `$invoke`/`$invokeAsync` and that `len(Arguments) == 3`; it
does **not** validate the element types. A malformed or malicious `$invoke`
request with a non-string first argument reaches this line and panics with
`interface conversion: interface {} is int, not string`.
### Reproduction
```go
inv := invocation.NewRPCInvocation(constant.Generic,
[]any{123, []string{}, []hessian.Object{}}, // arg[0] is int, not
string
map[string]any{constant.GenericKey: "true"})
// inv.IsGenericInvocation() == true
// inv.ActualMethodName() -> panic: interface conversion: interface {} is
int, not string
```
### Affected call sites
| Location | Side | Reachable by malformed network input? |
|---|---|---|
| `filter/otel/trace/filter.go:83` (otelServerFilter.Invoke) | server | Yes
— when the otel server filter is enabled (it is not in `DefaultServiceFilters`,
`common/constant/default.go:67`, so requires explicit opt-in). |
| `filter/otel/trace/filter.go:126` (otelClientFilter.Invoke) | client | No
— args constructed locally by the generic client filter. |
| `cluster/cluster/failover/cluster_invoker.go:64` | client | No |
| `cluster/cluster/failfast/cluster_invoker.go:49` | client | No |
| `cluster/cluster/forking/cluster_invoker.go:66` | client | No |
| `cluster/cluster/zoneaware/cluster_invoker.go:88` | client | No |
| `cluster/loadbalance/p2c/loadbalance.go:118` | client | No |
The only externally-reachable panic path is the otel **server** filter, and
only when explicitly enabled. The remaining call sites are client-side with
locally-constructed arguments.
### Environment
- dubbo-go version: `main` / `develop` @ `0c194ebf`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]