Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Potential regex compilation failure or mismatch with variable-length lookbehind in PCRE patterns

Đang mở
#3,537 2 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

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
48/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Ít trao đổi
Công nghệ
cpp
Lĩnh vực
security

Hướng nghiên cứu

Bắt đầu bằng cách tái hiện ví dụ SecRule, sau đó kiểm tra src/utils/regex.cc, tập trung vào cách ModSecurity bao bọc việc biên dịch và matching của PCRE và PCRE2. So sánh hành vi đối với lookbehind có độ dài biến đổi không được hỗ trợ và các cấu hình được hỗ trợ; công việc được coi là hoàn tất khi pattern khớp nếu được hỗ trợ hoặc tạo ra lỗi biên dịch rõ ràng khi không được hỗ trợ.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

3.x

Summary
I am experiencing issues when using regular expressions containing variable-length lookbehind assertions (e.g., (?<!.(?:target|origin).{0,20})\bhaving\b) in ModSecurity v3. The pattern fails to match as expected, likely due to limitations in the underlying PCRE library integration or configuration within src/utils/regex.cc.

Steps to Reproduce
Create a SecRule using a variable-length lookbehind:

SecRule ARGS "@rx (?<!.(?:target|origin).{0,20})\bhaving\b" "id:12345,phase:2,deny,status:403"
Send a request with a payload that should match (e.g., ?data=select having count).

Observe that the rule is not triggered.

Actual Behavior
The regex fails to match the input. In some environments, no explicit compilation error is shown in the debug log, leading to "silent failure" where the rule is simply ignored.

Expected Behavior
The regex should either:

Match the input if the linked PCRE library (PCRE2 10.30+) supports variable-length lookbehind.

Provide a clear compilation error in the ModSecurity log indicating that the pattern is unsupported by the current PCRE version.

Technical Context
Looking at src/utils/regex.cc, ModSecurity wraps PCRE/PCRE2. However:

Most PCRE1 versions (still common in many distros) strictly forbid non-fixed-width lookbehind (errors like lookbehind assertion is not fixed length).

If ModSecurity is compiled with PCRE2, it should theoretically support this, but the implementation may not be passing the necessary JIT or match options to handle complex lookbehind depth.

Ngôn ngữ chính
C++
Star
9.8k
Fork
1.8k
Merge trung bình
2 giờ 46 phút
Pull request đã merge (30 ngày)
1

Chuẩn bị môi trường

  • Không có Dockerfile hay tệp Docker Compose
  • Có mẫu pull request
  • Không có hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của owasp-modsecurity/ModSecurity

Tất cả issue của owasp-modsecurity/ModSecurity

Issue tương tự

Thêm issue về C++

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.