Coder Social home page Coder Social logo

austinbentlee / rocketchat-selinux Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 18 KB

A SELinux policy which confines RocketChat. If your RocketChat instance is compromised, it will be denied access to the rest of the system by SELinux.

Home Page: http://bentl.ee/

License: BSD 2-Clause "Simplified" License

Shell 100.00%
rocketchat selinux selinux-policy rocketchat-app

rocketchat-selinux's Introduction

RocketChat-SELinux

This SELinux policy confines RocketChat to only be able to use what it needs. The purpose of this is to segregate RocketChat, in case the application is compromised, the compromise is limited to RocketChat. This is for the default install of RocketChat -- plugins/etc will have to be evaluated separately (see the bottom section.)

RocketChat Install

This project is assuming you are using https://docs.rocket.chat/installation/manual-installation/centos/ as your install.

Compiling Policy

If you want to compile the policy, you will need selinux-policy-devel installed:

yum install selinux-policy-devel

Once you have that installed, you can run the following:

[root@localhost SELinux-RocketChat]# ./createMakefile.sh # if you are not running CentOS, your makefile is probably in a different location.
[root@localhost SELinux-RocketChat]# ./compilePolicy.sh 
Compiling targeted rocketchat module
/usr/bin/checkmodule:  loading policy configuration from tmp/rocketchat.tmp
/usr/bin/checkmodule:  policy configuration loaded
/usr/bin/checkmodule:  writing binary representation (version 19) to tmp/rocketchat.mod
Creating targeted rocketchat.pp policy package
rm tmp/rocketchat.mod tmp/rocketchat.mod.fc
[root@localhost SELinux-RocketChat]# 

Installing Policy

WARNING: The installation script will temporarily put SELinux into Permissive mode. Exercise extreme caution if you are running this on a production system. Ensure you check getenforce after running.

[root@localhost SELinux-RocketChat]# systemctl stop rocketchat
[root@localhost SELinux-RocketChat]# ./installPolicy.sh 
Removing existing policy, if any...
libsemanage.semanage_direct_remove_key: Unable to remove module rocketchat at priority 400. (No such file or directory).
semodule:  Failed!
Installing new policy...
Temporarily disabling SELinux Enforcement...
Setting permissions on /opt/Rocket.Chat ...
Setting permissions on /usr/local/bin/node ...
Re-enabling SELinux Enforcement...
Done.
[root@localhost SELinux-RocketChat]# systemctl start rocketchat
[root@localhost SELinux-RocketChat]# # wait a little while for rocketchat to completely start up ...
[root@localhost SELinux-RocketChat]# systemctl status rocketchat
● rocketchat.service - The Rocket.Chat server
   Loaded: loaded (/usr/lib/systemd/system/rocketchat.service; enabled; vendor preset: disabled)
   Active: active (running) since Thu 2020-07-16 14:13:52 EDT; 1min 20s ago
 Main PID: 2485 (node)
   CGroup: /system.slice/rocketchat.service
           └─2485 /usr/local/bin/node /opt/Rocket.Chat/main.js

Jul 16 14:14:13 localhost.localdomain rocketchat[2485]: ➔ |      MongoDB Version: 4.0.19                     |
Jul 16 14:14:13 localhost.localdomain rocketchat[2485]: ➔ |       MongoDB Engine: mmapv1                     |
Jul 16 14:14:13 localhost.localdomain rocketchat[2485]: ➔ |             Platform: linux                      |
Jul 16 14:14:13 localhost.localdomain rocketchat[2485]: ➔ |         Process Port: 3000                       |
Jul 16 14:14:13 localhost.localdomain rocketchat[2485]: ➔ |             Site URL: http://127.0.0.1:3000/  |
Jul 16 14:14:13 localhost.localdomain rocketchat[2485]: ➔ |     ReplicaSet OpLog: Enabled                    |
Jul 16 14:14:13 localhost.localdomain rocketchat[2485]: ➔ |          Commit Hash: 21157c0c4f                 |
Jul 16 14:14:13 localhost.localdomain rocketchat[2485]: ➔ |        Commit Branch: HEAD                       |
Jul 16 14:14:13 localhost.localdomain rocketchat[2485]: ➔ |                                                  |
Jul 16 14:14:13 localhost.localdomain rocketchat[2485]: ➔ +--------------------------------------------------+
[root@localhost SELinux-RocketChat]#

Ensure Enforced Mode On

[root@localhost SELinux-RocketChat]# getenforce
Enforcing
[root@localhost SELinux-RocketChat]#

We're good to go!

Supporting Additional Plugins

In a nutshell, you'll want to do the following:

  1. setenforce 0
  2. Thoroughly your application with the new plugin enabled.
  3. ./getDenys.sh
  4. Review generated policy rules
  5. Add required policy rules to rocketchat.te
  6. ./compilePolicy.sh
  7. systemctl stop rocketchat
  8. ./installPolicy.sh
  9. Enforcement mode is now enabled (if it isn't, then enable it.)
  10. systemctl start rocketchat
  11. Verify application plugin functions correctly.

rocketchat-selinux's People

Contributors

austinbentlee avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.