The exit condition is finding a day the excludes list misses
fixTaskDates lives in packages/mermaid/src/diagrams/gantt/ganttDb.js. The pre-patch body, lines 253 through 267:
const fixTaskDates = function (startTime, endTime, dateFormat, excludes, includes) {
let invalid = false;
let renderEndTime = null;
while (startTime <= endTime) {
if (!invalid) {
renderEndTime = endTime.toDate();
}
invalid = isInvalidDate(startTime, dateFormat, excludes, includes);
if (invalid) {
endTime = endTime.add(1, 'd');
}
startTime = startTime.add(1, 'd');
}
return [endTime, renderEndTime];
};
The loop iterates while startTime <= endTime. Each iteration: isInvalidDate decides whether the current startTime is on the excludes list. If it is, endTime advances by one day. startTime also advances by one day at the bottom of the loop. The two pointers move together.
The intended semantics is to stretch the task's end time forward over excluded days until enough non-excluded days have elapsed to cover the original task duration. A task that should span three working days, scheduled in a chart whose excludes covers weekends, becomes a task that runs five calendar days. The loop's exit condition startTime <= endTime depends on at least one day along the way being non-excluded. When a non-excluded day shows up, invalid becomes false, endTime stops advancing, and startTime catches up.
isInvalidDate is the predicate the loop checks against. From the same file, lines 169 through 187:
export const isInvalidDate = function (date, dateFormat, excludes, includes) {
const formattedDate = date.format(dateFormat.trim());
const dateOnly = date.format('YYYY-MM-DD');
if (includes.includes(formattedDate) || includes.includes(dateOnly)) {
return false;
}
if (
excludes.includes('weekends') &&
(date.isoWeekday() === WEEKEND_START_DAY[weekend] ||
date.isoWeekday() === WEEKEND_START_DAY[weekend] + 1)
) {
return true;
}
if (excludes.includes(date.format('dddd').toLowerCase())) {
return true;
}
return excludes.includes(formattedDate) || excludes.includes(dateOnly);
};
The penultimate clause is the relevant one. The current day's lower-cased English name (monday, tuesday, and so on) is checked against the excludes list. Any day whose name is in excludes is invalid.
The GHSA writeup names the four-line gantt source that triggers the CVE:
gantt
excludes monday,tuesday,wednesday,thursday,friday,saturday,sunday
DoS :2025-01-01, 1d
Every day of the week is in excludes. Every date isInvalidDate is asked about returns true. Inside fixTaskDates, invalid is true on every iteration; endTime advances every iteration; startTime advances every iteration; the loop's exit condition startTime <= endTime continues to hold because both sides advance by the same amount. The loop has no exit.
The advisory's separate note about mermaid.parse being unaffected unless ganttDb.getTasks() is then called maps to this. Parsing produces the AST, and the AST is safe to walk. Rendering is what invokes checkTaskDates per task, which invokes fixTaskDates, which is the function with no exit. A pipeline that parses markdown without rendering does not hit the bug. A pipeline that renders does.
The patch is a circuit breaker, not a contract
The 10.9.6 and 11.15.0 fix is commit faafb5d49106dd32c367f3882505f2dd625aa30e:
const fixTaskDates = function (startTime, endTime, dateFormat, excludes, includes) {
let invalid = false;
let renderEndTime = null;
+ const maxEndTime = endTime.add(10000, 'd');
while (startTime <= endTime) {
if (!invalid) {
renderEndTime = endTime.toDate();
}
invalid = isInvalidDate(startTime, dateFormat, excludes, includes);
if (invalid) {
endTime = endTime.add(1, 'd');
+ if (endTime > maxEndTime) {
+ throw new Error(
+ 'Failed to find a valid date that was not excluded by `excludes` after 10,000 iterations.'
+ );
+ }
}
startTime = startTime.add(1, 'd');
}
return [endTime, renderEndTime];
};
A maxEndTime is computed once at function entry as the original endTime plus ten thousand days. Each iteration of the inner invalid branch checks whether the running endTime has crossed it. If so, the function throws.
The commit message explains the constant's derivation:
I've picked 10k days, in case some users are using dateFormat and excludes to exclude entire years, since 10k days is 27 years, and anything above that starts to have noticable lag.
The number is chosen by intuition about which legitimate gantt charts the author is willing to break. Twenty-seven years is the budget. A chart whose excludes legitimately covers many years (entire calendar years marked as excluded, the example the author cites) needs the loop to keep running through them. A chart whose excludes covers all seven weekday names needs the loop to stop. The cap separates the two by the number of iterations, not by the structure of excludes.
The structural fact about the bug is that no caller of fixTaskDates asserts the upstream invariant the loop depends on, that at least one day inside the working window is not in the excludes list. The patch does not install that invariant. It installs a clock. The function's exit condition before the patch was the patience of the caller's render pipeline. The function's exit condition after the patch is the patience of the caller's render pipeline, bounded above at twenty-seven years.
The TODO is still in the file
The post-patch docblock for fixTaskDates, lines 242 through 253 of the same file after the fix landed:
/**
* TODO: what does this function do?
*
* @param {dayjs.Dayjs} startTime - The start time.
* @param {dayjs.Dayjs} endTime - The original end time (will return a different end time if it's invalid).
* @param {string} dateFormat - Dayjs date format string.
* @param {string[]} excludes - Dates or days to exclude.
* @param {string[]} includes - Dates to always include, even if they match the excludes.
* @returns {[endTime: dayjs.Dayjs, renderEndTime: Date | null]} The new `endTime`, and the end time to render.
* `renderEndTime` may be `null` if `startTime` is newer than `endTime`.
* @throws {Error} If a valid end time cannot be found after 10,000 iterations.
*/
The patch tightened the @param {*} excludes and @param {*} includes annotations into proper string[] types with one-line descriptions. The patch added a @throws clause naming the new failure mode. The patch did not delete the TODO: what does this function do? line standing above all of it.
The author who wrote the security fix improved the parameter documentation, added a throws clause for the new failure mode, and left in place the line above them asking what the function does.
The TODO is not isolated. The same file carries three sibling TODOs on the function directly above fixTaskDates, checkTaskDates:
/**
* TODO: fully document what this function does and what types it accepts
*
* @param {object} task - The task to check.
* @param {string | Date} task.startTime - Might be a `Date` or a `string`.
* TODO: is this always a Date?
* @param {string | Date} task.endTime - Might be a `Date` or a `string`.
* TODO: is this always a Date?
* @param {string} dateFormat - Dayjs date format string.
* @param {*} excludes
* @param {*} includes
*/
const checkTaskDates = function (task, dateFormat, excludes, includes) {
Four TODOs in two adjacent functions, all documenting the maintainers' uncertainty about what the code does and what types its arguments are. The functions belong to the gantt's date-arithmetic path. Both ship in every release of mermaid that supports gantt charts.
git log -S "TODO: what does this function do" traces the line back to commit a5db04b0, dated February 26 2023, the refactor(deps): replace moment with dayjs commit. The author who wrote the TODO was performing a moment-to-dayjs migration on a function whose original author had already left the codebase, did not understand what it did, annotated their incomprehension, and migrated it anyway. Three years and one month later, the function shipped CVE-2026-41150 because no later maintainer understood it well enough to ask whether excludes could legitimately cover every day of the week.
Gantt rendering is a design-debt driver
CVE-2026-41150's patch is the third denial-of-service-class fix to gantt rendering inside six months on the develop branch.
| Date |
Commit |
Subject |
| 2025-09-15 |
525a7de8 |
fix: gant chart crashing in browser |
| 2025-11-26 |
6025ec66 |
5496: fixed UI crash from excessive tick generation with invalid dates/intervals |
| 2026-03-30 |
faafb5d4 |
fix(gantt): limit loop if excluding all dates |
Three different code paths in the gantt rendering subsystem, three different attacker-influenced inputs (date format, tick interval, excludes list), three different unbounded operations. Each fix closes the specific path. The component continues to ship the underlying design: gantt rendering accepts user-supplied scheduling constraints and walks them out as iterations whose termination depends on the constraints being internally consistent. The November 2025 fix added error handling around tick generation. The March 2026 fix added a 10,000-iteration cap to date fixing. The next instance is one new attacker-supplied scheduling primitive away.
The four TODO comments in ganttDb.js are the substrate made legible. The component is fertile for this bug family because nobody owns it well enough to install upstream invariants. Patches address the specific symptom; the design holds the primitive.
The blast radius is wherever markdown renders mermaid server-side
The advisory's affected range is mermaid 10.0 through 10.9.5 and 11.0.0-alpha.1 through 11.14.0. The npm package is installed by the markdown rendering pipelines for mkdocs-material via mkdocs-mermaid2-plugin, Docusaurus via @docusaurus/theme-mermaid, mintlify, hashnode, and a long list of static-site generators that ship mermaid as the optional or default diagrammer. The mermaid CLI, @mermaid-js/mermaid-cli, ships a Puppeteer-backed renderer that takes mermaid source and produces SVG; documentation pipelines that pre-render at build time use it.
The CVSS vector AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L rates this as availability-only, network-reachable, no-privilege, no-interaction. The composition is: anyone who can submit markdown to a pipeline that renders mermaid server-side can wedge the pipeline's renderer with an eight-line gantt snippet. Pipelines that parse-but-not-render are unaffected. Pipelines that render block on the rendering thread until the host kills the process or the patch's 10,000-iteration ceiling fires.
Client-side renderers (GitHub's in-browser mermaid render, GitLab's in-browser mermaid render, viewers that ship mermaid as a JavaScript bundle) push the cost onto the viewer's browser instead of the server. The bug is the same. The victim is different. The CVSS scope is S:U; the actual scope is whatever process is unlucky enough to call ganttDb.getTasks() on attacker-supplied input.
What the function does
The function walks forward from a start date, advancing the end date past excluded days, until it finds a day the excludes list does not eliminate. The patch does not say this in the docblock. The patch leaves the question.
The TODO survived the patch.