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

Ruleset search bars don't sanitize input #3968

Closed
Tracked by #4312
jctello opened this issue Apr 12, 2022 · 6 comments
Closed
Tracked by #4312

Ruleset search bars don't sanitize input #3968

jctello opened this issue Apr 12, 2022 · 6 comments
Assignees
Labels
component/search-bar Issues related to the App's search bar component level/task Task issue request/operational Operational requests type/bug Bug issue

Comments

@jctello
Copy link
Contributor

jctello commented Apr 12, 2022

In the Management > {Rules, Decoders, CDB lists} screens if special characters such as & or ; (ampersand or semicolon) are used in the search bar an error occurs.
image

The full error dialog shows:
image

_callee3/_callee3$/<@https://WAZUH-DASHBOARD-ADDRESS/1/bundles/plugin/wazuh/wazuh.chunk.7.js:5:1885772

It's worth doing a thorough investigation of this as this may be indicative of a potential code injection possibility.

On 4.2.x the input is accepted although it won't find rules with a matching description.
image

Finally the error message Error when get the items of rules is grammatically incorrect and confusing.

@jctello jctello added type/bug Bug issue request/operational Operational requests release/4.3.0 labels Apr 12, 2022
@havidarou
Copy link
Member

Related to #4312

@AlexRuiz7 AlexRuiz7 added the component/search-bar Issues related to the App's search bar component label Jul 20, 2022
@snaow snaow added this to the Release 4.5.0 milestone Nov 16, 2022
@snaow snaow removed this from the Release 4.5.0 milestone Dec 21, 2022
@Desvelao Desvelao self-assigned this Feb 7, 2023
@Desvelao
Copy link
Member

Desvelao commented Feb 7, 2023

I was researching a problem with a particular API search in the Wazuh plugin. When the value of search query parameter contains &, the API replies that is not a valid format.

I was testing to do the desired request, without expected results. I don't know if this request is allowed by the API. I wil ask to the colleagues for more information.

Some tests with cURL:

Manager used: 4.4.0 built from sources v4.4.0-beta1
Wazuh plugin:
"name": "wazuh",
"version": "4.4.0",
"revision": "01",
"stage": "beta",
"commit": "c6c3bf7ef",
"pluginPlatform": {
"version": "2.4.1"
}

wz_api_token=$(curl -u wazuh:wazuh -s -k -X POST "https://localhost:55000/security/user/authenticate?raw=true")
curl -k -H "Authorization: Bearer ${wz_api_token}" https://localhost:55000/rules -G --data-urlencode "search=att&ck"
{"title": "Bad Request", "detail": "'att&ck' is not a 'search'. Failed validating 'format' in schema: {'format': 'search', 'type': 'string'}. On instance: 'att&ck'"}
curl -k -H "Authorization: Bearer ${wz_api_token}" https://localhost:55000/rules -G --data-urlencode "search=att%26ck"
{"title": "Bad Request", "detail": "'att&ck' is not a 'search'. Failed validating 'format' in schema: {'format': 'search', 'type': 'string'}. On instance: 'att&ck'"}

API logs:

2023/02/07 08:20:02 INFO: wazuh 172.18.0.1 "GET /rules" with parameters {"search": "att&ck"} and body {} done in 0.075s: 400
2023/02/07 08:20:45 INFO: wazuh 172.18.0.1 "GET /rules" with parameters {"search": "att%26ck"} and body {} done in 0.018s: 400

I attach some screenshots when using the Wazuh plugin.

Image
Image

API logs:

2023/02/07 08:24:16 INFO: wazuh-wui 172.18.0.3 "GET /rules" with parameters {"search": "att&ck", "offset": "0", "limit": "10", "sort": "+id"} and body {} done in 0.018s: 400
2023/02/07 08:24:59 INFO: wazuh-wui 172.18.0.3 "GET /rules" with parameters {"search": "att%26ck", "offset": "0", "limit": "10", "sort": "+id"} and body {} done in 0.017s: 400

@Desvelao
Copy link
Member

Desvelao commented Feb 7, 2023

According to the @vicferpoy , the search query parameter has a regex restriction.

_search_param = re.compile(r'^[^;|&^*>]+$')

image
image

The search query parameter doesn't support & or ; characters. I don't know the reason for this, according to @davidjiglesias this could be related to SQL injection or any other sort of thing.

I asked @gdiazlo what is the action item taking into account the shared information.

@Desvelao
Copy link
Member

Desvelao commented Feb 7, 2023

According to @davidjiglesias , we could use the q query parameter instead to do the search.

Another issue suggesting this approach: #5198

@Desvelao
Copy link
Member

Desvelao commented Feb 7, 2023

We move this issue to 4.5.0 because it needs some changes in the search bar and there is an epic issue #4312 to redo it.

@gdiazlo gdiazlo added the level/task Task issue label Mar 17, 2023
@gdiazlo
Copy link
Member

gdiazlo commented Jul 20, 2023

Closing this as the development is being done in #4312

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/search-bar Issues related to the App's search bar component level/task Task issue request/operational Operational requests type/bug Bug issue
Projects
None yet
Development

No branches or pull requests

6 participants