Lack of error checking on calls to UTF8toUTF16, rule filter bypass
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 35/100
Hướng nghiên cứu
Bắt đầu trong rules.c, xung quanh hai lệnh gọi UTF8toUTF16, và xem xét triển khai chuyển đổi trong linuxWideChar.c; sau đó kiểm tra các đường dẫn phân tích liên quan trong xml.cpp. Tái hiện đầu vào UTF-8 không hợp lệ và xác minh rằng việc lọc không truy cập dữ liệu heap không hợp lệ cũng không vượt qua quy tắc dự định; xác nhận hành vi khi chuyển đổi thất bại bằng các bài kiểm thử tập trung hoặc một bản tái hiện tối thiểu.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Summary
Event filtering in Sysmon For Linux incorrectly assumes event data, such as executable image paths, will be valid UTF-8 and that conversion to UTF-16 will always succeed. This can result in incorrect filtering results and event logging bypass.
Details
Event filtering on Linux makes two calls to UTF8toUTF16 before comparing event data against filter rules:
#if defined __linux__
// on Linux, convert data to UTF16, on heap
size_t fieldValueLen = UTF8toUTF16( NULL, (PCHAR)fieldValue, 0 );
WCHAR *fieldValueUTF16 = (WCHAR *)malloc(fieldValueLen * sizeof(WCHAR));
if (fieldValueUTF16 == NULL) {
printf("Out of memory\n");
return Failed;
}
UTF8toUTF16( fieldValueUTF16, (PCHAR)fieldValue, fieldValueLen );
fieldValue = fieldValueUTF16;
#endif
The first call to it is done in such a way that it just computes the length of the would-be converted string, the value of which is then used in a call to malloc, where the second call performs actual conversion on the newly allocated heap space.
The issue is that Linux paths are not required to be UTF-8 and calls to UTF8toUTF16 can fail, which is not accounted for:
- The first call to
UTF8toUTF16results in error, with returns zero. https://github.com/Sysinternals/SysmonForLinux/blob/f5d6219ec099acf61c1d3b3eecdabaed69faefe4/linuxWideChar.c#L38 mallocis then called with argument0(fieldValueLen * sizeof(WCHAR)), which can return a valid pointer on the heap.UTF8toUTF16is called again to perform the conversion on this newly allocated heap space, but no data will be written because the argument tolenis zero https://github.com/Sysinternals/SysmonForLinux/blob/f5d6219ec099acf61c1d3b3eecdabaed69faefe4/linuxWideChar.c#L58- The code continues to call
MatchFilterOnSpecificRulewith our pointer on the heap, which will result in either comparing against invalid heap data or aNULLpointer dereference.
This could be used to bypass filter rules where a match should be found for an event. For example, an executable at path /tmp/� (where the “�” is hex FF) with the following filter rule:
...
<ProcessCreate onmatch="include">
<Image condition="begin with">/tmp</Image>
</ProcessCreate>
...
On Fixing
The invalid heap access could be resolved by checking for errors from UTF8toUTF16. For example: https://github.com/inickles/SysmonCommon/commit/01a772320d385146cd91a71b186e9eaa7c912963
However, this does not fully mitigate the issue of being a potential event filter bypass. FilterEventRules will default to excluding events if no matches were found and there are multiple rules defined:
https://github.com/Sysinternals/SysmonCommon/blob/73ae2ac398dcba2ae01c2e40664f662c9fc270c8/rules.c#L1968
It seems the conversion to UTF-16 is done to be able to code shared with the Windows version, but in do so Sysmon For Linux apparently assumes these conversions will always succeed, which won’t always be the case.
Other issues in assuming UTF8toUTF16 will succeed can be found in Sysmon For Linux config parsing in https://github.com/Sysinternals/SysmonCommon/blob/73ae2ac398dcba2ae01c2e40664f662c9fc270c8/xml.cpp, though these are seemingly less serious, where a filter value might be terminated earlier than expected.
- Ngôn ngữ chính
- C
- Star
- 2.2k
- Fork
- 222
- Merge trung bình
- 4 giờ 50 phút
- Pull request đã merge (30 ngày)
- 3
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của microsoft/Sysmon-Linux
-
ProcessCreate: ParentImage is empty when the parent starts the process from a non-main threadĐang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 68/100
microsoft/Sysmon-Linux#253 ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 72/100
microsoft/Sysmon-Linux#252 ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 55/100
microsoft/Sysmon-Linux#247 ·
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 12/100
microsoft/Sysmon-Linux#246 · 3 bình luận ·
-
Sysmon service executable remains `(deleted)` after restart, causing repeated needrestart restarts and systemd start-limit-hitCó thể làm lại được @MarioHewardt đã nhận 31 ngày trước và không có pull request nào đang mở. Đang mở
microsoft/Sysmon-Linux#244 · 1 người được giao ·
Tất cả issue của microsoft/Sysmon-Linux
Issue tương tự
-
Implement looks_size reporterĐang mởenhancement good first issue help wanted
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
-
bug multiplayer status: planned
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 67/100
ChupathingyCE/chupathingyce#851 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 73/100
HigherOrderCO/Bend#2104 ·
-
Research radar digest 2026-W46Đang mởresearch-radar
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 1 ngày
-
good first issue help wanted program
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 83/100
hffgzktbcc-blip/ounce-core#297 ·
Maintainer thường phản hồi trong vòng 1 ngày