-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added documentation for BlueChi's revised SELinux policy
This PR reorders the table of contents for the readthedoc and bundles the mTLS as well as the networking and the new SELinux subsection together under the Security section. Signed-off-by: Michael Engel <mengel@redhat.com>
- Loading branch information
Showing
5 changed files
with
92 additions
and
54 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<!-- markdownlint-disable-file MD013--> | ||
# Security | ||
|
||
As a distributed system, BlueChi is subject to attacks from malicious actors within the network. | ||
However, similar to other services, protective measures can be employed to defend against such scenarios. By setting up [firewall rules](#setup-firewall-rules) and [IP address filter](#setup-ip-address-filter) the attack surface can be reduced. The security of the system can be enhanced even further by leveraging [BlueChi's SELinux policy](./selinux.md) as well as setting up a [double proxy for mTLS encryption](./securing_multi_node.md). | ||
|
||
## Setup firewall rules | ||
|
||
By using [firewalld](https://firewalld.org/), rules can be defined to secure BlueChi and the overall system: | ||
|
||
``` bash | ||
# Install firewalld | ||
$ sudo dnf install firewalld | ||
|
||
# Enable and start the service | ||
$ sudo systemctl enable --now firewalld | ||
|
||
# Allow communication on port 842/tcp | ||
$ sudo firewall-cmd --permanent --zone=public --add-port=842/tcp | ||
|
||
# Block a specific IP address from a malicious agent | ||
$ sudo firewall-cmd --permanent --zone=public --add-rich-rule='rule family="ipv4" source address="ADD_HERE_MALICIOUS_IP_FROM_BAD_ACTOR" port port="842" protocol="tcp" drop' | ||
|
||
# Reload firewalld with the new configuration | ||
$ sudo firewall-cmd --reload | ||
``` | ||
|
||
## Setup IP address filter | ||
|
||
Additionally, [iptables](https://linux.die.net/man/8/iptables) can be utilized to block connections from any IP address that attempts excessive connections: | ||
|
||
``` bash | ||
sudo iptables -A INPUT -p tcp --dport 842 -m conntrack --ctstate NEW -m recent --name BLUECHIRULE --set | ||
|
||
sudo iptables -A INPUT -p tcp --dport 842 -m conntrack --ctstate NEW -m recent --name BLUECHIRULE --update --seconds 60 --hitcount 5 -j DROP | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<!-- markdownlint-disable-file MD013--> | ||
# BlueChi's SELinux policy | ||
|
||
BlueChi provides a custom SELinux policy, limiting access of the `bluechi-controller` and `bluechi-agent`. It can be installed via | ||
|
||
```bash | ||
dnf install bluechi-selinux | ||
``` | ||
|
||
By default, the package allows `bluechi-controller` to bind and `bluechi-agent` to connect to any port so that changes of the [ControllerPort](../man/bluechi-agent-conf.md#controllerport-uint16_t) are not being blocked. | ||
|
||
## Enforce port restrictions | ||
|
||
In order to allow BlueChi to only use one port, the usage of any needs to be disabled with [setsebool](https://linux.die.net/man/8/setsebool): | ||
|
||
```bash | ||
# Turn off the any policy for bluechi-controller | ||
setsebool -P bluechi_controller_port_bind_any 0 | ||
|
||
# Turn off the any policy for bluechi-agent | ||
setsebool -P bluechi_agent_port_connect_any 0 | ||
``` | ||
|
||
Subsequently, the desired port needs to be allowed by using [semanage](https://linux.die.net/man/8/semanage): | ||
|
||
```bash | ||
# Set the allowed port for bluechi-controller | ||
semanage port -a -t bluechi_port_t -p tcp <port> | ||
|
||
# Set the allowed port for bluechi-agent | ||
semanage port -a -t bluechi_agent_port_t -p tcp <port> | ||
``` | ||
|
||
## Change from enforcing to permissive | ||
|
||
By default, BlueChi will enforce its SELinux policy. By using [semanage](https://linux.die.net/man/8/semanage) the permissive property can be added so that violations are blocked and create only an AVC entry: | ||
|
||
```bash | ||
# add the permissive property to bluechi-controller | ||
semanage permissive -a bluechi_t | ||
|
||
# add the permissive property to bluechi-agent | ||
semanage permissive -a bluechi_agent_t | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters