Exploitation As Code Reuse: on the Need of Formalization

Exploitation As Code Reuse: on the Need of Formalization

it 1/15 Exploitation as Code Reuse: On the Need of Formalization Sergey Bratus, Anna Shubina Abstract: This position paper discusses the need for modeling exploit computations and discusses possible formal approaches to it. ACM CCS: Security and privacy ! Formal methods and theory of security. Keywords: Exploitation, modeling, weird machines. 1 Introduction the security domain may be skewed due to the lack of uniform criteria. For example, Turing completeness of Exploitation of a vulnerability in software or hardware exploit programming models is a reasonable proxy for is making the system containing the vulnerability beha- the composability of their primitives|but is not equal ve unexpectedly. Since trustworthiness of a machine or to it. We may be under-studying practically important device is a matter of its expected behaviors, exploitation exploit models that are composable but not Turing com- is the central phenomenon of computer security. Acade- plete. mic computer security advances by formal models of the In this position paper, we attempt to unify the different computing phenomena it studies. Surprisingly, though, ideas regarding exploitation, and unpack the concepts it still lacks a unified formal approach to describing ex- possibly considered obvious|and thus overlooked. ploitation. One may argue that the concept of exploitation is so intuitive that it does not need formal definitions. Alt- hough we used to believe so in the past, we doubt it 2 Prior work now. For example, is being exploitable a property of a particular bug or feature, or a whole-system property of The understanding of exploitation as a programming the containing system? Our current terminology confu- discipline focusing on unexpected computation has a ses these alternatives. long history in the hacker community. Bratus et al. [8] give a sketch of how this discipline developed from lever- For a more substantive confusion, consider vastly diver- aging specific cases of memory corruption to chaining up gent treatment of exploitation across different techno- multiple primitives into powerful and generic program- logical domains. Academic literature on exploitation of ming models|up to Turing-completeness. executable binaries overwhelmingly uses the device of Turing completeness as a criterion of viable contributi- Exploits were understood both as proofs-by- on, whereas literature on exploitation of web applicati- construction of the unexpected computation's existence on platforms almost never uses this device, focusing in- (a.k.a. vulnerability) and as programs in their own stead on the specific techniques used (SQLi, XSS, etc.) right. But if exploits are programs, and generalize into or specific kinds of information that can be stolen. This programming models, what machines do they run on? is despite the fact that exploitation in both domains is Tautologically, exploits violate the expectations of the driven by crafted inputs and produces complex unex- original programmer or designer of the vulnerable soft- pected computations with unexpectedly meager means. ware, and hence their models of the target machine. The- This disparity is striking, and it persists across other se programmers or designers failed to see a richer ma- target domains. chine embedded or emergent in the target. Exploits run on these richer machines, and are proof-by-construction When closely related phenomena are treated so dif- that these richer machines exist. ferently, their root causes are masked, and their analysis is muddled. Research effort, after all, goes where success The term \weird machines", informally coined in [7] and is evident and likely to be recognized; our very view of expanded by [9], attempted to capture this intuition, by it { Information Technology 57 (2015) 1 c de Gruyter Oldenbourg 1 introducing the idea that an exploit's underlying execu- Intuitively, we might expect well-written programs to be tion model extended the programmer abstraction of the \stable" with respect to violations of their intermediary machine with additional \weird" states and transitions, conditions: we might expect small deviations from their arising, e.g., from memory corruptions or leaky abstrac- component preconditions to produce only small variati- tions. The underlying implementations or architectures ons in behavior. made these states representable and manipulable. The This expectation, however, is unfounded. The fact is manipulation (primarily, by means of crafted inputs) that correctness proofs of program verification—the was the subject of exploit programming, of \setting up, best weapon we have against unexpected execution|are instantiating, and programming the weird machine." [9] brittle with respect to any violations of their precondi- So formulated, the concept of a \weird machine" is in- tions. tuitive, and was indeed instantly recognizable to many exploitation researchers. This intuition has been applied 3.1 Program verification to a variety of programming models such as computa- tions driven by ELF metadata [21], x86 memory des- Proving the absence of unexpected computation is, of criptors [4], Linux kernel's signal-processing data struc- course, the holy grail of security|so it makes sense to tures [5], and Windows kernel's memory deduplication look at exploitation from the verification point of view. functionality [6], as well as others. Still, although pro- The foundations for proving correctness of computer ductive, it lacked a formal definition. programs were laid by the classic 1969 C.A.R. Hoare In [24], Vanegue produced the first formal definition paper [14]. for the weird machine as a computational phenomenon in the context of Proof-Carrying Code (PCC). Dullien in [10] constructs an architectural model demonstrating Hoare's formalism in a nutshell. In Hoare's con- the emergence of unexpected computation on a formally struction, code Q comes with pre-conditions P , and, defined platform. Vanegue in [25] develops an axiomatic given that these pre-conditions hold true, after execu- model connected with program verification. tion produces the post-conditions R (if Q terminates). Such statements P fQg R are written for all the ele- The purpose of this position paper is to explore the in- mentary operations of a programming language, and tuitions regarding exploitations in breadth rather than combined using intuitive Boolean logic axioms, such as: in depth. We leave the development of the formalisms to if P fQ1g R1 and R1 fQ2g R hold, then P fQ1 ; Q2g R the two papers mentioned above; here we discuss what hold. Then, if the entire program could be built up wi- could be formalized. thin the braces using such compositions, statement by statement, so that the condition P is empty|meaning \anything", \any circumstances"|then the program is 3 Exploitation and code reuse: a program considered proven to produce the desired post-condition, i.e., \proven correct". This construction from the ele- verification perspective mentary operations upwards is itself the proof|and cor- Code reuse in exploitation could be seen as a trivial responds directly to the more recent insights that pro- convenience (less attack payload to write and debug) or grams are proofs and propositions are types (cf. [26]). as a specialized trick to bypass certain protective mea- sures that prevent execution of foreign code (e.g., non- Code reuse vs proofs. An important property of the- executable stacks and heaps, or load-time code-signing se constructions is that they are brittle with respect to checks). When seen that way, code reuse may seem a violations of the pre-conditions at any point in the chain. marginal phenomenon that will be eventually mitigated No matter if some Q is proven correct under its precon- with further protective measures such as better ASLR, ditions P , we cannot assert anything about Q's behavior code diversity, etc. Defenders might also be tempted under a different P 0, however \small" (according to so- to apply these protections based on how desirable they me metric) the difference is. think the code is for the attackers to reuse (e.g., func- tion epilogues or indirect jumps for ROP), rather than Suppose we have a program fragment Q for which we throughout the code base. have proven P fQg R. Let us pose the question: what will Q compute, i.e., what set of post-conditions R it This view would be grossly misleading. If we take the can create, if we feed it inputs that don't obey P ? perspective that exploitation is unexpected computa- tion, then almost all code that runs under conditi- This is exactly how an exploit (re)uses Q. ons it was not meant to encounter|such as consu- For instance, can we use Q to construct a Turing- ming data not conforming to the type intended for its complete computation, similar to \weird machine" con- consumption|will likely perform unexpected computa- structions that reuse other code such as function epilo- tion. That is, any code that can have its assumptions gues, the ELF RTLD, or the x86 MMU? Can we use Q violated is potentially reusable by an exploit. as a primitive to combine with others in an exploit? In 2 short, what is the computational power of Q if we are located on the tape; for automata models, it is not spe- allowed to vary its inputs arbitrarily? cified where they exist before being fed in one by one, We can frame this question slightly differently. Given but we can assume a tape that moves only forward past P , Q, P fQg R and some variation P 0 of P , what can a fixed reading-only head. Nothing other that consump- we infer about the conditions R0 such

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    7 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