Panther informational experimental python
Kubernetes API Multiple 403 Responses from Single Public IP
This detection identifies when a public source IP generates multiple 403 (Forbidden) responses from the Kubernetes API server. This pattern may indicate reconnaissance attempts, permission enumeration, brute force attacks, or misconfigured access. Private IPs are excluded as they typically represent legitimate internal traffic.
Detection Logic
from ipaddress import ip_address
from panther_kubernetes_helpers import k8s_alert_context
def rule(event):
response_status = event.udm("responseStatus") or {}
source_ips = event.udm("sourceIPs") or []
# Check for 403 response (HTTP) or 7 (gRPC PERMISSION_DENIED)
status_code = response_status.get("code")
if status_code not in (403, 7):
return False
if not source_ips:
return False
try:
source_ip = source_ips[0]
ip_obj = ip_address(source_ip)
# alert on public IPs
# Check if is_global attribute exists (Python 3.4+)
if hasattr(ip_obj, "is_global") and ip_obj.is_global:
return True
except (ValueError, IndexError):
return False
return False
def title(event):
source_ips = event.udm("sourceIPs") or []
source_ip = source_ips[0] if source_ips else "<UNKNOWN_IP>"
return f"Multiple 403 responses from public IP [{source_ip}]"
def dedup(event):
source_ips = event.udm("sourceIPs") or []
source_ip = source_ips[0] if source_ips else "<UNKNOWN_IP>"
return f"k8s_403_{source_ip}"
def alert_context(event):
return k8s_alert_context(event) Field Validations
Loading…
Comments (0)
Loading comments...