Someone told me the other day that “no-one does SQL Injection by hand any more”. I want to tell you about a SQL Injection bug that I found and exploited manually.
Disclaimer: for the most part, I’m going to take you down the ‘happy path’ here. There were many more dead-ends, far more frustration, and much more head scratching in the discovery and exploitation of this bug than any of this would imply. I’d hate for all of that to get in the way of a good story though, so anyway…
I was looking at a JSON-RPC API on a target (a target with a bug bounty program; I’m a good boy, I am), when I spotted a telltale sign of a problem: a single quote in the parameter would throw an error:
tom@bash:~▶ cat payload.json { "jsonrpc": "2.0", "method": "getWidgets", "params": ["2'"] } tom@bash:~▶ curl -s $APIURL -d @payload.json // ERRORS! ERRORS EVERYWHERE!
But with the quote wrapped in a MySQL comment, there was no error:
tom