3 ms·
To probe for what? How does knowledge of a column name make it easier for me to discern whether a SQL injection vulnerability exists? I've spent a lot of time i
by tptacek 2y ago
To probe for what? How does knowledge of a column name make it easier for me to discern whether a SQL injection vulnerability exists? I've spent a lot of time in my career probing for SQL injection, and I can't remember an instance where my stimulus/response setup involved the table names.
SQL injection is a property of a SQL query, not of the schema itself. To have a meaningful chance of blind-one-shotting a query, getting a TRUE/FALSE answer about susceptibility without ever generating a SQL syntax error, I would need to see the queries themselves.
- default-kramer 2y ago> How does knowledge of a column name make it easier for me to discern whether a SQL injection vulnerability exists? It doesn't. It just means that as soon as you find one, you can immediately begin crafting valid queries instead of randomly guessing table names and columns, therefore not setting off the "DB query failed" alert. EDIT: I guess this is the part I missed: > To have a meaningful chance of blind-one-shotting a query, getting a TRUE/FALSE answer about susceptibility without ever generating a SQL syntax error, I would need to see the queries themselves. Really? I guess I have to take your word for it because I've never attempted it, but I would have thought that in some (horribly broken) systems `bobby tables' or 1=1 --` would have a very reasonable chance of detecting SQL injection without alerting anyone.
- jstanley 2y agoYou can craft valid queries that don't reference any table or column name.
- default-kramer 2y agoRight, and that's what you use to find the vulnerability. But imagine you've found the vulnerability and now you want to use it to update all of your parking tickets as paid. Without the schema, this is going to be quite tricky and will generate a lot of failed SQL. With the schema, you might be able to do it on your first try.
- tptacek 2y agoWhich is why in the ordinary course of a pentest you'd use the SQL injection vulnerability to recover the information in the schema.
- LegionMammal978 2y agoIs there not any SQLi vulnerability in practice that doesn't allow such an information recovery? That is, is the schema-recovery step so foolproof that it can always be performed on any target form? GP is suggesting that this may be difficult, depending on the kind of signal that gets returned from the form.
- tptacek 2y agoIn my entire experience as a software security practitioner, which at the time of my testimony encompassed some hundreds of assessments of SQL-backed websites, the availability of a schema has never impacted my ability to exploit a SQL injection. It's not my job as an expert witness, nor Matt's job as a plaintiff, to invent improbable scenarios where security could hinge on schema availability. The court (all of them, in fact) found that testimony dispositive, so I'm happy to leave the issue there.
- hot_gril 2y ago"Blind" SQLi is a thing, but even in the real-life example I could find, it wasn't exactly blind. They could still use the timing to get one bit of info at a time and discern the email addresses. https://www.invokesec.com/2025/01/13/a-real-world-example-of-blind-sqli/ https://www.invokesec.com/2025/01/13/a-real-world-example-of... It's hard to imagine a case where you can't even get info based on timing. But it requires more effort and knowledge to exploit this.
- default-kramer 2y agoMaybe I'm ignorant, but if the account the app is using doesn't have access to the information_schema how do you do this?
- kmoser 2y agoKnowledge of the column names doesn't give you insight into whether a vulnerability exists. It gives you insight into what you can do with a vulnerability, should it exist. For example, if you want to set your account balance to $1 million, you'd need to know the column name in order to generate a valid query. Without advance knowledge of the column name, your job becomes harder.
- hot_gril 2y agoSQL injection will give you the entire schema anyway. It doesn't help if someone tells you the col names beforehand. I'm more wondering about non-SQL-injection vulns.
- HDThoreaun 2y agoSQL injection isnt just an ssh tunnel to the database. If the line you've injected isnt a select and the backend never fetches it how does the injection give you the column names?
- hot_gril 2y agoOops you're right, it's possible that you have no way to read things back.
- wglb 2y agoI've seen this done by enumerating possible table names.
- hot_gril 2y agoThat's a typical way, but the errors might alert them, and of course maybe the names aren't so easily guessed.
- hot_gril 2y agoWait, this is known as a blind SQLi, and it's not so blind. You can still use timing to get the info you need one bit at a time. This may be slow, but it's doable without triggering any DB errors, so you have time.