A web app runs as `www-data` and you want it unable to read anything outside `/var/www`, even if exploited. What options do you have?
AdvancedScenarioSecurity, hardening and incident response
Answer
Situation read → Mandatory access control or systemd sandboxing.
What I'd do →
- systemd:
ProtectSystem=strict,ProtectHome=yes,ReadWritePaths=/var/www/uploads,TemporaryFileSystem=/etc:rowithBindReadOnlyPaths=for needed files, orInaccessiblePaths=/etc/ssh /root. - SELinux: keep the default
httpd_tdomain and label only allowed contenthttpd_sys_content_t. - AppArmor (Ubuntu): profile in
/etc/apparmor.d/with/var/www/** r,andaa-enforce.
Why → Even with code execution, the process is fenced by the kernel.
Interview tip → Mention starting AppArmor profiles in complain mode (aa-complain) and tuning from logs.
More on Security, hardening and incident response
Monitoring shows a web server making outbound connections to an unknown IP on port 4444 at 2 AM. You suspect it is compromised. What do you do?AdvancedAfter the compromise you need to find how the attacker got in. Where do you look?AdvancedYour CISO asks you to harden a fresh Linux server baseline. What's on your list?IntermediateA developer says "SELinux keeps breaking my app, can we just disable it?" How do you respond and what do you do?IntermediateYou need to know when anyone modifies `/etc/sudoers`, `/etc/passwd` or SSH config. How?IntermediateA critical OpenSSL CVE is announced. How do you find and patch affected servers quickly?Intermediate