Skip to content

Commit 932cfce

Browse files
committed
Merge remote-tracking branch 'origin/fix-GHSL-2022-099'
2 parents 24065ee + 23abded commit 932cfce

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

.DS_Store

6 KB
Binary file not shown.

extensions/autolink.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,17 @@ static size_t check_domain(uint8_t *data, size_t size, int allow_short) {
127127
break;
128128
}
129129

130-
if (uscore1 > 0 || uscore2 > 0)
131-
return 0;
130+
if (uscore1 > 0 || uscore2 > 0) {
131+
/* If the url is very long then accept it despite the underscores,
132+
* to avoid quadratic behavior causing a denial of service. See:
133+
* https://github.com/github/cmark-gfm/security/advisories/GHSA-29g3-96g3-jg6c
134+
* Reasonable urls are unlikely to have more than 10 segments, so
135+
* this extra condition shouldn't have any impact on normal usage.
136+
*/
137+
if (np <= 10) {
138+
return 0;
139+
}
140+
}
132141

133142
if (allow_short) {
134143
/* We don't need a valid domain in the strict sense (with

0 commit comments

Comments
 (0)