skip to main content
research-article

A trusted mechanised JavaScript specification

Published:08 January 2014Publication History
Skip Abstract Section

Abstract

JavaScript is the most widely used web language for client-side applications. Whilst the development of JavaScript was initially just led by implementation, there is now increasing momentum behind the ECMA standardisation process. The time is ripe for a formal, mechanised specification of JavaScript, to clarify ambiguities in the ECMA standards, to serve as a trusted reference for high-level language compilation and JavaScript implementations, and to provide a platform for high-assurance proofs of language properties.

We present JSCert, a formalisation of the current ECMA standard in the Coq proof assistant, and JSRef, a reference interpreter for JavaScript extracted from Coq to OCaml. We give a Coq proof that JSRef is correct with respect to JSCert and assess JSRef using test262, the ECMA conformance test suite. Our methodology ensures that JSCert is a comparatively accurate formulation of the English standard, which will only improve as time goes on. We have demonstrated that modern techniques of mechanised specification can handle the complexity of JavaScript.

Skip Supplemental Material Section

Supplemental Material

d1_right_t4.mp4

mp4

249.5 MB

References

  1. J. Alglave, L. Maranget, S. Sarkar, and P. Sewell. Fences in weak memory models. In Proc. CAV: 22nd International Conference on Computer Aided Verification, LNCS 6174, pages 258--272, 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. C. Anderson, P. Giannini, and S. Drossopoulou. Towards type inference for JavaScript. In ECOOP'05, pages 428--452. Springer, 2005. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. A. W. Appel. Verified software toolchain - (invited talk). In ESOP, pages 1--17, 2011. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. M. Batty, S. Owens, S. Sarkar, P. Sewell, and T.Weber. Mathematizing C++ concurrency. In POPL, pages 55--66, 2011. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. M. Batty, M. Dodds, and A. Gotsman. Library abstraction for C/C++ concurrency. In POPL, 2013. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. K. Bhargavan, A. Delignat-Lavaud, and S. Maffeis. Language-based defenses against untrusted browser origins. In USENIX Security Symposium, 2013. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. S. Bishop, M. Fairbairn, M. Norrish, P. Sewell, M. Smith, and K. Wansbrough. Engineering with logic: HOL specification and symbolic-evaluation testing for TCP implementations. In POPL, pages 55--66, 2006. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. S. Blazy and X. Leroy. Mechanized semantics for the Clight subset of the C language. J. Autom. Reasoning, 43(3):263--288, 2009.Google ScholarGoogle ScholarCross RefCross Ref
  9. E. Börger, N. G. Fruja, V. Gervasi, and R. F. Stärk. A high-level modular definition of the semantics of C#. Theor. Comput. Sci., 336 (2-3):235--284, 2005. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. C11. ISO/IEC 9899:2011. http://www.iso.org/iso/iso_catalogue/catalogue_tc/catalogue_detail.htm?csnumber=57853, 2011.Google ScholarGoogle Scholar
  11. A. Charguéraud. Pretty-big-step semantics. In ESOP, pages 41--60, 2013. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. R. Chugh and R. Jhala. Dependent types for JavaScript. CoRR, abs/1112.4106, 2011.Google ScholarGoogle Scholar
  13. R. Chugh, J. A. Meister, R. Jhala, and S. Lerner. Staged information flow for JavaScript. In PLDI'09, pages 50--62. ACM, 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. X. Clerc. Bisect. http://bisect.x9c.fr/, 2012.Google ScholarGoogle Scholar
  15. Compcert Team. Compcert. http://compcert.inria.fr/, 2013.Google ScholarGoogle Scholar
  16. D. Crockford. ADSafe: Making JavaScript safe for advertising. http://adsafe.org/, 2007.Google ScholarGoogle Scholar
  17. S. Drossopoulou and S. Eisenbach. Is the Java type system sound? In FOOL4, 1997.Google ScholarGoogle Scholar
  18. ECMA International. Test262. http://test262.ecmascript.org/, 2010.Google ScholarGoogle Scholar
  19. C. Ellison and G. Rosu. An executable formal semantics of C with applications. In POPL, pages 533--544, 2012. Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. A. Farzan, F. Chen, J. Meseguer, and G. Rosu. Formal analysis of Java programs in JavaFAN. In CAV, pages 501--505, 2004.Google ScholarGoogle Scholar
  21. C. Fournet, N. Swamy, J. Chen, P.-É. Dagand, P.-Y. Strub, and B. Livshits. Fully abstract compilation to JavaScript. In POPL, pages 371--384, 2013. Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. Free Software Foundation. C language testsuites: "C-torture" version 4.4.2. http://gcc.gnu.org/onlinedocs/gccint/C-Tests.html, 2010.Google ScholarGoogle Scholar
  23. D. Fugate. Test262 bug 56. https://bugs.ecmascript.org/show_bug.cgi?id=56, 2011.Google ScholarGoogle Scholar
  24. P. Gardner, S. Maffeis, and G. D. Smith. Towards a program logic for JavaScript. In POPL'12, pages 31--44. ACM, 2012. Google ScholarGoogle ScholarDigital LibraryDigital Library
  25. Google Inc. The Closure Compiler. https://developers.google.com/closure/compiler/, 2009.Google ScholarGoogle Scholar
  26. S. Guarnieri and V. B. Livshits. GATEKEEPER: Mostly static enforcement of security and reliability policies for JavaScript code. In USENIX Security Symposium, pages 151--168, 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  27. S. Guarnieri, M. Pistoia, O. Tripp, J. Dolby, S. Teilhet, and R. Berg. Saving the world wide web from vulnerable JavaScript. In ISSTA, pages 177--187, 2011. Google ScholarGoogle ScholarDigital LibraryDigital Library
  28. A. Guha, C. Saftoiu, and S. Krishnamurthi. The essence of JavaScript. ECOOP 2010, pages 126--150, 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  29. Y. Gurevich. Evolving algebras. In IFIP Congress (1), pages 423--427, 1994.Google ScholarGoogle Scholar
  30. D. Hedin and A. Sabelfeld. Information-flow security for a core of JavaScript. In CSF'12, pages 3--18. IEEE, 2012. Google ScholarGoogle ScholarDigital LibraryDigital Library
  31. D. Herman and C. Flanagan. Status report: specifying JavaScript with ML. In ML, pages 47--52, 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library
  32. D. Jang and K. Choe. Points-to analysis for JavaScript. Proc. of SAC'09, page 1930, 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  33. S. H. Jensen, A. Møller, and P. Thiemann. Type analysis for JavaScript. In SAS '09. Springer, 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  34. D. K. Lee, K. Crary, and R. Harper. Towards a mechanized metatheory of Standard ML. In POPL, pages 173--184, 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library
  35. S. Maffeis and A. Taly. Language-based isolation of untrusted JavaScript. In CSF'09. IEEE, 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  36. S. Maffeis, J. Mitchell, and A. Taly. ECMA 262-3 operational semantics. http://jssec.net/semantics/, 2007.Google ScholarGoogle Scholar
  37. S. Maffeis, J. Mitchell, and A. Taly. An operational semantics for JavaScript. In APLAS'08, pages 307--325. Springer, 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library
  38. S. Maffeis, J. Mitchell, and A. Taly. Isolating JavaScript with filters, rewriting, and wrappers. In ESORICS'09. Springer, 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  39. S. Maffeis, J. C. Mitchell, and A. Taly. Object capabilities and isolation of untrusted web applications. In Security and Privacy (SP), pages 125--140. IEEE, 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  40. G. Melquiond. Floats for Coq 2.1.0. http://flocq.gforge.inria.fr/, 2012.Google ScholarGoogle Scholar
  41. R. Milner, M. Tofte, and D. Macqueen. The Definition of Standard ML. MIT Press, Cambridge, MA, USA, 1997. ISBN 0262631814. Google ScholarGoogle ScholarDigital LibraryDigital Library
  42. Mozilla. Mozilla automated JavaScript tests. https://developer.mozilla.org/en-US/docs/SpiderMonkey/Running_Automated_JavaScript_Tests, 2013.Google ScholarGoogle Scholar
  43. T. Nipkow, L. C. Paulson, and M. Wenzel. Isabelle/HOL - A Proof Assistant for Higher-Order Logic, volume 2283 of Lecture Notes in Computer Science. Springer, 2002. Google ScholarGoogle ScholarDigital LibraryDigital Library
  44. M. Norrish. Formalising C in HOL. PhD thesis, Computer Lab., University of Cambridge, 1998.Google ScholarGoogle Scholar
  45. D. S. P. Phung and A. Chudnov. Lightweight self protecting JavaScript. In ASIACCS 2009. ACM Press, 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  46. C. Park, H. Lee, and S. Ryu. An empirical study on the rewritability of the with statement in JavaScript. In FOOL, 2011.Google ScholarGoogle Scholar
  47. C. Park, H. Lee, and S. Ryu. SAFE: Formal specification and implementation of a scalable analysis framewrok for ECMAscript. In FOOL, 2012.Google ScholarGoogle Scholar
  48. F. Pfenning and C. Schürmann. System description: Twelf - a metalogical framework for deductive systems. In CADE, pages 202--206, 1999. Google ScholarGoogle ScholarDigital LibraryDigital Library
  49. J. G. Politz, S. A. Eliopoulos, A. Guha, and S. Krishnamurthi. ADsafety: Type-based verification of JavaScript sandboxing. In USENIX Security Symposium, 2011. Google ScholarGoogle ScholarDigital LibraryDigital Library
  50. J. G. Politz, M. J. Carroll, B. S. Lerner, J. Pombrio, and S. Krishnamurthi. A tested semantics for getters, setters, and eval in JavaScript. SIGPLAN Not., 48(2):1--16, Oct. 2012. Google ScholarGoogle ScholarDigital LibraryDigital Library
  51. J. G. Politz, B. S. Lerner, H. Q. de la Vallee, T. Nelson, A. Guha, M. Carroll, and S. Krishnamurthi. Mechanized λJS. http://blog.brownplt.org/2012/06/04/lambdajs-coq.html, 2012.Google ScholarGoogle Scholar
  52. G. Richards, C. Hammer, B. Burg, and J. Vitek. The eval that men do - A large-scale study of the use of eval in JavaScript applications. In ECOOP'11, pages 52--78. Springer, 2011. Google ScholarGoogle ScholarDigital LibraryDigital Library
  53. G. Roşu and T. F. Şerbǎnuţǎ. An overview of the K semantic framework. Journal of Logic and Algebraic Programming, 79(6):397--434, 2010.Google ScholarGoogle ScholarCross RefCross Ref
  54. T. Schneidereit. Convert some array extras to self-hosted js implementations. https://hg.mozilla.org/mozilla-central/rev/5593cd83590e, 2012.Google ScholarGoogle Scholar
  55. P. Sewell, F. Z. Nardelli, S. Owens, G. Peskine, T. Ridge, S. Sarkar, and R. Strnisa. Ott: Effective tool support for the working semanticist. J. Funct. Program., 20(1):71--122, 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  56. D. Syme. Proving Java type soundness. In Formal Syntax and Semantics of Java, pages 83--118, 1999. Google ScholarGoogle ScholarDigital LibraryDigital Library
  57. A. Taly, Ú. Erlingsson, J. C. Mitchell, M. S. Miller, and J. Nagra. Automated analysis of security-critical JavaScript APIs. In IEEE Symposium on Security and Privacy, pages 363--378, 2011. Google ScholarGoogle ScholarDigital LibraryDigital Library
  58. The JSCert Team. Mozilla Bug 862771, V8 Issue 2529, ES6 Bugs 1442-1444, Test262 Bug 1445, 1450, 1600. https://bugzilla.mozilla.org/show_bug.cgi?id=862771, http://code.google.com/p/v8/issues/detail?id=2529, https://bugs.ecmascript.org/show_bug.cgi?id={1442-1445,1450,1600}, 2013.Google ScholarGoogle Scholar
  59. P. Thiemann. Towards a type system for analyzing JavaScript programs. In ESOP'05, pages 140--140. Springer, 2005. Google ScholarGoogle ScholarDigital LibraryDigital Library
  60. Various developers. Bugs in ES6, Test262 and browsers. https://bugs.webkit.org/show_bug.cgi?id={38970,104309} http://code.google.com/p/v8/issues/detail?id={705,2446} https://bugzilla.mozilla.org/show_bug.cgi?id=819125, 2010--2012.Google ScholarGoogle Scholar
  61. J. Ševčík, V. Vafeiadis, F. Zappa Nardelli, S. Jagannathan, and P. Sewell. Relaxed-memory concurrency and verified compilation. In Proc. POPL, 2011. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. A trusted mechanised JavaScript specification

      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

      Full Access

      • Published in

        cover image ACM SIGPLAN Notices
        ACM SIGPLAN Notices  Volume 49, Issue 1
        POPL '14
        January 2014
        661 pages
        ISSN:0362-1340
        EISSN:1558-1160
        DOI:10.1145/2578855
        Issue’s Table of Contents
        • cover image ACM Conferences
          POPL '14: Proceedings of the 41st ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages
          January 2014
          702 pages
          ISBN:9781450325448
          DOI:10.1145/2535838

        Copyright © 2014 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 the author(s) 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: 8 January 2014

        Check for updates

        Qualifiers

        • research-article

      PDF Format

      View or Download as a PDF file.

      PDF

      eReader

      View online with eReader.

      eReader