BYU logo Computer Science
CS 465 Introduction to Security and Privacy

Overflow defenses

Various defenses

  • note, attackers may find ways around some of these — see advanced reading

(1) make stack and heap non-executable

(2) stack canary

  • insert a randomly-chosen integer on the stack when a function is called
  • check that the canary is intact before examining the return pointer
  • can also use a heap canary
  • default with gcc — must turn off with -fno stack-protector

(3) address space layout randomization (ASLR)

(5) position-independent execution (PIE)

  • the binary is compiled so that each memory region has an offset from a fixed address, and the fixed address can change each time the binary is run
  • PIE enables the text and data positions to be randomly positioned by ALSR

(6) type-safe languages

(7) other

  • compiler bounds checking
  • safe C libraries
  • static analysis tools — tools that analyze your code and warn you

Adoption Barriers

  • no governing body
  • backwards compatibility
  • incomplete solutions

Advanced Reading