yyqdbngt opened a new pull request, #2898:
URL: https://github.com/apache/rocketmq-dashboard/pull/2898

   ## Summary
   
   The AI tool execution path is user-controlled and matched by prefix + suffix 
in the auth interceptor (`ToolAccessPolicy`), but the tool-name slice between 
them was not defensively bounded:
   
   - `POST /api/ai/tools/execute` (blank tool name) made `substring(start, 
end)` run past its start → raw `StringIndexOutOfBoundsException` 500.
   - A malformed percent-encoding (`%2z`) or invalid UTF-8 (`%FF`) made 
`URLDecoder.decode` throw `IllegalArgumentException` → raw 500 from the 
interceptor.
   
   Both bypassed the intended fail-closed semantics. Unresolvable tool names 
are now treated as unknown, so readers still require admin (403) instead of 
hitting a 500.
   
   ## Why
   
   Tool names come from AI agents, MCP clients and hand-typed URLs alike. The 
interceptor runs on every POST under `/api/ai/tools/*/execute`, so one mistyped 
name turns a clean 404/403 into an opaque 500 and a stack trace.
   
   ## Testing
   
   New `ToolAccessPolicyTest` (10 tests) covering: path recognition, blank tool 
name, percent-decoding, malformed percent sequence, invalid UTF-8, deny list, 
unknown tool, and admin/reader authorization.
   
   ```
   mvn -q -Dtest=ToolAccessPolicyTest test
   Tests run: 10, Failures: 0, Errors: 0, Skipped: 0
   ```
   


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