Back to Checks
openai

OpenAI project service accounts do not have the owner role

project_service_account_not_owner
Service: projectSeverity: medium
OfficialVerifiedPrivate
Categories:gen-aiidentity-access
Resource Type:OpenAIServiceAccount

Each service account in an active project is checked for a role other than owner.

Prowler logoProwlerprowler-provider-openai

Risk

A project owner can manage members, keys and settings. A service account's keys live in applications and pipelines, so owner rights there turn a leaked application key into control of the project.

Run this check with Prowler

Run in Prowler Cloud
Run
prowler openai --checks project_service_account_not_owner

Recommendation

Change the service account's role to member.

Remediation

CLI

curl -X POST https://api.openai.com/v1/organization/projects/<project_id>/service_accounts/<service_account_id> -H "Authorization: Bearer $OPENAI_ADMIN_KEY" -H "Content-Type: application/json" -d '{"role": "member"}'

Check Code

from prowler.lib.check.models import Check

from prowler_provider_openai.check_report import finding
from prowler_provider_openai.services.project.project_client import project_client


class project_service_account_not_owner(Check):
    def execute(self):
        accounts = project_client.service_accounts
        if accounts is None:
            return []
        findings = []
        for project in project_client.projects:
            for account in accounts.get(project["id"], []):
                resource = {
                    "id": account.get("id", ""),
                    "name": account.get("name") or account.get("id", ""),
                    "project": project["name"],
                    "role": account.get("role", ""),
                }
                owner = resource["role"] == "owner"
                text = f"Service account {resource['name']} in project {project['name']} has the {resource['role'] or 'no'} role."
                findings.append(finding(self.metadata(), resource, not owner, text))
        return findings