Skip to content

Latest commit

 

History

History
45 lines (25 loc) · 2.05 KB

T1166.md

File metadata and controls

45 lines (25 loc) · 2.05 KB

T1166 - Setuid and Setgid

When the setuid or setgid bits are set on Linux or macOS for an application, this means that the application will run with the privileges of the owning user or group respectively. Normally an application is run in the current user’s context, regardless of which user or group owns the application. There are instances where programs need to be executed in an elevated context to function properly, but the user running them doesn’t need the elevated privileges. Instead of creating an entry in the sudoers file, which must be done by root, any user can specify the setuid or setgid flag to be set for their own applications. These bits are indicated with an "s" instead of an "x" when viewing a file's attributes via ls -l. The chmod program can set these bits with via bitmasking, chmod 4777 [file] or via shorthand naming, chmod u+s [file].

An adversary can take advantage of this to either do a shell escape or exploit a vulnerability in an application with the setsuid or setgid bits to get code running in a different user’s context.

Detection: Monitor the file system for files that have the setuid or setgid bits set. Monitor for execution of utilities, like chmod, and their command-line arguments to look for setuid or setguid bits being set.

Platforms: Linux, macOS

Data Sources: File monitoring, Process Monitoring, Process command-line parameters

Effective Permissions: Administrator, root

Permissions Required: User

Atomic Tests


Atomic Test #1 - Setuid and Setgid

Setuid and Setgid

Supported Platforms: macOS, CentOS, Ubuntu, Linux

Inputs

Name Description Type Default Value
payload hello.c payload path hello.c

Run it with these steps!

  1. make hello

  2. sudo chown root hello

  3. sudo chmod u+s hello

  4. ./hello