Skip to content

timer correction#61

Merged
dwertent merged 3 commits into
mainfrom
stop-monitor-container-correction
May 1, 2023
Merged

timer correction#61
dwertent merged 3 commits into
mainfrom
stop-monitor-container-correction

Conversation

@rcohencyberarmor
Copy link
Copy Markdown
Contributor

Overview

Signed-off-by: Raziel Cohen <rcohen@armosec.io>
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 1, 2023

Summary:

  • License scan: success
  • Credentials scan: success
  • Vulnerabilities scan: success
  • Unit test: success
  • Go linting: success

Raziel Cohen added 2 commits May 1, 2023 17:08
Signed-off-by: Raziel Cohen <rcohen@armosec.io>
Signed-off-by: Raziel Cohen <rcohen@armosec.io>
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 1, 2023

Summary:

  • License scan: success
  • Credentials scan: success
  • Vulnerabilities scan: success
  • Unit test: success
  • Go linting: success

@dwertent dwertent merged commit 58a2275 into main May 1, 2023
@dwertent dwertent deleted the stop-monitor-container-correction branch July 30, 2023 07:22
entlein pushed a commit to k8sstormcenter/node-agent that referenced this pull request May 14, 2026
…tract

End-to-end unit test for the Test_32 dependency chain:
projectUserProfiles → mergeApplicationProfile → Apply →
projectField(Execs). Asserts that user-overlay AP Execs land in
projected.Execs.Values keyed by path (both full-path "/bin/sh" and
bare-name "sh" variants) AND in projected.ExecsByPath for the
was_executed_with_args matcher.

This passes locally — which proves the projection logic isn't the
cause of Test_32's R0001-precondition failure in CT. The gap must be
elsewhere: stale function_cache, reconciler timing, or cache-key
invalidation not tracking entry updates. Test kubescape#61 tracks the live-
agent diagnosis.
entlein pushed a commit to k8sstormcenter/node-agent that referenced this pull request May 14, 2026
…cape#61)

Diagnostic warning to capture exactly what's in the projected
container profile's Execs.Values at the moment a was_executed lookup
returns false. Compared against the agent's merge log (which claims
the user-overlay's Execs were appended), this will pinpoint whether
the projection actually contains the merged paths at decision time.

Remove this diagnostic after the merge-vs-evaluator gap is closed.
The user-overlay SyncChecksum fix (f80f349) did NOT silence R0001
on user-overlay-allowed paths in CT — so the bug is elsewhere (not
cache invalidation). This diagnostic narrows it.
entlein pushed a commit to k8sstormcenter/node-agent that referenced this pull request May 14, 2026
…faithful)

Inspektor Gadget's eBPF exec tracer follows the symlink and reports
event.exepath as the kernel-resolved target. On busybox-based images
every utility (sh, echo, nslookup, cat, ...) is a symlink to
/bin/busybox — so exepath always resolves to /bin/busybox regardless
of which symlink was actually invoked.

User-authored ApplicationProfile entries naturally list the symlink
form (/bin/sh, /usr/bin/nslookup) — that's how operators think about
binaries. With the prior "exepath wins unconditionally" precedence,
parse.get_exec_path(... '/bin/busybox') returned /bin/busybox while
profile.Path was /bin/sh. ap.was_executed missed → R0001 fired
forever on every busybox symlink. Same for the recording-side
resolveExecPath which recorded /bin/busybox into auto-learned
profiles, divorced from how users wrote their profiles.

Diagnostic captured the smoking gun (task kubescape#61, run 25871298210):
  DIAG ap.was_executed lookup MISS queriedPath=/bin/busybox
  execsValuesKeys=[sleep, /bin/sh, sh, /bin/echo, echo, /usr/bin/curl,
                   curl, /bin/sleep]  -- merge worked, profile has
                                         /bin/sh, but query asks for
                                         /bin/busybox

Fix — new symlink-faithful precedence on BOTH layers:
  1. argv[0] when it's an absolute path → symlink-as-invoked wins
  2. exepath when argv[0] is bare/empty → preserves argv[0]-spoofing
     protection (bare argv[0]="sshd" while exec'ing /usr/bin/curl
     resolves to the real exepath)
  3. argv[0] when bare and exepath empty (fexecve / AT_EMPTY_PATH)
  4. comm as last resort

Tier 2 keeps the existing argv[0]-spoofing test green. The new
"absolute argv[0] wins" rule is safe because the kernel only exposes
an absolute argv[0] when execve was called with that path (the kernel
follows the symlink itself; argv[0] reflects what the caller passed).

Pinned by unit tests on BOTH sides:
  - parse/parsing_test.go::TestGetExecPath_SymmetryWithRecordingSide
    + busybox symlink (/bin/sh, /usr/bin/nslookup)
    + bare argv[0] keeps spoof protection
  - containerprofilemanager/v1/event_reporting_test.go::
    TestResolveExecPath
    + busybox symlink (/bin/sh, /usr/bin/nslookup)
    + existing argv[0]-spoofing case stays green

Resolves task kubescape#60 (event.exepath empty for kubectl-exec'd processes —
actually it wasn't empty, it was just resolved to the symlink target)
and task kubescape#61 (user-overlay merge → rule-evaluator wiring gap —
actually it wasn't the wiring, it was the path-key mismatch).
Removes the diagnostic warn log from exec.go.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants