> For the complete documentation index, see [llms.txt](https://docs.autopilotmonitor.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.autopilotmonitor.com/concepts/agent-lifecycle-and-security.md). Agents can also search and read this documentation through its [MCP server](https://docs.autopilotmonitor.com/~gitbook/mcp).

# Agent Lifecycle & Security

The temporary agent from installation to self-destruct: timeline backfill, certificate authentication, binary integrity, provenance, and what data is collected.

The Autopilot Monitor agent is a lightweight .NET application that exists on a device **only for the duration of the enrollment**. This page explains its lifecycle and the security measures built around it.

## Lifecycle

```mermaid
flowchart LR
    A[Bootstrap script<br/>via Intune] --> B{Guards pass?}
    B -- no --> X[Skip<br/>nothing stays]
    B -- yes --> C[Install agent +<br/>scheduled task SYSTEM]
    C --> D[Backfill IME logs<br/>from byte 0]
    D --> E[Real-time monitoring<br/>+ streaming]
    E --> F[Enrollment complete]
    F --> G[Final upload +<br/>optional diagnostics]
    G --> H[Self-destruct —<br/>only registry marker remains]
```

1. **Installation** — the [bootstrap script](https://docs.autopilotmonitor.com/getting-started/deploy-the-agent.md) installs the agent and a scheduled task running as SYSTEM, but only on devices that pass all pre-requisite guards.
2. **Backfill — the full timeline from T=0** — the Intune Management Extension (IME) writes detailed logs from the first second of enrollment, long before the agent exists. On first launch the agent reads those logs **from byte position zero** — including archived (rotated) files, processed in chronological order. Every app state change, phase transition, and script execution that happened before the agent arrived is reconstructed, so the timeline has no blind spots.
3. **Real-time monitoring** — after the backfill, the agent switches to incremental polling: it tracks its byte position in each log file and reads only new data, streaming events to the backend as they happen, alongside its own collectors (device info, performance snapshots, security posture, Windows Hello and ESP signals).
4. **Completion** — when the enrollment completes (see [Sessions & Statuses](https://docs.autopilotmonitor.com/concepts/sessions-and-statuses.md#how-completion-is-detected)), the agent performs a final upload and, if configured, collects a diagnostics package. As a hard backstop the agent stops after 6 hours of active time (standby does not count).
5. **Self-destruct** — the agent removes its files and scheduled task. The only artifact left is the registry marker `HKLM:\SOFTWARE\AutopilotMonitor\Deployed`, which permanently prevents re-installation on that device. Self-destruct behavior is configurable per tenant (e.g. keep the log file, reboot on completion). On top of the normal lifecycle there is a **48-hour emergency brake**: at every start the agent checks how old its enrollment phase is, and removes itself if it is older than 48 hours — no matter what state it is in. With pre-provisioning, the technician phase and the user phase each have their own 48 hours. The agent also removes itself when its session no longer exists, for example after you delete it or the retention period removes it. The one exception is a pre-provisioned device that is just starting its user phase: it is monitored as a new session. The agent also ends monitoring when Microsoft Entra keeps refusing Autopilot Monitor's access to your tenant (see [Enrollment Monitoring Is Interrupted](https://docs.autopilotmonitor.com/troubleshooting-and-support/enrollment-monitoring-interrupted.md)). No device can be validated then, so the agent stops at its first contact instead of retrying. Whether it removes its files follows your self-destruct setting.

{% hint style="info" %}
**Per-enrollment by design.** The agent is not a permanent management footprint. If you re-enroll a device (after a reset the registry marker is gone too, since a reset wipes the disk), a fresh agent is installed for the new enrollment.
{% endhint %}

## Authentication

* The agent authenticates every backend call with the device's **MDM client certificate** — the certificate Intune issues to the device during enrollment (mutual TLS). Only genuinely Intune-enrolled devices can talk to the backend.
* The certificate is **bound to your tenant**. Intune stamps your Microsoft Entra tenant ID into the certificate it issues, and the backend verifies that stamp against the tenant the request is made for. If the certificate was issued to a different Microsoft Entra tenant, the request is refused — even though the certificate itself is genuine and Microsoft-issued.
* On the backend side, **Autopilot Device Validation** additionally verifies the device is registered as an Autopilot device in *your* tenant before any session data is accepted.
* For the short window at the very start of OOBE where no MDM certificate exists yet, optional **Bootstrap Tokens** provide pre-MDM authentication (see [Bootstrap Script & Tokens](https://docs.autopilotmonitor.com/reference/bootstrap-script-and-tokens.md)).
* All communication uses HTTPS with TLS 1.2+.

## Binary integrity

Every stage between our build and the running process is verified, and the checks answer two different questions: a hash proves the bytes were not altered, a signature proves who produced them.

1. **Signed at build time** — the agent's executables and libraries are Authenticode-signed by glueckkanja AG in the build pipeline, before any hash is computed. Third-party libraries enter the package only with a valid signature from their own vendor; otherwise the release stops. A **catalog** that lists the hash of every file in the package is created and signed the same way. The deployment scripts are signed by the same publisher.
2. **Build-time hashes** — the pipeline computes a hash for the agent package (published in `version.json`) and one for the executable (stored in the backend configuration).
3. **Script verification on the device** — the loader you assign in Intune checks the publisher of the bootstrapper it downloads and that it is current, in a folder only SYSTEM and administrators can change, and refuses to run anything else.
4. **Download verification** — the bootstrapper and the agent's self-updater verify the package hash before installation; a mismatch aborts the install.
5. **Package verification on the device** — before anything from a package runs, it is checked against its signed catalog: the catalog must carry our signature, and every file must be present and unchanged, with nothing added. The bootstrapper unpacks into a protected folder of its own and installs only a verified package; the bootstrap-token script does the same; the agent's self-updater checks every update before a single file is replaced. A failed check aborts the installation, and an update that fails it is skipped while the running agent stays.
6. **Backend cross-check** — the expected hash is *also* delivered through the authenticated configuration endpoint, an independent second trust channel. Tampering would require compromising the download server and the backend API simultaneously.
7. **Runtime self-check** — the running agent hashes its own executable and compares it against the value from the backend; a mismatch raises an emergency alert.
8. **Protected install folder** — the agent's folder under ProgramData can only be changed by SYSTEM and administrators, so a signed-in user cannot add files that the agent would load.

The signature checks close a gap the hashes cannot: the published hash is served from the same host as the package, while the expected publisher is carried by the signed script itself. The catalog extends that check from our own binaries to every file of the package.

### Build provenance (Sigstore attestation)

Hashes prove a download arrived **unmodified** — they cannot prove where a binary came from. That gap is closed by **build provenance**: agent release packages are built by a public GitHub Actions pipeline that signs a provenance statement at build time (a [GitHub Artifact Attestation](https://docs.github.com/en/actions/security-for-github-actions/using-artifact-attestations), based on Sigstore keyless signing). The statement binds the package's SHA-256 digest to the exact source repository, commit, and workflow run that produced it, and is recorded in a public transparency log. A valid attestation cannot be created outside the official pipeline — not even by the project maintainers on a local machine.

You can verify any agent package yourself with the GitHub CLI:

```bash
gh attestation verify AutopilotMonitor-Agent.zip --repo okieselbach/AutopilotMonitor
```

Because the attestation is bound to the file digest, the same verification covers every distribution copy of the package — the GitHub Release download and the package the bootstrapper fetches from the download server are the identical, attested bytes.

{% hint style="info" %}
Attestations are available for agent releases built through the GitHub Actions release pipeline (agent versions published from July 2026 onwards). For earlier versions the SHA-256 chain above still applies in full.
{% endhint %}

## What data is collected

The agent collects **enrollment telemetry**, not user data:

* ESP phases and enrollment progress signals
* App installations (names, IDs, states, error codes) and script executions as reported by the IME
* Device information: hardware model, OS version/build, network configuration, security posture (e.g. Secure Boot status)
* Performance snapshots (CPU, memory, disk) during enrollment
* Optional, controlled by you: geo location (IP-based, for the Geographic Performance view), local admin account analysis, software inventory with vulnerability correlation, the ConfigMgr Watcher (whether the Configuration Manager client is installed, with service state, version and site code), and a diagnostics package — uploaded to the built-in hosted storage or, if you prefer full control, to **your own Azure Blob Storage**

What the agent collects is itself configurable through Agent Settings, Collectors, Analyzers, and [Gather Rules](https://docs.autopilotmonitor.com/rules/gather-rules.md) — with strict guardrails on what custom collection is allowed to touch.


---

# 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://docs.autopilotmonitor.com/concepts/agent-lifecycle-and-security.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.
