IT 4510 : Information Security

Web Security

Dr Joe Francom


The OWASP Top 10 Web Application Security Risks

Remember that software security also applies to web software and websites.

So does INPUT VALIDATION!


Cross Site-Scripting Attacks (XSS)

Cross-Site Scripting attacks are a type of injection problem, in which malicious scripts are injected into the otherwise benign and trusted web sites. Cross-site scripting (XSS) attacks occur when an attacker uses a web application to send malicious code, generally in the form of a browser side script, to a different end user. Flaws that allow these attacks to succeed are quite widespread and occur anywhere a web application uses input from a user in the output it generates without validating or encoding it.


Cross Site-Scripting Attacks (XSS)

An attacker can use XSS to send a malicious script to an unsuspecting user. The end user’s browser has no way to know that the script should not be trusted, and will execute the script. Because it thinks the script came from a trusted source, the malicious script can access any cookies, session tokens, or other sensitive information retained by your browser and used with that site. These scripts can even rewrite the content of the HTML page. -OWASP


Cross Site-Scripting Attacks (XSS)

Reflected vs stored?

<script>alert('XSS');</script>
<script>alert(document.cookie);</script>

Cross Site-Scripting Attacks


PHP Mitigation for XSS

Strip_tags() removes HTML and PHP scripting tags from a string.

Utf8_decode() converts UTF-8 encoding to single byte ASCII characters. Decoding Unicode input prior to filtering it can help you detect attacks that the attacker has obfuscated with Unicode encoding.

Htmlspecialcharacters() turns characters such as &,>,<,” into their HTML equivalents. Converting special characters to HTML prevents them from being executable within browsers when outputted by an application.


PHP Mitigation for XSS

Strtr() filters any characters you specify. Make sure to filter “; : ( )” characters so that attackers cannot craft strings that generate alerts. Many XSS attacks are possible without the use of HTML characters, so filtering and encoding parentheses mitigates these attacks. For example:

" style="background:url(JavaScript:alert(Malicious Content));