News for hackers. Stuff that matters.
Re:Finding an authorization bypass on my own website by singron on Saturday March 05, 2022 @08:52PM (#30574202)
From the DB, no. E.g. you could always have `query("... a = ? and b = "+b, [a])`.

From within a language, you somehow need to restrict how you build up the query. E.g. a query builder or ORM usually makes it hard to use anything besides parameters, but they usually have escape hatches (e.g. a where method that takes arbitrary sql strings).

One trick you can do in Go is to create a type like `type sqlLiteral string`. The type is private, so other packages can't directly instantiate it, but a string literal will automatically coerce to it. Basically, you can't compute sqlLiteral from arbitrary expressions. It must be a single hardcoded string literal.

There are no comments on this comment yet.