-
Notifications
You must be signed in to change notification settings - Fork 408
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Base64 validation issue when handling binary payload sent with SENML_JSON format #1548
Comments
@vshorin very good catch, very well described ! Thx a lot for taking time to report this 🙏 This is now fixed in Waiting the workaround is to copy/paster the fixed version and configure your client/server/bsserver like : Map<ContentFormat, NodeDecoder> decoders = new HashMap<>(DefaultLwM2mDecoder.getDefaultNodeDecoders(false));
decoders.put(ContentFormat.TEXT, new LwM2mNodeTextDecoder(new DefaultLwM2mLinkParser(),
new FixedDefaultBase64Decoder(DecoderAlphabet.BASE64, DecoderPadding.REQUIRED)));
decoders.put(ContentFormat.SENML_JSON,
new LwM2mNodeSenMLDecoder(new SenMLJsonJacksonEncoderDecoder(false,
new FixedDefaultBase64Decoder(DecoderAlphabet.BASE64URL, DecoderPadding.FORBIDEN),
new DefaultBase64Encoder(EncoderAlphabet.BASE64URL, EncoderPadding.WITHOUT)), true));
decoders.put(ContentFormat.JSON,
new LwM2mNodeJsonDecoder(new LwM2mJsonJacksonEncoderDecoder(), new DefaultLwM2mLinkParser(),
new FixedDefaultBase64Decoder(DecoderAlphabet.BASE64, DecoderPadding.REQUIRED)));
builder.setDecoder(new DefaultLwM2mDecoder(decoders, DefaultLwM2mDecoder.getDefaultPathDecoder())); The fix should also be deployed on the sandbox : https://leshan.eclipseprojects.io/ (I think this bug exists since 2.0.0-M10 : ce98924#diff-d6e9393e636f661cde99688c1bbfedbd664fb43c7aefddd6a7a06eb32ff78826R158-R185) |
@cyril2maq, @JaroslawLegierski you could be interested by that ☝️ |
@sbernard31 wow, that was fast! Thanks a lot for your work! The workaround is fine for now, so I'll close. |
Version(s)
v2.0.0-M11 and up
Which components
leshan-core
Tested With
leshan-client-demo
What happened
When sending object 19 with a "send" operation from the leshan client, the server returns
[BAD_REQUEST(400)] : Invalid Payload.
if SENML_JSON is used and the Base64 version of the payload contains "w" in the end. If SENML_CBOR is used on the same operation, the server returns[CHANGED(204)].
.The server is using
org.eclipse.leshan.core.util.base64.DefaultBase64Decoder
methodvalidateIsCanonical
. There seems to be a typo here:leshan/leshan-core/src/main/java/org/eclipse/leshan/core/util/base64/DefaultBase64Decoder.java
Line 185 in fa6f7d2
and
leshan/leshan-core/src/main/java/org/eclipse/leshan/core/util/base64/DefaultBase64Decoder.java
Line 197 in fa6f7d2
where
validChar
array contains "W", but it seems that it should have contained "w" instead.How to reproduce
Relevant Output
client logs:
server logs:
The text was updated successfully, but these errors were encountered: