Below are practical steps to protect your site, followed by an explanation of how CrawlTrack helps in that task. They are complementary: the script stops part of the traffic, and your habits stop the rest.
Seven habits that matter
- 1. Keep every script up to date
- If you use a content management script, a blog, a board or a gallery, always install the latest version. As soon as a vulnerability is detected, the author publishes an updated release, but the vulnerability is also widely explained, so attackers try to exploit it immediately on sites that have not updated.
- 2. Never trust an external entry
- If you program your own scripts, all external entries, such as POST and GET values, need to be checked and treated before use. Otherwise you are at real risk of code injection or cross site scripting.
- 3. Escape external entries in SQL queries
- To avoid SQL injection, treat every external entry before using it in a query. With php scripts, look at the mysqli_real_escape_string function or, better, use prepared statements.
- 4. Do not leave a web folder at 777
- With 777 everybody has every right on your folders, which is a large risk. A value such as 705 is usually sufficient, and many hosts provide a safer default.
- 5. Choose proper passwords
- Never use the same login and password for your FTP and MySQL connections. If one is discovered, everything becomes accessible. Choose a password that is long enough and combines letters, numbers and signs.
- 6. Configure your own server carefully
- If you run your own server, keep Apache, php and MySQL up to date. A badly configured server can become a spam relay through wrong parameters alone.
- 7. Stay informed
- Many sites publish security alerts. The advice here is a minimum, and attackers find new ideas every day, so keep reading to be sure you are not leaving a vulnerability in place.
How CrawlTrack helps
Detection of code injection attempts
For each request on your site, CrawlTrack checks the url and looks for the presence of a link to another site inside it. A request such as www.yoursite.com/index.php?site=http://www.badsite.com is detected as an injection attempt, and if you have configured CrawlTrack to block attacks, the visitor, often a crawler, is redirected to an alert page.
This is why the tag is best placed first in your pages. If you use links to other sites inside your url, add those sites to the trust list to avoid wrong detections.
Detection of SQL injection attempts
For each request, CrawlTrack looks for what resembles an SQL query inside the url. A request such as www.yoursite.com/index.php?id=a OR 1=1 is detected as an SQL injection attempt and, with blocking enabled, redirected to an alert page. Again, the tag near the top prevents the injection from being executed before CrawlTrack reacts.
Recording of every attempt
CrawlTrack records all these attempts, so you have access to the addresses used by the attackers, the date and time of each attack, the code or SQL query they tried to inject, and the list of scripts for which a known vulnerability matches those attacks. The attack list is updated with one click, exactly like the crawler list. Unlike the crawler list it is not used for detection, but to tell you which script may be targeted.
CrawlTrack helps fight hacking attempts, but it can only be one part of your plan. Apply the seven habits above, and for the server side use CrawlProtect, the script dedicated to site security developed by the same team.
Security references
Sources and further reading, all outside this site. They open in a new context and are listed for reference only.
- OWASP Top Ten the most common web application risks
- OWASP SQL injection prevention prepared statements and escaping
- Apache mod security request filtering at server level
- PHP security manual language level guidance
- Suhosin hardening extension for php
- OWASP cross site scripting XSS prevention
- OWASP file upload upload risks
- OWASP security headers headers to add
- HTTP headers what each header does
- CVE database published vulnerabilities