Skip to content

Commit c86cefc

Browse files
committed
detect/base64_data: reset buffer offset
When in a `base64_decode`-`base64_data` pair the decode was depending on another match through the relative option, the `buffer_offset` would be updated to the relative position of the previous match. During the `base64_data` phase, a relative match would use that offset even though the match happened in a new buffer. Example:: http.request_body; content:"|27|"; \ base64_decode:relative; \ base64_data; content:"|ff ff ff ff|"; within:16; This use of the `buffer_offset` is incorrect as that value is relative to a buffer and the `base64_data` points to a new buffer. This patch addresses this by resetting DetectEngineThreadCtx::buffer_offset before inspecting `base64_data`. Bug: OISF#7842. (cherry picked from commit 5f92a6c)
1 parent d782b43 commit c86cefc

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

src/detect-engine-content-inspection.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -694,6 +694,8 @@ static int DetectEngineContentInspectionInternal(DetectEngineThreadCtx *det_ctx,
694694
if (DetectBase64DecodeDoMatch(det_ctx, s, smd, buffer, buffer_len)) {
695695
if (s->sm_arrays[DETECT_SM_LIST_BASE64_DATA] != NULL) {
696696
if (det_ctx->base64_decoded_len) {
697+
/* reset buffer offset, as we treat this like a new buffer */
698+
det_ctx->buffer_offset = 0;
697699
KEYWORD_PROFILING_END(det_ctx, smd->type, 1);
698700
int r = DetectEngineContentInspectionInternal(det_ctx, ctx, s,
699701
s->sm_arrays[DETECT_SM_LIST_BASE64_DATA], NULL, f,

0 commit comments

Comments
 (0)