IP Library › Granted Patent US 9,251,373
Granted Patent B2
US 9,251,373 · App. 13/804,056 · Granted Feb 2, 2016

Preventing stack buffer overflow attacks

Inventors: Khalid Nawaf AlHarbi (St. Manamah, SA); Xiaodong Lin (Waterloo, CA)
G06F21/64G06F21/52
View Patent ↗
Loading inventors, assignments & file history…
Monitor This Case
Get email alerts when status or documents change.
Order Certified Copies
Most orders are placed with the USPTO same day — all within 24 business hours.
Order via The Patent Place →
Pre-filled with this patent's details
Quick Facts
Patent No.
US 9,251,373
App. No.
13/804,056
Granted
Feb 2, 2016
Kind
B2
Abstract

Improved buffer overflow protection for a computer function call stack is provided by placing a predetermined ShadowKEY value on a function's call stack frame and copying the ShadowKEY, a caller EBP, and a return pointer are pushed onto a duplicate stack. The prologue of the function may be modified for this purpose. The function epilogue is modified to compare the current values of the ShadowKEY, caller EBP, and the return pointer on the function stack to the copies stored on the duplicate stack. If they are not identical, an overflow is detected. The preserved copies of these values may be copied back to the function stack frame thereby enabling execution of the process to continue. A function prologue and epilogue may be modified during compilation of the program.

Claims (118)

1. A method of protecting a function stack frame on a computer call stack, the function stack frame corresponding to a function, the method comprising:

modifying a prologue of the function wherein, when executed, the prologue performs the steps of:

creating in the function stack frame a starting ShadowKEY value, a starting extended base pointer (EBP) value, and a starting return pointer value; and

creating a duplicate stack frame on a duplicate stack different from the computer call stack, the duplicate stack frame comprising the starting ShadowKEY value, the starting EBP value, and the starting return pointer value; and

modifying an epilogue of the function wherein, when executed, the epilogue performs the steps of:

fetching from the function stack frame a finishing ShadowKEY value, a finishing EBP value, and a finishing return pointer value;

fetching from the duplicate stack frame the starting ShadowKEY value, the starting EBP value, and the starting return pointer value;

comparing the starting ShadowKEY value, the starting EBP value, and the starting return pointer value to the finishing ShadowKEY value, the finishing EBP value, and the finishing return pointer value, respectively; and

if any one of the starting ShadowKEY value, the starting EBP value, and the starting return pointer value is unequal to the finishing ShadowKEY value, the finishing EBP value, and the finishing return pointer value, respectively, replacing the finishing ShadowKEY value, the finishing EBP value, and the finishing return pointer value in the function stack frame with the starting ShadowKEY value, the starting EBP value, and the starting return pointer value, respectively; and

wherein the starting ShadowKEY value is pushed onto a duplicate stack which is located below the function's stack frame in memory.

2. A method of protecting a function stack frame on a computer call stack, the function stack frame corresponding to a function, the method comprising:

modifying a prologue of the function wherein, when executed, the prologue performs the steps of:

creating in the function stack frame a starting ShadowKEY value, a starting extended base pointer (EBP) value, and a starting return pointer value; and

creating a duplicate stack frame on a duplicate stack different from the computer call stack, the duplicate stack frame comprising the starting ShadowKEY value, the starting EBP value, and the starting return pointer value; and

modifying an epilogue of the function wherein, when executed, the epilogue performs the steps of:

fetching from the function stack frame a finishing ShadowKEY value, a finishing EBP value, and a finishing return pointer value;

fetching from the duplicate stack frame the starting ShadowKEY value, the starting EBP value, and the starting return pointer value;

comparing the starting ShadowKEY value, the starting EBP value, and the starting return pointer value to the finishing ShadowKEY value, the finishing EBP value, and the finishing return pointer value, respectively; and

if any one of the starting ShadowKEY value, the starting EBP value, and the starting return pointer value is unequal to the finishing ShadowKEY value, the finishing EBP value, and the finishing return pointer value, respectively, replacing the finishing ShadowKEY value, the finishing EBP value, and the finishing return pointer value in the function stack frame with the starting ShadowKEY value, the starting EBP value, and the starting return pointer value, respectively; and

wherein the duplicate stack frame is located below the function's stack frame in memory and comprises copies of a ShadowKEY, a caller EBP, and a return pointer.

3. A method of protecting a function stack frame on a computer call stack, the function stack frame corresponding to a function, the method comprising:

modifying a prologue of the function wherein, when executed, the prologue performs the steps of:

creating in the function stack frame a starting ShadowKEY value, a starting extended base pointer (EBP) value, and a starting return pointer value; and

creating a duplicate stack frame on a duplicate stack different from the computer call stack, the duplicate stack frame comprising the starting ShadowKEY value, the starting EBP value, and the starting return pointer value; and

modifying an epilogue of the function wherein, when executed, the epilogue performs the steps of:

fetching from the function stack frame a finishing ShadowKEY value, a finishing EBP value, and a finishing return pointer value;

fetching from the duplicate stack frame the starting ShadowKEY value, the starting EBP value, and the starting return pointer value;

comparing the starting ShadowKEY value, the starting EBP value, and the starting return pointer value to the finishing ShadowKEY value, the finishing EBP value, and the finishing return pointer value, respectively; and

if any one of the starting ShadowKEY value, the starting EBP value, and the starting return pointer value is unequal to the finishing ShadowKEY value, the finishing EBP value, and the finishing return pointer value, respectively, replacing the finishing ShadowKEY value, the finishing EBP value, and the finishing return pointer value in the function stack frame with the starting ShadowKEY value, the starting EBP value, and the starting return pointer value, respectively; and

wherein the starting ShadowKEY value is specified between the caller EBP and the local variables segments of the stack frame in the duplicate stack located below the function's stack frame in memory.

4. A method of protecting a function stack frame on a computer call stack, the function stack frame corresponding to a function, the method comprising:

modifying a prologue of the function wherein, when executed, the prologue performs the steps of:

creating in the function stack frame a starting ShadowKEY value, a starting extended base pointer (EBP) value, and a starting return pointer value; and

creating a duplicate stack frame on a duplicate stack different from the computer call stack, the duplicate stack frame comprising the starting ShadowKEY value, the starting EBP value, and the starting return pointer value; and

modifying an epilogue of the function wherein, when executed, the epilogue performs the steps of:

fetching from the function stack frame a finishing ShadowKEY value, a finishing EBP value, and a finishing return pointer value;

fetching from the duplicate stack frame the starting ShadowKEY value, the starting EBP value, and the starting return pointer value;

comparing the starting ShadowKEY value, the starting EBP value, and the starting return pointer value to the finishing ShadowKEY value, the finishing EBP value, and the finishing return pointer value, respectively; and

if any one of the starting ShadowKEY value, the starting EBP value, and the starting return pointer value is unequal to the finishing ShadowKEY value, the finishing EBP value, and the finishing return pointer value, respectively, replacing the finishing ShadowKEY value, the finishing EBP value, and the finishing return pointer value in the function stack frame with the starting ShadowKEY value, the starting EBP value, and the starting return pointer value, respectively; and

wherein the comparing comprises:

comparing the starting ShadowKEY value in the duplicate Stack to the finishing ShadowKEY value of the function Stack; and

only if the starting ShadowKEY value is equal to the finishing ShadowKEY value: comparing the starting EBP value in the duplicate Stack to the finishing EBP value of the function Stack; and

only if the EBP value is equal to the finishing EBP value:

comparing the starting return pointer value in the duplicate Stack to the finishing return pointer value of the function Stack.

5. A method of protecting a function stack frame on a computer call stack, the function stack frame corresponding to a function, the method comprising:

modifying a prologue of the function wherein, when executed, the prologue performs the steps of:

creating in the function stack frame a starting ShadowKEY value, a starting extended base pointer (EBP) value, and a starting return pointer value; and

creating a duplicate stack frame on a duplicate stack different from the computer call stack, the duplicate stack frame comprising the starting ShadowKEY value, the starting EBP value, and the starting return pointer value; and

modifying an epilogue of the function wherein, when executed, the epilogue performs the steps of:

fetching from the function stack frame a finishing ShadowKEY value, a finishing EBP value, and a finishing return pointer value;

fetching from the duplicate stack frame the starting ShadowKEY value, the starting EBP value, and the starting return pointer value;

comparing the starting ShadowKEY value, the starting EBP value, and the starting return pointer value to the finishing ShadowKEY value, the finishing EBP value, and the finishing return pointer value, respectively; and

if any one of the starting ShadowKEY value, the starting EBP value, and the starting return pointer value is unequal to the finishing ShadowKEY value, the finishing EBP value, and the finishing return pointer value, respectively, replacing the finishing ShadowKEY value, the finishing EBP value, and the finishing return pointer value in the function stack frame with the starting ShadowKEY value, the starting EBP value, and the starting return pointer value, respectively; and

wherein the starting EBP value is pushed onto a duplicate stack which is located below the function's stack frame in memory after the starting ShadowKEY.

6. A method of protecting a function stack frame on a computer call stack, the function stack frame corresponding to a function, the method comprising:

modifying a prologue of the function wherein, when executed, the prologue performs the steps of:

creating in the function stack frame a starting ShadowKEY value, a starting extended base pointer (EBP) value, and a starting return pointer value; and

creating a duplicate stack frame on a duplicate stack different from the computer call stack, the duplicate stack frame comprising the starting ShadowKEY value, the starting EBP value, and the starting return pointer value; and

modifying an epilogue of the function wherein, when executed, the epilogue performs the steps of:

fetching from the function stack frame a finishing ShadowKEY value, a finishing EBP value, and a finishing return pointer value;

fetching from the duplicate stack frame the starting ShadowKEY value, the starting EBP value, and the starting return pointer value;

comparing the starting ShadowKEY value, the starting EBP value, and the starting return pointer value to the finishing ShadowKEY value, the finishing EBP value, and the finishing return pointer value, respectively; and

if any one of the starting ShadowKEY value, the starting EBP value, and the starting return pointer value is unequal to the finishing ShadowKEY value, the finishing EBP value, and the finishing return pointer value, respectively, replacing the finishing ShadowKEY value, the finishing EBP value, and the finishing return pointer value in the function stack frame with the starting ShadowKEY value, the starting EBP value, and the starting return pointer value, respectively; and

wherein the starting return pointer value is pushed onto a duplicate stack which is located below the function's stack frame in memory after the starting EBP value.

7. A computer program product comprising a computer-readable memory storing instructions executable by a computer to protect a function stack frame on a computer call stack, the function stack frame corresponding to a function of:

modifying a prologue of the function wherein, when executed, the prologue performs the steps of:

creating in the function stack frame a starting ShadowKEY value, a starting extended base pointer (EBP) value, and a starting return pointer value; and

creating a duplicate stack frame on a duplicate stack different from the computer call stack, the duplicate stack frame comprising the starting ShadowKEY value, the starting EBP value, and the starting return pointer value; and

modifying an epilogue of the function wherein, when executed, the epilogue performs the steps of:

fetching from the function stack frame a finishing ShadowKEY value, a finishing EBP value, and a finishing return pointer value;

fetching from the duplicate stack frame the starting ShadowKEY value, the starting EBP value, and the starting return pointer value;

comparing the starting ShadowKEY value, the starting EBP value, and the starting return pointer value to the finishing ShadowKEY value, the finishing EBP value, and the finishing return pointer value, respectively; and

if any one of the starting ShadowKEY value, the starting EBP value, and the starting return pointer value is unequal to the finishing ShadowKEY value, the finishing EBP value, and the finishing return pointer value, respectively, replacing the finishing ShadowKEY value, the finishing EBP value, and the finishing return pointer value in the function stack frame with the starting ShadowKEY value, the starting EBP value, and the starting return pointer value, respectively; and

wherein the starting ShadowKEY value is pushed onto a duplicate stack which is located below the function's stack frame in memory.

8. A computer program product comprising a computer-readable memory storing instructions executable by a computer to protect a function stack frame on a computer call stack, the function stack frame corresponding to a function of:

modifying a prologue of the function wherein, when executed, the prologue performs the steps of:

creating in the function stack frame a starting ShadowKEY value, a starting extended base pointer (EBP) value, and a starting return pointer value; and

creating a duplicate stack frame on a duplicate stack different from the computer call stack, the duplicate stack frame comprising the starting ShadowKEY value, the starting EBP value, and the starting return pointer value; and

modifying an epilogue of the function wherein, when executed, the epilogue performs the steps of:

fetching from the function stack frame a finishing ShadowKEY value, a finishing EBP value, and a finishing return pointer value;

fetching from the duplicate stack frame the starting ShadowKEY value, the starting EBP value, and the starting return pointer value;

comparing the starting ShadowKEY value, the starting EBP value, and the starting return pointer value to the finishing ShadowKEY value, the finishing EBP value, and the finishing return pointer value, respectively; and

if any one of the starting ShadowKEY value, the starting EBP value, and the starting return pointer value is unequal to the finishing ShadowKEY value, the finishing EBP value, and the finishing return pointer value, respectively, replacing the finishing ShadowKEY value, the finishing EBP value, and the finishing return pointer value in the function stack frame with the starting ShadowKEY value, the starting EBP value, and the starting return pointer value, respectively; and

wherein the duplicate stack frame is located below the function's stack frame in memory and comprises copies of a ShadowKEY, a caller EBP, and a return pointer.

9. A computer program product comprising a computer-readable memory storing instructions executable by a computer to protect a function stack frame on a computer call stack, the function stack frame corresponding to a function of:

modifying a prologue of the function wherein, when executed, the prologue performs the steps of:

creating in the function stack frame a starting ShadowKEY value, a starting extended base pointer (EBP) value, and a starting return pointer value; and

creating a duplicate stack frame on a duplicate stack different from the computer call stack, the duplicate stack frame comprising the starting ShadowKEY value, the starting EBP value, and the starting return pointer value; and

modifying an epilogue of the function wherein, when executed, the epilogue performs the steps of:

fetching from the function stack frame a finishing ShadowKEY value, a finishing EBP value, and a finishing return pointer value;

fetching from the duplicate stack frame the starting ShadowKEY value, the starting EBP value, and the starting return pointer value;

comparing the starting ShadowKEY value, the starting EBP value, and the starting return pointer value to the finishing ShadowKEY value, the finishing EBP value, and the finishing return pointer value, respectively; and

if any one of the starting ShadowKEY value, the starting EBP value, and the starting return pointer value is unequal to the finishing ShadowKEY value, the finishing EBP value, and the finishing return pointer value, respectively, replacing the finishing ShadowKEY value, the finishing EBP value, and the finishing return pointer value in the function stack frame with the starting ShadowKEY value, the starting EBP value, and the starting return pointer value, respectively; and

wherein the comparing comprises:

comparing the starting ShadowKEY value in the duplicate Stack to the finishing ShadowKEY value of the function Stack; and

only if the starting ShadowKEY value is equal to the finishing ShadowKEY value: comparing the starting EBP value in the duplicate Stack to the finishing EBP value of the function Stack; and

only if the EBP value is equal to the finishing EBP value:

comparing the starting return pointer value in the duplicate Stack to the finishing return pointer value of the function Stack.

10. A computer program product comprising a computer-readable memory storing instructions executable by a computer to protect a function stack frame on a computer call stack, the function stack frame corresponding to a function of:

modifying a prologue of the function wherein, when executed, the prologue performs the steps of:

creating in the function stack frame a starting ShadowKEY value, a starting extended base pointer (EBP) value, and a starting return pointer value; and

creating a duplicate stack frame on a duplicate stack different from the computer call stack, the duplicate stack frame comprising the starting ShadowKEY value, the starting EBP value, and the starting return pointer value; and

modifying an epilogue of the function wherein, when executed, the epilogue performs the steps of:

fetching from the function stack frame a finishing ShadowKEY value, a finishing EBP value, and a finishing return pointer value;

fetching from the duplicate stack frame the starting ShadowKEY value, the starting EBP value, and the starting return pointer value;

comparing the starting ShadowKEY value, the starting EBP value, and the starting return pointer value to the finishing ShadowKEY value, the finishing EBP value, and the finishing return pointer value, respectively; and

if any one of the starting ShadowKEY value, the starting EBP value, and the starting return pointer value is unequal to the finishing ShadowKEY value, the finishing EBP value, and the finishing return pointer value, respectively, replacing the finishing ShadowKEY value, the finishing EBP value, and the finishing return pointer value in the function stack frame with the starting ShadowKEY value, the starting EBP value, and the starting return pointer value, respectively; and

wherein the starting EBP value is pushed onto a duplicate stack which is located below the function's stack frame in memory after the starting ShadowKEY.

11. A computer program product comprising a computer-readable memory storing instructions executable by a computer to protect a function stack frame on a computer call stack, the function stack frame corresponding to a function of:

modifying a prologue of the function wherein, when executed, the prologue performs the steps of:

creating in the function stack frame a starting ShadowKEY value, a starting extended base pointer (EBP) value, and a starting return pointer value; and

creating a duplicate stack frame on a duplicate stack different from the computer call stack, the duplicate stack frame comprising the starting ShadowKEY value, the starting EBP value, and the starting return pointer value; and

modifying an epilogue of the function wherein, when executed, the epilogue performs the steps of:

fetching from the function stack frame a finishing ShadowKEY value, a finishing EBP value, and a finishing return pointer value;

fetching from the duplicate stack frame the starting ShadowKEY value, the starting EBP value, and the starting return pointer value;

comparing the starting ShadowKEY value, the starting EBP value, and the starting return pointer value to the finishing ShadowKEY value, the finishing EBP value, and the finishing return pointer value, respectively; and

if any one of the starting ShadowKEY value, the starting EBP value, and the starting return pointer value is unequal to the finishing ShadowKEY value, the finishing EBP value, and the finishing return pointer value, respectively, replacing the finishing ShadowKEY value, the finishing EBP value, and the finishing return pointer value in the function stack frame with the starting ShadowKEY value, the starting EBP value, and the starting return pointer value, respectively; and

wherein the starting return pointer value is pushed onto a duplicate stack which is located below the function's stack frame in memory after the starting EBP value.

Assignments (1)
ASSIGNMENT OF LESS THAN ENTIRE INTEREST Recorded Mar 14, 2013
From: ALHARBI, KHALID NAWAF; LIN, XIAODONG
To: NORTHERN BORDERS UNIVERSITY
Reel/Frame 030003/0313 →
Priority Claims (1)
CA 2809516 · Mar 13, 2013 · national
Continuity (1)
Related Publication 20140283088A1 · Sep 18, 2014