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

Agent registration password includes \n #6906

Closed
asteriscos opened this issue Aug 13, 2024 · 1 comment · Fixed by #6909
Closed

Agent registration password includes \n #6906

asteriscos opened this issue Aug 13, 2024 · 1 comment · Fixed by #6909
Assignees
Labels
level/task Task issue type/bug Bug issue

Comments

@asteriscos
Copy link
Member

asteriscos commented Aug 13, 2024

Wazuh Rev Browser
4.9.0 05 Chrome, Firefox, Safari

Description
If Wazuh agent enrollment password is enabled the registration script renders a \n in a macOS password.

Preconditions

  1. Enable an agent registration password

Steps to reproduce

  1. Navigate to Endpoints summary
  2. Click on Deploy new agent
  3. Select macOS

Expected Result

  1. There should be no \n character

Actual Result

  1. There's a \n at the end of the password

Additional context

Registration command service:
https:/wazuh/wazuh-dashboard-plugins/blob/4.9.0/plugins/main/public/components/endpoints-summary/register-agent/services/register-agent-os-commands-services.tsx#L152

Screenshots

image

@asteriscos asteriscos added type/bug Bug issue level/task Task issue labels Aug 13, 2024
@JuanGarriuz JuanGarriuz self-assigned this Aug 13, 2024
@JuanGarriuz JuanGarriuz linked a pull request Aug 14, 2024 that will close this issue
6 tasks
@Desvelao
Copy link
Member

Desvelao commented Aug 14, 2024

The \n character in the echo command represents a new line. That character should be interpreted by the echo command and the generated file should not contain the literal \n and should contain a new line. This means the file /tmp/wazuh_envs should take 2 lines:

  • 1 that defines the environment variables
  • 1 blank/empty line

Depending on the echo version, this could need a flag to interpret the \n character.

In some test with macOS of @chantal-kelm and @yenienserrano, the echo commnad with the \n generates a file with a new line instead of the literal.

Testing on Linux Manjaro, the behavior of echo is different

console:~$ echo "WAZUH_MANAGER='186.0.141.122' && WAZUH_REGISTRATION_PASSWORD='mypass'\n" > /tmp/wazuh_envs
console:~$ cat /tmp/wazuh_envs
WAZUH_MANAGER='186.0.141.122' && WAZUH_REGISTRATION_PASSWORD='mypass'\n
console:~$ . /tmp/wazuh_envs
console:~$ echo $WAZUH_REGISTRATION_PASSWORD
mypassn
echo -e "WAZUH_MANAGER='186.0.141.122' && WAZUH_REGISTRATION_PASSWORD='mypass'\n" > /tmp/wazuh_envs
console:~$ cat /tmp/wazuh_envs
WAZUH_MANAGER='186.0.141.122' && WAZUH_REGISTRATION_PASSWORD='mypass'

console:~$ wc -l /tmp/wazuh_envs 

In my case, I need the usage of -e flag to interpret the \n.

It is not clear to me the problem, but I assume the issue is that the value for the password could contain a n that causes the deployment of the agent fails due to the registration password is invalid.

@JuanGarriuz found the documentation has no the new line character: https://documentation.wazuh.com/4.8/user-manual/agent/deployment-variables/deployment-variables-macos.html
image

So, we will remove the newline character for consistency with the command provided by documentation.

I was researching and I do not have context about the inclusion of that character in the wizard UI that could have been added here https:/wazuh/wazuh-dashboard-plugins/pull/5738/files#diff-7bd01e7e7705c5d16cf0f70438b484d88b2cbc8e49701e0237f52e329e516170R142

@Desvelao Desvelao reopened this Aug 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
level/task Task issue type/bug Bug issue
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

3 participants