A prime example of this problem is MySpace, which has been hit by the same vulnerability six times because it has not properly stopped attackers from entering malicious text through stripping. In providing a consumer benefit, MySpace has made its site far more dangerous to those very same consumers.Attackers at MySpace are using the MySpace tools to introduce exploit code into a MySpace web page. MySpace is responding by attempting to delete the offending code from the content.
As RSnake notes, this has led to an oscillating conflict between the MySpace web coders and the attackers. It looks something like this:
Submit(Post_html) where Post_html equals:
>html start ... [embedded exploit] ... html end<
Defender (server side of submit function)
Post_html = Strip_Exploit(Post_html)
This conflict oscillates because after each improvement the Defender makes to the “Strip_Exploit” logic, the Attacker adapts her efforts to defeat the system. To get out of this situation, the defender needs to change the rules.
There are many ways to solve this problem. I’ll delve into two examples: with “stripping” the Defender could iterate over the data until clean; another solution is to use Substitution instead of Strip.
Example 1: Defender using strip
Clean( Strip_Exploit(Post_html) )
Recursion prevents the attacker from passing a nested embed attack through the Strip function. As an alternative to recursion, the defender could iterate through a loop until the exploit code is gone:
Set Post_html to Strip_Exploit(Post_html)
Another solution is to replace the exploit code with a safe substitution. For example, if the offending code is “Crake” then replace each instance of Crake with “Oryx.” It is vital that the replacement text is the same length or less than the length of the exploit text – otherwise, the attacker may discover a method to overflow the buffer you are using to contain Post_html.
Example 2: Defender using substitution
Set Post_html to Replace_Exploit(Post_html)
Meanwhile, I recommend you disable scripting when you browse a page at MySpace.