-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Fix: Allow non-padded base64 data to be decoded by decode_base64_field #27311
Conversation
💚 CLA has been signed |
5b82d72
to
0f25a96
Compare
💔 Build Failed
Expand to view the summary
Build stats
Test stats 🧪
Trends 🧪Steps errors
Expand to view the steps failures
|
Test | Results |
---|---|
Failed | 0 |
Passed | 52574 |
Skipped | 5133 |
Total | 57707 |
The CLA has been signed now. |
This pull request is now in conflicts. Could you fix it? 🙏
|
Sure, I can fix the PR easily if somebody from the team could indicate if this is an accepted fix. |
/test |
Pinging @elastic/agent (Team:Agent) |
Hey @michaelarnauts, thanks for your contribution! I think the fix looks good, but not sure about the implications of decoding unpadded base64 data (if any), maybe @adriansr or @kvch can review or give their opinions? Thanks! |
I've moved the changelog entry from Breaking Changes to Added as I don't think anyone could have been taking advantage of the fact that this processor failed for non-padded strings. Also the documentation didn't make any claims regarding padding. For the same reason it's also not a bug fix. |
/test |
Sorry, I didn't mean to put it in a breaking change. Not sure if it should be called a feature though, especially since the docs didn't indicate that the base64 strings should be padded. I assumed it would support all variants. I don't know what the policy of backporting to a point release is, and if that depends if it's a bug or a feature :) |
I would consider it a feature. With this change, Beats can process non-padded base64 data. 🎉 |
Failing tests are unrelated. |
@michaelarnauts Thank you! |
…7311) ## What does this PR do? This change allows the decoding of any raw base64 input strings that were previously encoded without standard padding character (`=`). By stripping the padding, we can use `base64.RawStdEncoding.DecodeString` to decode the base64 string. This is easier than appending the padding characters. Another attempt to fix this has been made in #25817, but that PR has been closed. ## Why is it important? When attempting to decode the payload (middle) section of a JWT token, it was discovered that the decode was failing, because padding characters are not included in a JWT token string. Padding is not required in base64, so it makes sense to allow to decode both unpadded and padded strings. Currently, there is a workaround for some beats by appending the `=`-signs in a javascript processor, but that isn't available in all beats and is an ugly workaround anyway. See https://medium.com/@guyromb/decode-jwt-traefik-access-logs-using-filebeat-95d935eb7c4f Co-authored-by: Adrian Serrano <adrisr83@gmail.com> (cherry picked from commit 9c4f7f9)
…7311) (#27554) ## What does this PR do? This change allows the decoding of any raw base64 input strings that were previously encoded without standard padding character (`=`). By stripping the padding, we can use `base64.RawStdEncoding.DecodeString` to decode the base64 string. This is easier than appending the padding characters. Another attempt to fix this has been made in #25817, but that PR has been closed. ## Why is it important? When attempting to decode the payload (middle) section of a JWT token, it was discovered that the decode was failing, because padding characters are not included in a JWT token string. Padding is not required in base64, so it makes sense to allow to decode both unpadded and padded strings. Currently, there is a workaround for some beats by appending the `=`-signs in a javascript processor, but that isn't available in all beats and is an ugly workaround anyway. See https://medium.com/@guyromb/decode-jwt-traefik-access-logs-using-filebeat-95d935eb7c4f Co-authored-by: Adrian Serrano <adrisr83@gmail.com> (cherry picked from commit 9c4f7f9) Co-authored-by: Michaël Arnauts <michael.arnauts@gmail.com>
…astic#27311) ## What does this PR do? This change allows the decoding of any raw base64 input strings that were previously encoded without standard padding character (`=`). By stripping the padding, we can use `base64.RawStdEncoding.DecodeString` to decode the base64 string. This is easier than appending the padding characters. Another attempt to fix this has been made in elastic#25817, but that PR has been closed. ## Why is it important? When attempting to decode the payload (middle) section of a JWT token, it was discovered that the decode was failing, because padding characters are not included in a JWT token string. Padding is not required in base64, so it makes sense to allow to decode both unpadded and padded strings. Currently, there is a workaround for some beats by appending the `=`-signs in a javascript processor, but that isn't available in all beats and is an ugly workaround anyway. See https://medium.com/@guyromb/decode-jwt-traefik-access-logs-using-filebeat-95d935eb7c4f Co-authored-by: Adrian Serrano <adrisr83@gmail.com>
What does this PR do?
This change allows decoding of any raw base64 input strings that were previously encoded without standard padding character (
=
).By stripping the padding, we can use
base64.RawStdEncoding.DecodeString
to decode the base64 string. This is easier then appending the padding characters.Another attempt to fix this has been made in #25817, but that PR has been closed.
Why is it important?
When attempting to decode the payload (middle) section of a JWT token, it was discovered that the decode was failing, because padding characters are not included in a JWT token string. Padding is not required in base64, so it makes sense to allow to decode both unpadded and padded strings.
Currently, there is a workaround for some beats by appending the
=
-signs in a javascript processor, but that isn't available in all beats, and is a ugly workaround anyway. See https://medium.com/@guyromb/decode-jwt-traefik-access-logs-using-filebeat-95d935eb7c4fChecklist
CHANGELOG.next.asciidoc
orCHANGELOG-developer.next.asciidoc
.Author's Checklist
How to test this PR locally
Tests have been added that will test this behavior.
Related issues
Use cases
Screenshots
Logs