Skip to content

telemetry correction#60

Merged
dwertent merged 4 commits into
mainfrom
telemetry-correction
May 1, 2023
Merged

telemetry correction#60
dwertent merged 4 commits into
mainfrom
telemetry-correction

Conversation

@rcohencyberarmor
Copy link
Copy Markdown
Contributor

Overview

Raziel Cohen added 2 commits April 30, 2023 16:49
Signed-off-by: Raziel Cohen <rcohen@armosec.io>
Signed-off-by: Raziel Cohen <rcohen@armosec.io>
@github-actions
Copy link
Copy Markdown

Summary:

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

if !errors.Is(err, containerAlreadyExistError) {
logger.L().Ctx(ctx).Warning("fail to handle new container", helpers.String("ContainerID", contEvent.GetContainerID()), helpers.String("Container name", contEvent.GetContainerID()), helpers.String("k8s workload", contEvent.GetK8SWorkloadID()), helpers.Error(err))
}
defer span.End()
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Please notice the linter's warning

Raziel Cohen added 2 commits May 1, 2023 12:54
Signed-off-by: Raziel Cohen <rcohen@armosec.io>
…rection

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 2bf665d into main May 1, 2023
@matthyx matthyx deleted the telemetry-correction branch July 19, 2023 14:39
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