Skip to content

API security

API key lifecycle: test scope, rotation and revocation

Review API key ownership, scope and expiry, then verify a revoked test key stops working without interrupting legitimate integrations.

By BugSnaps · Updated

Add BugSnaps as a preferred source on Google(opens in a new tab)

Want more of our security guides? Select BugSnaps and confirm your choice on Google.

Direct answer

API keys need an owner, limited permissions and a tested revocation process. Treat a key as a credential even when it identifies an application rather than a person.

Inventory keys and owners

List key identifiers, integration owners, permissions, creation dates and last-use information without collecting the secret values. Identify shared keys and unknown owners; a single key embedded in several clients makes rotation and incident containment harder.

Reference: OWASP REST Security Cheat Sheet.

Check the intended scope

Using a dedicated test key, exercise one allowed operation and one harmless operation outside its intended permission. Compare the response and actual state. An API gateway may authenticate a key while a downstream operation still needs an independent authorization decision.

  • Record the key identifier, not the key value.
  • Check each environment separately.
  • Confirm usage restrictions do not substitute for authorization.

Exercise rotation

Create a replacement test key, update the test integration through the supported secret store, and confirm its operation. Revoke the old key after the agreed overlap. Send the old key again to each relevant endpoint and verify rejection; account for documented caches and propagation delay.

Prepare for leakage

Agree on the owner, notification path and recovery steps before a real incident. Review logs for the key identifier and suspicious usage, use a secret manager rather than source code where practical, and verify that logs and error messages do not contain the full credential.

Assessment limits

A controlled test key cannot prove all issued keys have correct scope or that every client has been migrated. Rate limits and IP restrictions reduce exposure but do not establish identity or sufficient permissions on their own.

Frequently asked questions

Are API keys a substitute for user authorization?

Not necessarily. They may identify a calling application, while user identity and permission checks are still needed for protected resources.

Why test a revoked key again?

The control is effective only when previously issued credentials are rejected across relevant paths after the expected propagation period.

Primary sources and further reading

These guides combine published security guidance with practical assessment planning. Adapt checks to the owner's policy, environment, and authorized scope.

This guide was prepared with AI assistance using the linked sources and illustrative examples. Check current vendor guidance and your environment before making changes.

Apply the guide to your own assessment.

Start with an authorized target, known test data, and a clear scope. Use the report's evidence and coverage limits to decide which checks need further review.

Open MyPentest