leaveWhite9088 opened a new issue, #11544:
URL: https://github.com/apache/rocketmq/issues/11544

   ### Before Creating the Bug Report
   
   - [x] I found a bug, not just asking a question, which should be created in 
[GitHub Discussions](https://github.com/apache/rocketmq/discussions).
   - [x] I have searched the [GitHub 
Issues](https://github.com/apache/rocketmq/issues) and [GitHub 
Discussions](https://github.com/apache/rocketmq/discussions) of this repository 
and believe that this is not a duplicate.
   - [x] I have confirmed that this bug belongs to the current repository, not 
other repositories of RocketMQ.
   
   ### Runtime platform environment
   
   OS: Windows 11 (platform-independent logic bug in `rocketmq-auth`)
   
   ### RocketMQ version
   
   - branch: `develop`
   - version: `5.5.1`
   - Git commit id: `28960fd2f`
   
   ### JDK Version
   
   Eclipse Temurin JDK 11.0.33
   
   ### Describe the Bug
   
   `Environment#isMatch(Environment environment)` in 
`auth/src/main/java/org/apache/rocketmq/auth/authorization/model/Environment.java`
 does not check whether the incoming `environment` argument is `null` before 
calling `environment.getSourceIps()`.
   
   This is triggered in `AclAuthorizationHandler#matchPolicyEntries`:
   
   ```java
   .filter(entry -> 
entry.isMatchEnvironment(Environment.of(context.getSourceIp())))
   ```
   
   When an ACL `PolicyEntry` has a non-empty source IP constraint 
(`this.sourceIps` is non-empty) and `context.getSourceIp()` is `null` or empty 
(for example, when a Netty channel is disconnected/has no remote address so 
`RemotingHelper.parseChannelRemoteAddr` returns `""`, or when a non-TCP gRPC 
transport omits `GrpcConstants.REMOTE_ADDRESS` metadata), 
`Environment.of(context.getSourceIp())` returns `null`, causing 
`Environment#isMatch(null)` to throw `NullPointerException` instead of 
returning `false`.
   
   ### Steps to Reproduce
   
   1. Create an ACL `PolicyEntry` with a source IP restriction (e.g., 
`Environment.of("192.168.1.0/24")`).
   2. Evaluate authorization via `AclAuthorizationHandler#handle` with a 
`DefaultAuthorizationContext` whose `sourceIp` is `null` or `""`.
   
   ### What Did You Expect to See?
   
   `Environment#isMatch(null)` returns `false`, and `AclAuthorizationHandler` 
rejects the request with `AuthorizationException` (`no matched policies.`).
   
   ### What Did You See Instead?
   
   `Environment#isMatch(null)` throws `NullPointerException`.
   


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