Skip to content

New Agent comms API endpoint client #1

Closed
@TomasTurina

Description

@TomasTurina

Description

As detailed in wazuh/wazuh#22677, Wazuh's current communication setup is complex and needs to be refactored.

We want to replace the current wazuh-agentd service in charge of communicating with the server with a new agent. Additionally, the agent-auth tool will also be replaced by this agent.

The new agent must be able to perform the following tasks:

  • Registration:
    • Whoever installs an agent has to register it on the server only once.
    • The UUID v7 is chosen by the agent and will identify it.
    • For the request, it will use its UUID.
    • The response will include the agent credentials that need to be stored.
    • The agent will use the Server management API (it needs the login token).
  • Authentication and authorization:
    • To send/receive events, the agent needs a token.
    • For the request, it will use its UUID and credentials.
    • When it expires it must request another one and so on.
    • Proposal: OAuth 2.0 with JWTs.
    • The agent will use the Agent comms API.
  • Communication agent → server:
    • Asynchronous and event driven.
    • Open connection, pass token, send events, close connection.
    • Bulking, batching, and buffering.
    • Proposal: HTTPS, API REST.
    • The agent will use the Agent comms API.
  • Communication server → agent:
    • Connection-oriented.
    • The connection is the agent's initiative and must be kept established (pass token).
    • The agent would pull to see if it has anything (long polling GET).
    • Proposal: HTTPS, API REST.
    • The agent will use the Agent comms API.

Additionally, these are the API endpoints that the agent will use to communicate with the server:

  • /login
    Authenticate (request token).
  • /events/stateless
    Send events.
  • /events/stateful
    The same as the previous one, but it requires persistent data.
  • /commands
    In opposite direction, request made by agent to manager.

The focus of this issue will be on the following tasks:

  • Initial client design, including technological and library research.
  • PoC implementation for agent.

Implementation restrictions

  • Work with C++ (at least 17) and CMake.
  • Look for a library that has everything: libcurl, boost, gRPC, etc.
  • Everything as standard as possible.
  • Collaborate with the server team to align on communication protocols and API integration.

Plan

  • Conduct initial research on system design and relevant technologies.
  • Explore client-side designs and technologies for seamless interaction with the Agent Comms API.
  • Describe the behavior of the new agent, create UML designs.
  • Define new building system and new repository structure: Proposal.
  • Work on a Proof of Concept implementation to validate communication flows between agents and servers.
    • Initially, work with mocks.
    • Establish connection, run endpoints.
    • Upload it to a /poc folder in the new repository.

POC working branch: https://github.com/wazuh/wazuh-agent/tree/1-spike-new-agent-comms-api-endpoint-client

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions