pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
SELECT of pseudo hex value gives unexpected result
4+ messages / 3 participants
[nested] [flat]

* SELECT of pseudo hex value gives unexpected result
@ 2019-01-29 16:18  Gunnar "Nick" Bluth <gunnar.bluth@pro-open.de>
  0 siblings, 2 replies; 4+ messages in thread

From: Gunnar \"Nick\" Bluth @ 2019-01-29 16:18 UTC (permalink / raw)
  To: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>

Hi,

I found this in an SQL-injection attempt today:
union select 0x5e73266725,0x5e73266725[,...],0x5e73266725;

Tried
SELECT 0x5e73266725;

and received:
-[ RECORD 1 ]--
x5e73266725 | 0

That was not what I expected... is this expected/documented behaviour?

Thx in advance!
-- 
Gunnar "Nick" Bluth
RHCE/SCLA

Mobil   +49 172 8853339
Email: gunnar.bluth@pro-open.de
__________________________________________________________________________
In 1984 mainstream users were choosing VMS over UNIX.  Ten years later
they are choosing Windows over UNIX.  What part of that message aren't you
getting? - Tom Payne

Attachments:

  signature.asc (application/pgp-signature, 487B) download

^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: SELECT of pseudo hex value gives unexpected result
@ 2019-01-29 16:39  Tom Lane <tgl@sss.pgh.pa.us>
  parent: Gunnar "Nick" Bluth <gunnar.bluth@pro-open.de>
  1 sibling, 1 reply; 4+ messages in thread

From: Tom Lane @ 2019-01-29 16:39 UTC (permalink / raw)
  To: Gunnar \"Nick\" Bluth <gunnar.bluth@pro-open.de>; +Cc: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>

"Gunnar \"Nick\" Bluth" <gunnar.bluth@pro-open.de> writes:
> Tried
> SELECT 0x5e73266725;

> and received:
> -[ RECORD 1 ]--
> x5e73266725 | 0

> That was not what I expected... is this expected/documented behaviour?

Well, there are no hex literals in (PG's notion of) SQL, so that isn't
a valid token.  But it's the concatenation of two valid tokens.  So
what you wrote is the same as

SELECT 0 x5e73266725;

which is an abbreviation for

SELECT 0 AS x5e73266725;

and that's the result you got.

I think that the SQL standard considers adjacent tokens to be invalid
unless one of them is punctuation (e.g. 1+2), but our lexer is a bit
less rigid about that.

			regards, tom lane




^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: SELECT of pseudo hex value gives unexpected result
@ 2019-01-29 16:41  Laurenz Albe <laurenz.albe@cybertec.at>
  parent: Gunnar "Nick" Bluth <gunnar.bluth@pro-open.de>
  1 sibling, 0 replies; 4+ messages in thread

From: Laurenz Albe @ 2019-01-29 16:41 UTC (permalink / raw)
  To: Gunnar \"Nick\" Bluth <gunnar.bluth@pro-open.de>; pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>

Gunnar "Nick" Bluth wrote:
> Tried
> SELECT 0x5e73266725;
> 
> and received:
> -[ RECORD 1 ]--
> x5e73266725 | 0
> 
> That was not what I expected... is this expected/documented behaviour?

Looks like you don't need a space between a number literal and
the column alias.

I don't see any problem with that.

Yours,
Laurenz Albe
-- 
Cybertec | https://www.cybertec-postgresql.com





^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: SELECT of pseudo hex value gives unexpected result
@ 2019-01-29 16:55  Gunnar "Nick" Bluth <gunnar.bluth@pro-open.de>
  parent: Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 4+ messages in thread

From: Gunnar \"Nick\" Bluth @ 2019-01-29 16:55 UTC (permalink / raw)
  To: pgsql-general@lists.postgresql.org

Am 29.01.2019 um 17:39 schrieb Tom Lane:
> "Gunnar \"Nick\" Bluth" <gunnar.bluth@pro-open.de> writes:
>> Tried
>> SELECT 0x5e73266725;

[...]

> SELECT 0 AS x5e73266725;
> 
> and that's the result you got.

Well, yeah, _that_ was pretty obvious. I just didn't expect ot to happen...

> I think that the SQL standard considers adjacent tokens to be invalid
> unless one of them is punctuation (e.g. 1+2), but our lexer is a bit
> less rigid about that.

it kind of comforts me that it's at least not defined like that in the
standard ;-)

Cheers anyway!
-- 
Gunnar "Nick" Bluth
RHCE/SCLA

Mobil   +49 172 8853339
Email: gunnar.bluth@pro-open.de
__________________________________________________________________________
In 1984 mainstream users were choosing VMS over UNIX.  Ten years later
they are choosing Windows over UNIX.  What part of that message aren't you
getting? - Tom Payne

Attachments:

  signature.asc (application/pgp-signature, 487B) download

^ permalink  raw  reply  [nested|flat] 4+ messages in thread


end of thread, other threads:[~2019-01-29 16:55 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2019-01-29 16:18 SELECT of pseudo hex value gives unexpected result Gunnar "Nick" Bluth <gunnar.bluth@pro-open.de>
2019-01-29 16:39 ` Tom Lane <tgl@sss.pgh.pa.us>
2019-01-29 16:55   ` Gunnar "Nick" Bluth <gunnar.bluth@pro-open.de>
2019-01-29 16:41 ` Laurenz Albe <laurenz.albe@cybertec.at>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox