Marseille - Advent of Sysadmin 2025 - 12/02
3 minute read •
This is part of Sad Servers’ Advent of Sysadmin 2025 series.
I’m doing each challenge every day and I’m publishing a quick write up for each one every day.
12-02: LAMP stack configuration
Spoiler alert! This gives the solution to the challenge. If you want to do it on your own, stop reading.
Scenario: “Marseille”: Rocky security
Level: Medium
Type: Fix
Tags: apache  php  advent2025
Access: Email
Description: As the Christmas shopping season approaches, the security team has asked Mary and John to implement more security measures. Unfortunately, this time they have broken the LAMP stack; the frontend is unable get an answer from upstream, thus they need your help again to fix it.
The application should be able to serve the content from the webserver.
Note for Pro users: direct SSH access is not available (yet) for this scenario.
Root (sudo) Access: True
Test: curl localhost | head -n1 returns SadServers - LAMP Stack
The “Check My Solution” button runs the script /home/admin/agent/check.sh, which you can see and execute.
Time to Solve: 15 minutes.
This one took me a bit more time than usual. Let’s start from the beginning. What do we know?
- We have a frontend and some kind of upstream server
- It’s a LAMP stack - probably apache and php from looking at the tags
- The name of the challenge points toward something about the security on Rocky linux
Let’s see what’s running on the machine:
|
So as we see here, we have apache and php-fpm running. apache is listening on port 80 and php-fpm on port 9000.
They are both running as systemd services:
|
What do we get when poking those services?
)
)
> GET
> Host:
> User-Agent:
> Accept:
>
)
Both returns a connection refused. Let’s look at the configuration files.
Going through /etc/, I found the defaults config file for apache:
<VirtualHost
<FilesMatch \.
</FilesMatch>
</VirtualHost>
There, I spotted the issue with the port: 9001 is not the right php port! It should be 9000.
Let me fix it:
# Change this line:
# SetHandler "proxy:fcgi://127.0.0.1:9001"
# To:
# SetHandler "proxy:fcgi://127.0.0.1:9000"
# Restart apache for changes to take effect
Then, the frontend was returning something else!
)
> GET
> Host:
> User-Agent:
> Accept:
>
< HTTP/1.1
< Date:
< Server: )
< Content-Length:
< Connection:
< Content-Type: ; charset=iso-8859-1
<
<!DOCTYPE <html><head>
<title>503 </head><body>
<h1>Service <p>The
</body></html>
Interestingly, we actually get a response back. Still, a 503, but better than what we had when we started!
This is where it took me some digging to find the next issue. I was not super familiar with Rocky linux. I ended up reading a lot on SELinux Security - Documentation
I grep’ed some logs in /var/log/audit/audit.log, looking for anything related to httpd.
type=AVC msg=audit()
type=SYSCALL msg=audit()) ses=4294967295 comm="httpd" exe="/usr/sbin/httpd" subj=system_u:system_r:httpd_t:s0 key=(null)ARCH=x86_64 SYSCALL=connect AUID="unset" UID="apache" GID="apache" EUID="apache" SUID="apache" FSUID="apache" EGID="apache" SGID="apache" FSGID="apache"
type=AVC msg=audit()
type=SYSCALL msg=audit()) ses=4294967295 comm="httpd" exe="/usr/sbin/httpd" subj=system_u:system_r:httpd_t:s0 key=(null)ARCH=x86_64 SYSCALL=connect AUID="unset" UID="apache" GID="apache" EUID="apache" SUID="apache" FSUID="apache" EGID="apache" SGID="apache" FSGID="apache"
This was very hard to read and didn’t give me much info. Basically, httpd was denied access to port 9000. But why?
But then I learned about audit2why and the magic happened:
| | |
type=AVC msg=audit()
# setsebool -P httpd_can_network_connect 1
# setsebool -P httpd_graceful_shutdown 1
# setsebool -P httpd_can_network_relay 1
# setsebool -P nis_enabled 1
Now this is way more readable! Reading on the first boolean, httpd_can_network_connect, I felt like I had a high chance of success: 13.3. Booleans | SELinux User’s and Administrator’s Guide | Red Hat Enterprise Linux | 7 | Red Hat Documentation
httpd_can_network_connectWhen disabled, this Boolean prevents HTTP scripts and modules from initiating a connection to a network or remote port. Enable this Boolean to allow this access.
Since we have httpd getting blocked when doing a request, that seems to match our case.
Let’s try it:
|
And success! đźš©