Client Secrets are like passwords for applications registered in Microsoft Entra. They essentially act as a single-factor authentication method, allowing the application to authenticate with Microsoft Entra and access resources like the Microsoft Graph API or other APIs.
You can liken the use of a Client Secret by an application to a user account signing in without MFA; once they enter their password, there are no other challenges before they can access those resources.
Like a user without MFA, using Client Secrets poses similar risks. If a Client Secret is exposed, leaked, or given to the wrong person, you are just one step away from a major incident.
This poses a challenge for administrators managing Microsoft Entra… how do we allow standard users to manage applications where necessary, but prevent them from adding insecure authentication methods, such as a Client Secret to the application, which could lead to a breach?
Blocking the creation of Client Secrets at tenant level
A simple solution to the problem would be to block the creation of new client secrets at tenant level for your whole organisation. This would prevent any users, whether standard or administrator, from adding a new Client Secret to a newly created application, without impacting existing client secrets, or the creation of new client secrets on older applications (if you allow).
For this, you need to update the Tenant-wide application authentication method policy which can only be done via Microsoft Graph. If you don’t have the Microsoft Graph PowerShell SDK installed yet, check out this article: How To Install the Microsoft Graph PowerShell Module.
Start by connecting to Microsoft Graph using a Global Administrator account and consenting to the Policy.ReadWrite.ApplicationConfiguration permission.
Connect-MgGraph -Scope Policy.ReadWrite.ApplicationConfiguration Once connected, you can use the following code example from the Microsoft Graph PowerShell SDK to enable the ability to restrict the creation of client secrets.
$payload = @{
applicationRestrictions = @{
passwordCredentials = @(
@{
restrictionType = "passwordAddition"
maxLifetime = $null
restrictForAppsCreatedAfterDateTime = [System.DateTime]::Parse("2025-01-01T00:00:00Z")
}
)
}
}
Update-MgPolicyDefaultAppManagementPolicy -BodyParameter $payload Take a look at the payload above, notice the restrictForAppsCreatedAfterDateTime property within the code, which is set to the 1st of January 2025. This means that any app registration created after that date will not allow new Client Secrets to be created for them.
If I now go to the Entra admin center and create an application, if I try to add a Client Secret to it, I am met with the following error.
This is also true if I try to create the Client Secret as a Global Administrator or if I attempted to register a new application with a Client Secret using Microsoft Graph PowerShell (Which would authorise via a different service principal).
Allow Client Secrets for some applications
In a perfect world you should maintain strict control over this setting, by:
- Defining an internal policy for the use of Client Secrets.
- Enforce a policy to prevent creation after a certain date.
- Phase out existing client secrets over a certain time.
Unfortunately, this isn’t always perfect and in some edge cases, new applications may need to be created with a Client Secret attached. For this, a separate policy need to be created and applied to your application, which would overwrite the default policy.
Start by creating a new policy with your desired settings. Here I have created a new policy which just allows the creation of Client Secrets.
$params = @{
displayName = "Development App Policy"
description = "Allows use of Client Secrets for Dev apps"
isEnabled = $true
restrictions = @{
passwordCredentials = @(
@{
restrictionType = "passwordAddition"
state = "disabled"
maxLifetime = $null
}
)
}
}
New-MgPolicyAppManagementPolicy -BodyParameter $params Get-MgPolicyAppManagementPolicy cmdlet to get the policy and store it in a variable. $policy = Get-MgPolicyAppManagementPolicy | Where {$_.DisplayName -eq 'Development App Policy'} New-MgApplicationAppManagementPolicyByRef cmdlet. $params = @{
"@odata.id" = "https://graph.microsoft.com/v1.0/policies/appManagementPolicies/$($policy.id)"
}
New-MgApplicationAppManagementPolicyByRef -ApplicationId "a8869296-860c-47f4-ae21-f5057e18783b" -BodyParameter $params Once the policy is applied, the change is not instant. In my testing, it took around 30 mins for the change to take affect before I could then create Client Secrets on my application.
Removing a policy assignment
Remove-MgApplicationAppManagementPolicyAppManagementPolicyByRef cmdlet and define the ApplicationId (Object Id) and the Id of the policy you wish to remove. Remove-MgApplicationAppManagementPolicyAppManagementPolicyByRef `
-ApplicationId "a8869296-860c-47f4-ae21-f5057e18783b" `
-AppManagementPolicyId $policy.id 

Wow, this is what I call deep-dive, thanks for sharing. It would be awesome to put this into an Azure Policy.
This is now one of the settings in Baseline Security Mode in the 365 admin centre.