Re: jsonb, unicode escapes and escaped backslashes

From: Peter Geoghegan <pg(at)heroku(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Andrew Dunstan <andrew(at)dunslane(dot)net>, Noah Misch <noah(at)leadboat(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: jsonb, unicode escapes and escaped backslashes
Date: 2015-01-30 05:37:15
Message-ID: CAM3SWZSyHSpxBQvupYNnOO6CAqZWpONA6v4JNvL1hQWY2P9a0A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Jan 28, 2015 at 9:36 AM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Anyway, there is a significant amount of work involved here, and there's
> no way we're getting it done for 9.4.1, or probably 9.4.anything. I think
> our only realistic choice right now is to throw error for \u0000 so that
> we can preserve our options for doing something useful with it later.

+1

I looked into it, and it turns out that MongoDB does not accept NUL in
at least some contexts (for object keys). Apparently it wasn't always
so. MongoDB previously had a security issue that was fixed by
introducing this restriction. Their JSON-centric equivalent of
per-column privileges was for a time compromised, because "NUL
injection" was possible:

https://www.idontplaydarts.com/2011/02/mongodb-null-byte-injection-attacks/

It's easy to bash MongoDB, but this is still an interesting data
point. They changed this after the fact, and yet I can find no
evidence of any grumbling about it from end users. No one really
noticed.

I agree that the restriction on NUL is consistent with the design of
JSONB. Disallowing all bytes invalid in the current encoding with the
sole exception of NUL was a mistake, IMV.
--
Peter Geoghegan

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2015-01-30 06:04:06 Re: jsonb, unicode escapes and escaped backslashes
Previous Message Matt Kelly 2015-01-30 05:27:01 Re: Exposing the stats snapshot timestamp to SQL