Skip to main content

Excessive Privileges - Kubernetes

Description

Kubernetes default configuration is overly permissive, allowing users to escalate privileges or execute commands as privileged users.

Impact

Gain total control over one or more PoDs.

Recommendation

Set strict security policy disabling potentially harmful actions and restricting the user permissions.

Threat

Authenticated attacker with local access to PoD or container.

Expected Remediation Time

⌚ 30 minutes.

Score

Default score using CVSS 3.1. It may change depending on the context of the vulnerability.

Base

  • Attack vector: L
  • Attack complexity: L
  • Privileges required: L
  • User interaction: N
  • Scope: U
  • Confidentiality: L
  • Integrity: L
  • Availability: L

Temporal

  • Exploit code madurity: U
  • Remediation level: O
  • Report confidence: C

Result

  • Vector string: CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:L/I:L/A:L/E:U/RL:O/RC:C
  • Score:
    • Base: 5.3
    • Temporal: 4.6
  • Severity:
    • Base: Medium
    • Temporal: Medium

Code Examples

Compliant code

The resource has enabled safe security policies by restricting privileges to authorized users

apiVersion: v1
kind: Pod
metadata:
name: rss-site
labels:
app: web
spec:
privileged: false
containers:
- name: front-end
image: nginx
ports:
- containerPort: 80
securityContext:
capabilities:
add:
- SYS_ADMIN
- NET_ADMIN
- name: rss-reader
image: nickchase/rss-php-nginxv1
ports:
- containerPort: 88
apiVersion: v1
kind: Pod
metadata:
name: rss-site
labels:
app: web
spec:
containers:
- name: front-end
image: nginx
ports:
- containerPort: 80
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop:
- all
add:
- NET_BIND_SERVICE
- name: rss-reader
image: nickchase/rss-php-nginxv1
ports:
- containerPort: 88

Non compliant code

The resource does not enable safe security policies allowing privileged execution

apiVersion: v1
kind: Pod
metadata:
name: rss-site
labels:
app: web
spec:
privileged: true
containers:
- name: front-end
image: nginx
ports:
- containerPort: 80
securityContext:
capabilities:
add:
- SYS_ADMIN
- NET_ADMIN
- name: rss-reader
image: nickchase/rss-php-nginxv1
ports:
- containerPort: 88
apiVersion: v1
kind: Pod
metadata:
name: rss-site
labels:
app: web
spec:
containers:
- name: front-end
image: nginx
ports:
- containerPort: 80
securityContext:
allowPrivilegeEscalation: true
capabilities:
drop:
- all
add:
- NET_BIND_SERVICE
- name: rss-reader
image: nickchase/rss-php-nginxv1
ports:
- containerPort: 88

Details

https://kubernetes.io/docs/concepts/security/pod-security-standards/#restricted https://kubernetes.io/docs/concepts/policy/pod-security-policy/

Requirements

free trial

Search for vulnerabilities in your apps for free with our automated security testing! Start your 21-day free trial and discover the benefits of our Continuous Hacking Machine Plan. If you prefer a full service that includes the expertise of our ethical hackers, don't hesitate to contact us for our Continuous Hacking Squad Plan.