Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Security concern for rule sets #2

Open
vvoovv opened this issue Sep 3, 2014 · 0 comments
Open

Security concern for rule sets #2

vvoovv opened this issue Sep 3, 2014 · 0 comments
Labels

Comments

@vvoovv
Copy link
Owner

vvoovv commented Sep 3, 2014

A rule set downloaded from the web, can exhibit malicious activity.

The solution is to block import of some python modules (e.g. httplib) and override some builtin functions (e.g. open()).

Keywords: sys.meta_path, find_module, load_module
Recipe: http://xion.org.pl/2012/05/06/hacking-python-imports/

class ImportBlocker(object):
def init(self, *args):
self.module_names = args

def find_module(self, fullname, path=None):
    if fullname in self.module_names:
        return self
    return None

def load_module(self, name):
    raise ImportError("%s is blocked and cannot be imported" % name)

import sys
sys.meta_path = [ImportBlocker("httplib")]

@vvoovv vvoovv added the bug label Sep 3, 2014
@vvoovv vvoovv changed the title security concern for rule sets Security concern for rule sets Nov 15, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant