Skip to content

blacklist getattr calls #649

@KOLANICH

Description

@KOLANICH

Is your feature request related to a problem? Please describe.
One of use cases for bandit is a backdoor detection. It doesn't fit it well though, since for proper backdoor detection intermodule and runtime interactions must be addressed, i.e. with taint analysis (and the fact that using bandit for backdoor detection can be easily bypassed must be clearly stated in bold big red font).

It can detect very crude backdoors with explicit eval. But it is easy to mask them, by just obfuscating the string eval and getting the function using getattr.

Also getattr is a bad smell by itself, since it is often dangerously misused. I.e.

class A:
    b = lambda b: b

function_id = "string from the net"
getattr(A, function_id)(*args_from_the_net)

Instead a collection should be used and A[function_id], which will only allow calling an explicitly defined set of functions.

Describe the solution you'd like

getattr should be blacklisted.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions