Back to Checks
chatgpt

ChatGPT service account credentials expire within the configured maximum

serviceaccount_credential_lifetime_within_maximum
Service: serviceaccountSeverity: medium
OfficialVerifiedPrivate
Categories:gen-aisecretsidentity-access
Resource Type:OpenAIServiceAccountCredential

Each unrevoked, unexpired service account credential is checked for an expiry no later than max_service_account_credential_days (default 90) after its creation.

Prowler logoProwlerprowler-provider-chatgpt

Risk

A long-lived credential stays useful to an attacker for its whole life if it leaks from a CI system or a developer machine.

Run this check with Prowler

Run in Prowler Cloud
Run
prowler chatgpt --checks serviceaccount_credential_lifetime_within_maximum

Recommendation

Revoke the credential and issue one with a shorter lifetime; rotate it on a schedule.

Check Code

from prowler.lib.check.models import Check

from prowler_provider_chatgpt.check_report import finding
from prowler_provider_chatgpt.services.serviceaccount.serviceaccount_client import serviceaccount_client


class serviceaccount_credential_lifetime_within_maximum(Check):
    def execute(self):
        maximum = serviceaccount_client.max_credential_days
        findings = []
        for account in serviceaccount_client.service_accounts or []:
            for credential in account["active_credentials"] or []:
                if credential["expires_at"] is None:
                    text = f"Service account credential {credential['name']} never expires."
                    findings.append(finding(self.metadata(), credential, False, text))
                    continue
                days = int((credential["expires_at"] - credential["created_at"]) // 86400)
                if days <= maximum:
                    text = f"Service account credential {credential['name']} lives {days} days, within the maximum of {maximum}."
                else:
                    text = f"Service account credential {credential['name']} lives {days} days, longer than the maximum of {maximum}."
                findings.append(finding(self.metadata(), credential, days <= maximum, text))
        return findings