[php-src] Issue #20187: base64_decode: reject inputs with non-base64 characters (fail safely)
| From: | touchweb-vincent | Date: | Thu, 16 Oct 2025 09:17:42 +0000 |
| Subject: | [php-src] Issue #20187: base64_decode: reject inputs with non-base64 characters (fail safely) | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-251071@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/20187
Author: touchweb-vincent
### Description
Hello,
I’m fully aware that I’m raising an issue that isn’t directly caused by PHP itself. However,
since we haven’t been able to find any viable technical solution that doesn’t either introduce
or worsen a chain of erratic side effects - some minor, some not - I would truly appreciate it if
you could give this matter some attention.
base64_decode currently accepts inputs containing characters outside the Base64 alphabet, which can
trigger erratic behavior in downstream systems.
<?php echo
base64_decode('P~.F$.~N~~Dc~.mlwd~Ao.+~IG~$FsZ.XJ0.K.D$c5Nik8L1$N$~D$cmlwdD.4~7$$');
It would be highly appreciated if this could fail loudly - ideally with a fatal error or exception -
when the input is not strictly valid.
This behavior causes issues for security infrastructures and DevSecOps teams, as many systems
downstream of PHP (WAFs, proxies, forensic tools) rely on strict decoding logic - unexpected input
can cause failures, inconsistent behavior, or even crashes.
https://github.com/owasp-modsecurity/ModSecurity/issues/3327
Thanks you
Vincent