![]() | |
#11
| ||||||
| ||||||
|
|
On Fri, 02 Jul 2010 01:26:20 +0100, The Natural Philosopher tnp (AT) invalid (DOT) invalid> wrote: Tyrone Slothrop wrote: |
|
I am logging to a text file from the PHP script that is called from the AJAX script. Once the SQL statement is generated and before it is executed, the query appends to a log file (which is archived daily in case I need to refer to it in a fit of madness). |
|
The thing that makes me crazy is that it is one in a million query triggers this thing. It has occurred 5 times in the last year. |
|
What happens is that not all fields are overwritten, but all 60,000+ records are. |
|
overwritten and not always the same set. |
|
by AJAX does incremental saves as the form is filled out, this is the script that is suspect. Within the log I can track the queries of an individual applicant as each query gets a bit longer as more fields of the form are completed. |
#12
| |||
| |||
|
|
Tyrone Slothrop <ts (AT) paranoids (DOT) org> wrote: How are you logging the queries? In terms of what is sent to the mysqld or is the mysqld itself logging the queries it has recieved? I am logging to a text file from the PHP script that is called from the AJAX script. This is not enough. You should let MySQL log the queries. If you're fine with just the query, the binlog would be enough. It has the advantage that it is rotated automatically and that it logs only queries that modify data. The general log provides more info, i.e. which MySQL account was used and from which machine the login was done. It also records *all* queries and thus grows rapidly. You have to rotate it manually. Finally I have a bit weird idea: use mysql-proxy to filter your queries. You just have to write few lines of Lua code to identify the problem query (i.e. with a regex). Then proxy can log it and/or suppress the execution of this query. |
| XL |
#13
| |||
| |||
|
|
Can you shed more light on the mysql-proxy? I had not heard of that.. |
#14
| |||
| |||
|
|
Axel Schwenke wrote: Finally I have a bit weird idea: use mysql-proxy to filter your queries. You just have to write few lines of Lua code to identify the problem query (i.e. with a regex). Then proxy can log it and/or suppress the execution of this query. Can you shed more light on the mysql-proxy? I had not heard of that.. It looks a most useful tool. |
#15
| ||||
| ||||
|
|
Tyrone Slothrop wrote: On Fri, 02 Jul 2010 01:26:20 +0100, The Natural Philosopher tnp (AT) invalid (DOT) invalid> wrote: Tyrone Slothrop wrote: cut to the chase I am logging to a text file from the PHP script that is called from the AJAX script. Once the SQL statement is generated and before it is executed, the query appends to a log file (which is archived daily in case I need to refer to it in a fit of madness). Right. Can you CONCLUSIVELY say that the corruption you get does NOT show up as a malformed SQL query logged by this script? |
|
What happens is that not all fields are overwritten, but all 60,000+ records are. That is almost definitely an update table ...set fields with no where.. |
|
You should - and its a vile thought - turn mysqld logging on. |
|
either you've missed some code that does a rogue update, or some other process is doing it.. |
#16
| |||
| |||
|
|
On 2 July, 09:57, The Natural Philosopher <t... (AT) invalid (DOT) invalid wrote: Can you shed more light on the mysql-proxy? I had not heard of that.. I'm sorry, the temptation is too great! http://lmgtfy.com/?q=mysql-proxy where you will find: http://dev.mysql.com/tech-resources/...ngstarted.html Cap'n sir, I already did that as soon as I saw it. |
#17
| |||
| |||
|
|
The Natural Philosopher <tnp (AT) invalid (DOT) invalid> wrote: Axel Schwenke wrote: Finally I have a bit weird idea: use mysql-proxy to filter your queries. You just have to write few lines of Lua code to identify the problem query (i.e. with a regex). Then proxy can log it and/or suppress the execution of this query. Can you shed more light on the mysql-proxy? I had not heard of that.. It looks a most useful tool. http://forge.mysql.com/wiki/MySQL_Proxy Written by a MySQL^WSun^WOracle employee. All the time critical part is C but you can plug Lua functions at certain stages of request and response handling. Some use cases: load balancing, read-write splitting + load balancing (to distribute connections on a replication cluster). Statistical analysis. I.e. proxy is used to collect data for the Enterprise Monitor http://www.mysql.com/products/enterprise/monitor.html XL The answer I wanted. Thanks. |
#18
| |||
| |||
|
|
What protection do you have against malicious or simply erroneous queries to your AJAX script? Are there any old and buggy versions of your AJAX script still on your server? Since it happens every couple of months, have you considered that it might be triggered by Google's (or some other search engine's) web spider? I once set up an administrative page (accessible from localhost only) for maintaining a SPAM filter. It (stupidly) used a url like: http://mysystem.example.org/spamfilt...e.php?id=63683 on a "DELETE" button when I examined a particular record. Later I ran a program to check for broken links on my site, doing a web-spider-walk (Google does much the same thing. However, this one was run from localhost, bypassing the security protection). Gee, where did all the spam filter entries go? Don't use GET on URLs intended to make changes in a database (add/delete records, change passwords, buy stuff, send email, etc.), except incidentally for things like hit counters. Use POST. And use SSL where appropriate. |
#19
| |||
| |||
|
|
On Fri, 02 Jul 2010 00:43:23 -0500, Gordon Burditt wrote: What protection do you have against malicious or simply erroneous queries to your AJAX script? Are there any old and buggy versions of your AJAX script still on your server? Since it happens every couple of months, have you considered that it might be triggered by Google's (or some other search engine's) web spider? I once set up an administrative page (accessible from localhost only) for maintaining a SPAM filter. It (stupidly) used a url like: http://mysystem.example.org/spamfilt...e.php?id=63683 on a "DELETE" button when I examined a particular record. Later I ran a program to check for broken links on my site, doing a web-spider-walk (Google does much the same thing. However, this one was run from localhost, bypassing the security protection). Gee, where did all the spam filter entries go? Don't use GET on URLs intended to make changes in a database (add/delete records, change passwords, buy stuff, send email, etc.), except incidentally for things like hit counters. Use POST. And use SSL where appropriate. This. And validate the input anyway. And check it again. If your delete operation is supposed to delete one record, run a select on that criteria first *every time*, spit back an error, log it, and *don't run the query*, if the number of records is anything OTHER than exactly what you're expecting: 1. |
![]() |
| Thread Tools | |
| Display Modes | |
| |