github.com/yuin/goldmark v1.7.17: cozy-stack's span inline parser rescans the rest of the line at every `[`
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 68/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- go
- Domain
- backend, performance
Research direction
Start at model/note/custom/span.go:52-75, where spanParser.Parse scans forward from each [ to the next ], and read its registration on trigger [ in model/note/markdown.go:572. Trace how goldmark calls inline parsers per byte, then bound the scan as the report suggests and add a test that parses 200000 [ characters within a time budget. Done means the parser no longer rescans the rest of the line for every bracket and the new test passes.
Written by the indexing model from the issue text.
Description
Severity: Minor — a limited or confusing misbehaviour, of a secondary feature or in an edge case.
- Severity: medium. A line of about 2 million
[without]costs about 2·10¹² byte comparisons, which is tens of minutes of CPU by the loop count (not measured). It runs in the request goroutine and cannot be cancelled. Authenticated attacker, availability only. - CVSS 3.1: CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H — 6.5
- Found by: claude
- Where:
model/note/custom/span.go:52-75(spanParser.Parse), registered on trigger[atmodel/note/markdown.go:572 - Report on:
linagora/cozy-stack - Introduced by: sha=723540f3a1963bf49542f66a03f30642f25809e3 pr=none confidence=likely — "Start working on inline markdown common attributes" (2021-11-17). This commit added the forward scan to the first
]of the line, with nothing remembered between calls. 7e2801417905c4ee81371c04751aa9f15e8d110f ("Fix span with attributes parsing", 2021-11-18) and c2e8b9d00542b50fb9fbe6d0f11d304b6d321439 ("Fix a panic when parsing note markdown", 2021-12-13) changed the body without changing the scan. - Weakness: goldmark's
parseBlockcalls every inline parser registered for a byte at each position where the byte occurs, and moves on by one byte when the parser returnsnil. For every[:
scans up to the end of the line (2 MiB), so Nline, _ := block.PeekLine() for pos := 1; pos < len(line); pos++ { if line[pos] == ']' {[cost N²/2. goldmark's own link parser, which also triggers on[, stays linear on this input. The quadratic cost therefore comes from the custom parser. Not a taint flow. Confirmed by reading the loop and the dispatch in goldmark'sparseBlock. - Impact: CPU denial of service for every instance on the server. No data is exposed.
- Remediation: bound the scan. Spans are short, so stop at a fixed length (e.g. 1 000 bytes) or at the next
[:
Alternatively, compute the position of the nextfor pos := 1; pos < len(line) && pos < maxSpanLabel; pos++ { if line[pos] == '[' { return nil } if line[pos] == ']' { ... }]{once per line and keep it in the parserContext. Add a test that parses"["×200000 within a time budget. RunningparseFilein a worker with a deadline would also bound SEV-1 to SEV-3.
Finding SEV-4 (medium) of the twake-qa deep dependency review of cozy-stack: github.com/yuin/goldmark v1.7.17 (yuin/goldmark at v1.7.17); full report: deep-dependency-reviews/20261122-204318-eed494-github-com-yuin-goldmark.md.
Found by automated QA (twake-qa, claude -p + deep dependency review) on cb46bbc4eca2, severity: minor, browsers: none, first seen 2026-11-22.
- Dominant language
- Go
- Stars
- 1.3k
- Forks
- 147
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 146
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from linagora/cozy-stack
-
ai-driven-qa bug claude Minor
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
linagora/cozy-stack#5370 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
linagora/cozy-stack#5231 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
linagora/cozy-stack#5228 ·
Maintainers usually reply within 1 day
-
Search: update ADR 008 to send share keys from the stackPossibly taken @shepilov claimed this 9 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
linagora/cozy-stack#5210 ·
Maintainers usually reply within 1 day
-
CSP: AppendCSPRule adds the sources to an earlier directive when the directive name appears in one of its sources (e.g. https://frame-src.example.com)Possibly taken A pull request linked to this issue is open or already merged. Openai-driven-fuzzing bug Minor
Difficulty 2/5 1-3 hours Newbie friendliness 79/100
linagora/cozy-stack#5161 · 1 comment ·
Maintainers usually reply within 1 day
All issues in linagora/cozy-stack
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
Maintainers usually reply within 1 day
-
Add CybeDefendOpen
Difficulty 1/5 Under an hour Newbie friendliness 66/100
slavakurilyak/awesome-ai-agents#1031 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
kagent-dev/kagent#3792 ·
Maintainers usually reply within 1 day
-
new-compilers request
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
compiler-explorer/compiler-explorer#9640 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 85/100
google/certificate-transparency-go#1859 ·
Maintainers usually reply within 1 day