Blog

Introduction to Linux Kernel Exploitation: Mitigation Bypass (KASLR and SMEP) – Part 4

Introduction

In the previous post of this series, we exploited the vulnerability and managed to escalate privileges by executing a shell as the root user. We also addressed an issue during the execution of the exploit, ensuring system stability throughout the process.

However, the entire exploitation was performed with mitigations disabled. When setting up the environment—as shown in the first part of this series—we configured it with mitigations disabled to facilitate our analysis and testing. This is a widespread practice when conducting vulnerability research and exploit development.

Now that we have exploited the vulnerability successfully, we will enable the mitigations individually. Next, we will bypass them to ensure our exploit functions even in environments where these protections are active. The mitigations we will bypass are Supervisor Mode Execution Protection (SMEP) and Kernel Address Space Layout Randomization (KASLR). Others, such as Supervisor Mode Access Prevention (SMAP) and Kernel Page Table Isolation (KPTI), will remain disabled, and we will explain the reasoning behind this at the end of the post.

Continue reading “Introduction to Linux Kernel Exploitation: Mitigation Bypass (KASLR and SMEP) – Part 4” →

Introduction to Linux Kernel Exploitation: Exploitation – Part 3

Introduction

In the first post of this series, we configured the environment required to work on a Linux kernel vulnerability. In the second post, we successfully triggered the vulnerability using C code. Now, we will dive deeper into the kernel’s internal state to better understand it and expand our code into a functional exploit for privilege escalation.

Our goal in this post is to exploit it using the ret2usr (return-to-user) technique. While modern hardware and software mitigations have made this technique less viable, it remains a good introductory technique for learning Linux kernel exploitation. By mastering this classic technique, you will build the conceptual foundation necessary for our final post, where we will bypass SMEP mitigation using Return-Oriented Programming (ROP).

Beyond successfully gaining a root shell, our objective is to ensure the system remains stable and continues to function correctly after the exploit. Post-exploitation instability is a common challenge; because the kernel is the system’s core, any orphaned pointers or corrupted counters can lead to a crash. It is our responsibility to investigate these unstable states, understand their root causes, and restore the system’s equilibrium.

Continue reading “Introduction to Linux Kernel Exploitation: Exploitation – Part 3” →

Introduction to Linux Kernel Exploitation: Triggering the Vulnerability – Part 2

Introduction

In the previous post of this series, we presented an introduction to exploiting vulnerabilities in the Linux kernel. We set up the environment that allows us to work on the vulnerability chosen for this series. In this post, we will trigger the vulnerability through our proof of concept written in C. By doing this, we take an essential step towards successfully exploiting the vulnerability to achieve our end goal: a Local Privilege Escalation (LPE) bypassing most of the modern mitigations.

Fortunately, the commit (36eec020fab66 net: sched: fix NULL pointer dereference in mq_attach) that fixes the vulnerability also includes shell commands that trigger the vulnerability in its description. So, we already have a great starting point.

Bash
1) ip link add bond0 type bond
2) ip link set bond0 up
3) tc qdisc add dev bond0 root handle ffff: mq
4) tc qdisc replace dev bond0 parent ffff:fff1 handle ffff: mq

We will start by using shell commands to trigger the vulnerability, and at the end, we will have a C program that accomplishes that same goal and goes a bit further, preparing the scene for a proper exploit. By writing it in C code, we can understand the pieces better, trigger the vulnerability with greater precision, create payloads to be executed, and so on.

Continue reading “Introduction to Linux Kernel Exploitation: Triggering the Vulnerability – Part 2” →

Introduction to Linux Kernel Exploitation: Vulnerability and Environment – Part 1

Introduction

We conducted an online training course titled “Introduction to Linux Kernel Exploitation” between September and October 2024. The course was delivered in Portuguese. A few months before the start date, we published a series of blog posts exploiting a vulnerability in the Linux kernel to give attendees a preview of the curriculum. We believe many introductory materials for Linux kernel exploitation available online are not well-suited for newcomers. They often jump directly into complex heap manipulation strategies that are difficult for beginners to grasp. Our course, however, serves as a foundational introduction to the topic even for those who do not intend to work as security researchers.

Continue reading “Introduction to Linux Kernel Exploitation: Vulnerability and Environment – Part 1” →

Why is my shellcode being corrupted?

In 2022, while one of our researchers was developing our Linux Binary Exploitation training, he approached me with a curious issue. During the exploitation of the simplest case of a stack-based buffer overflow, the shellcode was being corrupted on GDB. It took us a while to figure out what was happening, but we understood it. At least, we thought we had understood.

I revisited that topic this week to teach the students of our training about that case and I noticed something that I hadn’t noticed back then. I noticed that the behavior he faced was an illusion! I then started to write this blog post aiming to show the illusion GDB creates and in the middle of it, when experimenting on GDB, I came across weird behaviors that I didn’t understand immediately.

That journey led me to discover much more about GDB than I knew when I started this blog post. The main points I discovered about GDB are that a breakpoint hit is not always caused by hardware or software breakpoints, and that GDB has a feature called Displaced Stepping (or Out-Of-Line execution) that hides the execution of instructions from the user.

Continue reading “Why is my shellcode being corrupted?” →

A brief analysis of a vulnerability in the glibc (CVE-2025-4802)

Para acessar este post em Português, clique aqui.

In this blog post, we present a brief analysis of vulnerability CVE-2025-4802 [1], which affects libc developed by the GNU project, glibc, across versions 2.27 to 2.38, spanning the years 2017 to 2023 [2].

In simple terms, this vulnerability allows statically linked ELF binaries that execute dlopen() [3] either implicitly or explicitly to load arbitrary libraries via the LD_LIBRARY_PATH environment variable on a SUID binary. In practical terms, this enables a user with limited privileges to execute arbitrary code with elevated permissions.

Our objective is to provide the foundational knowledge required to understand the issue comprehensively. We will analyze the root cause of the vulnerability, the patch, its security impact, and how the involved components – the loader, the dynamic linker, and the kernel – interact to enable binary execution on the system. The operating system used for this blog post is Ubuntu 22.04, as provided to the students during our Linux binary exploitation training course.

Continue reading “A brief analysis of a vulnerability in the glibc (CVE-2025-4802)” →

Breve análise de uma vulnerabilidade na glibc (CVE-2025-4802)

To access this post in English, click here.

Nessa publicação apresentamos uma análise sucinta da vulnerabilidade CVE-2025-4802 [1] que afeta a implementação da libc feita pelo projeto GNU, a GLIBC, das versões 2.27 à 2.38 , entre 2017 e 2023 [2].

Tratando brevemente a seu respeito, essa vulnerabilidade permite que binários ELF estaticamente ligados (statically linked), que executem dlopen() [3] de forma implícita ou explícita e com o bit SUID habilitado carreguem bibliotecas arbitrárias através da variável de ambiente LD_LIBRARY_PATH. Em outras palavras, ela permite que um usuário com privilégios limitados execute código arbitrário com privilégios elevados.

Nossa proposta é apresentar os conhecimentos necessários para entender o problema de forma ampla, analisar a causa da vulnerabilidade, a correção, o impacto e como os componentes envolvidos, o loader, dynamic linker e o kernel, se relacionam para permitir a execução de binários no sistema. O sistema operacional utilizado para este blog post é o Ubuntu 22.04, como fornecido aos estudantes durante a turma do treinamento de exploração de vulnerabilidades em binários em ambiente Linux.

Continue reading “Breve análise de uma vulnerabilidade na glibc (CVE-2025-4802)” →

O Mindset que Separa o Sênior do Júnior: Lições de Nelson Elhage

Publicamos o texto a seguir no grupo de inscritos em nossos treinamentos na semana passada e resolvemos compartilhar essa reflexão aqui para que outros também possam lê-lo.

Conversando com um amigo ontem sobre o blog post [1] que publicamos esta semana e ao qual vocês tiveram acesso prévio, ele me lembrou do artigo de Nelson Elhage, intitulado: Computers can be understood [2] (em português: “Computadores podem ser compreendidos”).

Nelson Elhage é atualmente engenheiro de sistemas na Anthropic e trabalhou anteriormente na Ksplice, Stripe e, provavelmente, em outras empresas de destaque. Para quem não conhece, a Ksplice era uma startup americana que resolveu um problema que muitos consideravam impossível na época: atualizar o kernel sem reiniciar o sistema! Em 2011, a Ksplice foi adquirida pela Oracle e hoje faz parte das soluções oferecidas pela empresa. Seu envolvimento na Ksplice, em um projeto notoriamente desafiador, por si só já demonstra as diversas habilidades de Nelson.

Continue reading “O Mindset que Separa o Sênior do Júnior: Lições de Nelson Elhage” →