Back to Checks
claude

Inactive Claude API key is within the documented cleanup window

apikey_inactive_keys_archived
Service: apikeySeverity: low
OfficialVerifiedPrivate
Categories:gen-aisecretsidentity-access
Resource Type:ClaudeApiKey

Deactivated keys are cleaned up. A deactivated key can be reactivated, so leaving old ones around keeps a dormant credential one click from working again.

Prowler logoProwlerprowler-provider-claude

Risk

A deactivated key can be reactivated, so leaving old ones around keeps a dormant credential one click from working again.

Run this check with Prowler

Run in Prowler Cloud
Run
prowler claude --checks apikey_inactive_keys_archived

Recommendation

Archive keys that have been inactive beyond your cleanup window.

Remediation

Other

1Archive keys that have been inactive beyond your cleanup window.

Check Code

from prowler.lib.check.models import Check

from prowler_provider_claude.lib.dates import age_in_days
from prowler_provider_claude.lib.report import CheckReportClaude
from prowler_provider_claude.services.apikey.apikey_client import apikey_client


class apikey_inactive_keys_archived(Check):
    """Deactivated keys are cleaned up."""

    def execute(self) -> list[CheckReportClaude]:
        maximum = apikey_client.audit_config.get("claude_max_inactive_key_days", 30)
        findings = []
        for key in [k for k in apikey_client.api_keys if k.status == "inactive"]:
            age = age_in_days(key.created_at)
            if age is None:
                continue
            report = CheckReportClaude(metadata=self.metadata(), resource=key)
            if age > maximum:
                report.status = "FAIL"
                report.status_extended = (
                    f"API key {key.name} has been inactive on an account created {age} day(s) "
                    f"ago, beyond the {maximum} day cleanup window, and can be reactivated."
                )
            else:
                report.status = "PASS"
                report.status_extended = f"API key {key.name} is inactive and within the {maximum} day cleanup window."
            findings.append(report)
        return findings