CyberChef icon indicating copy to clipboard operation
CyberChef copied to clipboard

Bug report: Unpadded Base32 Decode Fails

Open quentin-k opened this issue 1 year ago • 1 comments

Describe the bug When decoding unpadded base32, if the base32 decode alphabet does not have a padding character decoding will return a "Data is not a valid byteArray" error.

To Reproduce

https://gchq.github.io/CyberChef/#recipe=To_Base32('0-9A-V')From_Base32('0-9A-V',true)&input=MQ

Expected behaviour Decode output will contain 1

Desktop (if relevant, please complete the following information):

  • Version: 10.19.4
  • Compile time: 16/07/2025 07:23:08 UTC
  • User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:140.0) Gecko/20100101 Firefox/140.0
  • Link to reproduce

Additional context Decoding works if an = is appended to the decode alphabet, it doesn't seem to work for other characters on an unpadded base32 output.

quentin-k avatar Jul 20 '25 18:07 quentin-k

The implementation for base32 decode hard-codes the padding character as a fallback if there are no more characters in the input.

This is not consistent with the base64 implementation which makes padding optional and has a toggle for strict mode which will strictly enforce padding or a correct length input that requires no padding.

This is closer to a feature request for a strict mode toggle for base32 decoding. Currently, it is in strict mode exclusively.

irebased avatar Jul 29 '25 04:07 irebased