Thanks to visit codestin.com
Credit goes to github.com

Skip to content

security: bound variable substitution expansion - #2923

Merged
alixander merged 2 commits into
masterfrom
security/substitution-expansion-limits
Sep 12, 2026
Merged

security: bound variable substitution expansion#2923
alixander merged 2 commits into
masterfrom
security/substitution-expansion-limits

Conversation

@alixander

Copy link
Copy Markdown
Collaborator

Human


AI

Summary

  • enforce a compilation-wide 65,536-unit default budget before variable substitutions or automatic copies materialize
  • cover scalar and Markdown output, array and map spreads, composite aliases, boards, imports, and classes
  • honor context cancellation throughout IR and graph compilation

Security

A few hundred bytes of D2 source could build a shared composite-variable DAG that materialized as hundreds of thousands of graph objects, exhausting more than a gigabyte of memory before cancellation could run. The compiler now accounts for every multiplicative occurrence and automatic copy before allocating it, while Markdown matching is linear in the input plus bounded match work.

Compatibility

Explicitly authored graph nodes do not consume the new budget unless D2 automatically copies them for boards, imports, or classes. The default is 65,536 work units; trusted Go callers can raise it with MaxVariableExpansion. Negative limits are rejected.

Testing

  • full Go suite and focused race tests
  • scalar, Markdown, array, map, composite, board, import, and class regression cases
  • deterministic cancellation tests during IR and graph compilation
  • adversarial reproductions for the prior composite, scalar, array, and class amplification paths

@alixander
alixander marked this pull request as ready for review September 12, 2026 19:27
@alixander
alixander merged commit 5d84d9b into master Sep 12, 2026
13 checks passed
@alixander
alixander deleted the security/substitution-expansion-limits branch September 12, 2026 19:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant