Close the PATH-hijack gap

Linux lab Beginner 2 tasks 10 points

A root cron job runs a script that calls backup-logs by bare name, with the world-writable /opt/maint/bin first on its PATH — a classic hijack setup.

Inspect the job, then lock down the writable directory.

How it works: the terminal below is a real Linux machine running in your browser. Click it and type. Tasks tick themselves off as you complete them; questions are answered in the box under each task. Press Reset any time for a fresh machine. Your password on this machine (for sudo) is student.

student@vulntech:~ Starting…
Getting your Linux machine ready…
The first start downloads about 20 MB. After that your browser keeps it, and labs start in a moment.

Hints

`cat /etc/cron.d/maint` shows /opt/maint/bin first on PATH; `ls -ld /opt/maint/bin` shows it is world-writable.

`sudo chmod 755 /opt/maint/bin` leaves only root able to write there.

Solution explanation

Root's job searched a world-writable directory first on its PATH and called a command by bare name — so any user could plant that command and have root run it. sudo chmod 755 /opt/maint/bin removed the write access that made the hijack possible. The sturdier long-term fix is to call programs by full path in privileged scripts and set an explicit PATH, but closing the directory shuts the door now.

Show solution
cd /home/student
cat /etc/cron.d/maint
ls -ld /opt/maint/bin
sudo chmod 755 /opt/maint/bin
ls -ld /opt/maint/bin
HOME LABS COMMUNITY DASHBOARD