Skip to content
/ lpcfi Public

Prototype of Live Path Control Flow Integrity as a C library

Notifications You must be signed in to change notification settings

mbarbar/lpcfi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

40 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LPCFI demo

This demo is intended to present a weakness of PICFI as overcome by LPCFI. Instructions to run the demo are provided below.

Implementation

LPCFI is implemented naively with a basic hash table serving as the fp-table. PICFI is not implemented but simulated. If a function address has been activated, the PICFI simulation regards such function as a legal target for any indirect call. This is more coarse than PICFI, but irrelevant for this demo.

The C code from the poster is available in demo.c.

Dependencies

  • Unix-like system
  • C compiler (at cc)
  • ar to create a static library
  • Python 2
    • This may be installed as python2 or python; this document will assume it is installed as python2.

Building

Simply run the build.sh script:

    sh buid.sh

Demo Instructions

  1. Build the demo binaries - demo-lpcfi and demo-picfi - according to the above build instructions.

  2. In a shell, run:

        python2 payload.py | ./demo-picfi
  1. The addresses of some functions will appear (attacking ASLR is orthogonal to our purposes).

    A prompt will appear asking for the desired value of fp when foo is called with argument n = 1. Enter the value of g as it appears without the leading '0x'.

  2. Press enter.

  3. A second prompt will appear asking for the desired value of fp when foo is called with argument n = 0. Enter the value of g again as before.

  4. Notice that PICFI allows g to be called during the second foo call despite that the only legal target at that point is h.

  5. Repeat steps 3 - 5 after running

        python2 payload.py | ./demo-lpcfi
  1. Notice that LPCFI prevents g from being called during the second foo call.

Other combinations may be input into the payload.

Extended Demo Instructions

The extended demo contains a vulnerability whereby an attacker may modify the value of a function pointer whose value directly depends upon the password entered by the user. When an incorrect password is input, op should be set to the value of nopriv and then called, and when the correct password ("secret") is input, op should be set to the value of priv and then called. This loops until "finish" is input as the password.

Observe the payload in payload.py - it,

  • on the first iteration, inputs the incorrect password and sets op to nopriv's value (as expected by the programmer)
  • on the second iteration, inputs the correct password and sets op to priv's value (also as expected by the programmer)
  • on the third iteration, inputs the incorrect password but sets op to priv's value (which is unexpected by the programmer)
  • finally, ends the demo by inputting "finish" as the password.
  1. Change to the extended demo directory.
        cd extended-demo
  1. Build the demo binaries - extended-demo-lpcfi and extended-demo-picfi - according to the above build instructions.

  2. Run

        python2 payload.py | ./extended-demo-picfi
  1. The addresses of some functions will appear (attacking ASLR is orthogonal to our purposes).

    A prompt will appear asking for the value of priv Enter the value of priv as it appears without the leading '0x'.

  2. Press enter.

  3. Repeat steps 4 and 5 for nopriv.

  4. Notice that PICFI allows the user to call the privileged operation on the third iteration since the privileged function has been activated.

  5. Repeat steps 4 - 6 after running

        python2 payload.py | ./extended-demo-lpcfi
  1. Notice that LPCFI prevents op from being called during the third iteration since it carries an illegal value unexpected by the programmer.

The payload may be modified for other combinations.

About

Prototype of Live Path Control Flow Integrity as a C library

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published