Chaos Mesh implements a comprehensive authorization system to ensure chaos experiments are executed securely and only by authorized users.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/chaos-mesh/chaos-mesh/llms.txt
Use this file to discover all available pages before exploring further.
Overview
Chaos Mesh uses Kubernetes’ native authorization mechanisms to control access to chaos experiments:- RBAC (Role-Based Access Control): Kubernetes RBAC controls who can create and manage chaos experiments
- Webhook-based Authorization: Validates user permissions when creating chaos resources
- Dashboard Security Mode: Token-based authentication for the web UI
- Namespace Isolation: Controls which namespaces can be affected by chaos experiments
Authorization Flow
When a user attempts to create a chaos experiment, Chaos Mesh performs authorization checks:- Webhook Validation: The
validate-authwebhook intercepts the request - Subject Access Review: Chaos Mesh performs a Kubernetes SubjectAccessReview to verify the user has permission
- Namespace Check: Validates the user has access to all affected namespaces
- Resource Creation: If authorized, the chaos resource is created
pkg/webhook/validate_auth.go:78-134
Security Modes
Controller Security Mode
Enables authorization validation in the admission webhook:Dashboard Security Mode
Requires users to provide credentials when using the dashboard:- Users must provide a Kubernetes service account token
- Dashboard uses the token to authenticate API requests
- Authorization checks use the user’s actual permissions
- Dashboard uses its own service account
- All users share the same permissions
- Not recommended for production
pkg/config/dashboard.go:42-43
GCP Security Mode
Enables Google Cloud Platform OAuth authentication:Dashboard Authorization
The dashboard uses a middleware to authorize API requests:- Extracts the user token from HTTP headers
- Determines the required verb (
listfor GET,patchfor modifications) - Creates a SelfSubjectAccessReview for the
chaos-mesh.orgresource group - Returns 403 if the user lacks permissions in the target namespace
Namespace-Level Authorization
The authorization validator checks permissions at the namespace level:pkg/webhook/validate_auth.go:119-128
Cluster-Level Privileges
Some chaos experiments require cluster-level privileges:- Experiments targeting multiple namespaces
- Experiments with empty namespace selector (cluster-wide)
- Physical machine chaos (affects nodes)
SubjectAccessReview API
Chaos Mesh uses Kubernetes SubjectAccessReview to validate permissions:pkg/webhook/validate_auth.go:142-163
Exempted Resource Types
Some resource types skip RBAC validation:AWSChaos,GCPChaos,AzureChaos(cloud provider chaos)PodNetworkChaos,PodIOChaos,PodHttpChaos(pod-level)PhysicalMachine(infrastructure resources)StatusCheck,RemoteCluster(supporting resources)WorkflowNode(internal workflow state)
pkg/webhook/validate_auth.go:36-47
Best Practices
Enable Security Mode
Always enable security mode in production:Use Service Account Tokens
Provide users with service account tokens with appropriate permissions:Implement Least Privilege
Grant users only the permissions they need:- Use
RoleandRoleBindingfor namespace-scoped access - Use
ClusterRoleandClusterRoleBindingonly when necessary - Create custom roles for specific chaos types if needed
Audit Authorization
Monitor authorization decisions:Troubleshooting
Permission Denied Errors
If users receive “forbidden” errors:- Check the user has the correct RBAC permissions
- Verify security mode is configured correctly
- Ensure the namespace is not filtered (if using
enableFilterNamespace) - Check SubjectAccessReview in controller logs
Dashboard Authentication Issues
If dashboard login fails:- Verify
securityMode: trueis set - Check the service account token is valid
- Ensure the service account has dashboard access permissions
- Review dashboard logs for authentication errors
Related Configuration
- See RBAC for role and permission details
- See Best Practices for production security recommendations