Question: Here's the vulnerable C code snippet: #include void malicious _ function ( ) { printf ( Malicious function executed! ) ; } void

Here's the vulnerable C code snippet:
#include
void malicious_function(){
printf("Malicious function executed!
");
}
void (*func_ptr)();
void vulnerable_function(){
// Vulnerability: Overwriting func_ptr with malicious_function's address
func_ptr = malicious_function;
}
int main(){
// Call vulnerable function
vulnerable_function();
// Indirect function call through func_ptr
func_ptr(); // Potential security risk if func_ptr is pointing to malicious_function
// Rest of the program
return 0;
}
With CFI enabled, describe in detail how it prevents the attack and ensures the control flow integrity.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!