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

Secure Bind Mount & Protect Hardware #202

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions usr/bin/secure-bind-protect-hardware
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash
mount --options defaults,nosuid,nodev --bind --make-private /opt /opt
mount --options defaults,nosuid,nodev --bind --make-private /home /home
mount --options defaults,nodev,nosuid --bind --make-private /tmp /tmp
mount --options defaults,nodev,nosuid,noexec --bind --make-private /boot/efi /boot/efi
mount --options defaults,nodev,noosuid,noexec --bind --make-private /boot /boot
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Type noosuid here but nvm.

mount --options defaults,nodev --bind --make-private /usr /usr
mount --options defaults,nosuid,nodev --bind --make-private /var /var
mount --options defaults,nosuid,nodev,noexec --bind --make-private /etc /etc
mount --options defaults,nosuid,nodev,noexec --bind --make-private /srv /srv
mount --options defaults,nosuid,nodev,noexec --bind --make-private /root /root
mount --options defaults,nosuid,nodev,noexec --bind --make-private /media /media
mount --options defaults,nosuid,nodev --bind --make-private /mnt /mnt
mount --options defaults,nosuid,nodev,noexec,remount,subset=pid /proc
mount --options defaults,nosuid,nodev,noexec,remount /sys
mount --options defaults,nosuid,nodev,noexec,remount /run
mount --options defaults,nosuid,nodev,noexec,remount /dev/shm
mount --options defaults,nosuid,noexec,remount /dev

chmod 0500 /sys/block
#chmod 0500 /sys/class
#chmod 0500 /sys/devices
#chmod 0500 /sys/fs
chmod 0500 /sys/kernel
chmod 0500 /sys/power
chmod 0500 /sys/bus
#chmod 0500 /sys/dev
chmod 0500 /sys/firmware
chmod 0500 /sys/hypervisor
chmod 0500 /sys/module
9 changes: 9 additions & 0 deletions usr/lib/systemd/system/secure-bind-protect-hardware.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[Unit]
Description=Securely bind directories to themselves with hardened mount options, remount api filesystems with hardened options, secure sensitive and volative non-persistent filesystems

[Service]
Type=oneshot
ExecStart=/usr/bin/secure-bind-protect-hardware

[Install]
WantedBy=multi-user.target