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

Fix race condition in XML parser #551

Merged
merged 3 commits into from
Apr 19, 2018
Merged

Fix race condition in XML parser #551

merged 3 commits into from
Apr 19, 2018

Conversation

vikman90
Copy link
Member

We detected that, in particular cases, the Windows agent shows this error on startup:

2018/04/17 23:42:08 ossec-agent: INFO: (4102): Connected to the server (192.168.74.2:1514).
2018/04/17 23:42:08 ossec-agent: ERROR: (1226): Error reading XML file 'ossec.conf': XMLERR: Element not opened. (line 2).
2018/04/17 23:42:08 ossec-agent: ERROR: (1226): Error reading XML file 'ossec.conf': XMLERR: Attribute '<ossec_config' has no value. (line 8).
2018/04/17 23:42:08 ossec-agent: INFO: Received exit signal.
2018/04/17 23:42:08 ossec-agent: INFO: Exiting...
2018/04/17 23:42:08 rootcheck: CRITICAL: (1202): Configuration error at 'ossec.conf'. Exiting.

(...)

2018/04/17 23:53:12 ossec-agent: INFO: (4102): Connected to the server (192.168.74.2:1514).
2018/04/17 23:53:12 ossec-agent: ERROR: (1226): Error reading XML file 'ossec.conf': XMLERR: Element not opened. (line 11).
2018/04/17 23:53:12 wazuh-modulesd:ciscat: INFO: Module disabled. Exiting...
2018/04/17 23:53:12 ossec-agent: INFO: Received exit signal.
2018/04/17 23:53:12 ossec-agent: INFO: Exiting...

This bug is due to a race condition between the Syscheck and the main thread: the former loads the Syscheck settings at the same time as the latter reads the modules. This produces a race condition in the XML parser since it uses some global variables.

This PR moves such variables to the XML structure, but does not change the algorithm.

@vikman90 vikman90 added the type/bug Something isn't working label Apr 19, 2018
@vikman90 vikman90 requested a review from albertomn86 April 19, 2018 06:07
@albertomn86
Copy link
Contributor

Tested in Windows Server 2016 👍

@albertomn86 albertomn86 merged commit cc18c29 into 3.2 Apr 19, 2018
@albertomn86 albertomn86 deleted the fix_xml_race branch April 19, 2018 06:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants