| From: | Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com> |
|---|---|
| To: | Daniel Gustafsson <daniel(at)yesql(dot)se> |
| Cc: | shihao zhong <zhong950419(at)gmail(dot)com>, 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:43:34 |
| Message-ID: | CAD21AoCrbbOsi1moWY=-x-iF_YUgAXeaPVA5b_LNZQ8DkHW+Pg@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-bugs |
On Mon, Nov 9, 2026 at 2:26 PM Daniel Gustafsson <daniel(at)yesql(dot)se> wrote:
>
> > 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.
Thank you for taking care of it. I was also reviewing the patches and
was about to send LGTM.
While I agree that we don't backpatch it to v18 or older, I think it
(or at least the base64url part) should go into v19 as well. v19 is
still in RC and base64url is new in v19, so there are no existing
users relying on the current behavior, and it would be better to make
base64url and base32hex consistent before the release. IIUC the
base64url truncation fix 5f57f58179b was backpatched to v19 for the
same reason.
Regards,
--
Masahiko Sawada
Amazon Web Services: https://aws.amazon.com
| From | Date | Subject | |
|---|---|---|---|
| Next Message | shihao zhong | 2026-11-09 22:59:43 | Re: BUG #19816: PL/Python SD dictionary is split by input collation in 19rc1 |
| Previous Message | Daniel Gustafsson | 2026-11-09 22:26:49 | Re: BUG #19843: decode(..., 'base64url') returns an extra byte for "ab=" |