Live data from Hacker News

Fuzzing Go APIs for SQL Injection

blog.fuzzbuzz.io

21–23 of 23 posts

Re: Fuzzing Go APIs for SQL Injection

#21
post #3

People are still constructing SQL statements using user provided data? Have they never used prepared statements before?

Prepared statements (in Postgres) don't work for:

- Dynamically generated queries, like a user specifying a query predicate via a UI.

- Dynamically selecting an identifier, like `SELECT * FROM $1` or `SELECT $1, count(*) FROM foo GROUP BY $1`.

You can use cleverness with types to parse user-provided data into a struct that emits sanitized SQL, but under the hood, there are only strings.

Re: Fuzzing Go APIs for SQL Injection

#22
post #9

Is there a open source fuzzing framework for Go?

As of go 1.18, fuzzing is built into the toolchain itself, and is what we're using in this post. We go over the basics here [0], if you'd like to start at the beginning [0]: https://blog.fuzzbuzz.io/go-fuzzing-basics/

Thanks!

Re: Fuzzing Go APIs for SQL Injection

#23
post #21
post #3

People are still constructing SQL statements using user provided data? Have they never used prepared statements before?

Prepared statements (in Postgres) don't work for: - Dynamically generated queries, like a user specifying a query predicate via a UI. - Dynamically selecting an identifier, like `SELECT * FROM $1` or `SELECT $1, count(*) FROM foo GROUP BY $1`. You can use cleverness with types to parse user-provided data into a struct that emits sanitized SQL, but under the hood, there are only strings.

Then you can't allow users to provide them. They must be constructed with constraints.
Post reply on HN