Encoding Information Flow in Haskell

Encoding Information Flow in Haskell

Encoding Information Flow in Haskell Peng Li Steve Zdancewic University of Pennsylvania University of Pennsylvania [email protected] [email protected] Abstract mode” available in the Perl language and the use of This paper presents an embedded security sublan- information-flow analysis to separate low-integrity com- guage for enforcing information-flow policies in the stan- ponents from high integrity components built in the dard Haskell programming language. The sublanguage SparkAda [3] language. provides useful information-flow control mechanisms in- One important reason why these domain-specific cluding dynamic security lattices, run-time code privi- security-typed languages have not been widely ap- leges and declassification, without modifying the base plied is that, because the information-flow policies are language. This design avoids the redundant work of pro- intended to apply in an end-to-end fashion, the whole sys- ducing new languages, lowers the threshold for adopting tem has to be written in the new language. However, it is security-typed languages, and also provides great flex- expensive to build large software systems in a new lan- ibility and modularity for using security-policy frame- guage. Doing so can be justified only if the benefit of us- works. ing the new language outweighs the cost of migrating to the The embedded security sublanguage is designed using new language—including the costs of retraining program- a standard combinator interface called arrows. Computa- mers and the time and expense necessary to port existing tions constructed in the sublanguage have static and ex- libraries and other code bases. plicit control-flow components, making it possible to im- Moreover, in practice, it may well be the case that only plement information-flow control using static-analysis tech- a small part of the system (maybe only a few variables niques at run time, while providing strong security guar- in a large program) has information-flow security require- antees. This paper presents a concrete Haskell implemen- ments. Although the system may be large and complex, tation and an example application demonstrating the pro- the secret information flow in the system may not be com- posed techniques. pletely unmanageable. In such cases, it is probably more convenient to use the programming language that best fits 1. Introduction the primary functionality of the system rather than its se- curity requirements, and manage security issues by tradi- Language-based information-flow security has a long, tional means such as code auditing and careful software en- rich history with many (mostly theoretical) results [11]. gineering practices. There is a language adoption threshold This prior work has focused mainly on the problems of based on the ratio of security requirements to functional- static program analysis for a wide variety of computation ity requirements, and this threshold is very high. models and policy features. Often these analyses are pre- sented as type systems whose soundness is justified by 1.1. Embedded security sublanguages some form of noninterference result. The approach is com- pelling because programming-language techniques can be This paper presents a different approach to enforcing used to specify and enforce security policies that cannot be information-flow security policies. Rather than producing achieved by conventional mechanisms such as access con- a new language from scratch, we show how to encode tradi- trol and encryption. Two full-scale language implementa- tional information-flow type systems using the general fea- tions have been developed: Jif [6, 4] by Myers et al. is a tures of existing, modern programming languages. In partic- variant of Java, and Flow Caml [13, 10] by Simonet et al. is ular, we show how the abstract datatype and typeclass fea- an extension of Caml. tures found in the general-purpose language Haskell can be However, despite this rather large (and growing!) used to build a module that effectively provides a security- body of work on language-based information-flow secu- typed sublanguage embedded in Haskell itself. This sublan- rity, there has been relatively little adoption of the proposed guage can interoperate smoothly with existing Haskell code techniques—two success stories are the “taint-checking while still providing strong information-flow security guar- antees. Importantly, we do not need to modify the design information might be quite complex, perhaps depend- or implementation of Haskell itself—we use features in its ing on information available only at run time. standard (but advanced) type system. Our solution to the first problem is to use arrows [5]. Our approach eliminates the adoption threshold for sys- Intuitively, arrows provide an abstract interface for defin- tems implemented in Haskell: such systems can be made ing embedded sublanguages that support standard program- more secure without completely rewriting them in a new ming constructs familiar to programmers: sequential com- language. The implementation can be a fine-grained mix- position, conditional branches, and loops. Haskell provides ture of normal code and security-hardened code (variables, convenient syntactic sugar for writing programs whose se- data and computations over secure data). The programmer mantics are given by an arrow implementation. needs to protect only sensitive data and computation using a To address the second problem, we use Haskell’s type- software library, which enforces the information-flow poli- class mechanism to give an interface for security lattices. cies throughout the entire system and provides end-to-end Programs written in the embedded language can be param- security goals like noninterference. eterized with respect to this interface. Moreover, the embed- Another benefit of our approach is flexibility. A special- ded language can easily be given security-specific features ized language like Jif must pick a fixed policy framework in such as a declassification operation or run-time representa- which the security policies are expressed. Considering the tion of privileges for access-control checks. plethora of possible features present in the literature with In both cases, we make use of Haskell’s strong type sys- regards to how to express the label lattice, declassification tem to guarantee that the abstractions enforcing the security options [12], dynamic policy information [14, 17], etc., it is policies are not violated. This encapsulation means that it is unlikely that any particular choice of policy language will not possible to use the full power of the Haskell language to be suitable for all programs with security concerns. By con- circumvent the information-flow checks performed by the trast, since it is much easier to build a library module than embedded language, for example. to build a new language, it is conceivable that different pro- Before diving into the details of how the embedded lan- grams would choose to implement entirely different policy guage is implemented, it is useful to see how we imag- frameworks. Our embedded sublanguage approach is mod- ine these techniques being used in practice. The next sec- ular in the sense that it provides an interface through which tion gives some example programs that illustrates how a the programmer can choose which policy framework and secure embedded language and the Haskell program can type system to use for specific security goals. In this pa- be smoothly integrated, explains some background about per we sketch one possible policy framework that illustrates Haskell syntax, and considers the issues with enforcing the one particular choice of label lattice, declassification mech- desired security properties. Section 3 describes the arrow anism, and support for dynamic policies, but others could interface and explains how it corresponds to the example. readily be implemented instead. Section 4 presents the detailed implementation of an arrow- Although we use Haskell’s advanced type system and based sublanguage for information-flow control. Section 5 helpful features like the ability to overload syntax, study- discusses some limitations and caveats with this approach ing how to encode information-flow policies in the context and describes some future work. Section 6 concludes. of Haskell can point to how similar efforts might be under- 2. Example use of the embedded language taken in more mainstream languages like Java. Also, since the features we use are intended to be “general purpose,” This section presents the features of our secure embed- they are more likely to find a home in a mainstream lan- ded sublanguage using code examples. We start by encod- guage than the less widely applicable security types. Evi- ing a security lattice and use simple program fragments to dence of this can be found, for example, in Sun’s recent ad- show how information-flow policies can be specified in pro- dition of parametric polymorphism, a key component of our grams. Then, we use a larger application to introduce de- approach, to Java. classification and policy enforcement mechanisms. 2.1. Encoding Security Lattices 1.2. Overview of technical development The security sublanguage provides a generic interface There are two key technical challenges in embed- for defining security labels as first-class values. A security ding a useful security-typed sublanguage in Haskell. The lattice can be implemented by the programmer using the first problem is that enforcing information-flow poli- Lattice typeclass: cies requires static analysis of the control flow graph

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    12 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us