Hacker News new | ask | show | jobs
by ineedasername 1641 days ago
Yes, people still forget to

  ; delete from comments where id = 29544262 */--
sanitize their inputs.

...still there?

2 comments

The humor here is that sanitizing inputs is not the proper mitigation.
but? It think it's far deeper than mitigation, it's the solution.

Edit: I apologize for getting 'sanitation' wrong. Don't do it.

For databases you simply parametize the inputs so that code is code and data is data and there's no mixing of the two.

Sanitization is a defence of last resort when you simply can't separate code and data. Usually used for user content on the web since HTML has no formal mechanism to separate code and data because the angled brackets that do this separation are also valid user input.

But databases do have a way to separate the query from the data. Parametize your queries.

Indeed. That's enforced system boundaries.
The proper solution to SQL injection is parameterized queries, not input sanitization, to my knowledge.
The irony here is that if you use the log4j equivalent of parameterized queries, parameterized logging strings, you're still vulnerable to this CVE, even if you did everything right.
> sanitize their inputs.

For anyone confused about why "sanitizing your inputs" isn't the right approach, please read (shameless self-promotion, but I think the concept is important): https://benhoyt.com/writings/dont-sanitize-do-escape/

I've pretty much always taken 'sanitize' as a catch-all for all of the things you need to do.
Fair enough on that part. But it's the "their inputs" part that's just as problematic: whatever massaging you do to your "inputs", they'll always be unsafe in some contexts. You need to encode/escape your output.