---
title: "Run authenticated dynamic scans"
description: "Give a target one request header so an active scan can reach pages behind a login, and what happens to that credential."
---

Without a credential a scan sees what an anonymous visitor sees. To test the
pages behind a login, give the target **one request header** that authenticates
a request: an `Authorization` header, a session cookie, or an API key header.

## Set the header

On the target, choose **Settings** and, under **Authenticated scan**, enter the header's name and its value,
and save. With the API:

```bash
curl -sS -X PATCH https://app.trustivan.com/api/v1/dast/targets/$TARGET_ID \
  -H "Authorization: Bearer $TRUSTIVAN_KEY" -H "Content-Type: application/json" \
  -d '{"auth_header_name": "Authorization", "auth_header_value": "Bearer eyJ..."}'
```

| You have | Header name | Header value |
|---|---|---|
| A bearer token | `Authorization` | `Bearer <token>` |
| A session cookie | `Cookie` | `session=<value>` |
| An API key | `X-API-Key` (or whatever your API reads) | `<key>` |

The value is one line of up to 4096 characters. The name may not be a header
the HTTP client itself controls (`Host`, `Content-Length`, `Connection` and
similar).

To remove it, choose **Remove the stored credential** in the same dialog, or send `{"clear_auth": true}`.

## Use a test account

<Warning>
An authenticated active scan acts as that account. It will submit the forms and
call the operations that account can reach, with attack payloads in them. Use a
dedicated test account in a staging environment, with the least access that
still reaches what you want tested, and never an administrator's session.
</Warning>

<Warning>
The header is static. TRUSTIVAN sends exactly the value you stored, and never logs
in or refreshes it. If the token expires half-way through a scan, the rest of the
scan is unauthenticated, pages behind the login are simply not reached, and **no
warning tells you this happened**: the scan completes and can close findings on
pages it could no longer see. Set the token's lifetime to at least the target's
time limit, and replace the stored value before it expires.
</Warning>

## What happens to the credential

- It is **encrypted at rest** with a key derived for this purpose, and is
  covered by key rotation.
- It is **write-only**. No API response and no page returns it. A target
  reports `has_auth` and the header's name, never its value.
- It is **never logged**.
- It is sent **only by an active scan**, so only to an application whose
  ownership is verified at that moment, and **only to the target's origin**.
  A passive check of an unverified target does not send it.
- It is **redacted from evidence**. The header's value is replaced with
  `[redacted]` in the stored request excerpt, and also wherever the literal
  value appears in a response, which catches an application that echoes a
  header back.
- Setting or replacing it is recorded in the [audit trail](/concepts/audit-trail)
  as an event, without the value.

## JWT checks

When the credential is a bearer **JSON Web Token**, an active scan also tests
how the application verifies it, using that one token against the endpoint it
unlocks. It reports a finding when the endpoint accepts a token with
`alg: none`, accepts a token whose signature has been replaced, is signed with a
weak HMAC secret from a short built-in list, or still accepts a token whose
expiry has passed. These run only on an authenticated scan and only against an
endpoint that rejects an unauthenticated request, so they say something real
about that endpoint's checks. See
[Dynamic scanning](/concepts/dynamic-scanning#checks-trustivan-adds-to-the-engine).

## Limits of this method

One static header is the whole of what is supported. There is no form login, no
recorded or scripted login sequence, no OAuth or single sign-on flow, no
multi-step or multi-factor login, and no per-request signing. An application
that needs a fresh anti-forgery token on every form, or that ties a session to
something a header cannot carry, may be only partly reached. See
[Limits](/concepts/dynamic-scanning-limits).
