Skip to content

[BUG] Wazuh SIEM service ignores instance secret when request leaves username/password empty #506

Description

@Minority2310

Description

When calling Wazuh_SIEM.Wazuh_SIEM/ListAgents through OctoBus without specifying
username or password, the request fails even though the instance contains valid
secret credentials.

Observed error:

INVALID_ARGUMENT: username and password are required for Wazuh JWT authentication

Root Cause

In services/wazuh__siem/src/wazuh-siem.js, requestWithDefaults does:

const username = firstDefined(req?.username, bindings.username);
const password = firstDefined(req?.password, bindings.password);

Because the proto fields are plain proto3 string fields, omitted fields decode to
empty strings "", not undefined. As a result, an empty request value incorrectly
takes priority over the instance secret.

Expected Behavior

  • Explicit non-empty request credentials should override the secret.
  • Omitted or empty request credentials should fall back to the instance secret.

Actual Behavior

Empty username and password are sent to the Wazuh Manager API, causing the
manager to reject the request as missing credentials.

Reproduction Steps

  1. Create a siem instance with valid secret.username and secret.password.
  2. Bind it to a capset.
  3. Call ListAgents with an empty JSON body:
curl -X POST \
  http://127.0.0.1:9000/capsets/dev/connect/wazuh-jxq/Wazuh_SIEM.Wazuh_SIEM/ListAgents \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer <redacted-token>' \
  -d '{}'
  1. Observe the missing-credentials error.

Suggested Fix

Treat empty strings as absent when merging request credentials:

const requestCredential = (value) => (
  value === undefined || value === null || value === '' ? undefined : value
);

const username = firstDefined(requestCredential(req?.username), bindings.username);
const password = firstDefined(requestCredential(req?.password), bindings.password);

Environment

  • Repository: chaitin/OctoBus
  • Service: services/wazuh__siem
  • Upstream commit: 43f0aca70cef817f69a7d90c220c699a99af7aca
  • OctoBus image: ghcr.io/chaitin/octobus:latest
  • Wazuh API: 4.10.0

Additional Context

ListAlerts, GetAlertSummary, ListVulnerabilities, and
GetVulnerabilitySummary may be affected anywhere Manager JWT credentials are
loaded through the same requestWithDefaults path.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions