Securing OpenSearch¶
Signalith keeps every event, finding and investigation in OpenSearch, so anyone who can reach OpenSearch can read or change them. This page sets OpenSearch up so that:
- it answers only over HTTPS, with a certificate from a small certificate authority (CA) of your own;
- nobody signs in with a password: Signalith signs in with a client certificate, and there are no built-in users and no anonymous access;
- Signalith's certificate may touch only Signalith's own indices (
signalith*) and read the cluster's health.
The Docker quick start does all of this by itself. For OpenSearch installed on Linux or
Windows, signalith opensearch-certs makes the files and the steps below put them in
place.
Do not keep OpenSearch's demo security configuration. Its certificates, keys and
passwords (such as admin, and the kirk admin certificate) are published with
OpenSearch, so anyone can use them.
Docker quick start¶
Nothing to set up by hand. Each docker compose ... up runs two short steps around
OpenSearch. First the setup step, signalith bootstrap-docker, which:
- makes the CA and three certificates the first time (RSA 3072, valid 10 years): one for
OpenSearch, one for Signalith (
CN=signalith,O=Signalith) and an admin certificate (CN=signalith-admin,O=Signalith) that can change OpenSearch's security settings; - keeps them in the
opensearch-certsandsignalith-secretsvolumes, readable only by the container that uses them, and leaves them alone on later runs. If one is missing, damaged or due to expire within 30 days, it makes a new set; restart both then withdocker compose -f deploy/docker/docker-compose.yml restart opensearch signalith; - makes the first admin password and the shared agent token (the quick start's
ingest-token) the same way.
Then, once OpenSearch has started, the step that loads OpenSearch's security settings
(the opensearch-security service, deploy/docker/opensearch/load-security.sh).
OpenSearch loads them by itself only as it starts with none stored yet, and tries just
once, which can fail on a slow computer. So this step checks that OpenSearch has them,
and loads them with securityadmin.sh and the admin certificate when it has none, or
when the files changed since the step last loaded them (after an update of Signalith, or
your own edit). When OpenSearch is too slow to take a file, it tries that file again, for
about 10 minutes in all. Signalith starts only after this step succeeds. When there is
nothing to do, it takes a second or two.
OpenSearch runs with its security plugin on and the demo setup skipped. Its settings are
in deploy/docker/opensearch/opensearch.yml, and the users and roles in
deploy/docker/opensearch/security/: config.yml (certificate sign-in only),
internal_users.yml (empty), roles.yml (the signalith_server role) and
roles_mapping.yml (Signalith's certificate gets that role). OpenSearch publishes no
port; only Signalith reaches it, on the Docker network.
To look at OpenSearch yourself, use the admin certificate from inside its container. From the folder you cloned Signalith into (one line, in PowerShell too):
docker compose -f deploy/docker/docker-compose.yml exec opensearch curl -s --cacert config/certs/root-ca.pem --cert config/certs/admin.pem --key config/certs/admin-key.pem "https://localhost:9200/_cat/indices?v"
If you change the files in security/, for example to give roles.yml another
index_prefix, run docker compose -f deploy/docker/docker-compose.yml up -d again: the
step sees the change and loads them.
If OpenSearch's security settings aren't loaded¶
You see one of these:
docker compose -f deploy/docker/docker-compose.yml up -dends withservice "opensearch-security" didn't complete successfully: exit 1, and Signalith does not start;- the Servers page shows a red alert that OpenSearch's security settings aren't
loaded, and OpenSearch answers every request with
503andOpenSearch Security not initialized.
OpenSearch refuses everyone until its security settings are loaded. From the folder you cloned Signalith into:
- Run the usual command again. It runs the step that loads OpenSearch's security settings again, which keeps trying for about 10 minutes, and then starts Signalith:
- If it fails again, the step's log says why:
OpenSearch did not answer: OpenSearch did not start, or keeps stopping.docker compose -f deploy/docker/docker-compose.yml ps -a opensearchshows whether it runs (Up;ExitedorRestartingwhen it stopped), and the end ofdocker compose -f deploy/docker/docker-compose.yml logs opensearchsays why. Fix what it says, then do step 1 again.... has a mistake, so OpenSearch can't read it: a file indeploy/docker/opensearch/security/that you changed. Correct it, or undo your changes withgit checkout deploy/docker/opensearch/security, then do step 1 again.OpenSearch's disk is nearly full(flood-stage watermark): free some disk space, then do step 1 again. OpenSearch lifts its block by itself once there is room.OpenSearch didn't answer within 30 seconds(SocketTimeoutException) on every try: OpenSearch is too slow on this computer right now. Close other programs, or give Docker more memory and CPU (below), then do step 1 again.- OpenSearch's own log may say more:
docker compose -f deploy/docker/docker-compose.yml logs opensearch - To load them by hand instead (step 1 does the same by itself, so try it first), run
this one line:
It ends with
docker compose -f deploy/docker/docker-compose.yml exec opensearch plugins/opensearch-security/tools/securityadmin.sh -cd config/opensearch-security -icl -nhnv -cacert config/certs/root-ca.pem -cert config/certs/admin.pem -key config/certs/admin-key.pem -h localhostDone with success. On a slow computer it can end withERR: cannot upload configuration, see errors aboveinstead, after aSocketTimeoutExceptionfor one of the files; on such a computer a whole run seldom gets every file in. Run it again: each run printsSUCC: Configuration for '...' created or updatedfor each kind it stored (config,roles,tenantsand so on). Once every kind has printed that in at least one run, ask OpenSearch to use what is stored (the same command with-rlin place of-cd config/opensearch-security, one line):It ends withdocker compose -f deploy/docker/docker-compose.yml exec opensearch plugins/opensearch-security/tools/securityadmin.sh -rl -icl -nhnv -cacert config/certs/root-ca.pem -cert config/certs/admin.pem -key config/certs/admin-key.pem -h localhostReload config on all nodes. To check that OpenSearch now uses them (one line; it shows"status":"UP"once they are loaded, and"status":"DOWN"while they aren't):Then start Signalith without the step: The nextdocker compose -f deploy/docker/docker-compose.yml exec opensearch curl -s --cacert config/certs/root-ca.pem https://localhost:9200/_plugins/_security/healthup -d(after an update, say) runs the step again, and it loads the files once more, since it did not load them itself.
To give Docker more memory and CPU: OpenSearch here needs about 2 GB of memory, so give Docker at least 4 GB and 2 processors, more if the computer has them to spare.
- Docker Desktop on Windows (with WSL 2, the default): Windows sets the limits. Open
(or create) the file
.wslconfigin your user folder (C:\Users\<you>\.wslconfig) and put in it, with the numbers you want: Then quit Docker Desktop, runwsl --shutdownin PowerShell, and start Docker Desktop again. - Docker Desktop on Mac or Linux: Settings > Resources.
OpenSearch on Linux or Windows¶
Below, <config> is OpenSearch's config folder: /etc/opensearch for the Linux
packages, or the config folder where you unpacked OpenSearch on Windows (such as
C:\opensearch\config).
1. Make the certificates¶
On the Signalith server:
This is enough when OpenSearch runs on the same machine as Signalith. When it runs on
another machine, give its name with -node and every other name or address Signalith
uses to reach it with -san:
The folder it writes holds:
| Path | For |
|---|---|
opensearch/certs/ |
OpenSearch: the CA, its own certificate and key, and the admin certificate and key |
opensearch/opensearch-security/ |
OpenSearch: config.yml, internal_users.yml, roles.yml, roles_mapping.yml |
opensearch/add-to-opensearch.yml |
Lines to add to opensearch.yml |
signalith/ |
Signalith: the CA, its client certificate and key, and add-to-signalith.yaml |
The *-key.pem files are private keys. Copy them only where the steps say, and delete the
opensearch-pki folder when you are done.
Signalith uses indices named signalith*. If you set another opensearch.index_prefix,
change index_patterns in opensearch-security/roles.yml to match before step 4.
2. Put the files in place on the OpenSearch machine¶
- Copy
opensearch/certsto<config>/certs. On Linux, let only OpenSearch read it: - Copy the four files in
opensearch/opensearch-security/into<config>/opensearch-security/, replacing the ones there (keep a copy of the old ones). - Edit
<config>/opensearch.yml: delete the block from######## Start OpenSearch Security Demo Configuration ########to######## End OpenSearch Security Demo Configuration ########if there is one, and any other line starting withplugins.security.. Then paste in the contents ofopensearch/add-to-opensearch.yml. Leavenetwork.hostas it is when Signalith runs on the same machine (OpenSearch then listens on this machine only). - Restart OpenSearch:
sudo systemctl restart opensearch, or on Windows restart its service (oropensearch.bat).
3. Load the security settings¶
If OpenSearch ran with its security plugin before, which the demo configuration does, it keeps its users and roles in an index and does not read the files again. Load them once with the admin certificate. On Linux:
sudo env OPENSEARCH_JAVA_HOME=/usr/share/opensearch/jdk \
bash /usr/share/opensearch/plugins/opensearch-security/tools/securityadmin.sh \
-cd /etc/opensearch/opensearch-security/ -cacert /etc/opensearch/certs/root-ca.pem \
-cert /etc/opensearch/certs/admin.pem -key /etc/opensearch/certs/admin-key.pem -h localhost
On Windows, in PowerShell (change C:\opensearch to where OpenSearch is):
$env:OPENSEARCH_JAVA_HOME = "C:\opensearch\jdk"
C:\opensearch\plugins\opensearch-security\tools\securityadmin.bat `
-cd C:\opensearch\config\opensearch-security\ -cacert C:\opensearch\config\certs\root-ca.pem `
-cert C:\opensearch\config\certs\admin.pem -key C:\opensearch\config\certs\admin-key.pem -h localhost
It ends with Done with success. The demo users, admin included, are gone from then
on. A new OpenSearch that never ran with its security plugin loads the files by itself on
first start; running this anyway does no harm.
The admin certificate can change every security setting. It is only needed for this
command, so keep admin-key.pem somewhere safe rather than on the server.
Check that OpenSearch now refuses everyone without a certificate. Both should print
401 (on Windows, type curl.exe and use the Windows paths):
curl -s -o /dev/null -w '%{http_code}\n' --cacert /etc/opensearch/certs/root-ca.pem https://localhost:9200/
curl -s -o /dev/null -w '%{http_code}\n' --cacert /etc/opensearch/certs/root-ca.pem -u admin:admin https://localhost:9200/
4. Point Signalith at it¶
- Copy the three
.pemfiles insignalith/next tosignalith.yamland let only Signalith read them. On Linux:On Windows, copy them tosudo cp opensearch-pki/signalith/opensearch-*.pem /etc/signalith/ sudo chown signalith /etc/signalith/opensearch-*.pem sudo chmod 400 /etc/signalith/opensearch-*.pemC:\ProgramData\Signalith\, whichinstall.ps1lets only Administrators and SYSTEM (the service) read. - In
signalith.yaml, setopensearch:as insignalith/add-to-signalith.yaml: thehttps://URL,ca_file,cert_fileandkey_file. Removeusernameandpasswordif they are there. The URL's host must be a name or address the certificate covers;add-to-signalith.yamllists them. - Run
signalith validate, then restart Signalith. The Health page shows OpenSearch's status.
Renewing¶
The certificates last 10 years. To replace them, run signalith opensearch-certs into a
new folder and repeat steps 2 and 4 (step 3 too if you changed the security files), then
restart OpenSearch and Signalith, since the CA is new as well.
Other setups¶
- A cluster of several nodes:
opensearch-certsmakes a certificate for one node. For more, use your own CA, list every node's certificate subject inplugins.security.nodes_dn, and give Signalith a client certificate whose common name issignalith(or map yours tosignalith_serverinroles_mapping.yml). - Passwords instead of certificates: Signalith can also sign in with
opensearch.usernameandopensearch.password(orSIGNALITH_OPENSEARCH_PASSWORD, orSIGNALITH_OPENSEARCH_PASSWORD_FILE). It sends them overhttps://only, unless the OpenSearch is on the same machine. Give that user thesignalith_serverrole fromroles.ymlrather than an admin role.