← Back to context

Comment by wglb

2 months ago

Sanitization almost always fails. This becomes an arms race.

If you do it wrong, yes. Sure, there is no 100% security, but honestly, it's 2025. We already know the techniques how to prevent SQL injection of any kind. I wrote about this here: https://valentin.willscher.de/posts/sql-api/

  • Right but the case that is being imagined here is a site that perfectly sanitises * but somehow still allows SQL injection? I don't think so.

    • > Right but the case that is being imagined here is a site that perfectly sanitises * but somehow still allows SQL injection? I don't think so.

      It could literally just reject anything with asterisks.

      It doesn't even need to do anything perfectly, it just needs to do it enough to produce hurdles for you. Like blowing through the number of attempts you realistically have remaining.

      4 replies →

  • The parser isn't shown there, so it isn't clear what would happen with weird input.

    Have you had anyone do a penetration test on it?

    • Well, I would suppose that you pick an existing parser that is well tested and battle proven. No need to write your own. For most languages those parsers already exist. I would also not write my own json parser, so why would I do that for SQL, which is even more complex?

      But in any case, the weird input would just be rejected. In my case I'd get a "parser error" from my library and then wrap it into my own "query not supported" error and return that as a 400.

      > Have you had anyone do a penetration test on it?

      Actually, yes. The pen-testers were surprised about the technique but did not find any problems with it.

      4 replies →