Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1xBApW-000000032uk-1I1z for pgsql-docs@arkaria.postgresql.org; Mon, 28 Sep 2026 12:51:38 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.98.2) (envelope-from ) id 1xBApU-00000009LVR-2y59 for pgsql-docs@arkaria.postgresql.org; Mon, 28 Sep 2026 12:51:36 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1xBApU-00000009LV3-1mxT for pgsql-docs@lists.postgresql.org; Mon, 28 Sep 2026 12:51:36 +0000 Received: from mail-ed2-x01.google.com ([2a00:1450:4864:33::1]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1xBApP-00000001jav-3ioW for pgsql-docs@lists.postgresql.org; Mon, 28 Sep 2026 12:51:36 +0000 Received: by mail-ed2-x01.google.com with SMTP id 4fb4d7f45d1cf-6a5d2b3fbe8so1349061a12.0 for ; Mon, 28 Sep 2026 05:51:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec.at; s=google; t=1790599891; x=1791204691; darn=lists.postgresql.org; h=mime-version:user-agent:content-transfer-encoding:content-type :references:in-reply-to:date:to:from:subject:message-id:from:to:cc :subject:date:message-id:reply-to:content-type; bh=cGS3NZbqA4e129T3pb/8JpcvKpNgb2E89GDlWVbPCEg=; b=CW3DdEua/arwAy+PttI2E/iJ7q7Jno9Mg/YAS2A/9BP1fc9ILPfgpfPqE4CbVZvQxv kM3r13QOc4K6smrActxHGVLz2MkaGHEtvLG68eXhpYqirMpnq4xshrCK3To9uoN93Cb3 CAZnH7oSwClPtw6K9U8mZ7t5xfss4dnaxko+DQtMvruXZpNFsKZANsH2PjdtD7c2XHsj TDOM7LmKwYhDTUvmn0rERoAKY8JMA6G9oD1Qdrr+mIMKQEHDc72YUdSbPg/4xkxvTzY5 vWbxShWoT2CZ0dmbeiM3SQ7xhyy0BXIcKXOP3bbpQXND6SeSnd6bt6rJvplJCNkwQerD EE0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790599891; x=1791204691; h=mime-version:user-agent:content-transfer-encoding:content-type :references:in-reply-to:date:to:from:subject:message-id:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=cGS3NZbqA4e129T3pb/8JpcvKpNgb2E89GDlWVbPCEg=; b=dGMIJ5Sjyo4TXkmYh1WLkYZ2aRYt0ZjlpOVFJ0eLH7BF1k1sz+E03B5HAyOPDdX0p/ +mbptCjQ6XGUC4EZPhpB9C9Jc9RuLQgNN5FcOs/00zQ4ZGjpUZtNCeRlNmJ0amIpboWH DwLuXNmsTamwUx/YtEXZCrW45jYu3KiESABCbRrKnEFf7/MwRaw3wJxzXLqPyBRYVFKi P4XCMm/RthGtBrdD9pX7R8Kf3GvI2mA0An8AYY9SEey29uBoPfU8gM4npjGpozn0eJUQ a4zb6aeEJ7wWP19SEg9OpyqhvGUGx16hqroj+aSHNrZiPkplVPsGS7kAg92PZ8MP4Ze+ qZaA== X-Forwarded-Encrypted: i=1; AKwUvBzFP8q2AwxQyCOBD95cAqHSmkdY9Od0BcDDleauB/8ZcPrMmCHePc/VUsITZ4dWf254qwnMw2m0Bd0Q@lists.postgresql.org X-Gm-Message-State: AFq9FYKLssBX5DjBlznnHXpXe8KjtzoY+BiVJyjzSfnOZbqbqUBo4zA7 WpPpWgTSdEguU3xZQgdvJgIjmVLeb/J+O5z/6U/DC/Ve8d16zRQ6Bb/tf+YGr18eYm0= X-Gm-Gg: AYBFou1tSF6Kb+k765Yui8iNtfW82meFw8i9/CY5AIFCCPyqtr46iBK/Rvh1nSdSlVv gDgpsn/d78H66X91ummFZsehy0LzVJc0slJW6mORhSyJ9kV9gXNHcyRUBZBZPefJgIrGjwDA3mp b6H2fB7hyqbmn9n4BqfXbHSFoEAyHHzM1GuOGc1ZsSE/IDQUZlfYMv70EJaWHygo+0ogUFXQZM7 KD2AheDTjjlNvMgfBnMzCn5zLr4qNocHvW2WOV98Rkwg7B6cx+jjdelVE9ckRvHPdg0XkJ3ixee qIEFjec5a1JeJoFNMVM5eC9i4dGSW/JMi/abxSwjXzKQJdUSP00MmrtR0BBIywPtbedVH+C+wKN +G+5hEsU9Gz/sIRVfAXZGUpaEe4amx8q3oZr02mNlLPkSvxY8sg2O4k83QDjbRgMpk//ZFHEj5c OC0D31PW+YonYEJtjWZO28wSDUBcjdcroZGM/htMsnqqcNust8T6rjaKZf2MTEqE7r7XlruBYcL aRJuJxxtFX+yTKOyTgBuEOs7oI= X-Received: by 2002:a05:6402:3059:b0:6a3:fdb0:c374 with SMTP id 4fb4d7f45d1cf-6aac8eed8e5mr8028705a12.13.1790599890962; Mon, 28 Sep 2026 05:51:30 -0700 (PDT) Received: from laurenz.albe-K4N0CV00F97414D ([2001:871:70:6ccf:866:7e79:2906:e18a]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-6aae600684esm4426940a12.30.2026.09.28.05.51.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Sep 2026 05:51:30 -0700 (PDT) Message-ID: Subject: Re: Possible command-injection or meta-command execution in `psql` input From: Laurenz Albe To: y.saburov@gmail.com, pgsql-docs@lists.postgresql.org Date: Mon, 28 Sep 2026 14:51:30 +0200 In-Reply-To: <179041123000.1026192.10336293169834979882@wrigleys.postgresql.org> References: <179041123000.1026192.10336293169834979882@wrigleys.postgresql.org> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.60.2 (3.60.2-2.fc44) MIME-Version: 1.0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Sat, 2026-09-26 at 08:27 +0000, PG Doc comments form wrote: > AI generated )) Then please validate the generated stuff rather than creating extra work. > The following SQL statement contains an unquoted regular-expression-like > expression: >=20 > db=3D# WITH products (id, name, price, action) AS > ( > VALUES > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (1, 'apple',=C2=A0 100, '...') > =C2=A0=C2=A0=C2=A0=C2=A0 , (2, 'banana', 200, '...') > =C2=A0=C2=A0=C2=A0=C2=A0 , (3, 'orange', 150, '...') > =C2=A0=C2=A0=C2=A0=C2=A0 , (4, 'potato',=C2=A0 80, '...') > =C2=A0=C2=A0=C2=A0=C2=A0 , (5, 'tomato', 120, '...') > ) > SELECT > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 p.id > =C2=A0=C2=A0=C2=A0=C2=A0 , p.name > =C2=A0=C2=A0=C2=A0=C2=A0 , p.price > =C2=A0=C2=A0=C2=A0=C2=A0 , p.action > =C2=A0 FROM products AS p > =C2=A0WHERE regexp_like(p.action, ((? ; > > [the complaint is that you get a list of tables rather than a result] There is no bug there. The statement is *not* a regular expression, because the single quotes around the string literal are missing. As a consequence, a metacommand (\d+) is executed. That "swallows" the two closing parentheses, and psql prompts you to close the two parentheses and end the statement. If you do that, you get the syntax error you deserve. In short: garbage in, garbage out. No bug. Yours, Laurenz Albe