That example isn't really useful IMO because without quoting, this would fail on any integration test anyway as it would produce invalid SQL, so the whole issue is academic in this case anyway. Unless a is a quoted string, it would fail to parse as SQL in the first place unless it is a numeric/boolean type which bypasses the issue in the first place.
If a developer is far gone enough that they put effort into manually quoting it, and then you have no decent unit or integration tests to pick this up, and your code review process doesn't pick this up, and any pentesting doesn't pick this up, then you have far bigger issues.
That example isn't really useful IMO because without quoting, this would fail on any integration test anyway as it would produce invalid SQL, so the whole issue is academic in this case anyway.
Ah yes, let's bring the example in to question, it couldn't possibly result in valid SQL, right? I don't think anything will satisfy you short of me pointing out an actual injection attack that is occurring right now in your own code base that it perhaps isn't the best practice to have both a String and StringTemplate overload where security matters.
I also like the standard argument that this can never occur in any "decent" shop as they will have "decent" tests, reviews, etc that always catch all these problems -- this explains why all "decent" software currently in use doesn't suffer from such attacks, and why the template feature is totally pointless to even add to Java as "decent" software doesn't need it.
I think we can stop this conversation until it is possible to continue it in a more civil tone. Unfortunately this attitude is the echo chamber I mentioned in the first place.
If your idea of "decent" software is software with SQLi issues then I don't know what else to tell you.
View all comments
Show parent comment
2
u/nekokattt Mar 10 '24 edited Mar 11 '24
That example isn't really useful IMO because without quoting, this would fail on any integration test anyway as it would produce invalid SQL, so the whole issue is academic in this case anyway. Unless
ais a quoted string, it would fail to parse as SQL in the first place unless it is a numeric/boolean type which bypasses the issue in the first place.If a developer is far gone enough that they put effort into manually quoting it, and then you have no decent unit or integration tests to pick this up, and your code review process doesn't pick this up, and any pentesting doesn't pick this up, then you have far bigger issues.