skip to main content
10.1145/2046707.2046775acmconferencesArticle/Chapter ViewAbstractPublication PagesccsConference Proceedingsconference-collections
research-article

Context-sensitive auto-sanitization in web templating languages using type qualifiers

Published:17 October 2011Publication History

ABSTRACT

Scripting vulnerabilities, such as cross-site scripting (XSS), plague web applications today. Most research on defense techniques has focused on securing existing legacy applications written in general-purpose languages, such as Java and PHP. However, recent and emerging applications have widely adopted web templating frameworks that have received little attention in research. Web templating frameworks offer an ideal opportunity to ensure safety against scripting attacks by secure construction, but most of today's frameworks fall short of achieving this goal.

We propose a novel and principled type-qualifier based mechanism that can be bolted onto existing web templating frameworks. Our solution permits rich expressiveness in the templating language while achieving backwards compatibility, performance and formal security through a context-sensitive auto-sanitization (CSAS) engine. To demonstrate its practicality, we implement our mechanism in Google Closure Templates, a commercially used open-source templating framework that is used in GMail, Google Docs and other applications. Our approach is fast, precise and retrofits to existing commercially deployed template code without requiring any changes or annotations.

References

  1. D. Balzarotti, M. Cova, V. Felmetsger, N. Jovanovic, E. Kirda, C. Kruegel, and G. Vigna. Saner: Composing Static and Dynamic Analysis to Validate Sanitization in Web Applications. In Proceedings of the IEEE Symposium on Security and Privacy, Oakland, CA, May 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. S. Bandhakavi, S. T. King, P. Madhusudan, and M. Winslett. VEX: Vetting browser extensions for security vulnerabilities, 2010.Google ScholarGoogle Scholar
  3. Google autoescape implementation for ctemplate (c code). http://google-ctemplate.googlecode.com/svn/trunk/doc/auto_escape.html.Google ScholarGoogle Scholar
  4. D. Bates, A. Barth, and C. Jackson. Regular expressions considered harmful in client-side XSS filters. In Proceedings of the 19th international conference on World wide web, WWW '10, 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. P. Bisht and V. N. Venkatakrishnan. XSS-GUARD: Precise dynamic prevention of cross-site scripting attacks. In Detection of Intrusions and Malware, and Vulnerability Assessment, 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. H. Bojinov, E. Bursztein, and D. Boneh. XCS: Cross channel scripting and its impact on web applications. In CCS, 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. Google Analytics XSS vulnerability. http://spareclockcycles.org/2011/02/03/google-analytics-xss-vulnerabili%ty/ .Google ScholarGoogle Scholar
  8. Google XSS Flaw in Website Optimizer Scripts explained. http://www.acunetix.com/blog/web-security-zonełinebreak/articles%/google-xss-website-optimizer-scripts/.Google ScholarGoogle Scholar
  9. How I met your girlfriend, DEFCON'10. ohack.us/xss/2010-defcon.ppt.Google ScholarGoogle Scholar
  10. XSS Attack Identified and Patch-Twitter. http://statusłinebreak.twitter.com/post/1161435117/xss-attackł%inebreak-identified-and-patched.Google ScholarGoogle Scholar
  11. ClearSilver: Template Filters. http://www.clearsilver.net/docs/man_filters.hdf.Google ScholarGoogle Scholar
  12. CodeIgniter/system/libraries/Security.php. https://bitbucket.org/ellislab/codeigniter/src/8af0fb079f90/system/libr%aries/Security.php.Google ScholarGoogle Scholar
  13. Ctemplate: Guide to Using Auto Escape. http://google-łinebreakctemplate.googlecode.com/svn/trunk/doc/auto_escape.html.Google ScholarGoogle Scholar
  14. django: Built-in template tags and filters. http://docs.djangoproject.com/en/dev/ref/templates/builtins.Google ScholarGoogle Scholar
  15. Google autoescape implementation for gwt (java code). http://code.google.com/p/google-web-toolkit/source/browse/tools/lib/str%eamhtmlparser/streamhtmlparser-jsilver-r10/streamhtmlparser-jsilver-r10--1.5.ja%r.Google ScholarGoogle Scholar
  16. J. S. Foster, T. Terauchi, and A. Aiken. Flow-sensitive type qualifiers. In Proceedings of the ACM SIGPLAN 2002 Conference on Programming language design and implementation, PLDI '02, 2002. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. B. Gourdin, C. Soman, H. Bojinov, and E. Bursztein. Towards secure embedded web interfaces. In Proceedings of the Usenix Security Symposium, 2011. Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. A. Guha, S. Krishnamurthi, and T. Jim. Using static analysis for ajax intrusion detection. In Proceedings of the 18th international conference on World wide web, WWW '09. Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. M. V. Gundy and H. Chen. Noncespaces: using randomization to enforce information flow tracking and thwart cross-site scripting attacks. 16th Annual Network & Distributed System Security Symposium, 2009.Google ScholarGoogle Scholar
  20. Google Web Toolkit: Developer's Guide -- SafeHtml. http://code.google.com/webtoolkit/doc/latest/DevGuideSecuritySafeHtml.h%tml.Google ScholarGoogle Scholar
  21. R. Hansen. XSS cheat sheet. http://ha.ckers.org/xss.html.Google ScholarGoogle Scholar
  22. P. Hooimeijer, B. Livshits, D. Molnar, P. Saxena, and M. Veanes. Fast and precise sanitizer analysis with BEK. In Proceedings of the Usenix Security Symposium, 2011. Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. HTML Purifier : Standards-Compliant HTML Filtering. http://htmlpurifier.org/.Google ScholarGoogle Scholar
  24. Y.-W. Huang, F. Yu, C. Hang, C.-H. Tsai, D.-T. Lee, and S.-Y. Kuo. Securing web application code by static analysis and runtime protection. In Proceedings of the 13th international conference on World Wide Web, WWW '04. Google ScholarGoogle ScholarDigital LibraryDigital Library
  25. JiftyManual. http://jifty.org/view/JiftyManual.Google ScholarGoogle Scholar
  26. T. Jim, N. Swamy, and M. Hicks. BEEP: Browser-enforced embedded policies. 16th International World World Web Conference, 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library
  27. N. Jovanovic, C. Krügel, and E. Kirda. Pixy: A static analysis tool for detecting web application vulnerabilities (short paper). In IEEE Symposium on Security and Privacy, 2006. Google ScholarGoogle ScholarDigital LibraryDigital Library
  28. Quasis demo - javascript shell 1.4. http://js-quasis-libraries-and-repl.googlecode.com/svn/trunk/index.html%.Google ScholarGoogle Scholar
  29. A. Kiezun, V. Ganesh, P. J. Guo, P. Hooimeijer, and M. D. Ernst. HAMPI: A solver for string constraints. In International Symposium on Software Testing and Analysis, 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  30. kses - PHP HTML/XHTML filter. http://sourceforge.net/projects/kses/.Google ScholarGoogle Scholar
  31. B. Livshits and M. S. Lam. Finding security errors in Java programs with static analysis. In Proceedings of the Usenix Security Symposium, 2005. Google ScholarGoogle ScholarDigital LibraryDigital Library
  32. B. Livshits, M. Martin, and M. S. Lam. SecuriFly: Runtime protection and recovery from Web application vulnerabilities. Technical report, Stanford University, Sept. 2006.Google ScholarGoogle Scholar
  33. M. Martin and M. S. Lam. Automatic generation of XSS and SQL injection attacks with goal-directed model checking. In 17th USENIX Security Symposium, 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library
  34. The Mason Book: Escaping Substitutions. http://www.masonbook.com/book/chapter-2.mhtml.Google ScholarGoogle Scholar
  35. L. Meyerovich and B. Livshits. ConScript: Specifying and enforcing fine-grained security policies for JavaScript in the browser. In IEEE Symposium on Security and Privacy, May 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  36. Y. Nadji, P. Saxena, and D. Song. Document structure integrity: A robust basis for cross-site scripting defense. In NDSS, 2009.Google ScholarGoogle Scholar
  37. A. Nguyen-Tuong, S. Guarnieri, D. Greene, J. Shirley, and D. Evans. Automatically hardening web applications using precise tainting. 20th IFIP International Information Security Conference, 2005.Google ScholarGoogle ScholarCross RefCross Ref
  38. XSS Prevention Cheat Sheet. http://www.owasp.org/index.php/XSS_(Cross_Site_Scripting)_Prevention_Ch%eat_Sheet.Google ScholarGoogle Scholar
  39. W. Robertson and G. Vigna. Static Enforcement of Web Application Integrity Through Strong Typing. In Proceedings of the USENIX Security Symposium, Montreal, Canada, August 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  40. Ruby on Rails Security Guide. http://guides.rubyonrails.org/security.html.Google ScholarGoogle Scholar
  41. P. Saxena, D. Akhawe, S. Hanna, F. Mao, S. McCamant, and D. Song. A symbolic execution framework for JavaScript. Technical Report UCB/EECS-2010--26, EECS Department, University of California, Berkeley, 2010.Google ScholarGoogle ScholarDigital LibraryDigital Library
  42. P. Saxena, S. Hanna, P. Poosankam, and D. Song. FLAX: Systematic discovery of client-side validation vulnerabilities in rich web applications. In 17th Annual Network & Distributed System Security Symposium, (NDSS), 2010.Google ScholarGoogle Scholar
  43. P. Saxena, D. Molnar, and B. Livshits. SCRIPTGARD: Automatic context-sensitive sanitization for large-scale legacy web applications. In Proceedings of the ACM Computer and communications security(CCS), 2011. Google ScholarGoogle ScholarDigital LibraryDigital Library
  44. Smarty Template Engine: escape. http://www.smarty.net/manual/en/language.modifier.escape.php.Google ScholarGoogle Scholar
  45. Google Closure Templates. http://code.google.com/closure/templates/.Google ScholarGoogle Scholar
  46. S. Stamm. Content security policy, 2009.Google ScholarGoogle Scholar
  47. Z. Su and G. Wassermann. The essence of command injection attacks in web applications. 2006.Google ScholarGoogle Scholar
  48. Template::Manual::Filters. http://template-toolkit.org/docs/manual/Filters.html.Google ScholarGoogle Scholar
  49. Ter Louw, Mike and V.N. Venkatakrishnan. BluePrint: Robust Prevention of Cross-site Scripting Attacks for Existing Browsers. In Proceedings of the IEEE Symposium on Security and Privacy, 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  50. J. Weinberger, P. Saxena, D. Akhawe, M. Finifter, R. Shin, and D. Song. A Systematic Analysis of XSS Sanitization in Web Application Frameworks. In Proceedings of the European Symposium on Research in Computer Security, 2011. Google ScholarGoogle ScholarDigital LibraryDigital Library
  51. Y. Xie and A. Aiken. Static detection of security vulnerabilities in scripting languages. In Proceedings of the Usenix Security Symposium, 2006. Google ScholarGoogle ScholarDigital LibraryDigital Library
  52. W. Xu, S. Bhatkar, and R. Sekar. Taint-enhanced policy enforcement: A practical approach to defeat a wide range of attacks. USENIX Security Symposium, 2006. Google ScholarGoogle ScholarDigital LibraryDigital Library
  53. Yii Framework: Security. http://www.yiiframework.com/doc/guide/1.1/en/topics.security.Google ScholarGoogle Scholar
  54. Zend Framework: Zend\_Filter. http://framework.zend.com/manual/en/zend.filter.set.html.Google ScholarGoogle Scholar

Index Terms

  1. Context-sensitive auto-sanitization in web templating languages using type qualifiers

      Recommendations

      Comments

      Login options

      Check if you have access through your login credentials or your institution to get full access on this article.

      Sign in
      • Published in

        cover image ACM Conferences
        CCS '11: Proceedings of the 18th ACM conference on Computer and communications security
        October 2011
        742 pages
        ISBN:9781450309486
        DOI:10.1145/2046707

        Copyright © 2011 ACM

        Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected]

        Publisher

        Association for Computing Machinery

        New York, NY, United States

        Publication History

        • Published: 17 October 2011

        Permissions

        Request permissions about this article.

        Request Permissions

        Check for updates

        Qualifiers

        • research-article

        Acceptance Rates

        CCS '11 Paper Acceptance Rate60of429submissions,14%Overall Acceptance Rate1,261of6,999submissions,18%

        Upcoming Conference

        CCS '24
        ACM SIGSAC Conference on Computer and Communications Security
        October 14 - 18, 2024
        Salt Lake City , UT , USA

      PDF Format

      View or Download as a PDF file.

      PDF

      eReader

      View online with eReader.

      eReader