
As developers, it's important that we protect our applications and data from all the possible attacks or hostile data that can be entered from a form, URL or Cookie as example. There is a golden rule to not trust any incoming data and only accept data in the expected format. In addition to just testing for numeric data or valid data, there are numerous attacks that we now need to defend against - these attacks include:
- Cross-Site Scripting (XSS)
- Cross-Site Request Forgeries (CRSF)
- SQL Injection
- SPAM attacks
Geeklog has always prided itself on a strong security focus. It can be a challenge keeping up with the latest exploit but Geeklog provides common core functions for filtering incoming data, bad language as well as plugins for filter span and ban content from users or IP addresses. As developers, we can not always block or filter out all HTML - example a comment input. This is where it get's more complicated but Geeklog does provide a nice set of core functions to filter out un-wanted HTML, Javascript. Another complication for developers is handling quotes and other special characters.
There are many great resources on the internet that will explain in detail, web development, security and input filtering. The purpose of this article was to share a small script I wrote that can be used to test the various Geeklog library functions and PHP native functions on input data and the resulting effect. The test script can be seen here. You can enter any test data including bad language, html and javascript and test the effects of the various filtering options.
The [Test Data] link will insert some test data and then you can toggle on the various filters and php functions to see the result - both the raw data equivalent and the resulting displayed data. The test data includes a XSS attack where a javascript function is included which could be replaced with a script that executes a more serious exploit.