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 the CA's key in a volume of its own (below). It leaves them alone on later runs. If a certificate is missing, damaged or due to expire within 30 days, it makes that one again under the same CA; 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
signalith_snapshots for scheduled snapshots) and
roles_mapping.yml (Signalith's certificate gets signalith_server, and
signalith_snapshots only once you register a snapshot repository with snapshot.sh register). 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.
Where the CA's key is kept¶
The CA's certificate and key are in the opensearch-ca volume, which only the setup step
mounts: OpenSearch and Signalith never see the key. Guard it like a password: whoever has
it can make certificates OpenSearch trusts. A backup of the Docker volumes holds it, so
keep such backups as private as the data itself.
Versions before this one did not keep the key. Such an install keeps working as it is, and
the setup step's log says once per up that the key was not kept. Its certificates last
10 years, but to renew one, or to add servers, give it a CA with a key first (see
Replacing the CA).
To run the setup step by hand with one of the options below, from the folder you cloned Signalith into (one line, in PowerShell too):
More names or nodes under the same CA¶
-opensearch-name NAMEadds a host name or IP address to OpenSearch's certificate, for when something reaches OpenSearch by another name. Repeat it, or separate names with commas. The certificate is made again under the same CA and keeps the name from then on; restart OpenSearch to use it.-nodes Nkeeps certificates for N OpenSearch nodes:node.pemfor the first (CN=opensearch), thennode-2.pem(CN=opensearch-2) and so on, all in theopensearch-certsvolume. They are kept and renewed like the first, and never deleted when N goes down.
Handing the CA key to Signalith¶
To add servers, Signalith gives each one its own OpenSearch certificate
(CN=signalith-server-<name>,O=Signalith), which roles_mapping.yml maps to the same
signalith_server role. For that it needs the CA:
This puts opensearch-ca.pem and opensearch-ca-key.pem in the import folder of
Signalith's state volume, readable only by Signalith. Within a minute Signalith keeps the
CA in the cluster's shared settings, its key encrypted with the cluster key, deletes the
key file, and switches itself to a certificate of its own (see
Each server's own OpenSearch certificate).
Start Signalith at least once before running it. If the files are already waiting there,
it leaves them as they are.
Loading changed security settings¶
docker compose -f deploy/docker/docker-compose.yml run --rm setup bootstrap-docker -apply-security
docker compose -f deploy/docker/docker-compose.yml up -d
The first command makes the step that loads OpenSearch's security settings forget what it
loaded last, so the next up loads every file again. You seldom need it: an update of
Signalith that changes roles_mapping.yml or another file in security/ is loaded on the
next up anyway, since the step compares the files with what it loaded last. On OpenSearch
installed without Docker, run securityadmin.sh (or .bat) as in
step 3.
Replacing the CA¶
docker compose -f deploy/docker/docker-compose.yml run --rm setup bootstrap-docker -new-ca
docker compose -f deploy/docker/docker-compose.yml restart opensearch signalith
This makes a new CA, keeps its key, and makes every certificate again under it. The setup
step never does this by itself, even when the CA is about to expire (after 10 years): it
stops with a message pointing here instead. Everything the old CA issued stops working:
the certificates Signalith made for other servers, and Signalith's own copy of the CA. Run
-export-ca-key again: Signalith then keeps the new CA in place of the old one, and each
server gets a new certificate of its own.
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 did not say whether the snapshot role is mapped: the step could not ask OpenSearch whether scheduled snapshots are set up, so it loaded nothing rather than take that permission away. It usually means OpenSearch was still starting or too busy to answer; 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 |
ca/ |
The CA's certificate and key: never copy it to OpenSearch |
The *-key.pem files are private keys. Copy them only where the steps say. Keep the ca
folder with the admin, somewhere safe, like a password: it makes certificates for more
nodes and servers under the same CA (below). Delete the rest of 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: - Delete the demo certificates OpenSearch put directly in
<config>(esnode.pem,kirk.pem,root-ca.pemand their keys), but not your newcertsfolder. OpenSearch refuses to start while they are there (Demo certificates found), and the Linux packages put them there even when the demo setup is skipped. On Linux: On Windows, delete the.pemfiles inC:\opensearch\config(not in itscertsfolder). - 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.
More nodes under the same CA¶
For another node of the same OpenSearch cluster, give -ca-dir the ca folder of the first
run (or that run's -out folder), the new node's name, and with -peer the names of the
other nodes:
signalith opensearch-certs -ca-dir opensearch-pki/ca -node search2 -san 10.0.0.6 -peer search1 -out opensearch-pki-search2
It writes that node's certificate and the CA's certificate in opensearch/certs/, and a
new Signalith client certificate in signalith/, all under the same CA; no new admin
certificate (use the first one). add-to-opensearch.yml lists every node in
plugins.security.nodes_dn; add the new node's name to the other nodes' nodes_dn too.
Node names may not be signalith or start with signalith-: those are for Signalith's own
certificates.
Snapshot permissions¶
The signalith_snapshots role lets Signalith keep its
scheduled snapshots policy, and lets OpenSearch take
and delete the snapshots as Signalith. It names each action it needs (the policy's
write, get, delete and explain, and cluster:admin/snapshot/create, get and
delete, with cluster:admin/repository/get), so it cannot restore or clone
snapshots. It is not given to Signalith until you want scheduled snapshots (see
What OpenSearch needs). Know what it allows:
- Snapshot rights cover every repository. OpenSearch cannot limit them to one, so Signalith can list, take and delete snapshots in any repository, not only its own.
- Snapshots that Signalith's credentials can delete do not protect against a compromised Signalith. Copy the repository off-site, or keep it on WORM storage such as an S3 bucket with Object Lock (see Copies elsewhere).
- Removing the mapping does not stop the snapshots. OpenSearch runs the policy with
the roles stored with it when Signalith wrote it. To turn them off, turn Scheduled
snapshots off in the settings, or delete the policy with the admin account
(
DELETE _plugins/_sm/policies/<opensearch.index_prefix>-daily), and then remove thesignalith_snapshotsmapping.
OpenSearch's own audit log¶
Signalith keeps its own audit log of what people do (see Audit). OpenSearch keeps one too, of who tried to reach it: failed sign-ins, requests refused for missing permissions, TLS and certificate errors, and every change to its security settings. Successful requests are left out, since they are Signalith's own searches and writes. These records go to OpenSearch's log rather than an index, so Signalith's certificate, which can write to the indices, cannot change them.
The Docker quick start, the Helm chart and the files signalith opensearch-certs makes
turn it on. To read it:
- Docker:
docker compose -f deploy/docker/docker-compose.yml logs opensearch | grep -i audit - Linux:
grep -i audit /var/log/opensearch/*.log - Windows: the
logsfolder of the OpenSearch install.
On OpenSearch set up before this, do these two steps in this order.
- Load Signalith's
audit.yml. Once the security settings are loaded, OpenSearch takes what it logs fromaudit.ymlin itsopensearch-securityfolder rather than fromopensearch.yml, and the one that comes with OpenSearch logs request bodies. Signalith's makes the same choices as the lines below. The Docker quick start and the Helm chart load it for you. Without Docker, copyopensearch/opensearch-security/audit.ymlfrom the filessignalith opensearch-certsmakes into theopensearch-securityfolder and load it withsecurityadmin.sh -f audit.yml -t audit(the certificates and host as when you loaded the other files). This changes nothing yet while the audit type is stillnoop. -
Add these lines to
opensearch.ymlin place ofplugins.security.audit.type: noop, and restart OpenSearch:plugins.security.audit.type: log4j plugins.security.audit.config.disabled_rest_categories: ["AUTHENTICATED", "GRANTED_PRIVILEGES"] plugins.security.audit.config.disabled_transport_categories: ["AUTHENTICATED", "GRANTED_PRIVILEGES"] plugins.security.audit.config.log_request_body: false plugins.security.audit.config.exclude_sensitive_headers: true
Loading audit.yml first means OpenSearch never logs request bodies, even for a moment.
Renewing¶
The CA and the certificates last 10 years. In the Docker quick start, the setup step makes a certificate again under the same CA when it is within 30 days of expiry; only the CA itself needs replacing by hand.
Without Docker, make new certificates under the same CA with
signalith opensearch-certs -ca-dir opensearch-pki/ca -node <name> -out <new folder> and
repeat steps 2 and 4, then restart OpenSearch and Signalith. Without the ca folder, run
signalith opensearch-certs into a new folder instead and repeat steps 2 and 4 (step 3
too if you changed the security files): the CA is then new as well.
Moving to OpenSearch 3.x¶
The Docker quick start uses OpenSearch 3.9 from Signalith 0.3.0 on; earlier versions used
2.17. Signalith works with both, and the security settings on this page are the same for
each. An OpenSearch 2.17 data volume starts directly on 3.9 and keeps its events, findings
and security settings, so a quick start updated with git pull moves on its next up.
OpenSearch can't go back to 2.17 on the same data once 3.9 has started on it, so copy the OpenSearch volume first, from the Signalith folder (PowerShell or a terminal):
docker compose -f deploy/docker/docker-compose.yml stop
docker run --rm -v docker_opensearch-data:/data -v "${PWD}:/backup" alpine tar czf /backup/opensearch-data-2.17.tgz -C /data .
Then update and start as in
Upgrading the Docker quick start.
The step that loads the security settings loads them once more after the move (3.x has no
whitelist.yml), which is expected. To stay on 2.17 for now, put the 2.17 image on the
opensearch and opensearch-security services in an override file and add
-f deploy/docker/docker-compose.override.yml to each command:
# deploy/docker/docker-compose.override.yml
services:
opensearch:
image: opensearchproject/opensearch:2.17.1
opensearch-security:
image: opensearchproject/opensearch:2.17.1
On OpenSearch installed without Docker, follow OpenSearch's own upgrade steps and keep the
opensearch.yml lines from step 2.
Other setups¶
- A cluster of several nodes: make each node's certificate under the same CA (see
More nodes under the same CA), or use your own CA, list
every node's certificate subject in
plugins.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, andsignalith_snapshotstoo for scheduled snapshots.