> For the complete documentation index, see [llms.txt](https://ir0nstone.gitbook.io/notes/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ir0nstone.gitbook.io/notes/binexp/stack/pointer-authentication.md).

# Pointer Authentication

An Arm hardware protection to combat ROP

## Overview

Pointer Authentication is a hardware feature available for Arm devices to protect against ROP attacks. A **Pointer Authentication Code** (PAC) is generated from the value of a given pointer, and must be used to verify pointers before using them. This protection requires **hardware support**, as the assembly instructions (such as [`paciasp`](https://developer.arm.com/documentation/ddi0602/2024-03/Base-Instructions/PACIA--PACIA1716--PACIASP--PACIAZ--PACIZA--Pointer-Authentication-Code-for-Instruction-address--using-key-A-) and [`retaa`](https://developer.arm.com/documentation/ddi0602/2025-12/Base-Instructions/RETAA--RETAB--Return-from-subroutine--with-pointer-authentication-)) that are required for this must exist on the processor, and **compiler support**.

PAC has two keys, called Key A and Key B. The instruction `paciasp` will sign the Link Register (`lr`) using Key A and the SP register, and is often used at function entry (to store the return pointer). `pacibsp` will do the same, but with Key B.

At function exit, when LR is popped off the stack, we use the `retaa` instruction instead. This instruction authenticates the address in LR using Key A and SP and branches to the authenticated address. `retab` is used for Key B instead.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://ir0nstone.gitbook.io/notes/binexp/stack/pointer-authentication.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
