Injecting Comments to Detect JavaScript Code Injection Attacks
Authors:
- Hossain ShahriarHSHossain Shahriar
- Mohammad ZulkernineMZMohammad Zulkernine
- 1 July 2011
- conference paper
- Published by Institute of Electrical and Electronics Engineers (IEEE)
- p. 104-109
Abstract
Most web programs are vulnerable to cross site scripting (XSS) that can be exploited by injecting JavaScript code. Unfortunately, injected JavaScript code is difficult to distinguish from the legitimate code at the client side. Given that, server side detection of injected JavaScript code can be a layer of defense. Existing server side approaches rely on identifying legitimate script code, and an attacker can circumvent the technique by injecting legitimate JavaScript code. Moreover, these approaches assume that no JavaScript code is downloaded from third party websites. To address these limitations, we develop a server side approach that distinguishes injected JavaScript code from legitimate JavaScript code. Our approach is based on the concept of injecting comment statements containing random tokens and features of legitimate JavaScript code. When a response page is generated, JavaScript code without or incorrect comment is considered as injected code. Moreover, the valid comments are checked for duplicity. Any presence of duplicate comments or a mismatch between expected code features and actually observed features represents JavaScript code as injected. We implement a prototype tool that automatically injects JavaScript comments and deploy injected JavaScript code detector as a server side filter. We evaluate our approach with three JSP programs. The evaluation results indicate that our approach detects a wide range of code injection attacks.Keywords
This publication has 9 references indexed in Scilit:
- Taxonomy and classification of automatic monitoring of program security vulnerability exploitationsJournal of Systems and Software, 2011
- Client-Side Detection of Cross-Site Request Forgery Attacks2010
- PhishTester: Automatic Testing of Phishing Attacks2010
- Efficient character-level taint tracking for Java2009
- SWAP: Mitigating XSS attacks using a reverse proxy2009
- MUTEC: Mutation-based testing of Cross Site Scripting2009
- XSSDS: Server-Side Detection of Cross-Site Scripting Attacks2008
- Static detection of cross-site scripting vulnerabilities2008
- Defeating script injection attacks with browser-enforced embedded policies2007