Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validate the agent name field in the "Deploy a new agent" section #4927

Closed
s-ocando opened this issue Nov 28, 2022 · 3 comments · Fixed by #5021, #5022, #5023, #5028 or #5029
Closed

Validate the agent name field in the "Deploy a new agent" section #4927

s-ocando opened this issue Nov 28, 2022 · 3 comments · Fixed by #5021, #5022, #5023, #5028 or #5029
Assignees
Labels
type/bug Bug issue

Comments

@s-ocando
Copy link
Contributor

s-ocando commented Nov 28, 2022

Wazuh Rev
4.4.0 4400

Description

Currently, the app allows agent names that are not valid. This causes the enrollment to fail.

The app must validate that the agent name has the minimum required length and that it contains only allowed characters.

In this example, I installed a 4.4.0 agent named "SALES DEPARTMENT" on Ubuntu 20.04 following the instructions from the UI. The installation worked without failure. The agent was active but I was unable to see it in the console.

I checked /var/ossec/logs/ossec.log and saw the message ERROR: Invalid agent name. Please pick a valid name. I changed the name to "SALES", restarted the agent and it enrolled successfully.

image

vagrant@wazuh-agent:~$ curl -so wazuh-agent-4.4.0.deb https://packages-dev.wazuh.com/staging/apt/pool/main/w/wazuh-agent/wazuh-agent_4.4.0-0.40400.20221116_amd64.deb && sudo WAZUH_MANAGER='192.168.56.44' WAZUH_AGENT_NAME='SALES DEPARTMENT' dpkg -i ./wazuh-agent-4.4.0.deb
Selecting previously unselected package wazuh-agent.
(Reading database ... 111293 files and directories currently installed.)
Preparing to unpack ./wazuh-agent-4.4.0.deb ...
Unpacking wazuh-agent (4.4.0-0.40400.20221116) ...
Setting up wazuh-agent (4.4.0-0.40400.20221116) ...
Processing triggers for systemd (245.4-4ubuntu3.15) ...
vagrant@wazuh-agent:~$ sudo systemctl daemon-reload
vagrant@wazuh-agent:~$ sudo systemctl enable wazuh-agent
Synchronizing state of wazuh-agent.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable wazuh-agent
Created symlink /etc/systemd/system/multi-user.target.wants/wazuh-agent.service → /lib/systemd/system/wazuh-agent.service.
vagrant@wazuh-agent:~$ sudo systemctl start wazuh-agent
vagrant@wazuh-agent:~$ systemctl status wazuh-agent
vagrant@wazuh-agent:~$ systemctl status wazuh-agent
● wazuh-agent.service - Wazuh agent
     Loaded: loaded (/lib/systemd/system/wazuh-agent.service; enabled; vendor preset: enabled)
     Active: active (running) since Mon 2022-11-28 09:50:15 UTC; 3min 11s ago
    Process: 3051 ExecStart=/usr/bin/env /var/ossec/bin/wazuh-control start (code=exited, status=0/SUCCESS)
      Tasks: 27 (limit: 1148)
     Memory: 109.2M
     CGroup: /system.slice/wazuh-agent.service
             ├─3083 /var/ossec/bin/wazuh-execd
             ├─3091 /var/ossec/bin/wazuh-agentd
             ├─3101 /var/ossec/bin/wazuh-syscheckd
             ├─3110 /var/ossec/bin/wazuh-logcollector
             └─3127 /var/ossec/bin/wazuh-modulesd

Nov 28 09:50:11 wazuh-agent systemd[1]: Starting Wazuh agent...
Nov 28 09:50:11 wazuh-agent env[3051]: Starting Wazuh v4.4.0...
Nov 28 09:50:11 wazuh-agent env[3051]: Started wazuh-execd...
Nov 28 09:50:11 wazuh-agent env[3051]: Started wazuh-agentd...
Nov 28 09:50:11 wazuh-agent env[3051]: Started wazuh-syscheckd...
Nov 28 09:50:12 wazuh-agent env[3051]: Started wazuh-logcollector...
Nov 28 09:50:13 wazuh-agent env[3051]: Started wazuh-modulesd...
Nov 28 09:50:15 wazuh-agent env[3051]: Completed.
Nov 28 09:50:15 wazuh-agent systemd[1]: Started Wazuh agent.

root@wazuh-agent:/home/vagrant# tail /var/ossec/logs/ossec.log 
2022/11/28 09:51:26 wazuh-agentd: ERROR: Invalid agent name "SALES DEPARTMENT". Please pick a valid name.
2022/11/28 09:51:56 wazuh-agentd: INFO: Requesting a key from server: 192.168.56.44
@s-ocando s-ocando added the type/bug Bug issue label Nov 28, 2022
@davidjiglesias davidjiglesias moved this from Triage to Todo in Release 4.4.0 Nov 28, 2022
@davidjiglesias davidjiglesias moved this to Triage in Release 4.4.0 Nov 28, 2022
@davidjiglesias davidjiglesias moved this from Todo to Triage in Release 4.4.0 Nov 29, 2022
@davidjiglesias
Copy link
Member

Agreed with @s-ocando suggestion. I would add that group name also need validation.

@Tostti Tostti self-assigned this Nov 30, 2022
This was linked to pull requests Nov 30, 2022
@Tostti
Copy link
Member

Tostti commented Nov 30, 2022

Hi @davidjiglesias, thanks for the recommendation.
However, the groups are selected from the already created groups in Wazuh, it is not possible to create new groups from the deploy new agent section.
From the groups section, it is currently not possible to create a group with an invalid name.

@asteriscos asteriscos moved this from Triage to In Review in Release 4.4.0 Dec 5, 2022
@asteriscos asteriscos moved this from In Review to Triage in Release 4.4.0 Dec 5, 2022
@davidjiglesias davidjiglesias moved this from Triage to In Progress in Release 4.4.0 Dec 13, 2022
@gdiazlo gdiazlo moved this from In Progress to In Review in Release 4.4.0 Dec 19, 2022
@chantal-kelm chantal-kelm moved this from In Review to In Progress in Release 4.4.0 Dec 20, 2022
@chantal-kelm chantal-kelm moved this from In Progress to In Review in Release 4.4.0 Dec 20, 2022
@chantal-kelm chantal-kelm removed a link to a pull request Dec 20, 2022
6 tasks
@Tostti Tostti moved this from In Review to In Progress in Release 4.4.0 Dec 20, 2022
@Tostti Tostti removed a link to a pull request Dec 20, 2022
6 tasks
@Tostti Tostti moved this from In Progress to In Review in Release 4.4.0 Dec 20, 2022
@Desvelao
Copy link
Member

Changes

  • Add validation for the characters length and valid characters

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