step-examples/12-11-adversarial/Ad107.stp
Sources
- bug-reporter language: "STEP-XML hangs the loader", "DTD entity expansion blows up memory"
- CWE-776 (improper restriction of recursive entity references)
- ISO 10303-28 STEP-XML transfer
Sender
deduced — adversarial input that exercises the XML-1.0 entity-expansion path with recursively-defined internal entities
Description
ISO 10303-28 specifies an XML transfer of STEP data. A STEP-XML file may include an internal DTD; XML 1.0 permits an internal DTD to declare named entities that reference other named entities. The classic billion-laughs construction declares `&lol;` as ten `&lol1;` references, `&lol1;` as ten `&lol2;` references, and so on; expansion produces 10^N copies of the leaf string from N+1 entity declarations. A receiver whose XML parser does not cap entity-expansion depth or expanded-text size allocates gigabytes from a one-kilobyte input. Bug-reporter language: "STEP-XML billion laughs", "entity expansion DoS", "recursive XML entities in STEP".
Reproducer recipe
a `.stpx` (STEP-XML) file with an internal DTD declaring `<!ENTITY lol "lol">` then `<!ENTITY lol1 "&lol;&lol;&lol;&lol;&lol;&lol;&lol;&lol;&lol;&lol;">` repeated through `&lol9;`, with the document body referencing `&lol9;` inside an attribute value.
Expected kernel behavior
cap entity-expansion depth and expanded-text size in the XML parser used to load STEP-XML; reject documents that exceed the cap with a precise diagnostic; treat as adversarial.
Notes
Sibling of Ad104 (XXE via SYSTEM URI); both attack the STEP-XML wrapper. Synonyms: "billion laughs in STEP", "XML entity bomb in STEP-XML", "exponential entity expansion". Provenance tier: cross-file-state; defect is in the .stpx wrapper's DTD layer, not in the .stp body; bytes-level demonstration is the XML prologue. **See also**: Ad104, Ad108, Ad109. **OCC behavior**: silently accepts (no diagnostic, empty result); outside catalog's allowed set ({reject}). Kernel-bug witnessed: receivers must reject this fixture per the catalog's stated invariant.
Expected validation
occt=empty/empty gmsh=empty ifc=schema_n/a
Provenance tier
cross-file-state — defect not fully embodied in fixture bytes.
Byte assertions
contains(b'<!DOCTYPE') and contains(b'<!ENTITY')contains(b'&lol') or contains(b'lol9')
Tier-3 assertions
load == "ok"
Cross-references
Live oracle output
No live oracle data — run _run_corpus to populate.
Fixture content
Show fixture bytes
1ISO-10303-21; 2/* Billion-laughs entity-expansion bomb (STEP-XML / ISO 10303-28 wrapper layer): 3 <?xml version="1.0" encoding="UTF-8"?> 4 <!DOCTYPE step [ 5 <!ENTITY lol "lol"> 6 <!ENTITY lol1 "&lol;&lol;&lol;&lol;&lol;&lol;&lol;&lol;&lol;&lol;"> 7 <!ENTITY lol2 "&lol1;&lol1;&lol1;&lol1;&lol1;&lol1;&lol1;&lol1;&lol1;&lol1;"> 8 <!ENTITY lol3 "&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;"> 9 <!ENTITY lol4 "&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;"> 10 <!ENTITY lol5 "&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;"> 11 <!ENTITY lol6 "&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;"> 12 <!ENTITY lol7 "&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;"> 13 <!ENTITY lol8 "&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;"> 14 <!ENTITY lol9 "&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;"> 15 ]> 16 <step:iso_10303_28 xmlns:step="urn:oid:1.0.10303.28.3.1"> 17 <step:header/> 18 <step:data name="&lol9;"/> 19 </step:iso_10303_28> 20 Receiver must cap entity-expansion depth and expanded-text size (CWE-776). 21 Expansion of &lol9; produces 10^9 copies of 'lol' â ~3 GB of text. 22*/ 23/* Ad107: STEP-XML wrapper carries billion-laughs entity-expansion bomb; internal DTD declares &lol; through &lol9; with 10x fanout per level; expansion produces 10^9 copies of leaf string from 10 entity declarations; receiver whose XML parser does not cap entity-expansion depth or expanded-text size allocates gigabytes from a one-kilobyte input; receiver must cap entity-expansion depth and expanded-text size; must reject documents exceeding the cap with a precise diagnostic; CWE-776; ISO 10303-28 STEP-XML transfer; GEOMETRIC_CURVE_SET IS model entity â OCC yields empty */ 24HEADER; 25FILE_DESCRIPTION(('Ad107'),'2;1'); 26FILE_NAME('Ad107.stp','2026-06-17T00:00:00',(''),(''),'cad-research-suite','',''); 27FILE_SCHEMA(('AUTOMOTIVE_DESIGN { 1 0 10303 214 3 1 1 }')); 28ENDSEC; 29DATA; 30#1=CARTESIAN_POINT('',(0.0,0.0,0.0)); 31#2=GEOMETRIC_CURVE_SET('',(#1)); 32ENDSEC; 33END-ISO-10303-21;