Aller au contenu

Hardcoded Secret (ARCH7110)

Ce contenu n’est pas encore disponible dans votre langue.

Key php.security.hardcoded-secret · Severity error · Category security · CWE CWE-798

Keeping secrets, API keys, passwords, and private keys as string literals in source gives the credential to anyone with repository access and makes rotation impossible.

<?php
$client = new ApiClient(['api_key' => 'sk_live_4eC39HqLyjWDarjtT1zdp7dc']);
<?php
$client = new ApiClient(['api_key' => getenv('STRIPE_API_KEY')]);

Read all secrets from environment variables or a secret manager; never keep them in source control.