PL EN
WB-31C19F1BTLP:CLEARWazuh 5

Wazuh 5 rc2 in Docker: a new deployment instead of upgrading rc1

Wazuh 5.0.0-rc2 in Docker: what changed since rc1, why rc1 must be deployed again, /etc/wazuh-manager, the apid certificate, passwords and agents.

Release 5.0.0-rc2 does not read the volumes of an rc1 stack, so moving from rc1 means a new deployment next to the old stack, with new volumes. I describe what changed in rc2, the procedure I went through on a single-node stack from the wazuh-docker repository, and what has to be recreated after startup.

Wazuh 5.0 is still a release candidate: the 5.0-rc documentation and the repository carry the tag v5.0.0-rc2, so names and settings may still change. I covered the basics of the Docker stack in the article on Wazuh 5 in Docker, and ports and token enrollment of agents in the post on installing Wazuh 5. The values in the examples are synthetic: name wazuh.example.com and passwords <password>.

What changed in rc2

The release descriptions of v5.0.0-rc1 and v5.0.0-rc2 in both repositories are the same cumulative [v5.0.0] changelog. The changes below appear only in the rc2 description. I left out the entries that rc1 already had under a different issue number (HTTPS agent transport, the wazuh-manager-analysisd engine). What remains are the changes to the manager and the Docker stack.

Manager (wazuh/wazuh):

IssueChange in rc2
#40338Manager configuration moved from /var/wazuh-manager/etc to a fixed /etc/wazuh-manager, with no symlink. The directory /etc/wazuh-manager/certs has root:wazuh-manager 0750, certificates and keys root:wazuh-manager 0640.
#40339The program bin/wazuh-manager-resolve-credentials was rewritten in Python. /etc/wazuh, the shared credentials.env and the downloaded wazuh-credentials.sh are gone. The manager keeps its own CA in /etc/wazuh-manager/ca/ and publishes the CA certificate and the API passwords for the dashboard in /etc/wazuh-manager/export/.
#40337wazuh-manager-remoted and wazuh-manager-db run without chroot. The systemd unit provides the confinement (ProtectSystem=full, ReadWritePaths).
#39923The default API user wazuh-wui (ID 2) is now called wazuh-internal-client. The key WAZUH_MANAGER_WUI_PASSWORD keeps its name.
#40684The API login lockout counts failed attempts per client address and user pair. In rc1 it counted them per address only.
#40125Active response gets an allowlist, and responses never target the manager or loopback.

Images and stack (wazuh/wazuh-docker):

IssueChange in rc2
#2743Images and Compose files adapted to separate credentials for each package and to /etc/wazuh-manager. Final images built on amazonlinux:2023-minimal.
#2728The Server API certificate issued by wazuh-certs-tool.sh is mounted in the manager.
#2758The dashboard listens on port 443 inside the container.
#2760Port 514/udp is no longer published, because manager 5.0 does not listen on it.
#2664Full TLS hostname verification between the dashboard and the indexer by default.
#2762The undocumented path /wazuh-migration was removed from the manager image.
#2724The image build checks the signature of the Wazuh packages and the checksum of tini.
#2721certificates-conf.sh stops when wazuh-certs-tool.sh returns an error or wazuh-certificates/ is missing.

The full list of changes between the tags is in the comparison v5.0.0-rc1...v5.0.0-rc2 in wazuh-docker (85 commits).

Why rc1 does not move to rc2 by swapping images

The upgrade.md guide from tag v5.0.0-rc2 says it directly: “A deployment of 5.0.0 RC 1 or an earlier pre-release cannot be upgraded either (wazuh/wazuh#40338): deploy 5.0 again with new volumes”. The “Between 5.x releases” procedure (stop, change the tags, docker compose up -d) only works from rc2 onwards.

The Compose file shows the reason. The configuration volume has the same name but a different mount point:

Elementrc1rc2
Volume wazuh_etc/var/wazuh-manager/etc/etc/wazuh-manager
Manager certificates/var/wazuh-manager/etc/certs//etc/wazuh-manager/certs/
Manager CA/var/wazuh-manager/etc/certs/root-ca.pem/etc/wazuh-manager/ca/root-ca.pem and certs/root-ca.pem
Server API pairnoneapid.pem, apid-key.pem
Dashboard443:5601, SERVER_PORT=5601443:443
514/udppublishedremoved

In rc1 defs.h the configuration paths are relative (etc/... under /var/wazuh-manager), and in rc2 the constant WAZUH_MANAGER_CONF_DIR has the value /etc/wazuh-manager. Binaries, logs and queue stay under /var/wazuh-manager. The agent still uses /var/ossec.

A second Compose project next to rc1

I stopped the rc1 stack without removing the volumes and kept its working directory in case of a rollback:

cd <rc1 checkout>/single-node
docker compose down
docker volume ls --filter name=wazuh_

Compose adds the project name to the volume name, and the default project name is the directory name, so the rc1 volumes are called single-node_wazuh_etc and so on. The rc2 Compose files use the same volume names, so rc2 in a second single-node directory would attach the rc1 volumes. That is why, in the new checkout of tag v5.0.0-rc2 and before the first docker compose command, I set a different project name, as the guide does for the path from 4.x:

echo "COMPOSE_PROJECT_NAME=wazuh-5" > .env

The network name changes together with the project: instead of single-node_default you get wazuh-5_default. A container attached to the rc1 network has to be moved to the new one.

Certificates: three manager pairs, --api-san and the same CA

In rc2 the manager mounts three pairs: indexer-connector for the indexer, remoted for agents and the new apid for the Server API on port 55000. The single-node documentation says the manager does not start without the remoted and apid pairs, and that the certificate tool must come from RC 2 or later, because earlier ones do not issue the apid pair. The rc1 tool indeed does not contain the string apid.

The certificates-conf.sh script in rc2 takes two address options:

[--cert] [--copy] [--priv] [--agent-san <ip|dns>]... [--api-san <ip|dns>]...

--agent-san adds an address to the agent listener certificates, and --api-san to the Server API certificate, for clients that reach 55000 through a name outside the manager node list in config.yml.

The root CA directory needs the most care. The rc1 tool read the CA from /etc/wazuh/ca by default. The rc2 tool looks for it in wazuh-ca/ next to itself, and when it is not there, it creates a new CA with a warning that the certificates “do not chain to the root CA of any existing deployment”. I kept the old CA, so that clients trusting the old root-ca.pem do not need a new file. Agents get the CA in the enrollment token anyway. The variable WAZUH_CA_DIR points to the existing CA directory and must be an absolute path. The script runs ./wazuh-certs-tool.sh, so I save the tool and config.yml from the pre-release pool under these names in the single-node directory. In config.yml I enter the node addresses, as in the steps of the single-node documentation:

curl -fsS -o wazuh-certs-tool.sh https://packages-staging.xdrsiem.wazuh.info/pre-release/5.x/installation-assistant/wazuh-certs-tool-5.0.0-rc2.sh
curl -fsS -o config.yml https://packages-staging.xdrsiem.wazuh.info/pre-release/5.x/installation-assistant/config-5.0.0-rc2.yml

I pass the variable through env so that it survives sudo:

sudo env WAZUH_CA_DIR=/etc/wazuh/ca bash ../tools/utils/deployment/certificates-conf.sh \
    --cert --copy --priv --agent-san wazuh.example.com --api-san wazuh.example.com

The output should include the message “Using the existing root CA in /etc/wazuh/ca”.

On my deployment the apid certificate had wazuh.manager, localhost, 127.0.0.1, ::1 and every address from --api-san in its SAN. The apid key is new, so an API client that pins the public key or the certificate fingerprint needs a new value.

Passwords from rc1 without retyping them

Both releases keep the passwords in config/credentials/indexer.env, manager.env and dashboard.env, with the same five keys: WAZUH_INDEXER_ADMIN_PASSWORD, WAZUH_INDEXER_KIBANASERVER_PASSWORD, WAZUH_INDEXER_MANAGER_PASSWORD, WAZUH_MANAGER_API_PASSWORD, WAZUH_MANAGER_WUI_PASSWORD. The rc1 script needed the downloaded wazuh-credentials.sh library for this. The rc2 script checks the passwords with the policy from build-docker-images/shared/password-policy.sh and needs nothing outside the checkout.

credentials-conf.sh takes the value of a key set in the environment, checks it and writes nothing if any value fails the policy. I passed the passwords from the rc1 files in environment variables, all five keys at once:

sudo env WAZUH_INDEXER_ADMIN_PASSWORD='<password>' \
    WAZUH_INDEXER_KIBANASERVER_PASSWORD='<password>' \
    WAZUH_INDEXER_MANAGER_PASSWORD='<password>' \
    WAZUH_MANAGER_API_PASSWORD='<password>' \
    WAZUH_MANAGER_WUI_PASSWORD='<password>' \
    bash ../tools/utils/deployment/credentials-conf.sh

The script never overwrites existing files. --force replaces them and, according to the documentation, is only for a deployment that has never been started. Editing the .env files after the first start changes nothing, because the deployment keeps the passwords from the first run. To change a password in a running stack, use password-tool.sh.

Agents

The new manager has an empty agent registry, so every agent must enroll again with a token. There is no enrollment password in 5.0. I issue the token through the API: first POST /security/user/authenticate?raw=true, then POST /agents/enrollment-tokens with the fields address and embed_ca. The token carries the manager address and its CA, so the agent needs no other connection settings.

The address in the token must be one of the addresses in the remoted certificate. I check the list with the command from the documentation:

for cert in config/wazuh_*/certs/*-remoted.pem; do sudo openssl x509 -noout -ext subjectAltName -in "$cert"; done

The error address not in certificate SAN means the address is not on that list. In my setup an agent built from rc1 enrolled with a token in the rc2 manager and connected. In my setup the staging pool published both releases as package 5.0.0-1, so apt did not upgrade the rc1 agent.

The shared configuration of the default group now lives in /etc/wazuh-manager/shared/default/agent.conf. In my setup I moved the 4.x procedure to the new paths: a copy under a temporary name, a check, and only then the replacement:

docker compose cp agent.conf wazuh.manager:/etc/wazuh-manager/shared/default/agent.conf.tmp
docker compose exec wazuh.manager /var/wazuh-manager/bin/verify-agent-conf -f /etc/wazuh-manager/shared/default/agent.conf.tmp
docker compose exec wazuh.manager sh -c 'cd /etc/wazuh-manager/shared/default && chown wazuh-manager:wazuh-manager agent.conf.tmp && chmod 660 agent.conf.tmp && mv agent.conf.tmp agent.conf'

What to recreate after the new deployment

ElementWhere it was in rc1What to do in rc2
Agent registryrc1 manager volumestoken enrollment
API users and rolesrc1 manager RBAC databasecreate again
Content Manager custom space (integration, decoders, Sigma rules)rc1 indexerupload and promote again
Clients pinning the API certificatepublic key without an apid pairnew fingerprint from the apid pair
Containers in the stack networksingle-node_defaultwazuh-5_default

I described promoting content between spaces in the article on Sigma rules in Wazuh 5. The path from 4.x with the wazuh-migrate-identity.py tool is covered in the post on migrating from 4.x.

Verification

After docker compose up -d I checked the container state and the default passwords with the script from the repository, as the guide says:

docker compose ps
../tools/tests/check-default-credentials.sh
docker compose exec wazuh.manager /var/wazuh-manager/bin/wazuh-manager-conf validate

In my setup the password script reported “17 checks, all passed”, and wazuh-manager-conf validate exited with code 0 and no messages. The VERSION.json file in the manager image has "stage": "rc2".

Rolling back to rc1

The rc1 volumes stay untouched, so rolling back means stopping rc2 and starting rc1 in its directory:

cd <rc2 checkout>/single-node
docker compose down
cd <rc1 checkout>/single-node
docker compose up -d

None of these commands gets -v, because that would remove the volumes.

What the documentation does not specify

  • A path from rc1 to rc2 beyond the sentence “deploy 5.0 again with new volumes”.
  • Whether wazuh-migrate-identity.py supports a 5.x source. The guide describes it only for 4.x.
  • The SAN content of the apid certificate. The list given above comes from my deployment.
  • Package numbering: rc1 and rc2 in the staging pool have the same version 5.0.0-1.
  • Uploading a group agent.conf in the 5.0 Docker stack. I carried the -f option of verify-agent-conf and mode 660 over from 4.x.
  • Agent behavior after rolling back to rc1. An agent enrolled in rc2 has a key from rc2, so I assume it enrolls again in rc1. I did not test this.

Sources

↑↓ select Enter open Esc close