Aias00 opened a new issue, #6876:
URL: https://github.com/apache/shenyu/issues/6876

   ## Description
   Each plugin's `doExecute` calls `CACHED_HANDLE.get().obtainHandle(key)` and 
immediately dereferences the result without a null check. 
`CommonHandleCache.obtainHandle(key)` returns `cached.get(key)` which is `null` 
on cache miss. The cache miss occurs when a rule is created with a null/empty 
`handle` field — every data handler guards the cache write with 
`Optional.ofNullable(ruleData.getHandle()).ifPresent(...)`, so a rule with no 
handle JSON is never cached but CAN still be matched by 
`AbstractShenyuPlugin.execute` (matching is condition-based, not handle-based).
   
   ## Location
   - 
`shenyu-plugin/shenyu-plugin-fault-tolerance/shenyu-plugin-hystrix/src/main/java/org/apache/shenyu/plugin/hystrix/HystrixPlugin.java:59-60`
   - 
`shenyu-plugin/shenyu-plugin-fault-tolerance/shenyu-plugin-resilience4j/src/main/java/org/apache/shenyu/plugin/resilience4j/Resilience4JPlugin.java:66-67`
   - 
`shenyu-plugin/shenyu-plugin-fault-tolerance/shenyu-plugin-sentinel/src/main/java/org/apache/shenyu/plugin/sentinel/SentinelPlugin.java:59-60`
   - 
`shenyu-plugin/shenyu-plugin-fault-tolerance/shenyu-plugin-ratelimiter/src/main/java/org/apache/shenyu/plugin/ratelimiter/RateLimiterPlugin.java:72-74`
   - 
`shenyu-plugin/shenyu-plugin-base/src/main/java/org/apache/shenyu/plugin/base/cache/CommonHandleCache.java:42-44`
   
   ## Impact
   Every request matching a rule that was created without a handle (or whose 
handle was cleared) receives an unhandled `NullPointerException` / 500. A 
single misconfigured rule takes down all traffic matching it.
   
   ## Suggested fix
   Add a null guard at the top of each `doExecute`, e.g. `if 
(Objects.isNull(handle)) { return chain.execute(exchange); }`, mirroring the 
guard added in `ContextPathPlugin` and `MockPlugin` (line 52-54).
   
   ## Related existing
   Distinct from #6657 (GeneralContextPlugin NPE) — that issue was filed only 
for `GeneralContextPlugin.java:54`. These are four separate plugins with 
separate caches and separate `doExecute` implementations, all of which lack the 
guard that #6657 added for `GeneralContextPlugin` only.
   


-- 
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]

Reply via email to