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

Main daemon should not be run as root (app.py) #48

Open
belavina opened this issue Mar 7, 2019 · 1 comment
Open

Main daemon should not be run as root (app.py) #48

belavina opened this issue Mar 7, 2019 · 1 comment

Comments

@belavina
Copy link
Contributor

belavina commented Mar 7, 2019

At the moment app.py is run as root due to snmp port binding to :161. This is a major security vulnerability (app is open to script injection etc.).

@ctyler
Copy link
Contributor

ctyler commented Mar 7, 2019

Traditional approach to this would be to start as root, open the port, and then drop root privilege. Example in Python: http://antonym.org/2005/12/dropping-privileges-in-python.html -- but you also need os.setgroups([]) to ensure that you don't have elevated privilege due to group membership.

However, a more advanced approach is to use capabilities(7) (see: "man 7 capabilities") which provides finer-grained privilege control than the traditional all/nothing approach -- see capsh(1), filecap(8), and setcap(8) for file-based capability setting (set maximum capabilities for an executable file), or the Python deescalate module (https://pypi.org/project/deescalate/) for code-based capability dropping. Using file-based cap setting to restrict privilege to just CAP_NET_BIND_SERVICE and then dropping that privilege after the port was open would probably be ideal (though I'm not sure how file capabilities apply to interpreted languages (?)).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants