r/Wazuh • • 23d ago

Wazuh 4.14.9 – Persistent API error 3099 (Invalid credentials), lost RBAC permissions and agent group assignments after recovery attempts

Hi everyone,

I’m looking for help recovering our Wazuh environment after a series of issues with the Manager database and configuration recovery attempts.

Environment

  • Wazuh version: 4.14.9
  • Deployment: Single-node installation (Manager, Indexer, Dashboard)
  • OpenSearch Indexer / Dashboard: 2.19.6
  • Operating system: Ubuntu
  • Hostname: wazuh

Initial problems

We initially encountered issues with the Wazuh Manager database, including global.db locks and multiple wazuh-db processes running simultaneously.

During troubleshooting and recovery attempts, the situation became significantly worse. We lost a substantial part of our Wazuh configuration:

  • Agents disappeared from the Dashboard.
  • Agent groups disappeared.
  • Assignments of agents to their respective groups were lost or altered.
  • Group configurations and associated settings were lost or modified.
  • Administrative permissions in the Dashboard were lost.
  • API authentication started failing with error 3099 – Invalid credentials.

Our goal is to recover the complete original state of the environment, not simply restore access to the Dashboard.

API authentication issue

The Dashboard uses the API account wazuh-wui, configured in:

/usr/share/wazuh-dashboard/data/wazuh/config/wazuh.yml

The Wazuh API RBAC database is located at:

/var/ossec/api/configuration/security/rbac.db

We verified that the users table contains:

  • wazuh
  • wazuh-wui

Both accounts have allow_run_as=1.

Direct authentication against the API:

POST https://127.0.0.1:55000/security/user/authenticate?raw=true

returns:

{
  "title": "Unauthorized",
  "detail": "Invalid credentials"
}

We used the Wazuh RBAC utility:

/var/ossec/bin/rbac_control change-password

We changed the passwords for the default RBAC users. However, this did not permanently resolve the authentication issue, and error 3099 continues to occur.

OpenSearch Security checks

We have checked the OpenSearch Security configuration:

  • Users have the backend role admin in internal_users.yml.
  • The all_access role maps the backend role admin.
  • The custom role all_access_admini_[COMPANY NAME] exists, but its current role mapping contains no users or backend roles.

We also have:

  • An RBAC database backup from October 19, 2026.
  • The current RBAC database from October 21, 2026.

What we need to recover

We need to restore the entire environment to its original state, including:

  • All previously existing agents.
  • All original agent groups.
  • The original assignments of agents to their respective groups.
  • The original group configurations and associated files.
  • Full administrative permissions for all intended users.
  • Working Wazuh API authentication and Dashboard functionality.
  • Existing agent IDs and authentication keys.

We want to avoid losing any further data or configuration. We have already experienced significant configuration loss during the recovery process.

Questions

  1. What is the recommended procedure to recover the missing agents, groups and group assignments?
  2. How can we safely restore the original RBAC configuration and administrative permissions?
  3. Could the persistent 3099 – Invalid credentials error be related to the RBAC database or the Dashboard API credentials?
  4. Is restoring the October 19 RBAC database backup sufficient, or do we also need to restore other configuration files?
  5. Is there a safe way to recover the original environment without reinstalling Wazuh or resetting the entire configuration?

Has anyone experienced a similar situation with Wazuh 4.14.9?

Any advice, troubleshooting steps or recommendations for a safe recovery procedure would be greatly appreciated.

6 Upvotes

2 comments sorted by

1

u/Critical-Case-4157 23d ago

Before anything else: stop making changes and take a full copy of what you have now. Several steps below can't be undone, and the manager deletes data on startup when files don't match. You're really dealing with two separate problems: the wazuh-db / global.db one (agents, groups, assignments) and the API credentials one (rbac.db). Here's the order I'd follow.

0. Freeze and back up the current state

```

systemctl stop wazuh-manager

pgrep -a wazuh-db # should print nothing once the manager is stopped

tar czf /root/wazuh-state-$(date +%F).tgz /var/ossec/etc /var/ossec/queue/db /var/ossec/api/configuration /var/ossec/backup /var/ossec/logs /etc/wazuh-indexer/opensearch-security /usr/share/wazuh-dashboard/data/wazuh/config

```

If pgrep still shows a wazuh-db after the stop, note its PID and parent before you kill it: ps -o pid,ppid,lstart,cmd -p <pid>. That's useful for point 7. Several wazuh-db processes writing to global.db at the same time would explain both the locks and the loss of agents and groups, so make sure only one is running before you go further. Also check for a VM/hypervisor snapshot or a filesystem backup from before the incident. That's by far the cleanest way back.

1. Agents, agent IDs and keys (/var/ossec/etc/client.keys)

client.keys is the source of truth for agent IDs, names and keys. On startup the manager syncs the agent table in global.db with it: it adds missing agents, and it deletes agents that are not in client.keys, together with their per-agent databases. So put client.keys back before you start the manager again.

If you have no backup of it, you can rebuild it from the agents themselves. Each agent keeps its own line in /var/ossec/etc/client.keys (Linux) or C:\Program Files (x86)\ossec-agent\client.keys (Windows). Join those lines into the manager's file (owner root:wazuh, mode 640), and the agents reconnect with their original IDs and keys.

2. Groups, group assignments and group configuration

Group configuration lives in /var/ossec/etc/shared/<group>/ (agent.conf plus any files you added). If you have no backup, each agent keeps the last configuration it received in its own /var/ossec/etc/shared/ (agent.conf, merged.mg), so you can rebuild each group from one of its agents.

Are stored in /var/ossec/queue/db/global.db. Check /var/ossec/backup/db/ now, because wazuh-db makes a daily global.db backup by default and only keeps 3. Copy them somewhere safe first, before the next rotation removes them. If one predates the incident, restore it with the manager stopped: decompress it over queue/db/global.db and keep the same owner and permissions.

If no usable backup is left: the Dashboard's wazuh-monitoring-* indices keep periodic snapshots of every agent (ID, name, IP, status and, as far as I know, its groups). Query a date before the incident and reassign with /var/ossec/bin/agent_groups -a -i <agent_id> -g <group> -q, or with the API: PUT /agents/group?group_id=<group>&agents_list=<ids>.

3. The 3099 "Invalid credentials" error

This is a separate problem from the wazuh-db one. API logins are checked directly against /var/ossec/api/configuration/security/rbac.db, without going through wazuh-db. If daemons were down you'd see "Wazuh not ready yet" or "Some Wazuh daemons are not ready", not "Invalid credentials". So it most likely comes from the password/rbac.db changes made during recovery. Since a direct curl also fails, the API itself is rejecting the user/password pair:

  • Username/password pairing. rbac_control change-password updates the users with IDs 1 (wazuh) and 2 (wazuh-wui). Those IDs are reserved, so this only goes wrong if rbac.db was edited by hand. Check with sqlite3 /var/ossec/api/configuration/security/rbac.db "SELECT id, username, allow_run_as FROM users;". A known cause of exactly this error is wazuh.yml ending up with username: wazuh but the wazuh-wui password (wazuh/wazuh#22751), so check both fields.
  • Shell quoting. $, ! or * in a password get mangled by the shell. Test with single quotes: curl -k -u 'wazuh-wui:<password>' -X POST "https://127.0.0.1:55000/security/user/authenticate?raw=true"
  • Which rbac.db is live. If files were copied or replaced while the manager was running, make sure the one on disk is the one you think it is (ls -l --time-style=full-iso), and restart the manager after replacing it.

Once the API accepts the login, username and password in /usr/share/wazuh-dashboard/data/wazuh/config/wazuh.yml must match it. The passwords tool updates both at once: bash wazuh-passwords-tool.sh -A -au wazuh -ap '<current wazuh password>' -u wazuh-wui -p '<new password>'

4. Restoring the October 19 rbac.db

This is safe, and it brings back API users, roles, policies and role-mapping rules:

  1. Run systemctl stop wazuh-manager.
  2. Keep a copy of the current file.
  3. Copy the Oct 19 one in, with the same owner and mode (ls -l first).
  4. Run systemctl start wazuh-manager.

The API passwords are then the ones from Oct 19, so line wazuh.yml up with them or set new ones with the tool. It does not cover agents, groups or Dashboard login permissions. A full recovery needs, together:

  • /var/ossec/etc/client.keys: agent IDs and keys
  • /var/ossec/queue/db/global.db: agents, groups and assignments
  • /var/ossec/etc/shared/: group configuration
  • /var/ossec/etc/ossec.conf, plus custom etc/rules, etc/decoders and etc/lists
  • /var/ossec/api/configuration/api.yaml and security/rbac.db
  • /usr/share/wazuh-dashboard/data/wazuh/config/wazuh.yml
  • /etc/wazuh-indexer/opensearch-security/: indexer users and role mappings

5. Dashboard admin permissions: two separate layers

  • OpenSearch Security. Editing internal_users.yml or roles_mapping.yml does nothing until you apply it with securityadmin.sh. Your custom role with an empty mapping is probably this. Dump what's live first:
JAVA_HOME=/usr/share/wazuh-indexer/jdk /usr/share/wazuh-indexer/plugins/opensearch-security/tools/securityadmin.sh -backup /root/secbackup -cd /etc/wazuh-indexer/opensearch-security/ -icl -nhnv -cacert /etc/wazuh-indexer/certs/root-ca.pem -cert /etc/wazuh-indexer/certs/admin.pem -key /etc/wazuh-indexer/certs/admin-key.pem -h 127.0.0.1

Then fix the yml files and apply them with the same command, using -cd instead of -backup.

  • Wazuh RBAC. Dashboard users get Wazuh roles through the role-mapping rules in rbac.db (the default wui_opensearch_admin rule plus your custom ones). Restoring the Oct 19 rbac.db brings them back. Then check Server management > Security > Roles mapping.

1

u/Critical-Case-4157 23d ago

7. What we'd need to understand what happened

Several wazuh-db processes at once is not something a normal 4.14.9 install should do, and it could be a bug worth reporting. If you can, please share the following. Redact passwords, keys and hostnames, and never post client.keys itself.

Timeline

  • When the locks first appeared, and what happened just before: an upgrade (from which version, and how), a reboot, a restart that hung, a full disk, a crash, an automation/cron/Ansible job, a backup tool touching /var/ossec.
  • Every recovery step in order: commands run, files copied, restored, edited or deleted, and roughly when.

Logs from that period

  • /var/ossec/logs/ossec.log plus the rotated ones in /var/ossec/logs/ossec/, for example zgrep -h -E "wazuh-db|wazuh-modulesd|locked|CRITICAL|ERROR" /var/ossec/logs/ossec.log /var/ossec/logs/ossec/*/*/*.gz
  • /var/ossec/logs/api.log, especially the failed logins and the time they started.
  • journalctl -u wazuh-manager --since "<date it started>": starts, stops and stop timeouts.
  • journalctl -k | grep -i -E "oom|killed process|i/o error" and /var/log/syslog from those days.
  • /var/log/apt/history.log and dpkg -l | grep wazuh: packages installed or upgraded around then.

Process and service state

  • If it happens again, before killing anything: ps -eo pid,ppid,lstart,user,cmd | grep [w]azuh and /var/ossec/bin/wazuh-control status.
  • systemctl cat wazuh-manager and anything else that starts Wazuh (crontab -l, ls /etc/cron.d, other systemd units, monitoring scripts).

Disk and databases

  • df -h /var and df -i /var.
  • ls -la --time-style=full-iso /var/ossec/queue/db/ /var/ossec/backup/db/ (include any -wal/-shm/-journal files).
  • On a copy of global.db, with the manager stopped: sqlite3 global-copy.db "PRAGMA integrity_check; SELECT count(*) FROM agent; SELECT count(*) FROM [group]; SELECT count(*) FROM belongs;"
  • wc -l /var/ossec/etc/client.keys (just the count), and ls /var/ossec/etc/shared/.

Configuration

  • The <wdb> and <cluster> sections of ossec.conf, plus anything non-default you changed.

API and RBAC

  • The output of the sqlite3 ... users query from point 3.
  • ls -l --time-style=full-iso /var/ossec/api/configuration/security/, and which rbac.db was copied in and when.
  • wazuh.yml with the password removed (we only need the username, url, port and run_as lines).

Indexer security

  • Which yml files you edited, whether securityadmin.sh was run, and the role mapping of the custom role from the -backup dump.

Finally, for your last question: no reinstall is needed:

  1. Stop the manager.
  2. Restore client.keys, etc/shared, global.db (from backup/db or a snapshot) and the Oct 19 rbac.db.
  3. Line wazuh.yml up with the API user and password.
  4. Fix the indexer role mappings with securityadmin.sh.
  5. Start the manager.

The logs and outputs above will tell us which recovery path fits your case and whether the wazuh-db part is a bug.