| From: | Daniel Gustafsson <daniel(at)yesql(dot)se> |
|---|---|
| To: | shihao zhong <zhong950419(at)gmail(dot)com> |
| Cc: | imchifan(at)163(dot)com, pgsql-bugs(at)lists(dot)postgresql(dot)org |
| Subject: | Re: BUG #19702: decode() accepts Base64 payload after terminal padding |
| Date: | 2026-11-09 22:26:11 |
| Message-ID: | D2D816AD-6B36-4EA4-B5EF-0077A999C7AD@yesql.se |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-bugs |
> On 19 Sep 2026, at 16:59, shihao zhong <zhong950419(at)gmail(dot)com> wrote:
>
> Hi Qifan,
>
> Thanks for reporting that issue.
>
> I can reproduce this on master. The decoder sets "end" at the first "="
> and never looks at it again, so later data and later "=" all pass
Sorry for missing this at the time of it being reported.
> 0001 raises an error for anything but whitespace after the padding, the
> same rule base32hex already has. 0002 adds tests. 0003 fixes the two
> copies of this code, pg_b64_decode() in src/common and the armor decoder
> in pgcrypto. dearmor() shows the same bug when the CRC matches.
I had to stare the code for some time to convince myself there were no more
bugs hiding in pgcrypto for this wrt RFC9580, but I think it's correct.
> This rejects input that used to pass, so I am not sure about the back
> branches. I would leave that to the committer.
Thanks for the patches, the attached is a rebased squash of the three patches
since I would prefer to apply them all at once. Given the lack of complaints I
will err on the side of caution and keep this in master only. At least for now.
--
Daniel Gustafsson
| Attachment | Content-Type | Size |
|---|---|---|
| 0001-Reject-invalid-base64-encoded-values-with-data-after.patch | application/octet-stream | 7.0 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Daniel Gustafsson | 2026-11-09 22:26:49 | Re: BUG #19843: decode(..., 'base64url') returns an extra byte for "ab=" |
| Previous Message | Marcos Castedo | 2026-11-09 20:04:55 | Re: BUG #19816: PL/Python SD dictionary is split by input collation in 19rc1 |