smoshiur1237
    • 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
    # Security vulnerabilily tool Kube-hunter and Kube-bench There are some vulnerability detection tools available, such as **kube-hunter** and **kube-bench** for kubernetes cluster. User can check and scan cluster both from inside or outside of the kubernetes cluster. The following information can be used for future use of these vulnerability tools in **metal3-dev-env**. Here is the step by step instructions for using **kube-hunter** and **kube-bench** as a vulnerability tool. ## **Kube-hunter** * Installing kube-hunter ``` which pip pip --version kubelet --version pip install --user kube-hunter which kube-hunter kube-hunter --help kube hunter ``` * **kube-hunter** command will list options for scanning the cluster, choose 1 for remote scanning and provide the internal IP for the node. It will print the following as a scan result for kind cluster. ``` Vulnerabilities For further information about a vulnerability, search its ID in: https://avd.aquasec.com/ +--------+-----------------+----------------------+----------------------+----------------------+----------+ | ID | LOCATION | MITRE CATEGORY | VULNERABILITY | DESCRIPTION | EVIDENCE | +--------+-----------------+----------------------+----------------------+----------------------+----------+ | KHV002 | 172.18.0.2:6443 | Initial Access // | K8s Version | The kubernetes | v1.23.4 | | | | Exposed sensitive | Disclosure | version could be | | | | | interfaces | | obtained from the | | | | | | | /version endpoint | | +--------+-----------------+----------------------+----------------------+----------------------+----------+ ``` * User can check the cluster from ephemeral cluster and give the internal ip for master and worker. For control plane node the output can be shown as: ``` Vulnerabilities For further information about a vulnerability, search its ID in: https://avd.aquasec.com/ +--------+----------------------+----------------------+----------------------+----------------------+----------+ | ID | LOCATION | MITRE CATEGORY | VULNERABILITY | DESCRIPTION | EVIDENCE | +--------+----------------------+----------------------+----------------------+----------------------+----------+ | KHV002 | 192.168.111.100:6443 | Initial Access // | K8s Version | The kubernetes | v1.23.5 | | | | Exposed sensitive | Disclosure | version could be | | | | | interfaces | | obtained from the | | | | | | | /version endpoint | | +--------+----------------------+----------------------+----------------------+----------------------+----------+ ``` * User can scan the for vulnerabilities from the control plane or worker node. Follow the same installation of kube-hunter and scan the cluster. * The ID **KHV00**2 indicates the information ID regarding the vulnerability. User can check the details and get remediation suggestion from this [link](https://avd.aquasec.com/). * We approached to test the scanning from inside the cluster whrere **kube-hunter** will run inside the cluster as a pod. But facing issues regarding cluster access. This issue was happening with many other users of this tool but no visible solution was given by the community. * Running the **kube-hunter** tests inside the cluster could be substituted by running **kube-bench** inside the cluster as explained in the next chapter. * The following information was printed when tried to run as a pod inside the cluster. ``` kubectl logs pod/kube-hunter-nhsdw Vulnerabilities For further information about a vulnerability, search its ID in: https://avd.aquasec.com/ +--------+----------------------+----------------------+----------------------+----------------------+----------------------+ | ID | LOCATION | MITRE CATEGORY | VULNERABILITY | DESCRIPTION | EVIDENCE | +--------+----------------------+----------------------+----------------------+----------------------+----------------------+ | KHV053 | Local to Pod (kube- | Discovery // | AWS Metadata | Access to the AWS | cidr: <html> | | | hunter-nhsdw) | Instance Metadata | Exposure | Metadata API exposes | <head> | | | | API | | information about | <title>404 Not | | | | | | the machines | Found</title> | | | | | | associated with the | < | | | | | | cluster | | +--------+----------------------+----------------------+----------------------+----------------------+----------------------+ | None | Local to Pod (kube- | Credential Access // | Access to pod's | Accessing the pod's | ['/var/run/secrets/k | | | hunter-nhsdw) | Access container | secrets | secrets within a | ubernetes.io/service | | | | service account | | compromised pod | account/ca.crt', '/v | | | | | | might disclose | ar/run/secrets/kuber | | | | | | valuable data to a | netes.io/serviceacco | | | | | | potential attacker | ... | +--------+----------------------+----------------------+----------------------+----------------------+----------------------+ | KHV050 | Local to Pod (kube- | Credential Access // | Read access to pod's | Accessing the pod | eyJhbGciOiJSUzI1NiIs | | | hunter-nhsdw) | Access container | service account | service account | ImtpZCI6ImVUWGJWOEp5 | | | | service account | token | token gives an | ZFZZN2dLTjItUUlzTXdW | | | | | | attacker the option | eDItYVd6YVM1a0tHR3dL | | | | | | to use the server | a3BGVFkifQ.eyJhdWQiO | | | | | | API | ... | +--------+----------------------+----------------------+----------------------+----------------------+----------------------+ Kube Hunter couldn't find any clusters ``` ## **Kube-bench** * Kube-bench will be used here from inside the kubernetes cluster and it will run as a pod. * Apply the following [job.yaml](https://raw.githubusercontent.com/aquasecurity/kube-bench/main/job.yaml) file and when the pod is up running and scan job is completed, check the logs of the the pod. It will show the scanning result with remediation suggestion. The following output will show the basic result of **kube-bench** scanning. Here is an example output in the cluster with trimmed text. ``` kubectl logs pod/kube-bench-tqmzr [INFO] 1 Control Plane Security Configuration [INFO] 1.1 Control Plane Node Configuration Files [PASS] 1.1.1 Ensure that the API server pod specification file permissions are set to 644 or more restrictive (Automated) [PASS] 1.1.2 Ensure that the API server pod specification file ownership is set to root:root (Automated) [PASS] 1.1.3 Ensure that the controller manager pod specification file permissions are set to 644 or more restrictive (Automated) [PASS] 1.1.4 Ensure that the controller manager pod specification file ownership is set to root:root (Automated) [PASS] 1.1.5 Ensure that the scheduler pod specification file permissions are set to 644 or more restrictive (Automated) [PASS] 1.1.6 Ensure that the scheduler pod specification file ownership is set to root:root (Automated) [PASS] 1.1.7 Ensure that the etcd pod specification file permissions are set to 644 or more restrictive (Automated) [PASS] 1.1.8 Ensure that the etcd pod specification file ownership is set to root:root (Automated) [WARN] 1.1.9 Ensure that the Container Network Interface file permissions are set to 644 or more restrictive (Manual) [WARN] 1.1.10 Ensure that the Container Network Interface file ownership is set to root:root (Manual) [PASS] 1.1.11 Ensure that the etcd data directory permissions are set to 700 or more restrictive (Automated) [FAIL] 1.1.12 Ensure that the etcd data directory ownership is set to etcd:etcd (Automated) [PASS] 1.1.13 Ensure that the admin.conf file permissions are set to 600 or more restrictive (Automated) [PASS] 1.1.14 Ensure that the admin.conf file ownership is set to root:root (Automated) [PASS] 1.1.15 Ensure that the scheduler.conf file permissions are set to 644 or more restrictive (Automated) == Remediations master == 1.1.9 Run the below command (based on the file location on your system) on the control plane node. For example, chmod 644 <path/to/cni/files> 1.1.10 Run the below command (based on the file location on your system) on the control plane node. For example, chown root:root <path/to/cni/files> == Summary master == 42 checks PASS 9 checks FAIL 11 checks WARN 0 checks INFO ``` ## **Links** * [*Kube-hunter docs*](https://aquasecurity.github.io/kube-hunter/) * [*kube-bench docs*](https://github.com/aquasecurity/kube-bench/blob/main/docs/running.md) * [*job.yaml file for kube-bench*](https://raw.githubusercontent.com/aquasecurity/kube-bench/main/job.yaml)

    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