Note: One, I am not sure if synthetic queries is right word for the risk I am talking about. Second, though I am considering 3-tier model of web-applications general answers are welcome in client-server situations where server side validation is not possible.
Currently I have a page where you do certain computations using what is called as DHTML, This computation generates a string which has no particular pattern as such. This string is sent to a server side script using AJAX.
Anyone with basic training in these technologies can read the code and realize that the query is sent is something like this:
http://domain.com/script.php?var=theStringSoGenerated
Hoping to exploit a possible flaw, a hacker types in his browser:
http://domain.com/script.php?var=aCompletelyRandomString
He does this a few times and sees no evident benefit and quits, but in the middle tier, the PHP script, completely helpless without a possible validation, updates and inserts the random string into the database impacting its integrity and leading to wastage of resources.
Question: How can I protect my application against such attacks?