Description
AiProxyPlugin.doExecute does DataBufferUtils.join(exchange.getRequest().getBody()) (no maxSize overload) which aggregates the entire inbound body into a single in-memory DataBuffer before the size check at line 106 runs. The 5 MB guard fires only after the full payload is already resident in heap.
Location
shenyu-plugin/shenyu-plugin-ai/shenyu-plugin-ai-proxy/src/main/java/org/apache/shenyu/plugin/ai/proxy/enhanced/AiProxyPlugin.java:103-110
Impact
A malicious/buggy client streaming a multi-GB body triggers full buffering → OutOfMemoryError before the 413 is ever produced. Trivially-achievable gateway DoS on any selector with the AI-proxy plugin enabled. (Mitigating factors: an upstream reverse proxy or Netty HttpObjectAggregator maxContentLength, if configured, could prevent this — but the plugin code itself has no defense.)
Suggested fix
Use the DataBufferUtils.join variant with a maxSize and emit 413 on DataBufferLimitException, or stream-count bytes and short-circuit before buffering.
Related existing
Distinct from AI-TOKENLIMITER-BODYWRITER-OOM (#6758, different plugin, response side).
Description
AiProxyPlugin.doExecutedoesDataBufferUtils.join(exchange.getRequest().getBody())(nomaxSizeoverload) which aggregates the entire inbound body into a single in-memoryDataBufferbefore the size check at line 106 runs. The 5 MB guard fires only after the full payload is already resident in heap.Location
shenyu-plugin/shenyu-plugin-ai/shenyu-plugin-ai-proxy/src/main/java/org/apache/shenyu/plugin/ai/proxy/enhanced/AiProxyPlugin.java:103-110Impact
A malicious/buggy client streaming a multi-GB body triggers full buffering →
OutOfMemoryErrorbefore the 413 is ever produced. Trivially-achievable gateway DoS on any selector with the AI-proxy plugin enabled. (Mitigating factors: an upstream reverse proxy or NettyHttpObjectAggregatormaxContentLength, if configured, could prevent this — but the plugin code itself has no defense.)Suggested fix
Use the
DataBufferUtils.joinvariant with amaxSizeand emit 413 onDataBufferLimitException, or stream-count bytes and short-circuit before buffering.Related existing
Distinct from AI-TOKENLIMITER-BODYWRITER-OOM (#6758, different plugin, response side).