Skip to content

fix(material/slider): prevent out of memory errors from tick marks on… - #34037

Merged
crisbeto merged 1 commit into
angular:mainfrom
SkyZeroZx:fix/slider-tick-marks-ssr
Nov 2, 2026
Merged

crisbeto merged 1 commit into
angular:mainfrom
SkyZeroZx:fix/slider-tick-marks-ssr

Conversation

@SkyZeroZx

Copy link
Copy Markdown
Contributor

The slider only renders its tick marks once it has a width, but it was computing them regardless, allocating one array entry per tick mark. Since the number of entries is derived from the min, max, step and value, a large range or a small step could result in an array big enough to exhaust the heap. This was especially problematic during server-side rendering, because the slider never has a width on the server so the array was always built and then discarded. If any of those inputs are derived from user input (e.g. query parameters), a single request could crash the server process along with every other request it was handling.

These changes skip computing the tick marks until the slider has a width.

Fixes #34036

… the server

The slider only renders its tick marks once it has a width, but it was computing them regardless, allocating one array entry per tick mark. Since the number of entries is derived from the `min`, `max`, `step` and value, a large range or a small step could result in an array big enough to exhaust the heap. This was especially problematic during server-side rendering, because the slider never has a width on the server so the array was always built and then discarded. If any of those inputs are derived from user input (e.g. query parameters), a single request could crash the server process along with every other request it was handling.

These changes skip computing the tick marks until the slider has a width.

Fixes angular#34036.
@crisbeto crisbeto added action: merge The PR is ready for merge by the caretaker target: patch This PR is targeted for the next patch release labels Nov 2, 2026
@crisbeto
crisbeto merged commit 52264e4 into angular:main Nov 2, 2026
34 of 36 checks passed
@crisbeto

crisbeto commented Nov 2, 2026

Copy link
Copy Markdown
Member

This PR was merged into the repository. The changes were merged into the following branches:

crisbeto pushed a commit that referenced this pull request Nov 2, 2026
… the server (#34037)

The slider only renders its tick marks once it has a width, but it was computing them regardless, allocating one array entry per tick mark. Since the number of entries is derived from the `min`, `max`, `step` and value, a large range or a small step could result in an array big enough to exhaust the heap. This was especially problematic during server-side rendering, because the slider never has a width on the server so the array was always built and then discarded. If any of those inputs are derived from user input (e.g. query parameters), a single request could crash the server process along with every other request it was handling.

These changes skip computing the tick marks until the slider has a width.

Fixes #34036.

(cherry picked from commit 52264e4)
@SkyZeroZx

Copy link
Copy Markdown
Contributor Author

@crisbeto Out of curiosity, I think this could be considered a security issue if an unauthenticated or low privileged attacker can control this value through a CMS API, query params, or configuration in SSR. Is there any reason why it wouldn't be?

@crisbeto

crisbeto commented Nov 2, 2026

Copy link
Copy Markdown
Member

I think that's a bit of a stretch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

action: merge The PR is ready for merge by the caretaker area: material/slider target: patch This PR is targeted for the next patch release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(MatSlider): showTickMarks can exhaust memory during SSR

2 participants