knife is a command-line tool that provides an interface between a local chef-repo and the Chef Infra Server.

This program can be abused, if improper permissions are given

Detect

1. Check user sudo permissions

  • sudo -l

Exploit

Shell

It can be used to break out from restricted environments by spawning an interactive system shell.

  • knife exec -E 'exec "/bin/sh"'

Sudo

If the binary is allowed to run as superuser by sudo, it does not drop the elevated privileges and may be used to access the file system, escalate or maintain privileged access.

  • sudo knife exec -E 'exec "/bin/sh"'
  • whoami

Remedy

Assign proper rights to users, by following general user management procedures