text code block:any where host.os.type == "linux" and event.dataset == "kubernetes.audit_logs" and kubernetes.audit.stage == "ResponseComplete" and `kubernetes.audit.annotations.authorization_k8s_io/decision` == "forbid" and not user_agent.original like~ ( "/", "karpenter", "csi-secrets-store/*", "elastic-agent/*", "agentbeat/*", "insights-operator*", "oc/*", "cloud-defend/*", "OpenAPI-Generator/*", "local-storage-operator/*", "falcon-client/*", "nginx-ingress-controller/*", "config-translator/*", "kwatch/*", "PrometheusOperator/*", "kube*" )
Install detection rules in Elastic Security
Detect Forbidden Request from Unusual User Agent in Kubernetes in the Elastic Security detection engine by installing this rule into your Elastic Stack.
To setup this rule, check out the installation guide for Prebuilt Security Detection Rules(external, opens in a new tab or window).