Back to Checks
openai

OpenAI project API key owners still have access to the project

apikey_owner_has_project_access
Service: apikeySeverity: high
OfficialVerifiedPrivate
Categories:gen-aisecretsidentity-access
Resource Type:OpenAIApiKey

Each enabled project API key is checked for an owner (user or service account) who still has effective access to the project.

Risk

A key keeps working after its owner leaves the project or the organization. Nobody owns it any more, so nobody rotates or revokes it, and a former member may still hold it.

Run this check with Prowler

Run in Prowler Cloud
Install
pip install --extra-index-url https://__token__:${PROWLER_REGISTRY_DOWNLOAD_API_KEY}@registry.prowler.com/simple/ "prowler-provider-openai[runtime]"
Run
prowler openai --checks apikey_owner_has_project_access

Recommendation

Delete the key, and issue a new one to a current project member or service account if it is still needed.

Remediation

CLI

curl -X DELETE https://api.openai.com/v1/organization/projects/<project_id>/api_keys/<key_id> -H "Authorization: Bearer $OPENAI_ADMIN_KEY"

Check Code

from prowler.lib.check.models import Check

from prowler_provider_openai.check_report import finding
from prowler_provider_openai.services.apikey.apikey_client import apikey_client
from prowler_provider_openai.services.apikey.apikey_service import label


class apikey_owner_has_project_access(Check):
    def execute(self):
        findings = []
        for key in apikey_client.project_keys or []:
            access = key["owner_project_access"]
            if access is None:
                continue
            if access == "inactive":
                text = f"{label(key)} is enabled but its owner no longer has access to the project."
            else:
                text = f"{label(key)} is owned by someone with access to the project."
            findings.append(finding(self.metadata(), key, access != "inactive", text))
        return findings