Skip to content

[BUG] Cryptor JsonUtil.parser throws NPE/CCE on JSON-array or non-object bodies and missing nested-field segments — 500s on valid and pre-auth traffic #6879

Closed

Description

@Aias00

Description

Both removeRule implementations gate the cache eviction behind Optional.ofNullable(ruleData.getHandle()).ifPresent(s -> CACHED_HANDLE.get().removeHandle(...)). If the rule-deletion event carries only the rule id (handle == null), ifPresent never fires and the cached SignRuleHandler / CryptorRuleHandler keyed by selectorId_ruleId is never evicted. Contrast JwtPluginDataHandler.removeRule:56-58, KeyAuthPluginDataHandler.removeRule:45-47, and BasicAuthPluginDataHandler.removeRule:55-57, which all call removeHandle unconditionally.

Location

  • shenyu-plugin/shenyu-plugin-security/shenyu-plugin-sign/src/main/java/org/apache/shenyu/plugin/sign/handler/SignPluginDataHandler.java:47-49
  • shenyu-plugin/shenyu-plugin-security/shenyu-plugin-cryptor/src/main/java/org/apache/shenyu/plugin/cryptor/handler/AbstractCryptorPluginDataHandler.java:60-62

Impact

Stale rule-handle objects accumulate in the CommonHandleCache indefinitely (memory leak). For cryptor, a stale CryptorRuleHandler (containing decryptKey/encryptKey/strategyName/fieldNames/way) persists; for sign, a stale SignRuleHandler (the signRequestBody flag) persists.

Suggested fix

Drop the getHandle() guard and call CACHED_HANDLE.get().removeHandle(CacheKeyUtils.INST.getKey(ruleData)) unconditionally (as JWT/key-auth/basic-auth already do), guarding only on ruleData itself.

Related existing

None — distinct from NEW-06 (#6772, removeRule handle guard), which lists redirect/rewrite/param-mapping/modify-response/context-path. The sign and cryptor data handlers are the same bug class but were omitted from NEW-06's file list; they are separate plugins with separate cached handle types.

Activity

  1. added
    type: bug
    priority: medium
    on Aug 4, 2026
  2. github-actions commented on Aug 4, 2026

    @github-actions
    Contributor

    👋 Hello @yuluo-yx

    A new issue has been opened by @Aias00:

    Please review when you have time. Thank you! 🙏

  3. zhang-arvin commented on Aug 30, 2026

    @zhang-arvin
    Contributor

    I will work on this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    plugin: cryptorpriority: mediumtype: bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions