Security

How to change the user Splunk runs scripts as?

Myelin
Explorer

We've been using the functionality in Splunk to have it kick off a script when certain search criteria is met. However, we noticed Splunk is executing those scripts as root. How can we change the user it runs scripts as? Note, that Splunk itself is not running from the root user, but a Splunk user.

0 Karma

lycollicott
Motivator

If your scripts run as root then modify your scripts to "su - desired_user -c commands".

There are actually two ways to go about that.

If your script is short and has let's say one command in it to run as another user then you could change this:

some_command_or_script_to_run

to this:

su - desired_user -c some_command_or_script_to_run

Or if your script is quite long with many different commands in it then you could make a wrapper script that had a line in it like this:

su - desired_user -c that_long_script_ with_too_many_lines_to_edit
0 Karma

LewisWheeler
Communicator

Splunk should be running scripts as the user which splunkd runs as as far as I am aware - do you have the scripts in the $SPLUNK_HOME/bin/scripts directory? or are they part of a custom app?

What sort of scripts are we talking about? Shell, VBS, Powershell?

0 Karma

Myelin
Explorer

The scripts are in fact in the $SPLUNK_HOME/bin/scripts directory and these are shell scripts.

0 Karma
Get Updates on the Splunk Community!

Detecting Remote Code Executions With the Splunk Threat Research Team

REGISTER NOWRemote code execution (RCE) vulnerabilities pose a significant risk to organizations. If ...

Observability | Use Synthetic Monitoring for Website Metadata Verification

If you are on Splunk Observability Cloud, you may already have Synthetic Monitoringin your observability ...

More Ways To Control Your Costs With Archived Metrics | Register for Tech Talk

Tuesday, May 14, 2024  |  11AM PT / 2PM ET Register to Attend Join us for this Tech Talk and learn how to ...