Architectural Aid to Secure Systems Engineering: Stack Smashing

Architectural Aid to Secure Systems Engineering: Stack Smashing
Slide Note
Embed
Share

Stack smashing is a critical vulnerability in system security where attackers exploit buffer overflows to inject and execute malicious code. Understanding how stack frames work and how buffer overflows can lead to code execution is essential in preventing such attacks.

  • Security
  • Systems Engineering
  • Stack Smashing
  • Buffer Overflow
  • Cybersecurity

Uploaded on Feb 28, 2025 | 0 Views


Download Presentation

Please find below an Image/Link to download the presentation.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.

You are allowed to download the files provided on this website for personal or commercial use, subject to the condition that they are used lawfully. All files are the property of their respective owners.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.

E N D

Presentation Transcript


  1. Information Security - 2 Topic: Architectural Aid to Secure Systems Engineering V. Kamakoti RISE LAB, Department of Computer Science and Engineering IIT Madras SESSION 4: STACK SMASHING

  2. A Stack Frame. Pushed to stack on function CALL The return address is copied to the CPU Instruction Pointer when the function returns and it s stack frame is POP d.

  3. The buffer overflow vulnerability. The user injected data writes beyond the unchecked buffer length, overwriting the stack frame return address!

  4. Take control. The last byte of the buffer is the return address. To run arbitrary code of the users choice, set to the address of the buffer.

  5. Stack Buffers Suppose Web server contains this function void func(char *str) { char buf[126]; strcpy(buf,str); } When this function is invoked, a new frame with local variables is pushed onto the stack Allocate local buffer (126 bytes reserved on stack) Copy argument into local buffer Stack grows this way ret addr Top of stack Frame of the calling function str buf sfp Local variables Pointer to previous frame Execute code at this address after func() finishes Arguments

  6. What If Buffer is Overstuffed? Memory pointed to by str is copied onto stack void func(char *str) { char buf[126]; strcpy(buf,str); } If a string longer than 126 bytes is copied into buffer, it will overwrite adjacent stack locations strcpy does NOT check whether the string at *str contains fewer than 126 characters Top of stack str Frame of the calling function buf overflow This will be interpreted as return address!

  7. Executing Attack Code Suppose buffer contains attacker-created string For example, *str contains a string received from the network as input to some network service daemon Top of stack str Frame of the calling function ret code Attacker puts actual assembly instructions into his input string, e.g., binary code of execve( /bin/sh ) In the overflow, a pointer back into the buffer appears in the location where the system expects to find return address When function exits, code in the buffer will be executed, giving attacker a shell Root shell if the victim program is setuid root

  8. Spawn a shell. Write code such that a shell is spawned. provides platform independent code to spawn a shell. Shell command is executed in the program s security context . Allows user impersonation If program is running as root, the user now has total control of the host! Establish a Virtual Machine based Root Kit (VMBR) Learn it in Next Session

  9. End of Session-4 Thank You

More Related Content