Skip to content

[CWS] Add declared hardening infos - #55994

Open
mftoure wants to merge 11 commits into
mainfrom
momar/secprofiles-add-security-context
Open

[CWS] Add declared hardening infos#55994
mftoure wants to merge 11 commits into
mainfrom
momar/secprofiles-add-security-context

Conversation

@mftoure

@mftoure mftoure commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

What

Enrich CWS security profiles with the declared Kubernetes hardening posture (privileged, seccomp profile, capabilities add/drop).

How

  • pkg/proto/datadog/workloadmeta: add ContainerSecurityContext, Capabilities, SeccompProfile messages and wire them through Container; extend proto ↔ struct converters in comp/core/workloadmeta/proto. Without this, workloadmeta.Remote (used by system-probe) silently strips the field on the gRPC wire.
  • pkg/security/resolvers/securitycontext: new WorkloadmetaResolver that resolves a container's Declared posture from workloadmeta.
  • pkg/security/security_profile: attach Declared on dump creation; New HardeningDeclared wire message via agent-payload bump.

TODO

New release on agent-payload before merging: DataDog/agent-payload#519

@mftoure mftoure added changelog/no-changelog No changelog entry needed qa/done QA done before merge and regressions are covered by tests labels Sep 8, 2026
@dd-octo-sts dd-octo-sts Bot added internal Identify a non-fork PR team/agent-security labels Sep 8, 2026
@github-actions github-actions Bot added the long review PR is complex, plan time to review it label Sep 8, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AI review by Codex (OpenAI) - workflow run

patch is incorrect: the declared security context cannot reach system-probe through the existing remote workloadmeta transport, so the new field remains absent in deployed Agents.

Comment on lines +43 to +44
container, err := r.wmeta.GetContainer(string(id))
if err != nil || container == nil || container.SecurityContext == nil {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P1] Transport SecurityContext to system-probe before resolving it

System-probe uses workloadmeta.Remote, but Container.SecurityContext is marked proto:"ignore" in comp/core/workloadmeta/def/types.go and is omitted by the workloadmeta protobuf conversions. Consequently, even when the core Agent's kubelet collector populates this field, system-probe receives a container with a nil security context and this resolver always returns nil. Add the field to the remote workloadmeta transport and verify the deployed pipeline so Declared can actually be populated.

@dd-octo-sts

dd-octo-sts Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Go Package Import Differences

Baseline: efcfce5
Comparison: 26bdd40

binaryosarchchange
system-probelinuxamd64
+1, -0
+github.com/DataDog/datadog-agent/pkg/security/resolvers/securitycontext
system-probelinuxarm64
+1, -0
+github.com/DataDog/datadog-agent/pkg/security/resolvers/securitycontext

@datadog-prod-us1-4

datadog-prod-us1-4 Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

🎯 Code Coverage (details)
Patch Coverage: 66.90%
Overall Coverage: 51.47% (-4.93%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 26bdd40 | Docs | View more details | Give us feedback!

@dd-octo-sts

dd-octo-sts Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Files inventory check summary

File checks results against ancestor efcfce51:

Results for datadog-agent_7.85.0~devel.git.155.26bdd40.pipeline.136688439-1_amd64.deb:

No change detected

Results for datadog-iot-agent_7.85.0~devel.git.155.26bdd40.pipeline.136688439-1_amd64.deb:

No change detected

@dd-octo-sts

dd-octo-sts Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Static quality checks

❌ Please find below the results from static quality gates
Comparison made with ancestor efcfce5
📊 Static Quality Gates Dashboard
🔗 SQG Job

Error

Quality gate Change Size (prev → curr → max)
docker_agent_amd64 (on disk) +130.12 KiB (0.02% increase, -144.53% of buffer) 840.032 → 840.159 → 840.120
Gate failure full details
Quality gate Error type Error message
docker_agent_amd64 AbsoluteLimitExceeded static_quality_gate_docker_agent_amd64 failed!
Disk size 840.2 MB exceeds limit of 840.1 MB by 40.1 KB

Static quality gate failures prevent this PR from merging!
You can check the static quality gates runbooks page for guidance and tools. Please either fix the size violation or request an exception.

Successful checks

Info

Quality gate Change Size (prev → curr → max)
agent_deb_amd64 +138.25 KiB (0.02% increase, -7.38% of buffer) 781.111 → 781.246 → 782.940
agent_deb_amd64_fips +146.12 KiB (0.02% increase, -6.29% of buffer) 715.750 → 715.893 → 718.020
agent_heroku_amd64 +12.25 KiB (0.00% increase, -0.19% of buffer) 316.222 → 316.234 → 322.470
agent_msi +77.5 KiB (0.01% increase, -0.54% of buffer) 651.621 → 651.696 → 665.630
agent_rpm_amd64 +138.25 KiB (0.02% increase, -7.44% of buffer) 781.094 → 781.229 → 782.910
agent_rpm_amd64_fips +146.12 KiB (0.02% increase, -6.24% of buffer) 715.734 → 715.877 → 718.020
agent_rpm_arm64 +138.25 KiB (0.02% increase, -4.25% of buffer) 752.030 → 752.165 → 755.210
agent_rpm_arm64_fips +134.12 KiB (0.02% increase, -3.53% of buffer) 692.187 → 692.318 → 695.900
agent_suse_amd64 +138.25 KiB (0.02% increase, -7.44% of buffer) 781.094 → 781.229 → 782.910
agent_suse_amd64_fips +146.12 KiB (0.02% increase, -6.24% of buffer) 715.734 → 715.877 → 718.020
agent_suse_arm64 +138.25 KiB (0.02% increase, -4.25% of buffer) 752.030 → 752.165 → 755.210
agent_suse_arm64_fips +134.12 KiB (0.02% increase, -3.53% of buffer) 692.187 → 692.318 → 695.900
docker_agent_arm64 +138.12 KiB (0.02% increase, -4.13% of buffer) 836.012 → 836.147 → 839.280
docker_agent_jmx_amd64 +130.13 KiB (0.01% increase, -32.96% of buffer) 1030.944 → 1031.072 → 1031.330
docker_agent_jmx_arm64 +138.13 KiB (0.01% increase, -4.13% of buffer) 1015.704 → 1015.839 → 1018.970
docker_cluster_agent_amd64 +4.13 KiB (0.00% increase, -0.50% of buffer) 212.901 → 212.905 → 213.700
docker_cluster_agent_arm64 +64.12 KiB (0.03% increase, -8.30% of buffer) 225.905 → 225.968 → 226.660
docker_dogstatsd_amd64 +12.13 KiB (0.03% increase, -1.40% of buffer) 39.597 → 39.608 → 40.440
docker_host_profiler_amd64 +19.31 KiB (0.01% increase, -0.16% of buffer) 307.724 → 307.743 → 319.490
docker_host_profiler_arm64 +5.57 KiB (0.00% increase, -0.05% of buffer) 318.972 → 318.977 → 330.690
dogstatsd_deb_amd64 +8.12 KiB (0.03% increase, -0.90% of buffer) 30.343 → 30.351 → 31.220
dogstatsd_deb_arm64 +8.12 KiB (0.03% increase, -0.64% of buffer) 28.351 → 28.359 → 29.590
dogstatsd_rpm_amd64 +8.12 KiB (0.03% increase, -0.90% of buffer) 30.343 → 30.351 → 31.220
dogstatsd_suse_amd64 +8.12 KiB (0.03% increase, -0.90% of buffer) 30.343 → 30.351 → 31.220
iot_agent_deb_amd64 +4.12 KiB (0.01% increase, -0.46% of buffer) 46.669 → 46.673 → 47.550
iot_agent_deb_arm64 +12.12 KiB (0.03% increase, -1.27% of buffer) 43.286 → 43.298 → 44.220
iot_agent_deb_armhf +8.11 KiB (0.02% increase, -0.87% of buffer) 44.108 → 44.116 → 45.020
iot_agent_rpm_amd64 +4.12 KiB (0.01% increase, -0.46% of buffer) 46.669 → 46.674 → 47.550
iot_agent_suse_amd64 +4.12 KiB (0.01% increase, -0.46% of buffer) 46.668 → 46.672 → 47.550
3 successful checks with minimal change (< 2 KiB)
Quality gate Current Size
docker_cws_instrumentation_amd64 7.439 MiB
docker_cws_instrumentation_arm64 6.877 MiB
docker_dogstatsd_arm64 37.686 MiB

@cit-pr-commenter-54b7da

cit-pr-commenter-54b7da Bot commented Sep 8, 2026

Copy link
Copy Markdown

Regression Detector

Regression Detector Results

Metrics dashboard
Target profiles
Job ID: ada53a48-c931-43ee-8bd9-e213b270ad48

Baseline: efcfce5
Comparison: 26bdd40
Diff

Optimization Goals: ✅ No significant changes detected

Fine details of change detection per experiment

perf experiment goal Δ mean % Δ mean % CI trials links
quality_gate_idle_all_features memory utilization +0.55 [+0.51, +0.58] 1 Logs bounds checks dashboard
dsd_uds_10mb_3k_timestamped_contexts_memory memory utilization +0.52 [+0.30, +0.74] 1 Logs
quality_gate_security_idle memory utilization +0.42 [+0.38, +0.46] 1 Logs bounds checks dashboard
quality_gate_metrics_logs memory utilization +0.41 [+0.19, +0.64] 1 Logs bounds checks dashboard
quality_gate_security_no_fs_load memory utilization +0.25 [+0.17, +0.33] 1 Logs bounds checks dashboard
quality_gate_idle memory utilization +0.23 [+0.18, +0.27] 1 Logs bounds checks dashboard
quality_gate_security_mean_fs_load memory utilization -0.24 [-0.29, -0.20] 1 Logs bounds checks dashboard
dsd_uds_10mb_3k_timestamped_contexts_cpu % cpu utilization -0.40 [-0.65, -0.15] 1 Logs
quality_gate_private_action_runner memory utilization -0.96 [-1.09, -0.83] 1 Logs bounds checks dashboard
quality_gate_logs % cpu utilization -2.38 [-3.23, -1.53] 1 Logs bounds checks dashboard

Bounds Checks: ✅ Passed

perf experiment bounds_check_name replicates_passed observed_value links
quality_gate_idle intake_connections 10/10 4 ≤ 5 bounds checks dashboard
quality_gate_idle memory_usage 10/10 177.24MiB ≤ 179MiB bounds checks dashboard
quality_gate_idle total_bytes_received 10/10 746.88KiB ≤ 819.20KiB bounds checks dashboard
quality_gate_idle_all_features intake_connections 10/10 4 ≤ 5 bounds checks dashboard
quality_gate_idle_all_features memory_usage 10/10 525.85MiB ≤ 537MiB bounds checks dashboard
quality_gate_idle_all_features total_bytes_received 10/10 1.14MiB ≤ 1.25MiB bounds checks dashboard
quality_gate_logs intake_connections 10/10 20 ≤ 40 bounds checks dashboard
quality_gate_logs memory_usage 10/10 210.56MiB ≤ 228MiB bounds checks dashboard
quality_gate_logs missed_bytes 10/10 0B = 0B bounds checks dashboard
quality_gate_logs total_bytes_received 10/10 263.43MiB ≤ 292MiB bounds checks dashboard
quality_gate_metrics_logs cpu_usage 10/10 392.77 ≤ 2000 bounds checks dashboard
quality_gate_metrics_logs intake_connections 10/10 20 ≤ 40 bounds checks dashboard
quality_gate_metrics_logs memory_usage 10/10 418.62MiB ≤ 455MiB bounds checks dashboard
quality_gate_metrics_logs missed_bytes 10/10 0B = 0B bounds checks dashboard
quality_gate_metrics_logs total_bytes_received 10/10 0.94GiB ≤ 1.04GiB bounds checks dashboard
quality_gate_private_action_runner memory_usage 10/10 72.39MiB ≤ 75MiB bounds checks dashboard
quality_gate_security_idle cpu_usage 10/10 31.52 ≤ 100 bounds checks dashboard
quality_gate_security_idle memory_usage 10/10 326.71MiB ≤ 355MiB bounds checks dashboard
quality_gate_security_mean_fs_load cpu_usage 10/10 62.63 ≤ 200 bounds checks dashboard
quality_gate_security_mean_fs_load memory_usage 10/10 299.87MiB ≤ 335MiB bounds checks dashboard
quality_gate_security_no_fs_load cpu_usage 10/10 25.12 ≤ 100 bounds checks dashboard
quality_gate_security_no_fs_load memory_usage 10/10 315.17MiB ≤ 345MiB bounds checks dashboard

Explanation

Confidence level: 90.00%
Effect size tolerance: |Δ mean %| ≥ 5.00%

Performance changes are noted in the perf column of each table:

  • ✅ = significantly better comparison variant performance
  • ❌ = significantly worse comparison variant performance
  • ➖ = no significant change in performance

A regression test is an A/B test of target performance in a repeatable rig, where "performance" is measured as "comparison variant minus baseline variant" for an optimization goal (e.g., ingress throughput). Due to intrinsic variability in measuring that goal, we can only estimate its mean value for each experiment; we report uncertainty in that value as a 90.00% confidence interval denoted "Δ mean % CI".

For each experiment, we decide whether a change in performance is a "regression" -- a change worth investigating further -- if all of the following criteria are true:

  1. Its estimated |Δ mean %| ≥ 5.00%, indicating the change is big enough to merit a closer look.

  2. Its 90.00% confidence interval "Δ mean % CI" does not contain zero, indicating that if our statistical model is accurate, there is at least a 90.00% chance there is a difference in performance between baseline and comparison variants.

  3. Its configuration does not mark it "erratic".

CI Pass/Fail Decision

Passed. All Quality Gates passed.

  • quality_gate_idle, bounds check intake_connections: 10/10 replicas passed. Gate passed.
  • quality_gate_idle, bounds check total_bytes_received: 10/10 replicas passed. Gate passed.
  • quality_gate_idle, bounds check memory_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_idle_all_features, bounds check total_bytes_received: 10/10 replicas passed. Gate passed.
  • quality_gate_idle_all_features, bounds check memory_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_idle_all_features, bounds check intake_connections: 10/10 replicas passed. Gate passed.
  • quality_gate_logs, bounds check intake_connections: 10/10 replicas passed. Gate passed.
  • quality_gate_logs, bounds check total_bytes_received: 10/10 replicas passed. Gate passed.
  • quality_gate_logs, bounds check memory_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_logs, bounds check missed_bytes: 10/10 replicas passed. Gate passed.
  • quality_gate_security_no_fs_load, bounds check cpu_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_security_no_fs_load, bounds check memory_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_metrics_logs, bounds check total_bytes_received: 10/10 replicas passed. Gate passed.
  • quality_gate_metrics_logs, bounds check intake_connections: 10/10 replicas passed. Gate passed.
  • quality_gate_metrics_logs, bounds check cpu_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_metrics_logs, bounds check missed_bytes: 10/10 replicas passed. Gate passed.
  • quality_gate_metrics_logs, bounds check memory_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_security_idle, bounds check memory_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_security_idle, bounds check cpu_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_private_action_runner, bounds check memory_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_security_mean_fs_load, bounds check memory_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_security_mean_fs_load, bounds check cpu_usage: 10/10 replicas passed. Gate passed.

mftoure and others added 4 commits September 8, 2026 17:35
Co-authored-by: Cursor <cursoragent@cursor.com>

# Conflicts:
#	go.sum
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>

# Conflicts:
#	comp/core/tagger/fx-remote/go.sum
#	comp/core/tagger/impl-remote/go.sum
#	comp/logs-library/go.sum
#	comp/otelcol/collector-contrib/impl/go.sum
#	comp/otelcol/ddflareextension/impl/go.sum
#	comp/otelcol/logsagentpipeline/go.sum
#	comp/otelcol/logsagentpipeline/logsagentpipelineimpl/go.sum
#	comp/otelcol/otlp/components/exporter/datadogexporter/go.sum
#	comp/otelcol/otlp/components/exporter/logsagentexporter/go.sum
#	comp/otelcol/otlp/components/exporter/serializerexporter/go.sum
#	comp/otelcol/otlp/components/processor/infraattributesprocessor/go.sum
#	go.sum
#	internal/qbranch/anomalydetection-testbench/go.sum
#	pkg/config/remote/go.sum
#	pkg/process/util/api/go.sum
#	pkg/proto/go.sum
#	pkg/serializer/go.sum
#	pkg/trace/otel/go.sum
#	pkg/util/grpc/go.sum
#	test/e2e-framework/go.sum
#	test/fakeintake/go.sum
#	test/new-e2e/go.sum
#	test/otel/go.sum
Co-authored-by: Cursor <cursoragent@cursor.com>
The workspace-wide dda inv tidy after merging main churned 24 nested
modules to propagate the agent-payload pseudo-version. That churn is
unrelated to this PR's intent: our only genuine dep change is the
agent-payload pin in the root go.mod. Restoring those nested files to
their origin/main state.

Note: this will fail the check-mod-tidy CI gate (which runs
'go work sync' + 'git diff --exit-code **/go.mod **/go.sum'). Accepted
for now; will be addressed either by re-adding the sync (if we keep the
agent-payload pseudo-version) or by cutting a real agent-payload release
and re-pinning to it.

Co-authored-by: Cursor <cursoragent@cursor.com>
@dd-octo-sts dd-octo-sts Bot added the team/container-platform The Container Platform Team label Sep 9, 2026
@mftoure
mftoure force-pushed the momar/secprofiles-add-security-context branch from f17c21f to 2c36c3e Compare September 9, 2026 11:20
@mftoure mftoure changed the title add HardeningDeclared [CWS] Add declared hardening infos Sep 10, 2026
@mftoure
mftoure marked this pull request as ready for review September 10, 2026 11:52
@mftoure
mftoure requested review from a team as code owners September 10, 2026 11:52

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AI review by Codex (OpenAI) - workflow run

The patch is incorrect: a transient workloadmeta miss can permanently omit declared hardening information from an active profile. The added unit tests do not exercise this startup ordering or verify delivery through fakeintake.

Start: eventTime,
End: eventTime,
}
secprof.Declared = m.resolveDeclared(event.ProcessContext.Process.ContainerContext.ContainerID)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] Retry unresolved posture after profile creation

The remote tagger and remote workloadmeta populate independently, so image tags can be available before workloadmeta contains the container's security context. If this lookup returns nil, getOrCreateProfile subsequently returns the cached profile without resolving it again; the storage backfill only runs when loading a profile. Consequently, a transient startup or container-discovery delay leaves Declared absent for the profile's lifetime even after the data arrives. Retry resolution while the cached profile's Declared is nil, and cover delayed workloadmeta availability in a test.

Comment on lines +400 to +401
v := *src
return &v

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: can use new(*src) instead of de-ref into a variable and reference again.

Comment on lines +400 to +401
v := *src
return &v

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

similar nit with new(*src)

Comment on lines +394 to +396
// copyBoolPtr returns a fresh *bool with src's value, or nil if src is nil,
// so wire-side callers never alias workloadmeta cache storage.
func copyBoolPtr(src *bool) *bool {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not a big deal but this defensive measure doesn't seem that necessary. This is used for proto streaming - not like it'll be passed around different components. Similar thought with the other copyBoolPtr .

Comment on lines +100 to +107
// copyBoolPtr returns a fresh *bool with src's value, or nil if src is nil.
func copyBoolPtr(src *bool) *bool {
if src == nil {
return nil
}
v := *src
return &v
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

similar nit and thoughts on this method in general.

Comment thread go.mod
github.com/CycloneDX/cyclonedx-go v0.12.0
github.com/DATA-DOG/go-sqlmock v1.5.2
github.com/DataDog/agent-payload/v5 v5.0.209
github.com/DataDog/agent-payload/v5 v5.0.211-0.20260910152323-44bb6d8404c1

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Already mentioned in the PR description, but another reminder to pin to a release version instead of a commit hash before merging.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog/no-changelog No changelog entry needed component/system-probe internal Identify a non-fork PR long review PR is complex, plan time to review it qa/done QA done before merge and regressions are covered by tests team/agent-build team/agent-security team/container-integrations team/container-platform The Container Platform Team team/kubernetes-experiences

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants