Can I allow one service to execute scripts in /tmp without removing noexec?

0
0
Asked By MellowQuartz47 On

We run RHEL servers with /tmp mounted using noexec for compliance. A certificate-renewal application creates temporary scripts in /tmp and then executes them, so it currently fails. The vendor says changing the application to use another directory is not possible for now. Security has approved temporarily removing noexec, but would prefer a narrower solution where only the service account can execute the files required by this application. I considered ACLs, but directory traversal permissions and newly created files make that impractical. Is there a way to allow execution for just this service, or is the choice effectively limited to enabling or disabling execution on the mount?

5 Answers

Answered By HarborLynx59 On

If the application can place all of its temporary files in one dedicated directory, another option is to mount a separate filesystem there with exec enabled and restrict access to the service account. That is more manageable than changing permissions on every new file, but it still requires the application to use that directory and does not solve the problem if /tmp is hard-coded.

Answered By BrightClover_31 On

Remember that noexec is not a complete script-execution security boundary. It prevents direct execution through the filesystem, but an executable interpreter such as bash, Python, or Perl may still read and run a script from /tmp. So bypassing noexec this way may be possible for the service account or other users who can invoke an interpreter. Treat noexec as defense in depth, not as an execution policy.

Answered By RiverStoneM8 On

Before building a workaround, verify whether the software really hard-codes /tmp. Many programs honor TMPDIR or provide a temporary-directory setting. If it truly embeds /tmp, that is a vendor defect worth escalating. An application that creates and executes arbitrary files in a world-writable directory also deserves a security review, especially for unsafe temporary-file handling.

Answered By CedarFox_82 On

The cleanest workaround is to isolate the application in its own mount namespace or container. With systemd, look at PrivateTmp= and BindPaths=. You can give the service a private /tmp backed by a filesystem mounted with exec, while the host's shared /tmp remains noexec. A container, bubblewrap, or an equivalent namespace setup can do the same thing. Test carefully because PrivateTmp= behavior and filesystem details depend on the service and systemd version.

Answered By NorthwindJay6 On

SELinux or AppArmor can enforce which executable is allowed to run files from that location. You could create a policy for the service domain that permits the required scripts while denying execution elsewhere. This is more work than a mount option and needs proper testing, but it provides the per-service control you are looking for.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.