Skip to content

Conversation

@pcaversaccio
Copy link
Owner

@pcaversaccio pcaversaccio commented Nov 5, 2025

🕓 Changelog

This PR fixes incorrect padding detection in the base64 _decode function. The logic incorrectly identified / or _ (index 63) as the padding character instead of = (index 64), and checked single padding before double padding. This caused Base64 strings with / or _ in the third position (e.g. AA/A or AA_A) to be incorrectly truncated, and strings with double padding (==) to be mishandled. This patch corrects the index to 64, reorders the conditional checks to handle double padding before single padding, and adds an assertion to reject invalid padding combinations. Since the base64 contract is not used in production, this bug poses no security risk. Thanks to @Leminkay for identifying this bug!

🐶 Cute Animal Picture

Signed-off-by: Pascal Marco Caversaccio <pascal.caversaccio@hotmail.ch>
@pcaversaccio pcaversaccio self-assigned this Nov 5, 2025
@pcaversaccio pcaversaccio added bug 🐛 Something isn't working dependencies 🔁 Pull requests that update a dependency file labels Nov 5, 2025
@pcaversaccio pcaversaccio added this to the 0.1.3 milestone Nov 5, 2025
@pcaversaccio pcaversaccio changed the title 🐛 Fix base64 Double Padding Detection 🐛 Fix base64 _decode Double Padding Detection Nov 5, 2025
Signed-off-by: Pascal Marco Caversaccio <pascal.caversaccio@hotmail.ch>
Signed-off-by: Pascal Marco Caversaccio <pascal.caversaccio@hotmail.ch>
@Leminkay
Copy link

Leminkay commented Nov 6, 2025

🙂👍

Signed-off-by: Pascal Marco Caversaccio <pascal.caversaccio@hotmail.ch>
@pcaversaccio pcaversaccio added the documentation 📖 Improvements or additions to documentation label Nov 6, 2025
@pcaversaccio pcaversaccio merged commit b58155f into main Nov 6, 2025
17 of 19 checks passed
@pcaversaccio pcaversaccio deleted the fix/base64-decode branch November 6, 2025 11:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug 🐛 Something isn't working dependencies 🔁 Pull requests that update a dependency file documentation 📖 Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants