March 6, 2012
How To Avoid sql injections to existing code
Question by Maths Brain Teasers
There was a mysql injections on my website.It has 1000 of existing php files. From last 6 months , when i code i keep sure the code is injections free.But is there any solution how can i secure the legacy code without changing every file.
Answer by Starx
This is a very vast field. However, There are few points I can give you
- Sanitize and filter every input you receive from the user.
- Handle every errors correctly. Do not even leave one possibility of an error being triggered
(This is a very important point and the main reason of most of the hacks) - If there were previous breaches, check the
apache
‘s log files to see where the injection happened. or where the hacking occur.- There are mainly two types of logs file maintained in apache.
access_log
anderror_log
- Once a breach occurs, make a backup of the logs and mitigate the problem, reviewing the logs.
- There are mainly two types of logs file maintained in apache.
- If a documentation is available for the system you are maintaining currently, then the vulnerability can be detected quicker.