<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Aprakash</title>
    <description>The latest articles on DEV Community by Aprakash (@anuroop08).</description>
    <link>https://dev.to/anuroop08</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F799952%2Fa6267ecb-1ac3-438b-bc81-1081119cc912.jpeg</url>
      <title>DEV Community: Aprakash</title>
      <link>https://dev.to/anuroop08</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/anuroop08"/>
    <language>en</language>
    <item>
      <title>kube-hunter : Kubernetes Security</title>
      <dc:creator>Aprakash</dc:creator>
      <pubDate>Thu, 20 Jan 2022 16:55:11 +0000</pubDate>
      <link>https://dev.to/anuroop08/kube-hunter-k8s-security-3ihh</link>
      <guid>https://dev.to/anuroop08/kube-hunter-k8s-security-3ihh</guid>
      <description>&lt;p&gt;&lt;strong&gt;&lt;a href="https://github.com/aquasecurity/kube-hunter" rel="noopener noreferrer"&gt;&lt;em&gt;Kube-hunter&lt;/em&gt;&lt;/a&gt;&lt;/strong&gt; - &lt;em&gt;An open source tool that hunts for security issues in your Kubernetes clusters..&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Kube-hunter hunts for security weaknesses in Kubernetes clusters. This tool was developed to increase awareness and visibility for security issues in Kubernetes environments.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Kube-hunter Github&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://github.com/aquasecurity/kube-hunter" rel="noopener noreferrer"&gt;https://github.com/aquasecurity/kube-hunter&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Ways to Run kube-hunter&lt;/strong&gt;&lt;br&gt;
Three Ways for deploying kube-hunter. On Pod, On Machine, Container.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;&lt;strong&gt;Pod&lt;/strong&gt;&lt;/em&gt;&lt;br&gt;
We also run kube-hunter in pod mode in the cluster.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Go to the kube-hunter github repo and deploy the job.yaml&lt;/li&gt;
&lt;li&gt;Find the pod name&lt;/li&gt;
&lt;li&gt;View the test results with  kubectl logs
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl create -f https://raw.githubusercontent.com/aquasecurity/kube-hunter/main/job.yaml
kubectl describe job kube-hunter
kubectl logs &amp;lt;pod name&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;root@Aprakash:~# kubectl logs kube-hunter-59x7z
2022-01-20 06:54:05,667 INFO kube_hunter.modules.report.collector Started hunting
2022-01-20 06:54:05,672 INFO kube_hunter.modules.report.collector Discovering Open Kubernetes Services
2022-01-20 06:54:05,676 INFO kube_hunter.modules.report.collector Found vulnerability "Read access to pod's service account token" in Local to Pod (kube-hunter-59x7z)
2022-01-20 06:54:05,676 INFO kube_hunter.modules.report.collector
  Nodes
+-------------+------------+
| TYPE        | LOCATION   |
+-------------+------------+
| Node/Master | 10.244.1.1 |
+-------------+------------+
| Node/Master | 10.240.0.5 |
+-------------+------------+
| Node/Master | 10.240.0.4 |
+-------------+------------+
| Node/Master | 10.0.0.1   |
+-------------+------------+

Vulnerabilities
For further information about a vulnerability, search its ID in:
https://avd.aquasec.com/
+--------+----------------------+----------------------+----------------------+----------------------+----------------------+
| ID     | LOCATION             | MITRE CATEGORY       | VULNERABILITY        | DESCRIPTION          | EVIDENCE             |
+--------+----------------------+----------------------+----------------------+----------------------+----------------------+
| None   | Local to Pod (kube-  | Lateral Movement //  | CAP_NET_RAW Enabled  | CAP_NET_RAW is       |                      |
|        | hunter-59x7z)        | ARP poisoning and IP |                      | enabled by default   |                      |
|        |                      | spoofing             |                      | for pods.            |                      |
|        |                      |                      |                      |     If an attacker   |                      |
|        |                      |                      |                      | manages to           |                      |
|        |                      |                      |                      | compromise a pod,    |                      |
|        |                      |                      |                      |     they could       |                      |
|        |                      |                      |                      | potentially take     |                      |
|        |                      |                      |                      | advantage of this    |                      |
|        |                      |                      |                      | capability to        |                      |
|        |                      |                      |                      | perform network      |                      |
|        |                      |                      |                      |     attacks on other |                      |
|        |                      |                      |                      | pods running on the  |                      |
|        |                      |                      |                      | same node            |                      |
+--------+----------------------+----------------------+----------------------+----------------------+----------------------+
| KHV002 | 10.0.0.1:443         | Initial Access //    | K8s Version          | The kubernetes       | v1.21.7              |
|        |                      | Exposed sensitive    | Disclosure           | version could be     |                      |
|        |                      | interfaces           |                      | obtained from the    |                      |
|        |                      |                      |                      | /version endpoint    |                      |
+--------+----------------------+----------------------+----------------------+----------------------+----------------------+
| KHV003 | Local to Pod (kube-  | Discovery //         | Azure Metadata       | Access to the Azure  | cidr: 10.240.0.0/16  |
|        | hunter-59x7z)        | Instance Metadata    | Exposure             | Metadata API exposes |                      |
|        |                      | API                  |                      | information about    |                      |
|        |                      |                      |                      | the machines         |                      |
|        |                      |                      |                      | associated with the  |                      |
|        |                      |                      |                      | cluster              |                      |
+--------+----------------------+----------------------+----------------------+----------------------+----------------------+
| KHV005 | 10.0.0.1:443         | Discovery // Access  | Access to API using  | The API Server port  | b'{"kind":"APIVersio |
|        |                      | the K8S API Server   | service account      | is accessible.       | ns","versions":["v1" |
|        |                      |                      | token                |     Depending on     | ],"serverAddressByCl |
|        |                      |                      |                      | your RBAC settings   | ientCIDRs":[{"client |
|        |                      |                      |                      | this could expose    | CIDR":"0.0.0.0/0","s |
|        |                      |                      |                      | access to or control | ...                  |
|        |                      |                      |                      | of your cluster.     |                      |
+--------+----------------------+----------------------+----------------------+----------------------+----------------------+
| None   | Local to Pod (kube-  | Credential Access // | Access to pod's      | Accessing the pod's  | ['/var/run/secrets/k |
|        | hunter-59x7z)        | Access container     | secrets              | secrets within a     | ubernetes.io/service |
|        |                      | service account      |                      | compromised pod      | account/namespace',  |
|        |                      |                      |                      | might disclose       | '/var/run/secrets/ku |
|        |                      |                      |                      | valuable data to a   | bernetes.io/servicea |
|        |                      |                      |                      | potential attacker   | ...                  |
+--------+----------------------+----------------------+----------------------+----------------------+----------------------+
| KHV050 | Local to Pod (kube-  | Credential Access // | Read access to pod's | Accessing the pod    | eyJhbGciOiJSUzI1NiIs |
|        | hunter-59x7z)        | Access container     | service account      | service account      | ImtpZCI6Im5VRURSVTBh |
|        |                      | service account      | token                | token gives an       | R01YZzdPY2sxNXF2T1Ez |
|        |                      |                      |                      | attacker the option  | cDM5dmtlTkZsY29GdDg4 |
|        |                      |                      |                      | to use the server    | MG12M2cifQ.eyJhdWQiO |
|        |                      |                      |                      | API                  | ...                  |
+--------+----------------------+----------------------+----------------------+----------------------+----------------------+
root@Aprakash:~/security#
root@Aprakash:~/security#
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;em&gt;&lt;strong&gt;On Machine&lt;/strong&gt;&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pip install kube-hunter
kube-hunter
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;From source&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git clone https://github.com/aquasecurity/kube-hunter.git
cd ./kube-hunter
pip install -r requirements.txt
python3 kube_hunter
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;&lt;strong&gt;Container&lt;/strong&gt;&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker run -it --rm --network host aquasec/kube-hunter
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Remediation&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;For further information about a vulnerability, search the vulnerability ID in:&lt;br&gt;
&lt;a href="https://avd.aquasec.com" rel="noopener noreferrer"&gt;https://avd.aquasec.com&lt;/a&gt;. Remediation steps for each vulnerability is listed in the document.  &lt;a href="https://aquasecurity.github.io/kube-hunter/kbindex.html" rel="noopener noreferrer"&gt;&lt;em&gt;All vulnerabilies KB&lt;/em&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5ivaupt1y1pr899bci0r.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5ivaupt1y1pr899bci0r.png" alt="kube-hunter"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Thanks!!&lt;/p&gt;

</description>
      <category>kubernetes</category>
      <category>security</category>
      <category>kubehunter</category>
      <category>devops</category>
    </item>
  </channel>
</rss>
