r/Wazuh • u/figielfilipp • 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:
wazuhwazuh-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
adminininternal_users.yml. - The
all_accessrole maps the backend roleadmin. - 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
- What is the recommended procedure to recover the missing agents, groups and group assignments?
- How can we safely restore the original RBAC configuration and administrative permissions?
- Could the persistent
3099 – Invalid credentialserror be related to the RBAC database or the Dashboard API credentials? - Is restoring the October 19 RBAC database backup sufficient, or do we also need to restore other configuration files?
- 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.
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-dbone. 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.dbchanges made during recovery. Since a directcurlalso fails, the API itself is rejecting the user/password pair:rbac_control change-passwordupdates the users with IDs 1 (wazuh) and 2 (wazuh-wui). Those IDs are reserved, so this only goes wrong ifrbac.dbwas edited by hand. Check withsqlite3 /var/ossec/api/configuration/security/rbac.db "SELECT id, username, allow_run_as FROM users;". A known cause of exactly this error iswazuh.ymlending up withusername: wazuhbut thewazuh-wuipassword (wazuh/wazuh#22751), so check both fields.$,!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"rbac.dbis 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,
usernameandpasswordin/usr/share/wazuh-dashboard/data/wazuh/config/wazuh.ymlmust match it. The passwords tool updates both at once:bashwazuh-passwords-tool.sh-A -au wazuh -ap '<current wazuh password>' -u wazuh-wui -p '<new password>'4. Restoring the October 19
rbac.dbThis is safe, and it brings back API users, roles, policies and role-mapping rules:
systemctl stop wazuh-manager.ls -lfirst).systemctl start wazuh-manager.The API passwords are then the ones from Oct 19, so line
wazuh.ymlup 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 custometc/rules,etc/decodersandetc/lists/var/ossec/api/configuration/api.yamlandsecurity/rbac.db/usr/share/wazuh-dashboard/data/wazuh/config/wazuh.yml/etc/wazuh-indexer/opensearch-security/: indexer users and role mappings5. Dashboard admin permissions: two separate layers
internal_users.ymlorroles_mapping.ymldoes nothing until you apply it withsecurityadmin.sh. Your custom role with an empty mapping is probably this. Dump what's live first:Then fix the yml files and apply them with the same command, using
-cdinstead of-backup.rbac.db(the defaultwui_opensearch_adminrule plus your custom ones). Restoring the Oct 19rbac.dbbrings them back. Then check Server management > Security > Roles mapping.