Skillpedia
النشر والسحابة (DevOps)35k · #8107

implementing-rbac-hardening-for-kubernetes

ما الذي تفعله

هذه المهارة تجعل نظام Kubernetes أكثر أماناً، بالتحكم في من يمكنه الوصول إلى ماذا. تضمن أن كل مستخدم أو خدمة تملك فقط الصلاحيات الضرورية لأداء مهامها، فتمنع الوصول غير المصرح به.

متى تستخدمها

  • ✓عندما تريد تقييد الوصول إلى الموارد المهمة في مجموعة Kubernetes الخاصة بك.
  • ✓عندما تُعدّ بيئة Kubernetes جديدة وتريد البدء بشكل آمن.
  • ✓عندما تشك في أن بعض حسابات الخدمة تملك صلاحيات أكثر من اللازم.

رابط المهارة

https://github.com/mukul975/Anthropic-Cybersecurity-Skills/blob/main/skills/implementing-rbac-hardening-for-kubernetes/SKILL.md

انسخه والصقه في الذكاء الاصطناعي الذي تستخدمه (Claude أو ChatGPT أو Cursor) واطلب منه اتباع التعليمات.

طريقة الاستخدام

أسهل طريقة: انسخ الرسالة والصقها في الذكاء الاصطناعي الذي تستخدمه. سيقرأ المهارة وينفّذ تعليماتها.

رسالة جاهزة للصق

استخدم هذه المهارة لمساعدتي: https://github.com/mukul975/Anthropic-Cybersecurity-Skills/blob/main/skills/implementing-rbac-hardening-for-kubernetes/SKILL.md اقرأ ملف SKILL.md في هذا الرابط ونفّذ تعليماته لمهمتي.
تريد أن يجد الذكاء الاصطناعي مهارات مثل هذه بنفسه؟ثبّت خادم Skillpedia MCP المجاني: سطر واحد، ويبحث في 15,000+ مهارة قبل كل مهمة.ثبّته في دقيقة واحدة →

مثال على ما تطلبه من الذكاء الاصطناعي

“كيف أقيّد وصول خدمة معينة إلى قراءة معلومات الـ pods فقط في مساحة الاسم «production»؟”

5 مهارات جديدة كل أسبوع. قراءة في دقيقة واحدة.

كيف تعمل

تحلل هذه المهارة الصلاحيات الموجودة، وتقترح إعدادات أكثر تقييداً أو تطبقها. يتضمن ذلك إنشاء قواعد وصول أكثر تحديداً (Roles) بدلاً من الصلاحيات الواسعة (ClusterRoles)، والتأكد من أن كل خدمة تستخدم هوية خاصة بها بأقل الصلاحيات.

المحتوى التقني (ملف SKILL.md الأصلي)

النص الأصلي من المؤلف، مباشرة من GitHub.

Implementing RBAC Hardening for Kubernetes

Overview

Kubernetes RBAC regulates access to cluster resources based on roles assigned to users, groups, and service accounts. Default configurations often grant excessive permissions, and without active hardening, RBAC becomes a primary attack vector for privilege escalation, lateral movement, and data exfiltration. Hardening requires implementing least-privilege principles, eliminating unnecessary ClusterRole bindings, separating service accounts, integrating external identity providers, and continuous auditing.

When to Use

  • When deploying or configuring implementing rbac hardening for kubernetes capabilities in your environment
  • When establishing security controls aligned to compliance requirements
  • When building or improving security architecture for this domain
  • When conducting security assessments that require this implementation

Prerequisites

  • Kubernetes cluster v1.24+ with RBAC enabled (default since v1.6)
  • kubectl access with cluster-admin for initial audit
  • External identity provider (OIDC) for user authentication
  • Audit logging enabled on the API server

Core Hardening Principles

1. Eliminate cluster-admin Sprawl

Audit and remove unnecessary cluster-admin bindings:

# List all cluster-admin bindings
kubectl get clusterrolebindings -o json | jq -r '
  .items[] |
  select(.roleRef.name == "cluster-admin") |
  "\(.metadata.name) -> \(.subjects[]? | "\(.kind)/\(.name) (\(.namespace // "cluster"))")"
'

2. Namespace-Scoped Roles Over ClusterRoles

Use Role and RoleBinding instead of ClusterRole and ClusterRoleBinding:

# Good: Namespace-scoped role
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
  namespace: application
  name: app-developer
rules:
  - apiGroups: ["apps"]
    resources: ["deployments"]
    verbs: ["get", "list", "watch", "create", "update", "patch"]
  - apiGroups: [""]
    resources: ["pods", "pods/log"]
    verbs: ["get", "list", "watch"]
  - apiGroups: [""]
    resources: ["configmaps"]
    verbs: ["get", "list"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
  namespace: application
  name: app-developer-binding
subjects:
  - kind: Group
    name: dev-team
    apiGroup: rbac.authorization.k8s.io
roleRef:
  kind: Role
  name: app-developer
  apiGroup: rbac.authorization.k8s.io

3. Dedicated Service Accounts Per Workload

apiVersion: v1
kind: ServiceAccount
metadata:
  name: payment-processor
  namespace: payments
automountServiceAccountToken: false  # Disable auto-mount
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: payment-processor
  namespace: payments
spec:
  template:
    spec:
      serviceAccountName: payment-processor
      automountServiceAccountToken: true  # Only mount when explicitly needed
      containers:
        - name: processor
          image: payments/processor:v2.1@sha256:abc...

4. Restrict Dangerous Permissions

Block permissions that enable privilege escalation:

# Dangerous verbs/resources to restrict:
# - secrets: get, list, watch (exposes all secrets in namespace)
# - pods/exec: create (enables command execution in pods)
# - pods: create with privileged securityContext
# - serviceaccounts/token: create (generates new tokens)
# - clusterroles/clusterrolebindings: create, update (self-escalation)
# - nodes/proxy: create (bypasses API server authorization)

# Safe read-only role example
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  name: security-viewer
rules:
  - apiGroups: [""]
    resources: ["pods", "services", "namespaces", "nodes"]
    verbs: ["get", "list", "watch"]
  - apiGroups: ["apps"]
    resources: ["deployments", "daemonsets", "statefulsets"]
    verbs: ["get", "list", "watch"]
  - apiGroups: ["networking.k8s.io"]
    resources: ["networkpolicies"]
    verbs: ["get", "list", "watch"]

5. OIDC Integration for User Authentication

# API server flags for OIDC integration
apiVersion: v1
kind: Pod
metadata:
  name: kube-apiserver
spec:
  containers:
    - name: kube-apiserver
      command:
        - kube-apiserver
        - --oidc-issuer-url=https://idp.company.com
        - --oidc-client-id=kubernetes
        - --oidc-username-claim=email
        - --oidc-groups-claim=groups
        - --oidc-ca-file=/etc/kubernetes/pki/oidc-ca.crt

RBAC Audit Process

Step 1: Enumerate All Bindings


…
الأسئلة الشائعة

ما هو RBAC؟

RBAC (التحكم في الوصول القائم على الأدوار) نظام يحدد ما يمكن للمستخدمين أو الخدمات فعله داخل Kubernetes، بناءً على «الأدوار» الممنوحة لهم.

لماذا تُعدّ صلاحية «cluster-admin» خطيرة؟

تمنح صلاحية «cluster-admin» سيطرة كاملة على مجموعة Kubernetes بأكملها. ومنحها لأشخاص أو خدمات كثيرة يزيد خطر الأخطاء أو الهجمات.

ماذا تعني «least-privilege»؟

تعني منح كل مستخدم أو خدمة الحد الأدنى من الصلاحيات اللازمة لأداء عملها، ولا أكثر. وهي مبدأ أمني أساسي.

التفاصيل

الوصف الأصلي من المؤلف

Hardens Kubernetes RBAC by designing least-privilege Roles and ClusterRoles, auditing RoleBindings, eliminating cluster-admin sprawl, separating service accounts, and integrating an external OIDC identity provider. Use when tightening cluster access control, removing excessive ClusterRoleBindings, or hardening service-account permissions against escalation and lateral movement. Keywords: RBAC, Rol

repo: mukul975/Anthropic-Cybersecurity-Skills

الشعبية

نجوم GitHub
35k
الترتيب
#8107
الترخيص
Apache-2.0
آخر تحديث
31‏/8‏/2026

هل هذه المهارة مفيدة؟

0

سجّل الدخول للتصويت.

التعليقات

  • …

المزيد من المهارات من هذا المستودع

مهارات مشابهة