The CKS curriculum names both tools in one line ("Perform static analysis of user workloads and container images (e.g. Kubesec, KubeLinter)"), and plenty of pipelines run both. They answer different questions, though. kubesec (controlplane, v2.15.0, October 2026) gives each object a risk score. KubeLinter (StackRox, v0.8.3) gives you a list of findings, each with its fix. Here is one bad Deployment through both.
$ cat web.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: web
namespace: shop
spec:
replicas: 1
selector:
matchLabels:
app: web
template:
metadata:
labels:
app: web
spec:
containers:
- name: web
image: nginx:latest
securityContext:
privileged: truekubesec: a score made of points
$ kubesec scan web.yaml
[
{
"object": "Deployment/web.shop",
"valid": true,
"fileName": "web.yaml",
"message": "Failed with a score of -30 points",
"score": -30,
"scoring": {
"critical": [
{
"id": "Privileged",
"selector": "containers[] .securityContext .privileged == true",
"reason": "Privileged containers can allow almost completely unrestricted host access",
"points": -30
}
],
"advise": [
{
"id": "ApparmorAny",
"selector": ".spec .securityContext .appArmorProfile .type | .spec .containers[] .securityContext .appArmorProfile .type | .spec .initContainers[] .securityContext .appArmorProfile .type | .spec .ephemeralContainers[] .securityContext .appArmorProfile .type",
"reason": "Well defined AppArmor policies may provide greater protection from unknown threats.",
"points": 3
},
...Every rule has points. A rule that matches adds them: negative ones are listed under critical (privileged -30, SYS_ADMIN -30, hostNetwork / hostPID / hostIPC -9, the Docker socket -9), positive ones under passed (a service account +3, AppArmor +3, runAsNonRoot, readOnlyRootFilesystem, capabilities.drop: [ALL], seccomp, requests and limits +1 each). A positive rule that does not match is listed under advise, which is a free to-do list. The object is named Kind/name.namespace.
The output is JSON, so a pipeline asks it questions with jq:
$ kubesec scan web.yaml | jq -r '.[0].scoring.critical[].id'
PrivilegedKubeLinter: a finding per problem, with the fix
$ kube-linter lint web.yaml; echo "exit $?"
KubeLinter 0.8.3
web.yaml: (object: shop/web apps/v1, Kind=Deployment) The container "web" is using an invalid container image, "nginx:latest". Please use images that are not blocked by the `BlockList` criteria : [".*:(latest)$" "^[^:]*$" "(.*/[^:]+)$"] (check: latest-tag, remediation: Use a container image with a specific tag other than latest.)
web.yaml: (object: shop/web apps/v1, Kind=Deployment) container "web" does not have a read-only root file system (check: no-read-only-root-fs, remediation: Set readOnlyRootFilesystem to true in the container securityContext.)
web.yaml: (object: shop/web apps/v1, Kind=Deployment) container "web" is Privileged hence allows privilege escalation. (check: privilege-escalation-container, remediation: Ensure containers do not allow privilege escalation by setting allowPrivilegeEscalation=false, privileged=false and removing CAP_SYS_ADMIN capability. See https://kubernetes.io/docs/tasks/configure-pod-container/security-context/ for more details.)
web.yaml: (object: shop/web apps/v1, Kind=Deployment) container "web" is privileged (check: privileged-container, remediation: Do not run your container as privileged unless it is required.)
web.yaml: (object: shop/web apps/v1, Kind=Deployment) container "web" is not set to runAsNonRoot (check: run-as-non-root, remediation: Set runAsUser to a non-zero number and runAsNonRoot to true in your pod or container securityContext. Refer to https://kubernetes.io/docs/tasks/configure-pod-container/security-context/ for details.)
web.yaml: (object: shop/web apps/v1, Kind=Deployment) container "web" has cpu request 0 (check: unset-cpu-requirements, remediation: Set CPU requests for your container based on its requirements. Refer to https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/#requests-and-limits for details.)
web.yaml: (object: shop/web apps/v1, Kind=Deployment) container "web" has memory limit 0 (check: unset-memory-requirements, remediation: Set memory limits for your container based on its requirements. Refer to https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/#requests-and-limits for details.)
Error: found 7 lint errors
exit 1Seven findings where kubesec had one critical rule. KubeLinter does not weigh anything: latest-tag and privileged-container count the same, and any finding fails the run with exit code 1. It also flags things kubesec has no rule for at all, like the latest tag.
The difference that matters
| kubesec | KubeLinter | |
|---|---|---|
| Answers | how risky is this object? (a sum of points) | what is wrong, and how do I fix it? |
| Output | JSON by default: critical, passed, advise | one line per finding: check + remediation (or --format json) |
| Fails when | any object scores 0 or less: exit 2 (--exit-code changes it) | any finding: exit 1 |
| Context | one object at a time | also the other objects in the same run (Services, ServiceAccounts) |
| Silence a rule | --rules picks which rules run | --exclude CHECK, or the annotation ignore-check.kube-linter.io/<check> |
Two score traps
A pass is not "secure". The score is a sum, and only a privileged container is heavy enough to sink everything. This node agent shares the host's process namespace, which is serious, and still passes:
$ kubesec scan agent.yaml | jq -r '.[0] | .message, (.scoring.critical[] | "\(.points) \(.id)")'
Passed with a score of 7 points
-9 HostPID
$ kubesec scan agent.yaml > /dev/null; echo "exit $?"
exit 0AppArmor, a service account, non-root and the resource settings earned 16 points, hostPID cost 9. A CI gate on the exit code lets it through, so gate on the critical list instead (jq -e '.[0].scoring.critical | length == 0'), or let KubeLinter catch it. It does, along with something kubesec cannot see:
$ kube-linter lint agent.yaml; echo "exit $?"
KubeLinter 0.8.3
agent.yaml: (object: monitoring/node-agent apps/v1, Kind=DaemonSet) object shares the host's process namespace (via hostPID=true). (check: host-pid, remediation: Ensure the host's process namespace is not shared.)
agent.yaml: (object: monitoring/node-agent apps/v1, Kind=DaemonSet) serviceAccount "node-agent" not found (check: non-existent-service-account, remediation: Create the missing service account, or refer to an existing service account.)
Error: found 2 lint errors
exit 1non-existent-service-account looks at the other objects in the run. Lint the DaemonSet together with the ServiceAccount it uses (same file, or the whole directory) and that finding goes away.
"Passed" can still fail the build. kubesec writes "Passed" for a score of 0 or more, but exits 2 for a score of 0 or less (pkg/ruler/ruleset.go and cmd/scan.go in v2.15.0). Exactly 0 gets both:
$ kubesec scan zero.yaml | jq -r '.[0].message'; kubesec scan zero.yaml >/dev/null; echo "exit $?"
Passed with a score of 0 points
exit 2That pod has hostNetwork: true (-9) and exactly 9 hardening points. If a pipeline fails with nothing but "Passed" in the log, this is why.
Fix the manifest, then rescan
Silencing is for real exceptions. The node agent does need hostPID, so it gets an annotation with the reason, as the KubeLinter docs ask. Anyone who reads the YAML later sees why:
metadata:
name: node-agent
annotations:
ignore-check.kube-linter.io/host-pid: "reads every process's /proc/PID/status for the node dashboard; reviewed by security, SEC-412"(kube-linter.io/ignore-all skips every check for one object. Avoid it.) For the web Deployment there is no excuse, so fix it: no privileged, a pinned image, non-root, a read-only root filesystem, capabilities dropped, a CPU request and a memory limit:
$ kubesec scan web.yaml | jq -r '.[0].message'
Passed with a score of 9 points
$ kube-linter lint web.yaml; echo "exit $?"
KubeLinter 0.8.3
No lint errors found!
exit 0kubesec still lists AppArmor, a service account and a CPU limit, among others, under advise. Advice is not a failure, but it is the next thing to look at. Neither scanner runs the container, so run it once before you merge: a read-only root filesystem breaks any image that writes into its own directories (give those paths an emptyDir), and the symptom is a CrashLoopBackOff.
Where each one fits
Run both in CI on every manifest and every rendered chart (helm template ... | kubesec scan - reads from stdin). Fail the build on KubeLinter's findings and on kubesec's critical list. Treat the kubesec score as a trend, not a gate. Neither replaces admission control: a scanner checks the files you gave it, while an admission policy (ValidatingAdmissionPolicy or Kyverno, now with its CEL policy types) checks every request that reaches the API server, however it got there.
Practise it
In the Kubernetes Security (CKS) chapter, the lesson Static analysis: kubesec and kube-linter before you apply explains both tools, and the lab Get a manifest past kubesec and kube-linter hands you the privileged nginx:latest Deployment above: both scanners must pass before you are done, with no critical rule and a score of at least 5.