An authenticated API scan becomes anonymous when its token expires or its requests stop validating, so the server answers 401 to everything. The report then shows few findings, which looks like good news. Prevent it with a session check at the start, a canary request during the run, and a clear failure when the session dies.
How it happens
OWASP's reconnaissance guidance gives the core reason: when fuzzing authenticated APIs, you have to reproduce the session handling and recompute dynamic fields, such as nonces or signatures, for each request. A scanner that replays a captured request with a fixed token or a stale signature gets rejected.
Common causes:
- Access tokens with short lifetimes and no refresh in the tool.
- Per-request signatures or timestamps the scanner does not recompute.
- One-time or rotating tokens that a parallel request invalidates.
- A login step that works in a browser but needs a CAPTCHA or MFA prompt for automation.
- An account locked after repeated failures, or a test user whose password was rotated.
- A gateway rule that blocks the scanner's address after some number of requests.
Why it is dangerous
A scan that returns mostly 401 and 403 responses produces a short report. People read short reports as clean ones. In fact the scan tested only the login wall.
Detect it in three ways
| Check | How |
|---|---|
| Pre-flight | Before scanning, call one protected endpoint with the scan's credentials and require a 200 |
| Canary during the run | Every few minutes, repeat that same call. If it fails, stop and flag the run |
| Post-run response mix | Count status codes. A run dominated by 401 should be marked invalid |
Also compare run to run. If last week's scan made 3,000 successful authenticated calls and this week's made 40, something broke.
Prevent it
- Give the scan a test account with a long enough token lifetime for the run, or configure a refresh flow the tool understands.
- If requests are signed, supply the signing logic or a test mode, and say so in the handover to whoever runs the scan.
- Disable multi-factor prompts for the scan account only if policy allows, with a compensating control such as an address allow list and a short expiry.
- Exclude the scan account from lockout rules, or reset it before each run.
- Keep credentials in a secrets manager. Do not hard-code them in a scan config stored in a repository.
- Decide who is told when the canary fails. A silent failure is the whole problem.
What to report
Put the following in every scan report: the accounts used, whether the pre-flight and canaries passed, and the percentage of requests that were authenticated. A reviewer reading that line knows whether the result means anything.
For CI
In a pipeline, treat "scan lost its session" as a failure of the job, separate from "scan found issues". Otherwise a broken login step will pass your gate every night.
Worked example: a scan that looked clean for three weeks
A team runs a nightly active scan on its staging API. The reports show two or three low findings each night. Nobody worries. Then a manual tester finds an object access flaw in ten minutes. Why did the scanner miss it?
Investigation. The security engineer opens the raw scan log for the last run and counts status codes.
| Status | Count |
|---|---|
| 200 | 41 |
| 401 | 2,870 |
| 403 | 130 |
| Other | 12 |
Of about 3,000 requests, only 41 succeeded. The scan was logged in for roughly the first minute. Then something went wrong.
Cause. The test account's access token has a lifetime of fifteen minutes. The scan tool was configured with a token pasted in when the job was created, and it never refreshed it. Everything after the first few minutes was effectively anonymous. The first scan, three weeks ago, ran quickly while the token was fresh. As the API grew, the scan took longer and the token expired earlier in the run.
Why nobody noticed. The report listed findings only. It did not state how many requests were authenticated. The count of findings fell slowly, which looked like improvement.
The fix, in four parts
- Refresh. Configure the scan to obtain a new token before each run and to refresh during it, using the account's credentials from the secrets manager.
- Pre-flight. Before attacking anything, call a protected route and require a 200.
- Canary. Every two minutes during the run, repeat the call. If it returns 401, pause and log in again. If login fails, stop the scan and mark it failed.
- Report line. Add to every report: accounts used, canary pass rate, percentage of requests that returned success or an expected authorization error.
A related trap: expected 403 versus lost session
Not every 401 or 403 means the session died. A scan that tests whether a lower role can reach an admin route expects a 403. The pre-flight and canary calls must use routes where the account should succeed. Distinguish between "denied as intended" and "no longer logged in" by watching the canary, not by counting codes alone.
What to check in CI
In a pipeline, a failed canary should fail the job with a distinct message, such as "scan lost authentication", separate from "scan found issues". Otherwise a broken login step passes the gate every night with a green tick.
After the repair
The next night's run shows 2,600 successful authenticated calls, and nine findings, including the object access flaw the manual tester found. The team keeps a trend chart of authenticated request counts, so a sudden drop is visible at a glance.
The broader lesson: a result is only as good as the evidence that the test did what you think. For API scanning, the cheapest piece of evidence is a count of successful authenticated requests.
Try it yourself
Open the demo and look at how an example scan lists endpoints. Ask yourself what the same page would look like if every request had returned 401.
Click through it at your own pace, or open it full screen.
Quick check
Is a scan with few findings a good sign?
Only if the scan was authenticated for the whole run. Check the status code mix and the canary results before trusting it.
Should the scan account be an admin?
Use the roles you want to test, each with its own account. An admin-only scan hides authorization problems.
Can a longer token lifetime solve this on its own?
It can help for a short scan, but a refresh flow and a canary are safer. A longer lifetime on a test account is acceptable only if the account has no access to real data and expires soon.
Sources
Last reviewed: 19 October 2026.