Skip to content

ApplicationProfile records symlink path instead of resolved executable path for exec events #787

@CarlMarstorp

Description

@CarlMarstorp

Description

When node-agent builds an ApplicationProfile, exec entries are recorded from the exec event path chosen in userspace, typically argv[0]. If this path is a symlink, the profile stores the symlink path rather than the resolved executable path. This can cause downstream policy generation less precise.

For example, in an nginx container on Ubuntu, the profile may record /bin/sh even though /bin/sh resolves to /usr/bin/dash inside the container.

Environment

OS: Ubuntu 22.04 LTS
Version: sha256:fe7195e32d7e08c3b2102fabf9eea27799c717110d79c0872f0d1ab7fc151630
Installed via: Kubescape-operator Helm chart 1.30.2

Steps To Reproduce

  1. Deploy the node-agent in a Kubernetes cluster with ApplicationProfileServiceEnabled: true
  2. Run an nginx-container (or any Debian/Ubuntu-based image where /bin/sh is a symlink to /usr/bin/dash
  3. Wait for the learning period to complete and an ApplicationProfile to be generated
  4. Inspect the execs field of the ApplicationProfile

Expected behavior

The ApplicationProfile should record /usr/bin/dash, the resolved executable path that actually runs in the container.

Actual Behavior

The ApplicationProfile records /bin/sh, which is a symlink path used by the process invocation.

Additional context

The underlying exec event handling appears to capture the invoked path from userspace, but the ApplicationProfile generation does not currently resolve the symlink path before storing the exec path. A possible fix would be to resolve the executable path in the container profile manager after receiving the exec event, with a fallback to the original path if resolution fails.

I am willing to implement this and submit a PR if the approach is acceptable.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

Status

High Priority

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions