Dit deel is nog niet vertaald. Je ziet de Engelse tekst.
Doel
Turn the access control ideas of the ISC2 course (least privilege, separation of duties, RBAC, DAC vs MAC, account lifecycle) into real settings on one server. Three people need different access: a web developer, a database admin and an auditor. You give each one exactly what the role needs — no more — and finish with an access review that proves it.
Voordat je begint
- A practice VM where you are root. Make the folders:
mkdir -p /srv/web /srv/db-backups /var/log/app. - The roles: webdev (change the web files, restart nginx), dba (read and write DB backups, restart the database), auditor (read logs only, change nothing).
Taken
Vink een taak aan als hij klaar is. Alleen je browser onthoudt dit.
- Make the groups
webdev,dba,auditorsand the usersamal(webdev),badr(dba) andcarla(auditor). Force a password change at the first login and an account expiry date for the contractorcarlain 90 days. - DAC:
/srv/webbelongs to the groupwebdev(setgid, others no access);/srv/db-backupstodba(mode2770). - ACLs: give
auditorsread-only access to/var/log/app, also for files made later (default ACL). - sudo by role:
webdevmay only runsystemctl reload nginxandsystemctl restart nginx;dbaonly the same forpostgresql. NoALL, no shell escapes. - Separation of duties: make sure the auditor can read the logs but can not delete them, and the developers can not read the DB backups.
- Lock the account of a person who left (
amalchanges jobs): lock it, expire it, and keep the files for the hand-over. - Access review: produce a list of every user with a shell, their groups, their sudo rights and their password age.
Controleer je werk
sudo -l -U amal
su - carla -c 'cat /var/log/app/app.log >/dev/null && echo can-read; rm -f /var/log/app/app.log || echo cannot-delete'
su - badr -c 'ls /srv/web' ; su - amal -c 'ls /srv/db-backups'
getfacl /var/log/app
chage -l carla | grep -i "account expires"
passwd -S amalamalmay run only the two nginx commands with sudo.carlaprintscan-readandcannot-delete.badrcan not list/srv/web;amalcan not list/srv/db-backups(Permission denied).getfaclshowsgroup:auditors:r-xanddefault:group:auditors:r-x.carlahas an expiry date in 90 days;amalshowsL/LK(locked).
Hints
Toon de hints
useradd -m -G GROUP NAME,chage -d 0 NAME(change at next login),chage -E YYYY-MM-DD NAME.setfacl -R -m g:auditors:rX DIRandsetfacl -d -m g:auditors:rX DIR.- Write sudo rules in
/etc/sudoers.d/and always check withvisudo -cf FILE. Use full paths (/usr/bin/systemctl). - To delete a file you need write permission on the directory, not on the file.
usermod -Llocks the password,chage -E 0expires the account;usermod -s /sbin/nologinstops logins with keys too.
Oplossing
Toon de oplossing
- Groups, users, lifecycle.
- Folders with the right owners (discretionary access control).
- Read-only ACL for the auditors, also for new files.
- sudo per role./etc/sudoers.d/roles
Cmnd_Alias NGINX_CTL = /usr/bin/systemctl reload nginx, /usr/bin/systemctl restart nginx Cmnd_Alias PG_CTL = /usr/bin/systemctl reload postgresql, /usr/bin/systemctl restart postgresql %webdev ALL=(root) NGINX_CTL %dba ALL=(root) PG_CTL - Separation of duties is already in place: the auditors have
r-xon the directory (they can not delete or create files there), andwebdevis not in the groupdba. - The leaver.
- The access review.
for u in $(awk -F: '$7 !~ /(nologin|false)$/ {print $1}' /etc/passwd); do echo "== $u: $(id -nG $u) | last pw change: $(chage -l $u | awk -F': ' '/Last password change/ {print $2}')"; sudo -l -U $u 2>/dev/null | sed -n '/may run/,$p' | tail -n +2; doneKeep the output, sign it with the date, and repeat the review every quarter (and at every role change).
Mijn notities
Nog geen notities.