Ensure legacy authorization is set to disabled on Kubernetes clusters. The legacy authorizer in Kubernetes grants broad, statically defined permissions.
To remediate the “Legacy Authorization Should Be Disabled” misconfiguration in GCP using GCP console, follow these steps:
Open the GCP console and navigate to the IAM & Admin page.
Click on the “Settings” tab.
Scroll down to the “Authorization” section.
Under “Legacy authorization”, click on the “Edit” button.
Select the checkbox for “Disable project-wide legacy authorization”.
Click on the “Save” button to apply the changes.
Once you have completed these steps, legacy authorization will be disabled for your GCP project. It is recommended to periodically review your IAM settings to ensure that they are up-to-date and secure.
Check if the “allUsers” or “allAuthenticatedUsers” member exists in any of the IAM policy’s bindings:
Copy
Ask AI
for binding in policy.bindings: if 'allUsers' in binding.members or 'allAuthenticatedUsers' in binding.members: binding.members = [m for m in binding.members if m not in ['allUsers', 'allAuthenticatedUsers']]
Print a message indicating that the remediation is complete:
Copy
Ask AI
print('Legacy authorization has been disabled.')
Save the script and run it using the command:
Copy
Ask AI
python script.py
This will remediate the “Legacy Authorization Should Be Disabled” misconfiguration in GCP by removing the “allUsers” and “allAuthenticatedUsers” members from any IAM policy bindings that contain them.