Rory McCune
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Versions and GitHub Sync Note Insights Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       owned this note    owned this note      
    Published Linked with GitHub
    Subscribed
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    Subscribe
    --- title: Kubernetes API server bypass risks description: > Security architecture information relating to the API server and other components content_type: concept --- <!-- overview --> The Kubernetes API server is the main point of entry to a cluster for external parties (users and services) interacting with it. As part of this role, several key security controls are present in the API server; for example: audit logging and admission control. However there are other ways in which the configuration or content of the cluster may be modified, which will bypass those controls. This page documents the ways that such a bypass could occur, so that cluster operators and security architects can ensure that they are appropriately restricted. <!-- body --> ## Static Pods The kubelet has [functionality](/docs/tasks/configure-pod-container/static-pod) which will load any manifests stored in a named directory, or fetched from a specific URL, as workloads in your cluster. An attacker with write access to this location could modify the configuration of static pods loaded from that source, or could introduce new static pods. Static pods have certain restrictions in place which prevent them from accessing other objects in the Kubernetes API (for example they can't be configured to mount a Secret from the cluster); however they can take other security sensitive actions, like using `hostPath` mounts from the underlying node. In the general case static pods are visible in the Kubernetes API as a {{< glossary_tooltip text="mirror pod" term_id="mirror-pod">}} is created by the kubelet, however if the attacker uses an invalid namespace name when creating the pod, it will not be visible via the Kubernetes API and can only be discovered by tooling which has access to the affected host(s). Creation of static pods is not subject to admission control, however if pod creation fails admission control it will prevent the pod being registered by the API server, although the pod will still run ([reference](https://github.com/kubernetes/kubeadm/issues/1541#issuecomment-487331701)). ### Mitigations - The static pod manifest feature should only be enabled on nodes where this is required for operation of the cluster. - Where it is used, access to the static pod manifest directory and/or URL should be restricted to administrative staff only. - Access to kubelet configuration parameters and files should be restricted to prevent an attacker setting a static pod path/URL. - All access to directories or web storage that hosts static manifests and Kubelet configuration files should be audited and centrally reported. ## Kubelet API The kubelet provides an HTTP API that is typically exposed on TCP port 10250 on cluster worker nodes, and potentially on control-plane nodes depending on the Kubernetes distribution in use. Direct access to the API allows for disclosure of information about the pods running on a node, the logs from those pods, and also execution of commands in every container running on the node. When Kubernetes cluster users have RBAC rights to Node object sub-resources, that access serves as authorization to interact with the kubelet API. The exact access will depend on which sub-resource access has been granted, as detailed in [kubelet authorization](https://kubernetes.io/docs/reference/access-authn-authz/kubelet-authn-authz/#kubelet-authorization). Direct access to the kubelet API is not subject to admission control and is not logged by Kubernetes audit logging. As such, an attacker who can use this API may be able to controls otherwise intended to detect/prevent certain actions. The kubelet API can be configured to authenticate requests in a number of ways. By default the kubelet configuration is to allow anonymous access. Most Kubernetes providers set configuration to use webhook and certificate authentication. This would enable the control plane to ensure that the caller is authorized to access the `nodes` API or its subresource. If set to anonymous access, there is no such assertion. ### Mitigations - Minimize access to subresources of the `nodes` API, using mechanisms such as RBAC. This access is likely to be needed for some services (for example: monitoring services) , but should not be provided where not needed. - Consider restricting access to the kubelet port, to only allow access from specified and trusted IP address ranges. - Ensure that kubelet authentication is set to webhook or certificate mode. ## Etcd API Kubernetes clusters use etcd as a datastore. The etcd service listens on TCP port 2379; the only clients that need access are the Kubernetes API server and any backup tooling that you use. Direct access to this API allows for disclosure or modification of any data held in the cluster. Access to the etcd API is typically managed by client certificate authentication. Any certificate issued by a certificate authority that etcd trusts will allow full access to the data stored inside etcd. Direct access to etcd is not subject to Kubernetes admission control and is not logged by Kubernetes audit logging. An attacker who is able to gain read access to the API server's etcd client certificate (or is able create a new trusted client certificate) can gain cluster admin rights by accessing cluster secrets or modifying access rules. Even without elevating their privileges, an attacker who can modify etcd can retrieve any API object or create new workloads inside the cluster. You can configure etcd in a number of ways. For the most part Kubernetes providers configure etcd to use mutual TLS (both client and server verify each other's certificate for authentication). There is not a widely accepted implementation of authorization for the etcd API, although the feature does exist. Since there is no authorization model, this means that any certificate with client access can be used to gain full access to etcd. Typically, client certificates that are only used for health checksing can also grant full read and write access. One way in which an attacker can make use of stolen etcd credentials is to create a special-purpose API server to manipulate resources in a cluster. All audit events would stay with the API server that handled the request and would therefore not be present in the audit log for the target cluster. This particular attack would be very difficult to detect, and easier to execute than creating data in etcd directly. ### Mitigations - Ensure that the certificate authority trusted by etcd is used only for the purposes of authentication to that service. - Control access to the private key for the etcd server certificate, and to the API server's client certificate and key. - Consider restricting access to the the etcd port at a network level, to only allow access from specified and trusted IP address ranges. ## Container runtime socket On each node in a Kubernetes cluster, access to interact with containers is controlled via the container runtime (or runtimes, if you have configured more than one). Typically, the container runtime exposes a Unix socket that the kubelet can access. An attacker with access to this socket can launch new containers or interact with running containers. The impact of this, at a cluster level, is likely to depend on whether there are containers running on the compromised node which have Secrets, or other confidential data, that could be used to escalate privileges to other nodes or cluster control plane components. ### Mitigations - Ensure that access permissions to container runtime sockets are tightly defined. Typically, you restrict this access to the `root` user. - Isolate the kubelet from other components running on the node, using container-like mechanisms such as Linux kernel namespaces. - Ensure that `hostPath` mounts which include the container runtime socket are restricted (or even forbidden). - Restrict user access to nodes, and especially restrict superuser access to nodes.

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully