Skip to content

fix(date): cap strftime widths and account padding in memoryLimit#895

Merged
harttle merged 9 commits into
masterfrom
fix/date-strftime-width-dos
May 10, 2026
Merged

fix(date): cap strftime widths and account padding in memoryLimit#895
harttle merged 9 commits into
masterfrom
fix/date-strftime-width-dos

Conversation

@harttle
Copy link
Copy Markdown
Owner

@harttle harttle commented May 8, 2026

  • Clamp numeric strftime pad widths to MAX_STRFTIME_PAD (1024)
  • Export estimateStrftimePaddingMemory for the date filter to charge memoryLimit
  • Replace unbounded pad() concatenation loop with ch.repeat + single concat
  • Add regression tests for clamping and memoryLimit on huge %width directives

- Clamp numeric strftime pad widths to MAX_STRFTIME_PAD (1024)
- Export estimateStrftimePaddingMemory for the date filter to charge memoryLimit
- Replace unbounded pad() concatenation loop with ch.repeat + single concat
- Add regression tests for clamping and memoryLimit on huge %width directives

Co-authored-by: Cursor <cursoragent@cursor.com>
@coveralls
Copy link
Copy Markdown

coveralls commented May 8, 2026

Coverage Report for CI Build 25621737948

Coverage decreased (-0.02%) to 99.54%

Details

  • Coverage decreased (-0.02%) from the base build.
  • Patch coverage: 13 of 13 lines across 3 files are fully covered (100%).
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 2995
Covered Lines: 2988
Line Coverage: 99.77%
Relevant Branches: 1136
Covered Branches: 1124
Branch Coverage: 98.94%
Branches in Coverage %: Yes
Coverage Strength: 21948.83 hits per line

💛 - Coveralls

harttle and others added 8 commits May 9, 2026 01:37
Move strftime memory charging into the same formatting path used for padding, enforce pre-allocation checks, and add regression tests for non-string date format PoCs. Add dedicated docs clarifying that memoryLimit is cooperative DoS mitigation and not strict heap isolation.

Co-authored-by: Cursor <cursoragent@cursor.com>
Add a Chinese security-model tutorial and link it from the Chinese DoS guide to clarify that memoryLimit is cooperative accounting, list uncounted custom conversion cases, and recommend avoiding fully user-defined templates in online services.

Co-authored-by: Cursor <cursoragent@cursor.com>
Merge DoS guidance into security-model docs in both English and Chinese, and remove the placeholder dos.md pages to avoid duplicate/redirect-only docs.

Co-authored-by: Cursor <cursoragent@cursor.com>
Move the detailed parseLimit/renderLimit/memoryLimit explanations and examples into the English and Chinese security-model pages so content from the removed dos pages is preserved.

Co-authored-by: Cursor <cursoragent@cursor.com>
Restructure English and Chinese security-model docs into a consistent flow: security boundary, limits overview, per-limit details, and online service guidance.

Co-authored-by: Cursor <cursoragent@cursor.com>
Use regex-backed width assumptions to simplify %N width normalization and padding memory accounting while keeping behavior equivalent.

Co-authored-by: Cursor <cursoragent@cursor.com>
Remove MAX_STRFTIME_PAD hard capping and rely on memoryLimit enforcement before padding allocation. Update strftime/date tests and security-model docs to match the new boundary and renderLimit caveats.

Co-authored-by: Cursor <cursoragent@cursor.com>
- pad(): replace per-char loop with a single add(str, ch.repeat(n)) call.
  The earlier `probe[0] === ch` heuristic was wrong when ch happened to
  equal a leading char of 'probe' (e.g. ch === 'p').
- strftime.ts: revert unrelated typing/structural refactors so the diff
  contains only the memoryLimit threading and the %N memory charge.
- docs: rewire the deleted dos.html sidebar entry to security-model.html
  (with localized labels) so the deleted page does not 404 from the
  sidebar.

Co-authored-by: Cursor <cursoragent@cursor.com>
@harttle harttle merged commit 3129d46 into master May 10, 2026
13 checks passed
github-actions Bot pushed a commit that referenced this pull request May 14, 2026
# [10.26.0](v10.25.7...v10.26.0) (2026-05-14)

### Bug Fixes

* **date:** cap strftime widths and account padding in memoryLimit ([#895](#895)) ([3129d46](3129d46))
* enforce renderLimit for empty renderTemplates calls ([#894](#894)) ([5b9c346](5b9c346))
* propagate ownPropertyOnly into Context.spawn() for {% render %} ([#893](#893)) ([dbbf628](dbbf628))
* **security:** block Object.prototype filter/tag lookups (RCE) ([#897](#897)) ([457fae0](457fae0))
* strip html newline tags ([#892](#892)) ([26ea285](26ea285))
* **strip_html:** rewrite as linear single-pass scan to avoid ReDoS ([#896](#896)) ([3616a74](3616a74))

### Features

* add sha256 and hmac_sha256 filters for cryptographic operations ([#889](#889)) ([1c816d4](1c816d4))
@github-actions
Copy link
Copy Markdown

🎉 This PR is included in version 10.26.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants