apache / apache/shenyu

[BUG] Data-handler removeRule guards on ruleData.getHandle(), leaking cache entries when handle is null at deletion time

Open
#6,772 1 comment 0 reactions 0 assignees View on GitHub
plugin: redirect priority: medium type: bug
Dominant language
Java
Stars
8.8k
Forks
3.1k
Avg merge
7d 1h
Merged PRs (30d)
85

Description

- severity: Medium
- files: `shenyu-plugin/shenyu-plugin-redirect/.../RedirectPluginDataHandler.java:49`; `.../shenyu-plugin-rewrite/.../RewritePluginDataHandler.java:49`; `.../shenyu-plugin-param-mapping/.../ParamMappingPluginDataHandler.java:49`; `.../shenyu-plugin-modify-response/.../ModifyResponsePluginDataHandler.java:49`; `.../shenyu-plugin-context-path/.../ContextPathPluginDataHandler.java:63`
- description: Five `removeRule` implementations guard removal with `Optional.ofNullable(ruleData.getHandle()).ifPresent(...)`. If `handle` is null when the rule is deleted (deletion event carries only rule ID, or rule was previously updated to null handle), the cache entry keyed by `selectorId_ruleId` is never removed. `RequestPluginHandler.removeRule` and `GeneralContextPluginDataHandler.removeRule` correctly guard on `ruleData` itself.
- impact: Stale rule-handle objects accumulate in cache indefinitely (memory leak + potential stale config reuse).
- suggested_fix: Guard on `Optional.ofNullable(ruleData)` and always call `removeHandle`.
- confidence: Medium
- related_existing: none

---

## Low

---
_Identified during the 2026-08-02 deep re-scan; full list in [`docs/scan2-2026-08-02/06-medium-tiers.md`](docs/scan2-2026-08-02/06-medium-tiers.md)._

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the five listed removeRule implementations and compare their null handling with RequestPluginHandler.removeRule and GeneralContextPluginDataHandler.removeRule. Trace how each cache entry is keyed by selectorId_ruleId and confirm that deletion with a null handle still reaches removeHandle. Done means all five handlers remove the cache entry when ruleData exists, regardless of whether its handle is null.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
70/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.