GithubHelp home page GithubHelp logo

quarkslab / kdigger Goto Github PK

View Code? Open in Web Editor NEW
420.0 420.0 21.0 242 KB

Kubernetes focused container assessment and context discovery tool for penetration testing

License: Apache License 2.0

Makefile 1.81% Go 98.19%
containers kubernetes pentest security tool

kdigger's Issues

[feat] Add flag for namespaces during kdigger gen

While kdigger gen the namespace flag is missing. It will be good to have the namespace flag during kdigger gen.
One can still use ./kdigger gen | kubectl -n <namespace> apply -f - but adding a flag will help in generation of manifest along with namespace and then editing the same manifest after that.

/assign

Token path

Salut,

first of all great tool, I'm loving it.

I was just testing it and noticed that it failed to retrieve the ServiceAccount token from a privileged pod. I guess that the source of the issue is that in the token.go file, the tokenPath is set as /run/secrets/kubernetes.io/serviceaccount instead of /var/run/secrets/kubernetes.io/serviceaccount:

tokenPath = "/run/secrets/kubernetes.io/serviceaccount"

Feature Request: kdigger gen --fuzz

Hi,
I enjoy kdigger, it is helpful during pentests.
Would it be possible to extend the gen command for fuzzing Kubernetes admission controllers?

Wouldn't it be great if it could generate Kubernetes YAML manifests with all cutting edge container spec and security context fields?
This should include pods with privileged initContainer and ephemeralContainers, as well as windows node specific security context fields.
This could be used to test admission controls more thoroughly.

Implementation ideas:

  • The existing Kubernetes mutating webhook logic could be extracted from K8s codebase and used to implement this
  • The tool could fetches the latest kubernetes OpenAPI spec for apps and use this as basis to generate valid manifests with all possible values for dangerous spec fields mutated
  • In order to fine-tune the mutator, the dangerous configs from the api spec must be studied to identify problematic combinations.
  • A small yet versatile base image should be used in the generated manifests that has sudo pre-installed (for allowPrivilegeescalation checks)

Let me know your opinion about such a feature :-)

feat: flag for read-write mounts

While invoking the command kdigger dig mount we get all the mounted file systems. I tried looking for mounts with read and write permissions.

bash-5.1# kdigger dig mount | grep rw
| overlay    | /                               | overlay    | rw,relatime,lowerdir=/var/lib/c |
| proc       | /proc                           | proc       | rw,nosuid,nodev,noexec,relatime |
| tmpfs      | /dev                            | tmpfs      | rw,nosuid,size=65536k,mode=755  |
| devpts     | /dev/pts                        | devpts     | rw,nosuid,noexec,relatime,gid=5 |
| mqueue     | /dev/mqueue                     | mqueue     | rw,nosuid,nodev,noexec,relatime |
| shm        | /dev/shm                        | tmpfs      | rw,nosuid,nodev,noexec,relatime |
| /dev/sda1  | /dev/termination-log            | ext4       | rw,relatime,commit=30           |
| /dev/sda1  | /etc/hosts                      | ext4       | rw,relatime,commit=30           |
| /dev/sda1  | /etc/hostname                   | ext4       | rw,nosuid,nodev,relatime,commit |
| /dev/sda1  | /etc/resolv.conf                | ext4       | rw,nosuid,nodev,relatime,commit |
| shm        | /run/containerd/io.containerd.g | tmpfs      | rw,nosuid,nodev,noexec,relatime |
| overlay    | /run/containerd/io.containerd.r | overlay    | rw,relatime,lowerdir=/var/lib/c |
| overlay    | /run/containerd/io.containerd.r | overlay    | rw,relatime,lowerdir=/var/lib/c |
| shm        | /run/containerd/io.containerd.g | tmpfs      | rw,nosuid,nodev,noexec,relatime |

You can notice that some of the longer paths in the second column are getting squeezed. It will be great to have a flag that will only print the rw mounts.

Another similar flag can be developed for socks as well.

bash-5.1# kdigger dig mount | grep sock 
| tmpfs      | /run/containerd/containerd.sock | tmpfs      | ro,size=804600k,nr_inodes=81920 |

cc @mtardy

aarch64-linux support

aarch64-linux support tracker


Current build issues:

# github.com/quarkslab/kdigger/pkg/plugins/syscalls
pkg/plugins/syscalls/syscalls.go:155:7: undefined: unix.SYS_SELECT
pkg/plugins/syscalls/syscalls.go:156:7: undefined: unix.SYS_PAUSE
pkg/plugins/syscalls/syscalls.go:163:7: undefined: unix.SYS_FORK
pkg/plugins/syscalls/syscalls.go:164:7: undefined: unix.SYS_VFORK
pkg/plugins/syscalls/syscalls.go:173:47: undefined: unix.SYS_SELECT
pkg/plugins/syscalls/syscalls.go:173:72: undefined: unix.SYS_PAUSE
pkg/plugins/syscalls/syscalls.go:183:40: undefined: unix.SYS_FORK
pkg/plugins/syscalls/syscalls.go:183:63: undefined: unix.SYS_VFORK
pkg/plugins/syscalls/syscalls.go:230:12: undefined: unix.SYS_OPEN
pkg/plugins/syscalls/syscalls.go:234:12: undefined: unix.SYS_STAT
pkg/plugins/syscalls/syscalls.go:234:12: too many errors
github.com/quarkslab/kdigger/pkg/plugins/authorization
Original post
# github.com/quarkslab/kdigger/pkg/plugins/syscalls
pkg/plugins/syscalls/syscalls.go:155:7: undefined: unix.SYS_SELECT
pkg/plugins/syscalls/syscalls.go:156:7: undefined: unix.SYS_PAUSE
pkg/plugins/syscalls/syscalls.go:163:7: undefined: unix.SYS_FORK
pkg/plugins/syscalls/syscalls.go:164:7: undefined: unix.SYS_VFORK
pkg/plugins/syscalls/syscalls.go:173:47: undefined: unix.SYS_SELECT
pkg/plugins/syscalls/syscalls.go:173:72: undefined: unix.SYS_PAUSE
pkg/plugins/syscalls/syscalls.go:183:40: undefined: unix.SYS_FORK
pkg/plugins/syscalls/syscalls.go:183:63: undefined: unix.SYS_VFORK
pkg/plugins/syscalls/syscalls.go:230:12: undefined: unix.SYS_OPEN
pkg/plugins/syscalls/syscalls.go:234:12: undefined: unix.SYS_STAT
pkg/plugins/syscalls/syscalls.go:234:12: too many errors
github.com/quarkslab/kdigger/pkg/plugins/authorization

on aarch64-linux and x86_64-darwin

are there plans for supporting non-x86_64-linux platforms in the future or no?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.