Skip to content
KitploitKITPLOIT
StrumentiBlog
Invia
StrumentiBlog
Invia

Strumenti di Hacking, PenTest e Cybersecurity per il tuo Arsenale di Sicurezza!

Kitploit è una directory di strumenti di hacking, cybersecurity e pentesting. Scopri gli ultimi aggiornamenti dei progetti per trovare vulnerabilità, analizzare sistemi, automatizzare i test e rafforzare la tua sicurezza.

··Feed·Contatto·Privacy·© 2026 Kitploit

Directory degli strumenti

Categorie

Vedi tutte le categorie
Loading categories
kubesec — Analisi dei rischi di sicurezza per le risorse Kubernetes | Kitploit
Strumenti/GitHubGitHub/controlplaneio/kubesec
Sicurezza dell'Infrastruttura CloudStrumenti DifensiviAnalisi StaticaSicurezza dei ContenitoriAnalisi Statica del Codice (SAST)Audit di ConfigurazioneSicurezza CloudDevSecOpsConfigurazione ErrataEscape dal ContainerTop in Audit di Configurazione n.13
1.5k108203 mesi faRevisionato da Kitploit
Top in Escape dal Container n.15
Top in Sicurezza dei Contenitori n.9
Top in Configurazione Errata n.13
Top in Analisi Statica del Codice (SAST) n.18
GitHubcontrolplaneio/kubesec

kubesec

Analisi dei rischi di sicurezza per le risorse Kubernetes

Vedi RepositorySito web

Più Popolari

Vedi tutti →

Scopri gli strumenti più utilizzati dalla nostra community.

Esplora tutti gli strumenti

Sfoglia la nostra collezione di strumenti

Vedi tutti gli strumenti →
Condividi

Kubesec

Testing Workflow Security Analysis Workflow Release Workflow

Go Report Card PkgGoDev

🚨 L'API v1 è deprecata, leggi le note di rilascio 🚨

Analisi del rischio di sicurezza per le risorse Kubernetes

Scarica lo strumento

🎬 Demo

Demo CLI di Kubesec

Per altri esempi visita Kubesec.io, che utilizza l'API ospitata da ControlPlane all'indirizzo v2.kubesec.io/scan.


  • Avvio rapido
  • Scarica Kubesec
  • Esempi di utilizzo
    • Scansione
      • Utilizzo con Docker
      • Formati di output
    • Stampa regole
    • Schemi personalizzati
  • Modalità server HTTP
  • Kubesec-as-a-Service
  • Contribuire
  • Assistenza
  • Changelog

🚀 Avvio rapido

1. Prepara il tuo manifest

Crea un file di risorsa Kubernetes (ad es. kubesec-test.yaml) da analizzare. Per una prova rapida, puoi salvare il seguente manifest Pod:

root@kitploit:~
$ cat <<EOF > kubesec-test.yaml
apiVersion: v1
kind: Pod
metadata:
  name: kubesec-demo
spec:
  containers:
  - name: kubesec-demo
    image: gcr.io/google-samples/node-hello:1.0
    securityContext:
      readOnlyRootFilesystem: true
EOF

2. Esegui la tua prima scansione

Esegui una scansione del tuo file manifest:

root@kitploit:~
# Using the local binary
kubesec scan kubesec-test.yaml

# Or using Docker
docker run -i kubesec/kubesec:v2 scan /dev/stdin < kubesec-test.yaml

# Using the local binary with a human-readable table output format
kubesec scan kubesec-test.yaml --format table

[!TIP] Per visualizzare i risultati in una tabella leggibile invece del formato JSON predefinito, usa il flag --format table

kubesec produrrà un punteggio di sicurezza e un'analisi dettagliata della tua risorsa.

📦 Scarica Kubesec

Kubesec è disponibile come:

  • Immagine container Docker all'indirizzo docker.io/kubesec/kubesec:v2
  • Binario per Linux/MacOS/Win (scarica l'ultima release)
  • Kubernetes Admission Controller
  • Plugin Kubectl

Oppure installa l'ultimo commit da GitHub con:

Go 1.16+

root@kitploit:~
$ go install github.com/controlplaneio/kubesec/v2@latest

Go version < 1.16

root@kitploit:~
$ GO111MODULE="on" go get github.com/controlplaneio/kubesec/v2

📖 Esempi di utilizzo

Scansione

Analizza risorse Kubernetes da file locali o da standard input.

Kubesec può analizzare più documenti YAML in un singolo file di input, oppure analizzare documenti da più file contemporaneamente, purché siano formattati correttamente come più documenti separati da ---.

root@kitploit:~
# Scan a specific local YAML file
kubesec scan ./deployment.yaml

# Scan from standard input (JSON or YAML)
cat file.json | kubesec scan -

# Scan a rendered Helm chart
helm template -f values.yaml ./chart | kubesec scan /dev/stdin

# Scan multiple YAML documents separated by '---'
{ cat test/asset/multi.yml; echo "---"; cat test/asset/critical.yml; } | kubesec scan -

Utilizzo con Docker

Puoi eseguire gli stessi comandi di scansione utilizzando l'immagine Docker ufficiale:

root@kitploit:~
# Scan a file via Docker using standard input
docker run -i kubesec/kubesec:v2 scan /dev/stdin < kubesec-test.yaml

Formati di output

Kubesec supporta tre diversi formati di output, specificati dal flag --format / -f: json (predefinito), table e template, e può analizzare più documenti YAML in un singolo file di input.

root@kitploit:~
# JSON array output (default behaviour)
kubesec scan ./deployment.yaml --format json

# Human-readable table output
kubesec scan ./deployment.yaml --format table

# Use a custom template for the output
kubesec scan ./deployment.yaml --format template --template report-template.tmpl

Analizza regole specifiche

root@kitploit:~
# One rule
kubesec scan --rules CapSysAdmin kubesec-test.yaml

# Multiple rules
kubesec scan --rules RunAsNonRoot,SeccompAny,ApparmorAny kubesec-test.yaml
Esempio di output JSON
root@kitploit:~
[
  {
    "object": "Pod/security-context-demo.default",
    "valid": true,
    "message": "Failed with a score of -30 points",
    "score": -30,
    "scoring": {
      "critical": [
        {
          "selector": "containers[] .securityContext .capabilities .add == SYS_ADMIN",
          "reason": "CAP_SYS_ADMIN is the most privileged capability and should always be avoided",
          "points": -30
        }
      ],
      "advise": [
        {
          "selector": "containers[] .securityContext .runAsNonRoot == true",
          "reason": "Force the running image to run as a non-root user to ensure least privilege",
          "points": 1
        },
        {
          // ...
        }
      ]
    }
  }
]
Esempio di output tabellare

Output tabellare

Stampa regole

root@kitploit:~
# Print all scanning rules with their associated point scores
kubesec print-rules

# Print all scanning rules with their associated point scores as a table
kubesec print-rules --format table

Esempio di output JSON delle regole

root@kitploit:~
[
  {
    "id": "AllowPrivilegeEscalation",
    "selector": "containers[] .securityContext .allowPrivilegeEscalation == true",
    "reason": "Ensure a non-root process can not gain more privileges",
    "kinds": [
      "Pod",
      "Deployment",
      "StatefulSet",
      "DaemonSet"
    ],
    "points": -7,
    "advise": 0
  },
...
]

Schemi personalizzati

Kubesec si avvale di kubeconform (grazie a @yannh) per validare i manifest da analizzare. Ciò implica che la specifica di posizioni diverse degli schemi segue le regole descritte nel README di kubeconform.

root@kitploit:~
# Usees the latest schema from upstream
# Schema will be fetched from: https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master/master-standalone-strict/pod-v1.json
kubesec scan ./pod.yaml

# Use a specific schema version from upstream (format x.y.z with no v prefix)
# Schema will be fetched from: https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master/v1.25.3-standalone-strict/pod-v1.json
kubesec scan ./pod.yaml --kubernetes-version 1.25.3

# Use a specific schema version in an airgapped environment over HTTP
# Schema will be fetched from: `https://host.server/v<version>-standalone-strict/pod-v1.json`
kubesec scan ./deployment.yaml --kubernetes-version <version> --schema-location https://host.server

# Use a specific schema version in an airgap environment with local files
# Schema will be read from: `/opt/schemas/v<version>-standalone-strict/pod-v1.json`
kubesec scan ./deployment.yaml --kubernetes-version <version> --schema-location /opt/schemas

Nota: per limitare le chiamate di rete esterne e consentire l'uso in ambienti air-gapped, l'immagine kubesec incorpora gli schemi. Se si desidera modificare la posizione degli schemi, è necessario modificare le variabili d'ambiente K8S_SCHEMA_VER e SCHEMA_LOCATION in fase di esecuzione.

Modalità server HTTP

Kubesec include un server HTTP integrato che puoi eseguire localmente o in un container per accettare richieste di scansione tramite rete.

Utilizzo da CLI

root@kitploit:~
# Start the HTTP server in the background on port 8080
kubesec http 8080 &

# Send a file to the running server via POST
curl -sSX POST --data-binary @deployment.yaml http://localhost:8080/scan

# Stop the background local server when finished
kill %

Utilizzo con Docker

root@kitploit:~
# Start the HTTP server using Docker
docker run -d -p 8080:8080 kubesec/kubesec:v2 http 8080

# Send a file to the running server via POST
curl -sSX POST --data-binary @deployment.yaml http://localhost:8080/scan

Non dimenticare di arrestare il server.

Kubesec-as-a-Service

Kubesec è disponibile anche via HTTPS all'indirizzo v2.kubesec.io/scan.

Non inviare YAML sensibili a questo servizio pubblico.

Il servizio è gestito in buona fede e con il massimo sforzo.

root@kitploit:~
# Submit a manifest directly to the hosted v2 API
curl -sSX POST --data-binary @"deployment.yaml" https://v2.kubesec.io/scan

# Parse the API output using jq to return a non-zero exit code if the score is <= 10
curl -sSX POST --data-binary @"deployment.yaml" https://v2.kubesec.io/scan | jq --exit-status '.score > 10'

# Use the "rule" query parameter to scan only specific rules (multiple supported)
curl -sSX POST --data-binary @test/asset/score-0-cap-sys-admin.yml "http://localhost:8080/scan?rule=SeccompAny&rule=ApparmorAny"

Puoi anche definire una funzione Bash, ad esempio:

root@kitploit:~
# Define a BASH function
$ kubesec ()
{
    local FILE="${1:-}";
    [[ ! -e "${FILE}" ]] && {
        echo "kubesec: ${FILE}: No such file" >&2;
        return 1
    };
    curl --silent \
      --compressed \
      --connect-timeout 5 \
      -sSX POST \
      --data-binary=@"${FILE}" \
      https://v2.kubesec.io/scan
}


# POST a Kubernetes resource to v2.kubesec.io/scan
$ kubesec ./deployment.yml

# Return non-zero status code is the score is not greater than 10
$ kubesec ./score-9-deployment.yml | jq --exit-status '.score > 10' >/dev/null
# status code 1

Contribuire

Consulta CONTRIBUTING.md per maggiori informazioni.

Assistenza

Se hai domande su Kubesec e sulla sicurezza di Kubernetes:

  • Leggi la documentazione di Kubesec
  • Contatta su Twitter @sublimino o @controlplaneio
  • Apri una segnalazione (issue)

Il tuo feedback è sempre benvenuto!


Fatto con ❤ da ControlPlane