Feature request: Settings to disable comments and multiple statements in a connection - Mailing list pgsql-general

From Glen K
Subject Feature request: Settings to disable comments and multiple statements in a connection
Date
Msg-id BN0P223MB0152E29A351757553BB74C19A86CA@BN0P223MB0152.NAMP223.PROD.OUTLOOK.COM
Whole thread Raw
Responses Re: Feature request: Settings to disable comments and multiple statements in a connection
Re: Feature request: Settings to disable comments and multiple statements in a connection
List pgsql-general
Given that most SQL injections 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

pgsql-general by date:

Previous
From: Matthew Tice
Date:
Subject: Re: Sudden increase in n_dead_tup with no corresponding insert/update/delete
Next
From: Tom Lane
Date:
Subject: Re: Feature request: Settings to disable comments and multiple statements in a connection