[BUG] Response cryptor returns plaintext when the configured field is missing
- Dominant language
- Java
- Stars
- 8.8k
- Forks
- 3.1k
- Avg merge
- 7d 1h
- Merged PRs (30d)
- 85
Description
### Current Behavior
The response cryptor plugin returns the original response body unchanged when the configured field path is missing.
For field mapping, `MapTypeEnum.FIELD.convert()` returns `null` when the configured field cannot be parsed from the response body:
```java
String parseBody = JsonUtil.parser(originalBody, ruleHandle.getFieldNames());
if (Objects.isNull(parseBody)) {
return null;
}
```
`AbstractCryptorPlugin.convert()` treats `null` as a field-parse error and delegates to `fieldErrorParse(...)`. For response cryptor, `CryptorResponsePlugin.fieldErrorParse()` returns `originalBody` unchanged.
### Expected Behavior
When response encryption/decryption is configured but the target field cannot be found, the plugin should fail closed or return a clear cryptor configuration error instead of silently returning the unmodified body.
### Impact
If an upstream response shape changes or a configured field path is wrong, response cryptor can silently bypass the configured response transformation and send plaintext/unencrypted data downstream.
### Code Location
- `shenyu-plugin/shenyu-plugin-security/shenyu-plugin-cryptor/src/main/java/org/apache/shenyu/plugin/cryptor/strategy/MapTypeEnum.java`
- `shenyu-plugin/shenyu-plugin-security/shenyu-plugin-cryptor/src/main/java/org/apache/shenyu/plugin/cryptor/plugin/AbstractCryptorPlugin.java`
- `shenyu-plugin/shenyu-plugin-security/shenyu-plugin-cryptor/src/main/java/org/apache/shenyu/plugin/cryptor/plugin/CryptorResponsePlugin.java`
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with MapTypeEnum.java and trace the null result through AbstractCryptorPlugin.java into CryptorResponsePlugin.java. Reproduce the missing-field case and inspect existing cryptor error handling before choosing the expected failure behavior. Done means a missing configured field cannot return the original response body and is covered by a regression test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api, security
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 58/100