Back to Checks
Prowlerprowler-provider-claude
Claude API key is scoped to a single workspace
apikey_workspace_scoped
Service: apikeySeverity: medium
OfficialVerifiedPrivate
Categories:gen-aisecretsidentity-access
Resource Type:ClaudeApiKey
API keys are bound to one workspace. An organization-scoped key reaches every workspace the linked account can reach, so one leaked key crosses the boundaries workspaces were created to draw.
Risk
An organization-scoped key reaches every workspace the linked account can reach, so one leaked key crosses the boundaries workspaces were created to draw.
Run this check with Prowler
Run in Prowler CloudRun
prowler claude --checks apikey_workspace_scopedRecommendation
Recreate organization-scoped keys inside the single workspace that needs them.
Remediation
Other
1Recreate organization-scoped keys inside the single workspace that needs them.
Check Code
from prowler.lib.check.models import Check
from prowler_provider_claude.lib.report import CheckReportClaude
from prowler_provider_claude.services.apikey.apikey_client import apikey_client
class apikey_workspace_scoped(Check):
"""API keys are bound to one workspace.
Scope is read from the ``scope`` object rather than the deprecated
top-level ``workspace_id``, which is null both for default-workspace keys
and for keys with no workspace at all.
"""
def execute(self) -> list[CheckReportClaude]:
findings = []
for key in [k for k in apikey_client.api_keys if k.status == "active"]:
report = CheckReportClaude(metadata=self.metadata(), resource=key)
if key.scope_type == "workspace":
report.status = "PASS"
report.status_extended = f"API key {key.name} is scoped to workspace {key.scope_workspace_id}."
else:
report.status = "FAIL"
report.status_extended = (
f"API key {key.name} is scoped to the whole organization rather than one "
f"workspace (scope.type is {key.scope_type or 'unset'})."
)
findings.append(report)
return findings