Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(PermissionEvaluationUtils): MQTT topic resource does not allow all possible characters #51

Open
jbutler opened this issue Aug 31, 2021 · 0 comments
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@jbutler
Copy link
Contributor

jbutler commented Aug 31, 2021

Describe the bug

private static final String SERVICE_RESOURCE_NAME_PATTERN_STRING = "([\\w -\\/:-@\\[-\\`{-~]+)";

The regular expression used to validate MQTT resource strings is too restrictive and does not allow all characters allowed by the MQTT spec.

To Reproduce
One possible way to reproduce is to publish to an MQTT topic containing single quotes (from a client device). I'm sure there are other characters that should be allowed as well. E.g. 'clients/Demodev2/sensor'

Expected behavior
The requested topic resource should be allowed and be evaluated against an appropriate device group policy.

Actual behavior
An IllegalArgumentException is thrown.

[ERROR] (nioEventLoopGroup-5-2) io.moquette.broker.NewNettyMQTTHandler: Error processing protocol message: PUBLISH. {} java.lang.IllegalArgumentException: Resource mqtt:topic:'clients/Demodev2/sensor' is not in the form of ([a-zA-Z]+):([a-zA-Z]+):([\w -\/:-@\[-\{-~]+)`

Environment

  • OS: N/A
  • JDK version: JDK 8
  • Nucleus version: N/A
  • Client Device Auth version: 2.0.2

Additional context
This bug prevents client devices from publishing/subscribing on certain MQTT topics and topicfilters which are allowable by the MQTT spec.

@jbutler jbutler added bug Something isn't working good first issue Good for newcomers labels Aug 31, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant