SlideShare a Scribd company logo
Stack Frame Protection
    with LD_PRELOAD




               @auth: pancake
               @place: FIST
               @date: 20040507
Outlook
●   Buffer overflows and stack basics;
●   Protection methods;
●   Target on preload;
●   LibSFP {aka my testing lib};
●   Internal work;
●   Few code examples;
●
    Links and EOF;
Buffer overflows basics
●   The first cause of insecurity;
●   Every function is closed into an stack
    frame.
●   The stack frame saves information
    about local variables and return
    pointer.
●   Programmers must focus in secure
    code, not just external security.
Protection methods
●   Development stage.
    –   Patches to Gcc that uses canary-based
        methods to ensure the SF integrity.
    –   Use lint to clean insecure function calls.
●   Runtime
    –   Ptrace-based security. 3x slower, but the
        most secure.
    –   Library-based security. Faster and
        protects almost basic bugs.
Preload method
●   Dynamically load of a library with
    LD_PRELOAD or ld.so.conf by ld.so;
●   Replacement for the most buggy
    function symbols by secure ones
    (strcpy, memcpy, strlen, ...);
●   Exists some libraries that do that:
    –   Libsafe – secure libc functions.
    –   Libformat - secure format strings.
●   Main problem: non-portable.
LibSFP
●   I decide to write a libformat/libsafe
    replacement.
●   Target on:
    –   UNIX-OSes portability (GNU,*BSD,...)
    –   Architecture portability (endian, stack)
    –   Open, active development. It's GPLd.
●
    Actually its development is stopped.
    But i'll be happy to receive
    contributions and follow the project.
Internal work
●   Basically it's a library that rewrites
    every symbol.
●   Cross all stack frames layers until find
    the current one.
●   Measures the current SF size and
    limits calls to this size.
●   Library can be configured at runtime
    –   Offset: Change overflow margins.
    –   Action: alert, ignore, force CoreDump...
Internal work
●   There are 3 kind of variables:
    –   Local –   stored in the stack frame. (easy to protect).

    –   Global –   stored in Heap. (difficult to know the limits).

    –   Malloc –    stored in Heap space with chunk header
        information. (the assigned space limits could be read from
        chunk headers).
●   Malloc techniques:
    –   LibSFP stores a magic value into the chunk header to
        separate global variables from chunked ones.
    –   Chunks are memory-aligned, it means that size isn't exact.
Internal work
●   There are 3 kind of variables:
    –   Local –   stored in the stack frame. (easy to protect).

    –   Global –   stored in Heap. (difficult to know the limits).

    –   Malloc –    stored in Heap space with chunk header
        information. (the assigned space limits could be read from
        chunk headers).
●   Malloc techniques:
    –   LibSFP stores a magic value into the chunk header to
        separate global variables from chunked ones.
    –   Chunks are memory-aligned, it means that size isn't exact.
Few examples



Now it's the moment for going to the
terminal and show some examples...
Links and EOF

●   Libsafe
    –   http://www.research.avayalabs.com/project/libsafe/
●   Immunix Gcc StackGuard
    –   http://www.cse.ogi.edu/DISC/projects/immunix/StackGuard/
●   Libsfp isn't released yet, but if I receive
    interest I would probably upload into:
    –   http://www.nopcode.org/
    –   http://pancake.host.sk/altres/src/
EOF
[questions,tips,apologise..]

More Related Content

PDF
Threads - Why Can't You Just Play Nicely With Your Memory?
PDF
Concurrent/ parallel programming
PDF
Threads - Why Can't You Just Play Nicely With Your Memory_
PPTX
LLJVM: LLVM bitcode to JVM bytecode
PPTX
Java variables and classes
PDF
RPC in Smalltalk
PPTX
Metasploit Module Development
PPT
Parallel programming
Threads - Why Can't You Just Play Nicely With Your Memory?
Concurrent/ parallel programming
Threads - Why Can't You Just Play Nicely With Your Memory_
LLJVM: LLVM bitcode to JVM bytecode
Java variables and classes
RPC in Smalltalk
Metasploit Module Development
Parallel programming

What's hot (20)

PDF
Dennis Benkert & Matthias Lübken - Patterns in a containerized world? - code....
PDF
Embedded Recipes 2018 - Shared memory / telemetry - Yves-Marie Morgan
PDF
IPv4aaS tutorial and hands-on
PPT
what every web and app developer should know about multithreading
PDF
Caffe + H2O - By Cyprien noel
PDF
NUMA and Java Databases
PPT
Lecture2
PDF
Stefan Richter - Writing simple, readable and robust code: Examples in Java, ...
PDF
An End to Order (many cores with java, session two)
PDF
Bloc: a Modern Core for Highly Dynamic Graphics
PDF
Pthread
PPTX
Java one2015 - Work With Hundreds of Hot Terabytes in JVMs
PDF
Multithreading
PPTX
PPTX
PDF
Userspace RCU library : what linear multiprocessor scalability means for your...
PDF
Memcached And MySQL
PDF
Unba.se – San Diego Rust – march 2017 (abridged)
PDF
Building Topology in NS3
PDF
Type safe, versioned, and rewindable stream processing with Apache {Avro, K...
Dennis Benkert & Matthias Lübken - Patterns in a containerized world? - code....
Embedded Recipes 2018 - Shared memory / telemetry - Yves-Marie Morgan
IPv4aaS tutorial and hands-on
what every web and app developer should know about multithreading
Caffe + H2O - By Cyprien noel
NUMA and Java Databases
Lecture2
Stefan Richter - Writing simple, readable and robust code: Examples in Java, ...
An End to Order (many cores with java, session two)
Bloc: a Modern Core for Highly Dynamic Graphics
Pthread
Java one2015 - Work With Hundreds of Hot Terabytes in JVMs
Multithreading
Userspace RCU library : what linear multiprocessor scalability means for your...
Memcached And MySQL
Unba.se – San Diego Rust – march 2017 (abridged)
Building Topology in NS3
Type safe, versioned, and rewindable stream processing with Apache {Avro, K...
Ad

Viewers also liked (20)

PDF
The Stack Frame
PPTX
How Functions Work
PPTX
CILK/CILK++ and Reducers
PDF
Task based Programming with OmpSs and its Application
PPTX
[若渴計畫]64-bit Linux Return-Oriented Programming
PDF
Numbers and Values in Objective-C and C Programming
PPTX
Cpu cycle
DOCX
Authoring tools worksheet
PPT
Wk1to4
PPTX
02 - Introduction to the cdecl ABI and the x86 stack
KEY
Python Yield
KEY
2장. Runtime Data Areas
PDF
Smashing The Stack
PDF
Functions in Objective-C and C Programming
PPTX
Introduction to Linux Exploit Development
PDF
Exploit techniques and mitigation
PPT
Introduction to pointers and memory management in C
PPT
Addressing
PPTX
Reversing & Malware Analysis Training Part 4 - Assembly Programming Basics
PDF
Low Level Exploits
The Stack Frame
How Functions Work
CILK/CILK++ and Reducers
Task based Programming with OmpSs and its Application
[若渴計畫]64-bit Linux Return-Oriented Programming
Numbers and Values in Objective-C and C Programming
Cpu cycle
Authoring tools worksheet
Wk1to4
02 - Introduction to the cdecl ABI and the x86 stack
Python Yield
2장. Runtime Data Areas
Smashing The Stack
Functions in Objective-C and C Programming
Introduction to Linux Exploit Development
Exploit techniques and mitigation
Introduction to pointers and memory management in C
Addressing
Reversing & Malware Analysis Training Part 4 - Assembly Programming Basics
Low Level Exploits
Ad

Similar to Stack Frame Protection (20)

PPTX
Pune-Cocoa: Blocks and GCD
PDF
PDF
High-Performance Networking Using eBPF, XDP, and io_uring
ODP
Quick introduction to Java Garbage Collector (JVM GC)
PPTX
Memory model
PPTX
Attack on the Core
PDF
Advanced Arm Exploitation
PPTX
Ice Age melting down: Intel features considered usefull!
PDF
Performance optimization techniques for Java code
PDF
Open Source Storage at Scale: Ceph @ GRNET
PDF
Linux kernel development chapter 10
PDF
Linux kernel development_ch9-10_20120410
PPTX
Open arkcompiler
PDF
Ippevent : openshift Introduction
PPTX
Back to the CORE
KEY
Polyglot and Functional Programming (OSCON 2012)
PDF
Performance Optimization of SPH Algorithms for Multi/Many-Core Architectures
PPTX
1 Introduction to JAVA.pptx
PDF
So you want to liberate your data?
PDF
Let's Talk Locks!
Pune-Cocoa: Blocks and GCD
High-Performance Networking Using eBPF, XDP, and io_uring
Quick introduction to Java Garbage Collector (JVM GC)
Memory model
Attack on the Core
Advanced Arm Exploitation
Ice Age melting down: Intel features considered usefull!
Performance optimization techniques for Java code
Open Source Storage at Scale: Ceph @ GRNET
Linux kernel development chapter 10
Linux kernel development_ch9-10_20120410
Open arkcompiler
Ippevent : openshift Introduction
Back to the CORE
Polyglot and Functional Programming (OSCON 2012)
Performance Optimization of SPH Algorithms for Multi/Many-Core Architectures
1 Introduction to JAVA.pptx
So you want to liberate your data?
Let's Talk Locks!

More from Conferencias FIST (20)

PDF
Seguridad en Open Solaris
PDF
Seguridad en Entornos Web Open Source
PDF
Spanish Honeynet Project
PDF
Seguridad en Windows Mobile
PDF
SAP Security
PDF
Que es Seguridad
PDF
Network Access Protection
PDF
Las Evidencias Digitales en la Informática Forense
PDF
Evolución y situación actual de la seguridad en redes WiFi
PDF
El Information Security Forum
PDF
Criptografia Cuántica
PDF
Inseguridad en Redes Wireless
PDF
Mas allá de la Concienciación
PDF
Security Metrics
PDF
PKI Interoperability
PDF
Wifislax 3.1
PDF
Network Forensics
PDF
Riesgo y Vulnerabilidades en el Desarrollo
PDF
Demostracion Hacking Honeypot y Análisis Forense
PDF
Security Maturity Model
Seguridad en Open Solaris
Seguridad en Entornos Web Open Source
Spanish Honeynet Project
Seguridad en Windows Mobile
SAP Security
Que es Seguridad
Network Access Protection
Las Evidencias Digitales en la Informática Forense
Evolución y situación actual de la seguridad en redes WiFi
El Information Security Forum
Criptografia Cuántica
Inseguridad en Redes Wireless
Mas allá de la Concienciación
Security Metrics
PKI Interoperability
Wifislax 3.1
Network Forensics
Riesgo y Vulnerabilidades en el Desarrollo
Demostracion Hacking Honeypot y Análisis Forense
Security Maturity Model

Recently uploaded (20)

PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PPT
Teaching material agriculture food technology
PDF
Empathic Computing: Creating Shared Understanding
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PPTX
Programs and apps: productivity, graphics, security and other tools
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PPTX
MYSQL Presentation for SQL database connectivity
PPTX
Cloud computing and distributed systems.
Diabetes mellitus diagnosis method based random forest with bat algorithm
Digital-Transformation-Roadmap-for-Companies.pptx
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Teaching material agriculture food technology
Empathic Computing: Creating Shared Understanding
Per capita expenditure prediction using model stacking based on satellite ima...
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
NewMind AI Weekly Chronicles - August'25 Week I
Programs and apps: productivity, graphics, security and other tools
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Understanding_Digital_Forensics_Presentation.pptx
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Spectral efficient network and resource selection model in 5G networks
Mobile App Security Testing_ A Comprehensive Guide.pdf
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Dropbox Q2 2025 Financial Results & Investor Presentation
MYSQL Presentation for SQL database connectivity
Cloud computing and distributed systems.

Stack Frame Protection

  • 1. Stack Frame Protection with LD_PRELOAD @auth: pancake @place: FIST @date: 20040507
  • 2. Outlook ● Buffer overflows and stack basics; ● Protection methods; ● Target on preload; ● LibSFP {aka my testing lib}; ● Internal work; ● Few code examples; ● Links and EOF;
  • 3. Buffer overflows basics ● The first cause of insecurity; ● Every function is closed into an stack frame. ● The stack frame saves information about local variables and return pointer. ● Programmers must focus in secure code, not just external security.
  • 4. Protection methods ● Development stage. – Patches to Gcc that uses canary-based methods to ensure the SF integrity. – Use lint to clean insecure function calls. ● Runtime – Ptrace-based security. 3x slower, but the most secure. – Library-based security. Faster and protects almost basic bugs.
  • 5. Preload method ● Dynamically load of a library with LD_PRELOAD or ld.so.conf by ld.so; ● Replacement for the most buggy function symbols by secure ones (strcpy, memcpy, strlen, ...); ● Exists some libraries that do that: – Libsafe – secure libc functions. – Libformat - secure format strings. ● Main problem: non-portable.
  • 6. LibSFP ● I decide to write a libformat/libsafe replacement. ● Target on: – UNIX-OSes portability (GNU,*BSD,...) – Architecture portability (endian, stack) – Open, active development. It's GPLd. ● Actually its development is stopped. But i'll be happy to receive contributions and follow the project.
  • 7. Internal work ● Basically it's a library that rewrites every symbol. ● Cross all stack frames layers until find the current one. ● Measures the current SF size and limits calls to this size. ● Library can be configured at runtime – Offset: Change overflow margins. – Action: alert, ignore, force CoreDump...
  • 8. Internal work ● There are 3 kind of variables: – Local – stored in the stack frame. (easy to protect). – Global – stored in Heap. (difficult to know the limits). – Malloc – stored in Heap space with chunk header information. (the assigned space limits could be read from chunk headers). ● Malloc techniques: – LibSFP stores a magic value into the chunk header to separate global variables from chunked ones. – Chunks are memory-aligned, it means that size isn't exact.
  • 9. Internal work ● There are 3 kind of variables: – Local – stored in the stack frame. (easy to protect). – Global – stored in Heap. (difficult to know the limits). – Malloc – stored in Heap space with chunk header information. (the assigned space limits could be read from chunk headers). ● Malloc techniques: – LibSFP stores a magic value into the chunk header to separate global variables from chunked ones. – Chunks are memory-aligned, it means that size isn't exact.
  • 10. Few examples Now it's the moment for going to the terminal and show some examples...
  • 11. Links and EOF ● Libsafe – http://www.research.avayalabs.com/project/libsafe/ ● Immunix Gcc StackGuard – http://www.cse.ogi.edu/DISC/projects/immunix/StackGuard/ ● Libsfp isn't released yet, but if I receive interest I would probably upload into: – http://www.nopcode.org/ – http://pancake.host.sk/altres/src/