Proceedings Article10.1145/2535838.2535889
Gradual typing embedded securely in JavaScript
Nikhil Swamy,Cédric Fournet,Aseem Rastogi,Karthikeyan Bhargavan,Juan Chen,Pierre-Yves Strub,Gavin Bierman +6 more
- 08 Jan 2014
- Vol. 49, Iss: 1, pp 425-437
TL;DR: TS# , a gradual type system and source-to-source compiler for JavaScript, is presented and all the runtime invariants of the translation of TS# to JavaScript are proved, showing that translated programs are well-typed in JS#, a previously proposed dependently typed language for proving functional correctness of JavaScript programs.
read more
Abstract: JavaScript's flexible semantics makes writing correct code hard and writing secure code extremely difficult. To address the former problem, various forms of gradual typing have been proposed, such as Closure and TypeScript. However, supporting all common programming idioms is not easy; for example, TypeScript deliberately gives up type soundness for programming convenience. In this paper, we propose a gradual type system and implementation techniques that provide important safety and security guarantees.We present TS# , a gradual type system and source-to-source compiler for JavaScript. In contrast to prior gradual type systems, TS# features full runtime reflection over three kinds of types: (1) simple types for higher-order functions, recursive datatypes and dictionary-based extensible records; (2) the type any, for dynamically type-safe TS# expressions; and (3) the type un, for untrusted, potentially malicious JavaScript contexts in which TS# is embedded. After type-checking, the compiler instruments the program with various checks to ensure the type safety of TS# despite its interactions with arbitrary JavaScript contexts, which are free to use eval, stack walks, prototype customizations, and other offensive features. The proof of our main theorem employs a form of type-preserving compilation, wherein we prove all the runtime invariants of the translation of TS# to JavaScript by showing that translated programs are well-typed in JS# , a previously proposed dependently typed language for proving functional correctness of JavaScript programs.We describe a prototype compiler, a secure runtime, and sample applications for TS#. Our examples illustrate how web security patterns that developers currently program in JavaScript (with much difficulty and still with dubious results) can instead be programmed naturally in TS#, retaining a flavor of idiomatic JavaScript, while providing strong safety guarantees by virtue of typing.
read more
Chat with Paper
AI Agents for this Paper
Find similar papers on Google Scholar, PubMed and Arxiv
Write a critical review of this paper
Analyze citations of this paper to find unaddressed research gaps
Citations
Formal Verification of Smart Contracts: Short Paper
Karthikeyan Bhargavan,Antoine Delignat-Lavaud,Cédric Fournet,Anitha Gollamudi,Georges Gonthier,Nadim Kobeissi,Natalia Kulatova,Aseem Rastogi,Thomas Sibut-Pinote,Nikhil Swamy,Santiago Zanella-Béguelin +10 more
- 24 Oct 2016
TL;DR: This paper outlines a framework to analyze and verify both the runtime safety and the functional correctness of Ethereum contracts by translation to F*, a functional programming language aimed at program verification.
Foundations of Security Analysis and Design V: FOSAD 2007/2008/2009 Tutorial Lectures
TL;DR: This paper, summarizing the six hours lesson taught during the Summer School FOSAD’12, gives an overview of the test data selection techniques and provides a state-of-the-art about Model-Based approaches for security testing.
298
Understanding TypeScript
Gavin Bierman,Martín Abadi,Mads Torgersen +2 more
- 01 Aug 2014
TL;DR: TypeScript as mentioned in this paper is an extension of JavaScript intended to enable easier development of large-scale JavaScript applications, and it offers a module system, classes, interfaces, and a rich gradual type system.
Refined Criteria for Gradual Typing
Jeremy G. Siek,Michael M. Vitousek,Matteo Cimini,John Boyland +3 more
- 01 Jan 2015
TL;DR: This paper draws a crisp line in the sand that includes a new formal property, named the gradual guarantee, that relates the behavior of programs that differ only with respect to their type annotations, and argues that the gradually guarantee provides important guidance for designers of gradually typed languages.
174
Safe & Efficient Gradual Typing for TypeScript
Aseem Rastogi,Nikhil Swamy,Cédric Fournet,Gavin Bierman,Panagiotis Vekris +4 more
- 14 Jan 2015
TL;DR: It is concluded that, at least during development and testing, subjecting JavaScript/TypeScript programs to safe gradual typing adds significant value to source type annotations at a modest cost.
References
Robust defenses for cross-site request forgery
Adam Barth,Collin Jackson,John C. Mitchell +2 more
- 27 Oct 2008
TL;DR: This paper presents a new variation on CSRF attacks, login CSRF, in which the attacker forges a cross-site request to the login form, logging the victim into the honest web site as the attacker.
Gradual Typing for Functional Languages
Jeremy G. Siek,Walid Taha +1 more
- 01 Jan 2006
TL;DR: In this paper, the authors propose a gradual type system for functional languages with structural types, based on the intuition that the structure of a type may be partially known/unknown at compiletime and the job of the type system is to catch incompatibilities between the known parts of types.
Multiple facets for dynamic information flow
Thomas H. Austin,Cormac Flanagan +1 more
- 25 Jan 2012
TL;DR: Faceted values is introduced, a new mechanism for providing information flow security in a dynamic manner that overcomes limitations of static type systems and dynamic analyses, taking inspiration from secure multi-execution.
Authenticity by typing for security protocols
Andrew D. Gordon,Alan Jeffrey +1 more
- 11 Jun 2001
TL;DR: The main theorem guarantees that any well-typed protocol is robustly safe, that is, its correspondence assertions are true in the presence of any opponent expressible in spi.
Information-Flow Security for a Core of JavaScript
Daniel Hedin,Andrei Sabelfeld +1 more
- 25 Jun 2012
TL;DR: A dynamic type system is developed that guarantees information-flow security for Java Script, powerful enough to naturally encode native constructs as arrays, as well as functionalities of Java Script's API from the document object model related to document tree manipulation and event processing.
Related Papers (5)
Philip Wadler,Robert Bruce Findler +1 more
- 28 Mar 2009
Jeremy G. Siek,Walid Taha +1 more
- 01 Jan 2006
Sam Tobin-Hochstadt,Matthias Felleisen +1 more
- 22 Oct 2006
Robert Bruce Findler,Matthias Felleisen +1 more
- 17 Sep 2002
Fritz Henglein
- 01 Jun 1994