Automating local threat intelligence feeds in Enterprise Security with a scripted input
Your threat intelligence vendor provides indicators of compromise (IOCs), such as malicious IP addresses, through a REST API, for example the Palo Alto Networks Threat Vault API, CrowdStrike Falcon Intelligence API, Recorded Future Connect API, or Microsoft Defender Threat Intelligence. There is no Structured Threat Information Expression (STIX) or Trusted Automated Exchange of Indicator Information (TAXII) feed that Splunk Enterprise Security (ES) can download, and the API returns JSON with its own field names.
You want those IOCs in native threat intelligence in ES, so that detections and investigations use them like any other threat intelligence source. The process to do this is:
- A scripted input calls the API on a schedule and indexes one JSON event per IOC. It reads the API key from Splunk platform credential storage.
- A saved search uses Search Processing Language (SPL) to map the vendor fields to the headers that Local IP Intel (
local_ip_intel) requires,description,ip,weightand writes the lookup. - The threatlist modular input loads
local_ip_intelinto theip_intelkey-value store (KV Store) collection.
This article uses IP addresses. For domains, URLs, or file hashes, write to local_domain_intel, local_http_intel, or local_file_intel with the headers listed in Supported types of threat intelligence in Splunk Enterprise Security.
Prerequisites
- Splunk Enterprise Security 8.x on a single Splunk Enterprise search head, with file system access
- An account with the
adminrole, or a role with theedit_storage_passwordscapability - The API URL and an API key
In a search head cluster, deploy the app from the deployer. The run_only_one setting in inputs.conf is not currently supported, so every cluster member runs the scripted input and calls the API independently; plan API rate limits accordingly. On Splunk Cloud Platform, package the app as a private app and submit it for vetting.
Confirm that Local IP Intel (local_ip_intel) is present under Security content > Content management. It comes with Splunk Enterprise Security and is enabled by default.
How to use Splunk software for this use case
Creating the app
Create ta_threatintel_custom under $SPLUNK_HOME/etc/apps/. Do not place it inside another app, such as SA-ThreatIntelligence or DA-ESS-ThreatIntelligence; the Splunk platform resolves some threat intelligence lookups by app name, so a custom lookup nested inside a shipped app can fail to resolve. Put app.conf in default/ and your settings in local/, so upgrades do not overwrite them. See How to edit a configuration file.
$SPLUNK_HOME/etc/apps/ta_threatintel_custom/ default/app.conf bin/fetch_threat_intel.py local/inputs.conf local/props.conf local/savedsearches.conf
default/app.conf:
[ui] is_visible = 0 label = Custom Threat Intel Scripted Input [launcher] description = Indexes threat indicators from an HTTPS REST API for Enterprise Security local intel. version = 1.0.0
Restart the Splunk platform so that it loads the app. You store the API key in this app in Storing the API key.
Storing the API key
On the search head, run the following commands. Replace <admin_user> with your account. curl prompts for your password, and read -rs reads the API key without showing it or saving it in your shell history.
read -rs API_KEY curl -k -u <admin_user> \ https://localhost:8089/servicesNS/nobody/ta_threatintel_custom/storage/passwords \ --data-urlencode name=api_key \ --data-urlencode realm=threatintel_api \ --data-urlencode "password=$API_KEY" unset API_KEY
If the XML response includes an <entry> for threatintel_api:api_key:, the credential is stored. The Splunk platform encrypts it in ta_threatintel_custom/local/passwords.conf. -k skips the certificate check on the management port, which uses a self-signed certificate by default. See Manage credentials used by apps and data inputs.
To change the key later, post the new value to the credential itself. The scripted input uses it on its next run.
read -rs API_KEY curl -k -u <admin_user> \ https://localhost:8089/servicesNS/nobody/ta_threatintel_custom/storage/passwords/threatintel_api%3Aapi_key%3A \ --data-urlencode "password=$API_KEY" unset API_KEY
Configuring the scripted input
The script follows the standard pattern in Get data from APIs and other remote data interfaces through scripted inputs. It prints one JSON object per line, and the Splunk platform indexes each line as an event. Change each line marked # Replace to match your API.
- ► Click to see the full Python script
-
bin/fetch_threat_intel.py:#!/usr/bin/env python3 import json import sys import urllib.request import splunk.rest # Replace: your vendor's API endpoint API_URL = "https://api.example.com/v1/indicators" # The app that holds the stored credential APP = "ta_threatintel_custom" # Name of the stored credential, not a file path: <realm>:<name>: from # "Storing the API key", URL-encoded (":" becomes %3A). Replace only if you # used a different realm or name. CREDENTIAL = "threatintel_api%3Aapi_key%3A" def get_api_key(session_key): _, content = splunk.rest.simpleRequest( f"/servicesNS/nobody/{APP}/storage/passwords/{CREDENTIAL}", sessionKey=session_key, getargs={"output_mode": "json"}, raiseAllErrors=True, ) return json.loads(content)["entry"][0]["content"]["clear_password"] session_key = sys.stdin.readline().strip() api_key = get_api_key(session_key) # Replace: the request body your API expects body = json.dumps({"query": "get_iocs", "days": 1}).encode("utf-8") req = urllib.request.Request( API_URL, data=body, headers={ "Content-Type": "application/json", "Accept": "application/json", # Replace "Auth-Key" with the header name your API uses "Auth-Key": api_key, }, # Replace if your API uses GET method="POST", ) with urllib.request.urlopen(req, timeout=60) as resp: payload = json.loads(resp.read().decode("utf-8")) # Replace "data" with the JSON key that holds the list of IOCs rows = payload if isinstance(payload, list) else payload.get("data", []) for row in rows: sys.stdout.write(json.dumps(row, separators=(",", ":")) + "\n")
The script holds no key. The Splunk platform passes it a session key on standard input (passAuth below), and the script uses that session key to read the credential. By default, the Splunk platform returns stored credentials only to requests from localhost; admins can change this with the Network Allow List. See Manage credentials used by apps and data inputs and Manage secret storage. The Palo Alto Networks Threat Vault API, for example, authenticates with an X-API-KEY header, not Auth-Key.
Make the script executable and owned by the account that runs the Splunk software, for example splunk:
chmod 755 $SPLUNK_HOME/etc/apps/ta_threatintel_custom/bin/fetch_threat_intel.py chown -R splunk:splunk $SPLUNK_HOME/etc/apps/ta_threatintel_custom
local/inputs.conf:
[script://./bin/fetch_threat_intel.py] interval = 3600 sourcetype = threatintel_api_raw # Replace main with your index index = main passAuth = splunk-system-user disabled = 0
local/props.conf keeps each JSON object as its own event:
[threatintel_api_raw] SHOULD_LINEMERGE = false LINE_BREAKER = ([\r\n]+) KV_MODE = json
Mapping fields with a saved search
This follows the pattern in Add threat intelligence from Splunk events: a search ends with outputlookup to a local intel lookup, and the threatlist modular input loads it. The saved search here maps the vendor's indicator field to ip, sets weight from the vendor's severity, and overwrites local_ip_intel each hour. weight is an integer from 1 to 100 that raises the risk score of matching objects; the default is 60. Use explicit spath output= and mvindex so each field has a single value. A bare | spath with KV_MODE = json can write the same field twice on one event, which leaves ip empty.
Before you use it:
- Run
| inputlookup local_ip_intel. If the lookup already holds IOCs you need to keep, export a copy first from Security content > Content management, in the Actions column, select Export, then write to a custom lookup instead of overwriting it. See Create and manage lookups in Splunk Enterprise Security. - Do not write to
ip_inteldirectly. The threatlist modular input fills it. - The search ships unscheduled (
enableSched = 0). You test it before you turn on the schedule.override_if_empty=falsekeeps the existing lookup if the search returns no results.
local/savedsearches.conf:
# Replace index=main with your index, and the path= field names with those from your API
[ta_threatintel_normalize]
search = index=main sourcetype=threatintel_api_raw earliest=-70m latest=now \
| spath output=raw_ip path=indicator \
| spath output=raw_severity path=severity \
| spath output=raw_category path=category \
| spath output=raw_tags path=tags{} \
| eval ip=mvindex(raw_ip,0) \
| eval severity=mvindex(raw_severity,0) \
| eval category=mvindex(raw_category,0) \
| eval weight=case(severity="critical" OR severity="high",80, severity="medium",60, 1=1,40) \
| eval description=category.": ".mvjoin(raw_tags,",") \
| where isnotnull(ip) AND ip!="" \
| dedup ip \
| table description ip weight \
| outputlookup local_ip_intel override_if_empty=false
cron_schedule = 0 * * * *
dispatch.earliest_time = -70m
dispatch.latest_time = now
enableSched = 0
disabled = 0
The -70m window is slightly longer than the hourly input, so a late run is still included.
Setting the refresh interval and IOC age
The shipped local_ip_intel threatlist stanza, in DA-ESS-ThreatIntelligence/default/inputs.conf, loads the lookup every 12 hours. To load it hourly, add this stanza to SA-ThreatIntelligence/local/inputs.conf; the Splunk platform merges inputs.conf across apps, so this overrides the shipped stanza:
[threatlist://local_ip_intel] interval = 3600 max_age = -7d
Make sure the saved search has run at least once, with results, before the first threatlist load; otherwise ES logs No observables or indicators found in file. max_age removes IOCs that your API stops returning. Without it, they stay for the default 30 days. You can also set Maximum age in ES: select Configure > Threat intelligence, select local_ip_intel on the Data sources page, then select Advanced edit. See Modify existing intelligence sources in Splunk Enterprise Security.
Verifying the data
Restart the Splunk platform to load the input, the saved search, and the threatlist settings. The scripted input runs when the Splunk platform starts. The saved search and the threatlist input then each run hourly, so the whole flow can take up to two hours end to end; do not treat an empty result as a failure before that.
- Confirm the raw events. You should see one event per IOC, with the vendor's field names.
index=main sourcetype=threatintel_api_raw
- Test the saved search. This is the same search without
outputlookup, so it does not change the lookup. You should see one row per IP address with a numericweight. If more than 70 minutes have passed since the restart, changeearliest=-70mtoearliest=-24h.index=main sourcetype=threatintel_api_raw earliest=-70m latest=now | spath output=raw_ip path=indicator | spath output=raw_severity path=severity | spath output=raw_category path=category | spath output=raw_tags path=tags{} | eval ip=mvindex(raw_ip,0) | eval severity=mvindex(raw_severity,0) | eval category=mvindex(raw_category,0) | eval weight=case(severity="critical" OR severity="high",80, severity="medium",60, 1=1,40) | eval description=category.": ".mvjoin(raw_tags,",") | where isnotnull(ip) AND ip!="" | dedup ip | table description ip weight - Turn on the schedule. Your role needs the
schedule_searchcapability. In Splunk Web, select Settings > Searches, reports, and alerts, findta_threatintel_normalize, click Edit, select Edit Schedule, select Schedule Report, choose the schedule, and click Save. Or run this command, which takes effect without a restart:curl -k -u <admin_user> \ https://localhost:8089/servicesNS/nobody/ta_threatintel_custom/saved/searches/ta_threatintel_normalize \ -d is_scheduled=1
To write the lookup straight away, click Run next to the search.
- Confirm the lookup. You should see the same rows as the test search.
| inputlookup local_ip_intel
- Confirm that ES loaded the lookup. This can take up to an hour after step 4. Look for
status="Wrote records to collection"withcollection="ip_intel".index=_internal sourcetype="threatintel:download" stanza=local_ip_intel
- Confirm that the IOCs are in the KV Store collection.
| inputlookup ip_intel | search threat_key=local_ip_intel
Threat findings under Analytics > Security intelligence > Threat Intelligence > Threat findings appear only after events match these IOCs.
Troubleshooting
- ► Click to see troubleshooting steps
-
- No raw events. Search
index=_internal sourcetype=splunkd component=ExecProcessor fetch_threat_intel. The Splunk platform logs everything the script writes to standard error atERRORlevel, so read the message, such as a Python traceback orConnection refused. - A password already exists when you store the key. The credential is already there. Use the command to change the key.
- The lookup looks correct but
ip_inteldoes not update. Check thatoutputlookupwrote toDA-ESS-ThreatIntelligence/lookups/local_ip_intel.csv. If that file is missing,outputlookupcreates a copy in the app that ran the search, and ES does not read it. ip_intelhas more rows than the lookup. IOCs from earlier runs stay untilmax_ageremoves them. The retention input runs every 24 hours, and only removes an IOC after the threatlist has reprocessed the file and the IOC is no longer in it, so removal can lag behindmax_ageby up to a day. To see removals, searchindex=_internal sourcetype=lookup_retention collection=ip_inteland checkdelete_count.
- No raw events. Search
Next steps
After the IOCs are in ip_intel, see Detecting threats and enriching investigations with native threat intelligence in Enterprise Security 8.5 for matching, alerting, and investigation. For URL and TAXII feeds that ES can download, see Configuring native threat intelligence sources in Enterprise Security 8.5.
These resources might help you understand and implement this guidance:
- Splunk Lantern: Working with threat intelligence sources in Enterprise Security 8.5
- Splunk Lantern: Configuring native threat intelligence sources in Enterprise Security 8.5
- Splunk Lantern: Enriching threat intelligence with cloud-based sources in Enterprise Security 8.5
- Splunk Help: Supported types of threat intelligence in Splunk Enterprise Security
- Splunk Help: Add new threat intelligence sources in Splunk Enterprise Security
- Splunk Help: Get data from APIs and other remote data interfaces through scripted inputs
- Splunk Help: Modify existing intelligence sources in Splunk Enterprise Security
- Splunk Help: Manage credentials used by apps and data inputs
- Palo Alto Networks: Threat Vault APIs

