News for hackers. Stuff that matters.
Re:JEP 430: String Templates (Preview) Proposed to Target Ja... by bcrosby95 on Friday March 03, 2023 @04:48PM (#35015502)
The database stuff looks like an example, and shows how you could extend the template system in a way that doesn't introduce security problems.
Re:JEP 430: String Templates (Preview) Proposed to Target Ja... by nezirus on Friday March 03, 2023 @05:15PM (#35015782)
That is exactly the point, you should not use general string templating system for SQL queries, together with "roll your own" escape and validation mechanisms. I really don't see why they included that part, if not to show how to shoot yourself in the foot.
Re:JEP 430: String Templates (Preview) Proposed to Target Ja... by bcrosby95 on Friday March 03, 2023 @05:21PM (#35015844)
There is no roll your own escape mechanics. The example uses prepared statements.
Re:JEP 430: String Templates (Preview) Proposed to Target Ja... by imtringued on Saturday March 04, 2023 @05:36AM (#35019878)
I am very confused by your comments. PHP developers thought "sanitizing" strings aka escaping and validating strings is enough to get rid of SQL injections and that is how they ended up with multiple iterations of escaping functions. The problem, which is the separation of code from data, has not been solved and that is why it is a bad idea. The SQL example template in the article uses positional parameters via JDBC and is therefore completely safe to use. It is impossible to get it wrong except by using STR which is obviously the wrong template processor.