Feature request: Settings to disable comments and multiple statements in a connection

From: Glen K <glenk1973(at)hotmail(dot)com>
To: "pgsql-general(at)lists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Feature request: Settings to disable comments and multiple statements in a connection
Date: 2025-06-04 22:41:15
Message-ID: BN0P223MB0152E29A351757553BB74C19A86CA@BN0P223MB0152.NAMP223.PROD.OUTLOOK.COM
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-general

Given that most SQL injections<https://www.invicti.com/blog/web-security/sql-injection-cheat-sheet/> involve use of comments and/or insertion of semi-colons to start a new statement, it seems to me that injection attacks could be substantially reduced if client connections could be configured to disallow comments in SQL and to only allow one statement to be executed per request. In my experience developing backends for APIs, I have never come across a case where comments were needed or desired within SQL statements generated for API requests, and I'm not aware of any use cases where it was essential to send two statements in the same execute request (but perhaps there are).

My feature requests are thus:

*
Provide a client connection option (and/or implement the backend support) to disallow comments in SQL statements
*
Provide a client connection option (and/or implement the backend support) to allow only one statement in an execute request
*
Provide an option in the client execute functions (and/or implement the backend support) to specify the expected number of statements. This would override the client connection option and would inhibit attackers from injecting additional statements

Such features would not be an alternative to using parameterized queries, sanitized user input or any other injection mitigation measures, but would provide another layer of security on top of those measures.

-Glen

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2025-06-04 23:05:52 Re: Feature request: Settings to disable comments and multiple statements in a connection
Previous Message Matthew Tice 2025-06-04 18:37:34 Re: Sudden increase in n_dead_tup with no corresponding insert/update/delete