Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/webmention-fix-polynomial-redos-link-header.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@dwk/webmention": patch
---

fix(webmention): remove ambiguous quantifier pair in `Link` header parsing regex flagged by CodeQL as a polynomial ReDoS (`js/polynomial-redos`). The redundant `\s*` immediately before `(.*)$` overlapped with what `.` can already match, allowing crafted `Link` header values (attacker-controlled, fetched from a webmention source/target) to force excessive backtracking. Parameter-leading whitespace is still stripped by the per-parameter `rel` regex in `extractRel`, so behavior is unchanged.
2 changes: 1 addition & 1 deletion packages/webmention/src/html.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export function parseLinkHeader(value: string | null): LinkHeaderEntry[] {
}
const entries: LinkHeaderEntry[] = [];
for (const part of splitLinks(value)) {
const match = /^\s*<([^>]*)>\s*(.*)$/.exec(part);
const match = /^\s*<([^>]*)>(.*)$/.exec(part);
if (match === null) {
continue;
}
Expand Down
Loading