Skip to content
Noroxi
OSV ecosystem advisory

GHSA-5478-66c3-rhxr: Pretext: Algorithmic Complexity (DoS) in the text analysis phase

High—No exploit Fix available

Noroxi assessment

Priority: Monitor (action score 0/100)

  • The sources we track (CISA KEV, Exploit-DB, Metasploit, Nuclei, GitHub) show no public exploit code or exploitation in the wild.
  • Anyone who can reach it over the internet can trigger it. No account or password is required. No user action is required. No special conditions are required; it is repeatable.
  • Fixed version: @chenglou/pretext (npm) 0.0.5.

Low priority for now. Upgrade to @chenglou/pretext (npm) 0.0.5 or later.

Generated automatically from the record's data: CVSS (NVD and CNA), CISA KEV and SSVC, FIRST EPSS, exploit sources, fixed versions. How we calculate it

Primary sources: OSV

`isRepeatedSingleCharRun()` in `src/analysis.ts` (line 285) re-scans the entire accumulated segment on every merge iteration during text analysis, producing O(n²) total work for input consisting of repeated identical punctuation characters. An attacker who controls text passed to `prepare()` can block the main thread for ~20 seconds with 80KB of input (e.g., `"(".repeat(80_000)`). Tested against commit 9364741d3562fcc65aacc50953e867a5cb9fdb23 (v0.0.4) on Node.js v24.12.0, Windows x64. A standalone PoC and detailed write-up are attached below. --- ## Root Cause The `buildMergedSegmentation()` function (line 795) processes text segments produced by `Intl.Segmenter`. When consecutive non-word-like segments consist of the same single character (e.g., `(`, `[`, `!`, `#`), the code merges them into one growing segment (line 859): ```typescript // analysis.ts:849-859 - the merge branch inside the build loop } else if ( isText && !piece.isWordLike && mergedLen > 0 && mergedKinds[mergedLen - 1] === 'text' && piece.text.length === 1 && piece.text !== '-' && piece.text !== '—' && isRepeatedSingleCharRun(mergedTexts[mergedLen - 1]!, piece.text) // <- O(n) per call ) { mergedTexts[mergedLen - 1] += piece.text // append to accumulator ``` Before each merge, it calls `isRepeatedSingleCharRun()` (line 857) to verify that ALL characters in the accumulated segment match the new character: ```typescript // analysis.ts:285-291 function isRepeatedSingleCharRun(segment: string, ch: string): boolean { if (segment.length === 0) return false for (const part of segment) { // <- Iterates ENTIRE accumulated string if (part !== ch) return false } return true } ``` `Intl.Segmenter` with `granularity: 'word'` produces individual non-word segments for each punctuation character. For a string of N identical punctuation characters, the merge check is called N times. On the k-th call, the accumulated segment is k characters long, so `isRepeatedSingleCharRun` performs k comparisons. Total work: `1 + 2 + 3 + ... + N = N(N+1)/2 = O(n^2)` ### Call chain ``` prepare(text, font) // layout.ts:472 -> prepareInternal(text, font, ...) // layout.ts:424 -> analyzeText(text, profile, whiteSpace='normal') // layout.ts:430 -> analysis.ts:993 -> buildMergedSegmentation(normalized, profile, ...) // analysis.ts:1013 -> analysis.ts:795 -> for each Intl.Segmenter segment: -> isRepeatedSingleCharRun(accumulated, newChar) // line 857 -> line 285 -> iterates entire accumulated string // O(k) per call, k growing ``` ## Proof of Concept The simplest payload is a string of repeated `(` characters: ```typescript import { prepare } from '@chenglou/pretext' // 80,000 characters -> ~20 seconds of main-thread blocking const payload = '('.repeat(80_000) prepare(payload, '16px Arial') // Blocks for ~20 seconds ``` Any single character that meets these criteria works: 1. Classified as `'text'` by `classifySegmentBreakChar` (analysis.ts:321) - i.e., not a space, NBSP, ZWSP, soft-hyphen, tab, or newline 2. Produced as individual non-word segments by `Intl.Segmenter` (word granularity) 3. Not `-` or em-dash (explicitly excluded at lines 855-856) Working payload characters include: `(`, `[`, `{`, `#`, `@`, `!`, `%`, `^`, `~`, `<`, `>`, etc. --- ## Impact - **Chat/messaging applications:** User sends an 80KB message of `(` characters; the receiving client's UI thread freezes for ~20 seconds while rendering. - **Comment/form systems:** User-supplied text in any text field that uses `pretext` for layout measurement blocks the main thread. - **Server-side rendering:** If `prepare()` is called server-side (Node.js/Bun), a single request can consume 20+ seconds of CPU time per 80KB of payload. The attack requires no authentication, special characters, or encoding tricks - just repeated ASCII punctuation. 80KB is well within typical text input limits. As an application-level mitigation, callers can cap the length of text passed to `prepare()` before a library-level fix is available. ## Suggested Fix Replace the O(n) full-scan verification with O(1) constant-time checks. Since the merge only ever appends the same character to an existing repeated-char run, the invariant is maintained structurally: **Option A - Check only endpoints (O(1)):** ```typescript function isRepeatedSingleCharRun(segment: string, ch: string): boolean { return segment.length > 0 && segment[0] === ch && segment[segment.length - 1] === ch } ``` This works for the current code because this branch only fires after earlier merge branches (CJK, Myanmar, Arabic) have been skipped, and those branches produce segments that would not start and end with the same ASCII punctuation character. However, the safety relies on an emergent property of the branch ordering and the other merge branches. Future refactors that add new merge branches or reorder the existing ones could silently break the invariant. **Option B - Track with metadata** Add a boolean `lastMergeWasSingleCharRun` alongside the accumulator arrays. Set it to `true` when a single-char merge succeeds, `false` when any other merge branch is taken. Check the flag instead of re-scanning the string.

Published
Apr 8, 2026
Updated
Apr 8, 2026
EPSS
—

Report tools

JSON

Action score

0

Monitor

Low priority for now.

CVSS
0 / 40 · —
CISA KEV
0 / 30 · Not listed
EPSS
0 / 30 · —

Get told when this record changes

  • Not in KEV: no record of exploitation in the wild
  • No public exploit code on record
  • A fix has been released

If any of these changes, we'll tell you in the daily email digest.

Follow GHSA-5478-66c3-rhxr

When you'll hear from us

  • when it enters CISA KEV
  • when exploit code appears or is weaponized
  • when the record is updated (including a fixed version)
  • when EPSS rises 20 points in a week

One daily email digest (06:00 UTC); connect a webhook for KEV listings and weaponized exploits every 10 minutes on paid plans, on the hour on the free plan.

Your free account also gets you

  • CVE alerts: add the products and versions you run, get the new CVEs that affect them
  • Uptime monitoring: 1 site, instant email when it goes down
  • Add your domain: subdomains and takeover risk scanned every week (1 domain)
  • 10 scans an hour on the security tools, at most 30 a day (3 a day without an account), an API key and MCP
  • All your scans in one panel: findings, what changed in the last scan, a report per domain or per client (PDF, share link)
All free tools
Is your version affected? Check it

Noroxi analysis

What does it mean in your environment?

The assessment above is generated automatically from the record's data; it doesn't know your environment. Our team verifies on your systems whether this vulnerability is actually exploitable and which mitigation is enough.

We use this product, ask for help

Affected systems

Is your version affected?

Pick the product and type the version you run. It's compared with this record's version ranges in your browser; the version isn't sent anywhere.

VendorProduct
npm@chenglou/pretext

Package-level exposure

OSV and GitHub Advisory data: ecosystem, package and range. SBOM matching uses this table.

EcosystemPackageAffected rangeFix
npm@chenglou/pretextbefore 0.0.50.0.5

Remediation

Which version to upgrade to

Fix versions compiled from the vendor, package registries and Microsoft. Verify the vendor's note before upgrading.

Product / packageFixed versionSource
npm:@chenglou/pretext0.0.5Package registry (OSV)

Exploit status

No known public exploit

No public exploit has been observed yet. That doesn't mean you're safe, only that the bar is a little higher.

Research context

For pentesters and researchers: attack profile, score disagreement, timeline, patch commits, credits, variant and chain candidates, bug bounty scope. All derived from existing data; no exploit code.

Timeline

From publication to today: proof of concept, Metasploit module, CISA KEV and fix record. Dates are as reported by the sources.

No dated events beyond publication.

Not on record for this CVE: EPSS history · patch commit or PR link · researcher credit · variant or chain candidate · public bounty program.

Technical details

Attack conditions

  • Anyone who can reach it over the internet can trigger it.
  • No account or password is required.
  • No user action is required.
  • No special conditions are required; it is repeatable.

If successful

Confidentiality
Integrity
Availability
Attack vector
Network
Attack complexity
Low
Privileges required
None
User interaction
None

CVSS vector

CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N

osv

Attack context

MITRE CAPEC attack patterns and ATT&CK techniques for this weakness class (CWE). A starting point for detection rules and threat hunting.

MITRE has no CAPEC/ATT&CK mapping for this CWE.

References

Show all references (2 more)

Vendor advisories and official records. Exploit/PoC links are deliberately left out.

All records