From 37e308d7a38935fa0a00b884e9d317f699e7e570 Mon Sep 17 00:00:00 2001 From: DorEdelman Date: Thu, 14 May 2026 16:45:22 +0300 Subject: [PATCH 1/2] charts: s1-agent: add fargate_ptrace_allow injection toggle New value configuration.env.injection.fargate_ptrace_allow (default true) that flows to the helper as S1_FARGATE_PTRACE_ALLOW. When set to false, the helper webhook skips injecting s1-fargate-init / libptrace_allow.so into Fargate pods and leaves their container CMD unchanged. Add LD_PRELOAD env to helper's agent container to load libptrace_allow.so when ptrace injection is enabled. Co-Authored-By: Moshe Friedland Co-Authored-By: Claude Sonnet 4.6 --- charts/s1-agent/templates/_helpers.tpl | 5 +++++ charts/s1-agent/templates/helper/statefulset.yaml | 4 ++++ charts/s1-agent/values.yaml | 1 + 3 files changed, 10 insertions(+) diff --git a/charts/s1-agent/templates/_helpers.tpl b/charts/s1-agent/templates/_helpers.tpl index 04e00a2..089493c 100644 --- a/charts/s1-agent/templates/_helpers.tpl +++ b/charts/s1-agent/templates/_helpers.tpl @@ -556,6 +556,10 @@ procMount: Default value: "0" - name: S1_POD_GID value: "0" +{{- if .Values.configuration.env.injection.fargate_ptrace_allow }} + - name: LD_PRELOAD + value: "/usr/local/lib/libptrace_allow.so" +{{- end }} {{- end -}} {{- define "helper.rbac.annotations" -}} @@ -625,6 +629,7 @@ requests: {{- if .Values.configuration.env.injection.enabled -}} {{- $_ := set $helperConfig "S1_NAMESPACE_INJECTION_SELECTORS" (default "" (toJson .Values.agentInjection.selector.namespaceSelector.matchLabels)) -}} {{- $_ := set $helperConfig "S1_INJECTION_CREATE_SITE_TOKEN_SECRET" (include "site_key.secret.create" .) -}} +{{- $_ := set $helperConfig "S1_FARGATE_PTRACE_ALLOW" (printf "%t" .Values.configuration.env.injection.fargate_ptrace_allow) -}} {{- if include "custom_ca.secret.create" . -}} {{- $_ := set $helperConfig "S1_CUSTOM_CA_SECRET_NAME" (include "custom_ca.secret.name" .) -}} {{- end -}} diff --git a/charts/s1-agent/templates/helper/statefulset.yaml b/charts/s1-agent/templates/helper/statefulset.yaml index 66d6f00..e763866 100644 --- a/charts/s1-agent/templates/helper/statefulset.yaml +++ b/charts/s1-agent/templates/helper/statefulset.yaml @@ -121,6 +121,10 @@ spec: {{- end }} - name: AGENT_CONTAINER_NAME value: "{{ include "agent.container_name" . }}" +{{- if and .Values.configuration.env.injection.enabled .Values.configuration.env.injection.fargate_ptrace_allow }} + - name: LD_PRELOAD + value: "/s1-helper/bin/libptrace_allow.so" +{{- end }} ports: - name: https containerPort: {{ include "service.target_port" . }} diff --git a/charts/s1-agent/values.yaml b/charts/s1-agent/values.yaml index f92a149..bab960b 100644 --- a/charts/s1-agent/values.yaml +++ b/charts/s1-agent/values.yaml @@ -60,6 +60,7 @@ configuration: hostNetwork: false # set to 'true' in case you are running on EKS with amazon linux 2023 ami and hop limit for the instance metadata of 1 in order for the helper to fetch instance metadata injection: enabled: false # to enable agent injection mode on AWS Fargate, set to 'true' + fargate_ptrace_allow: true # inject s1-fargate-init + libptrace_allow.so into Fargate pods so the agent can ptrace workload processes; set to 'false' to skip the CMD wrap + LD_PRELOAD injection admission_controllers: validating: enabled: false # to enable validating admission controller, set to 'true' From e8ee8ca24ca451681255ab7c3fdab12d319c2e26 Mon Sep 17 00:00:00 2001 From: Moshe Friedland Date: Wed, 27 May 2026 13:00:12 +0300 Subject: [PATCH 2/2] charts: s1-agent: set S1_FARGATE_PTRACE_ALLOW on injected agent Add S1_FARGATE_PTRACE_ALLOW to the env of the agent container that the helper webhook injects into Fargate pods, sharing the existing fargate_ptrace_allow gate next to LD_PRELOAD. The agent's cws_deployment startup reads this env var and translates it to the daemon_executor_ptrace_allow_enabled config key. When set, the agent's shell_spawner opts its remote-shell child (orphaned to pid 1 by daemon_executor's double-fork) into prctl(PR_SET_PTRACER, PR_SET_PTRACER_ANY) so the agent's subsequent PTRACE_ATTACH succeeds under YAMA mode 1. The same toggle now drives all three Fargate ptrace fixes: workload LD_PRELOAD libptrace_allow.so, workload CMD wrap with s1-fargate-init, and the agent's own remote-shell PR_SET_PTRACER opt-in. --- charts/s1-agent/templates/_helpers.tpl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/charts/s1-agent/templates/_helpers.tpl b/charts/s1-agent/templates/_helpers.tpl index 089493c..19eff8d 100644 --- a/charts/s1-agent/templates/_helpers.tpl +++ b/charts/s1-agent/templates/_helpers.tpl @@ -559,6 +559,8 @@ procMount: Default {{- if .Values.configuration.env.injection.fargate_ptrace_allow }} - name: LD_PRELOAD value: "/usr/local/lib/libptrace_allow.so" + - name: S1_FARGATE_PTRACE_ALLOW + value: "true" {{- end }} {{- end -}}