Skip to content

Security check of external programs before launching #1844

@Explorer09

Description

@Explorer09

This is a feature ticket.

There are several feature requests in htop that would involve in launching an external program or script (#506, #526). The strace feature implemented in htop also involves in launching a program.

For now, there are volunteer pull requests (#1571, #1843, #1793) that try to implement some the features above, however, a major problem in these implementations are that they simply launch external programs without check, which is a bad idea regarding security.

htop is often run with root privileges, and if user is not careful, they can execute a malicious program accidentally, or run a program with elevated privileges that is not technically necessary.

Even for strace it can present a similar problem: The program might be a malicious program with the same name installed by a malicious local user, and root user isn't aware of that ahead of time.

This feature ticket is to encourage new contributers to implement internal APIs that allow secure checking and launching programs in htop.

These APIs:
(1) must have an option to decide whether the external program should have elevated privileges, or drop privileges whenever possible,
(2) if the program is to be launched with elevated privileges, must ensure the program is trusted by root (for example, a program is owned by root and has user execute permission can imply trust by root),

For security reasons, these system call / APIs should be avoided: execl, execv and similar, popen(3), system(3).

Instead try one of these: fexecve(3), execveat(2) These APIs allow launching an external program by the opened file descriptor rather than the path. Programs launching through FD can avoid the TOCTOU vulnerability that paths cannot .

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions