@locker/cli 0.28.7 → 0.29.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -28,6 +28,7 @@
28
28
  const {
29
29
  assign: ObjectAssign$LWS$1,
30
30
  freeze: ObjectFreeze$LWS$1,
31
+ defineProperty: ObjectDefineProperty$LWS,
31
32
  defineProperties: ObjectDefineProperties$LWS,
32
33
  getOwnPropertyDescriptors: ObjectGetOwnPropertyDescriptors$LWS,
33
34
  getOwnPropertySymbols: ObjectGetOwnPropertySymbols$LWS,
@@ -1017,6 +1018,10 @@
1017
1018
  const {
1018
1019
  parse: JSONParse$LWS
1019
1020
  } = JSON;
1021
+ // Used by '@locker/near-membrane-dom'.
1022
+ const {
1023
+ stringify: JSONStringify$LWS$1
1024
+ } = JSON;
1020
1025
  function getNearMembraneProxySerializedValue$LWS$1(object$LWS) {
1021
1026
  if (typeof object$LWS === 'object' && object$LWS !== null || typeof object$LWS === 'function') {
1022
1027
  // To extract the serialized value of a blue near-membrane proxy we must
@@ -1369,7 +1374,7 @@
1369
1374
  // reads identically to what isGaterEnabledFeature stores (register and
1370
1375
  // deregister also accept the short form via fullName above). Frozen so a
1371
1376
  // consumer cannot mutate the shared array.
1372
- Object.freeze([`${FEATURE_NAME_PREFIX$LWS}changesSince.260`, `${FEATURE_NAME_PREFIX$LWS}changesSince.262`, `${FEATURE_NAME_PREFIX$LWS}changesSince.264`, `${FEATURE_NAME_PREFIX$LWS}htmlAnchorElementHrefValidation`, `${FEATURE_NAME_PREFIX$LWS}enableSandboxedSameOriginIframe`, `${FEATURE_NAME_PREFIX$LWS}xmlEntityAttackPrologScan`]);
1377
+ Object.freeze([`${FEATURE_NAME_PREFIX$LWS}changesSince.260`, `${FEATURE_NAME_PREFIX$LWS}changesSince.262`, `${FEATURE_NAME_PREFIX$LWS}changesSince.264`, `${FEATURE_NAME_PREFIX$LWS}changesSince.266`, `${FEATURE_NAME_PREFIX$LWS}htmlAnchorElementHrefValidation`, `${FEATURE_NAME_PREFIX$LWS}enableSandboxedSameOriginIframe`, `${FEATURE_NAME_PREFIX$LWS}iframeSrcSameOriginPreflightCheck`, `${FEATURE_NAME_PREFIX$LWS}xmlEntityAttackPrologScan`]);
1373
1378
  function registerGaterEnabledFeatures$LWS(lockerGaterEnabledFeatures$LWS) {
1374
1379
  if (ArrayIsArray$LWS$1(lockerGaterEnabledFeatures$LWS)) {
1375
1380
  lockerGaterEnabledFeatures$LWS.forEach(feature$LWS => gaterEnabledFeatures$LWS.add(fullName$LWS(feature$LWS)));
@@ -1436,7 +1441,22 @@
1436
1441
  if (constructor$LWS === ObjectCtor$LWS$1) {
1437
1442
  // If the constructor, own or inherited, points to `Object`
1438
1443
  // then `target` is not likely a prototype object.
1439
- return true;
1444
+ //
1445
+ // `constructor` is read by prototype-walking destructuring, so
1446
+ // it reflects any writable `constructor` data property anywhere
1447
+ // on the chain, including one owned entirely by sandboxed code.
1448
+ // A genuine plain object (`{}`) reaches `Object` because its
1449
+ // *immediate* prototype IS `Object.prototype`; a real host node
1450
+ // whose `[[Prototype]]` runs through a sandboxed subclass merely
1451
+ // *inherits* a `constructor` the sandbox can repoint to the
1452
+ // captured `Object` (e.g. `Carrier.prototype.constructor = Object`
1453
+ // on a custom element). Requiring the immediate prototype to be
1454
+ // `Object.prototype` keeps `{}` live while denying the forged
1455
+ // signal to such nodes. Failing this check errs toward "static",
1456
+ // the fully-distorted path, so it cannot open a new bypass.
1457
+ if (!isGaterEnabledFeature$LWS('changesSince.266') || ReflectGetPrototypeOf$LWS$1(target$LWS) === ObjectProto$LWS$1) {
1458
+ return true;
1459
+ }
1440
1460
  }
1441
1461
  // eslint-disable-next-line no-empty
1442
1462
  } catch (_unused16$LWS) {}
@@ -1539,7 +1559,7 @@
1539
1559
  const PromiseResolve$LWS = PromiseCtor$LWS.resolve.bind(PromiseCtor$LWS);
1540
1560
  const PromiseReject$LWS = PromiseCtor$LWS.reject.bind(PromiseCtor$LWS);
1541
1561
  toSafeSet$LWS(new SetCtor$LWS$1());
1542
- /*! version: 0.28.7 */
1562
+ /*! version: 0.29.1 */
1543
1563
 
1544
1564
  /*!
1545
1565
  * Copyright (C) 2019 salesforce.com, inc.
@@ -1562,6 +1582,24 @@
1562
1582
  get: AttrProtoValueGetter$LWS,
1563
1583
  set: AttrProtoValueSetter$LWS
1564
1584
  } = ReflectGetOwnPropertyDescriptor$LWS(AttrProto$LWS, 'value');
1585
+ // Realm-generic structural check for a genuine `Attr` instance: recognizes an
1586
+ // `Attr` minted from ANY realm (e.g. a same-origin iframe's document), unlike
1587
+ // `instanceof Attr`, which only matches instances from the realm that
1588
+ // captured the `Attr` constructor. A real `Attr`, from any realm, carries the
1589
+ // internal slot backing `AttrProtoNameGetter` and the call succeeds; anything
1590
+ // else (including a same-realm impostor with a forged prototype chain)
1591
+ // throws a TypeError ("Illegal invocation").
1592
+ function isAttr$LWS(value$LWS) {
1593
+ if (value$LWS === null || typeof value$LWS !== 'object' && typeof value$LWS !== 'function') {
1594
+ return false;
1595
+ }
1596
+ try {
1597
+ ReflectApply$LWS$1(AttrProtoNameGetter$LWS, value$LWS, []);
1598
+ return true;
1599
+ } catch (_unused$LWS) {
1600
+ return false;
1601
+ }
1602
+ }
1565
1603
  function normalizeNamespacedAttributeName$LWS(attrName$LWS) {
1566
1604
  const href$LWS = 'href';
1567
1605
  // Prevent arbitrary:href from being treated like a valid namespaced href value
@@ -1595,6 +1633,7 @@
1595
1633
  get: DocumentProtoCookieGetter$LWS,
1596
1634
  set: DocumentProtoCookieSetter$LWS
1597
1635
  } = ReflectGetOwnPropertyDescriptor$LWS(DocumentProto$LWS$1, 'cookie');
1636
+ const DocumentProtoCurrentScriptGetter$LWS = ObjectLookupOwnGetter$LWS$1(DocumentProto$LWS$1, 'currentScript');
1598
1637
  const DocumentProtoDefaultViewGetter$LWS = ObjectLookupOwnGetter$LWS$1(DocumentProto$LWS$1, 'defaultView');
1599
1638
  const DocumentProtoDocumentElementGetter$LWS = ObjectLookupOwnGetter$LWS$1(DocumentProto$LWS$1, 'documentElement');
1600
1639
  const DocumentProtoHeadGetter$LWS = ObjectLookupOwnGetter$LWS$1(DocumentProto$LWS$1, 'head');
@@ -1685,7 +1724,7 @@
1685
1724
  location$LWS.replace(url$LWS);
1686
1725
  }
1687
1726
  // eslint-disable-next-line no-empty
1688
- } catch (_unused$LWS) {}
1727
+ } catch (_unused2$LWS) {}
1689
1728
  }
1690
1729
  return win$LWS;
1691
1730
  }
@@ -1738,7 +1777,7 @@
1738
1777
  ReflectApply$LWS$1(WindowLocationGetter$LWS, value$LWS, []);
1739
1778
  return true;
1740
1779
  // eslint-disable-next-line no-empty
1741
- } catch (_unused2$LWS) {}
1780
+ } catch (_unused3$LWS) {}
1742
1781
  }
1743
1782
  return false;
1744
1783
  }
@@ -1920,6 +1959,118 @@
1920
1959
  get: ElementProtoOuterHTMLGetter$LWS
1921
1960
  } = ReflectGetOwnPropertyDescriptor$LWS(ElementProto$LWS, 'outerHTML');
1922
1961
  const ElementProtoTagNameGetter$LWS = ObjectLookupOwnGetter$LWS$1(ElementProto$LWS, 'tagName');
1962
+ // Realm-generic structural check for a genuine `Element` instance: recognizes
1963
+ // an `Element` minted from ANY realm (e.g. a same-origin iframe's document),
1964
+ // unlike `instanceof Element`, which only matches instances from the realm
1965
+ // that captured the `Element` constructor. A real `Element`, from any realm,
1966
+ // carries the internal slot backing `ElementProtoTagNameGetter` and the call
1967
+ // succeeds; anything else (including an `Attr` or a same-realm impostor with a
1968
+ // forged prototype chain) throws a TypeError ("Illegal invocation").
1969
+ function isElement$LWS(value$LWS) {
1970
+ if (value$LWS === null || typeof value$LWS !== 'object' && typeof value$LWS !== 'function') {
1971
+ return false;
1972
+ }
1973
+ try {
1974
+ ReflectApply$LWS$1(ElementProtoTagNameGetter$LWS, value$LWS, []);
1975
+ return true;
1976
+ } catch (_unused4$LWS) {
1977
+ return false;
1978
+ }
1979
+ }
1980
+ // Bounded set of IDL-reflected, slot-backed accessor names from which a
1981
+ // realm-generic WebIDL "brand" witness is derived for an element interface. For
1982
+ // every element interface LWS registers an attribute distortion against, at
1983
+ // least one of these names resolves -- on the interface's own prototype, or a
1984
+ // nearer ancestor than the shared Element/Node bases -- to a native accessor
1985
+ // whose getter reads an internal slot and throws ("Illegal invocation") when
1986
+ // applied to a receiver lacking that slot. 'targetElement' covers the SMIL
1987
+ // animation interfaces (SVGAnimateElement/SVGSetElement), whose own prototypes
1988
+ // expose no slot-backed accessor of their own (it lives on their shared
1989
+ // SVGAnimationElement ancestor). Extend this list when a new distortion targets
1990
+ // an interface none of these accessors reaches.
1991
+ const INTERFACE_BRAND_WITNESS_NAMES$LWS = ['src', 'href', 'data', 'action', 'formAction', 'targetElement'];
1992
+ // A non-instance sentinel. Applying a genuine slot-backed interface accessor to
1993
+ // it must throw; that is how a candidate witness is validated to actually
1994
+ // brand-check, rejecting any lenient accessor that would return undefined
1995
+ // instead of throwing (a lenient witness would match every value and select the
1996
+ // wrong distortion).
1997
+ const BRAND_WITNESS_SENTINEL$LWS = {
1998
+ __proto__: null
1999
+ };
2000
+ const interfaceBrandWitnessCache$LWS = toSafeWeakMap$LWS$1(new WeakMapCtor$LWS$1());
2001
+ // Sibling-subtype caveat: when the witness is found on an ANCESTOR rather than
2002
+ // on `Ctor.prototype` itself, it is shared by every sibling subtype of that
2003
+ // ancestor. `targetElement` lives on `SVGAnimationElement`, so it witnesses
2004
+ // both `SVGAnimateElement` and `SVGSetElement`, and `isElementOfInterface`
2005
+ // cannot tell those two apart. This is only observable once `instanceof` has
2006
+ // already missed (a repointed-prototype or cross-realm element) AND two such
2007
+ // siblings are registered under the same attribute; today the only overlap is
2008
+ // the SMIL 'attributeName'/'to' distortions, whose sibling implementations are
2009
+ // equivalent, so a substituted sibling applies the same sanitization. Every
2010
+ // HTML interface here has an OWN slot-backed accessor and so is witnessed
2011
+ // exactly. If a future SMIL distortion diverges between siblings, give that
2012
+ // interface an own-prototype witness rather than relying on the shared
2013
+ // ancestor.
2014
+ function deriveInterfaceBrandWitness$LWS(Ctor$LWS) {
2015
+ const proto$LWS = Ctor$LWS === null || Ctor$LWS === undefined ? undefined : Ctor$LWS.prototype;
2016
+ if (proto$LWS === null || typeof proto$LWS !== 'object' && typeof proto$LWS !== 'function') {
2017
+ return null;
2018
+ }
2019
+ for (let i$LWS = 0, {
2020
+ length: length$LWS
2021
+ } = INTERFACE_BRAND_WITNESS_NAMES$LWS; i$LWS < length$LWS; i$LWS += 1) {
2022
+ const name$LWS = INTERFACE_BRAND_WITNESS_NAMES$LWS[i$LWS];
2023
+ let current$LWS = proto$LWS;
2024
+ while (current$LWS !== null && current$LWS !== undefined) {
2025
+ const getter$LWS = ObjectLookupOwnGetter$LWS$1(current$LWS, name$LWS);
2026
+ if (getter$LWS !== undefined) {
2027
+ let brandChecks$LWS = false;
2028
+ try {
2029
+ ReflectApply$LWS$1(getter$LWS, BRAND_WITNESS_SENTINEL$LWS, []);
2030
+ } catch (_unused5$LWS) {
2031
+ brandChecks$LWS = true;
2032
+ }
2033
+ if (brandChecks$LWS) {
2034
+ return getter$LWS;
2035
+ }
2036
+ }
2037
+ current$LWS = ReflectGetPrototypeOf$LWS$1(current$LWS);
2038
+ }
2039
+ }
2040
+ return null;
2041
+ }
2042
+ // Realm-generic replacement for `value instanceof Ctor` when `Ctor` is a DOM
2043
+ // element-interface constructor. `instanceof` only recognizes instances minted
2044
+ // by the realm that captured `Ctor`; a genuine element created in another realm
2045
+ // -- a same-origin iframe's document, or a detached `createHTMLDocument()`
2046
+ // document owned by another realm -- carries the interface's internal slots yet
2047
+ // fails `instanceof`. This applies one of the interface's own slot-backed
2048
+ // accessors to `value`: a genuine instance of `Ctor`'s interface (or a
2049
+ // subclass), from ANY realm, carries the backing slot and the call succeeds;
2050
+ // anything else (a different interface, or a forged prototype chain a la
2051
+ // `Reflect.construct(Audio, [], HTMLScriptElement)`) throws and is rejected.
2052
+ //
2053
+ // Returns false when no slot-backed witness can be derived for `Ctor`, so a
2054
+ // caller keeps its realm-bound `instanceof` fast path for that entry.
2055
+ function isElementOfInterface$LWS(value$LWS, Ctor$LWS) {
2056
+ if (value$LWS === null || typeof value$LWS !== 'object' && typeof value$LWS !== 'function') {
2057
+ return false;
2058
+ }
2059
+ let witness$LWS = interfaceBrandWitnessCache$LWS.get(Ctor$LWS);
2060
+ if (witness$LWS === undefined) {
2061
+ witness$LWS = deriveInterfaceBrandWitness$LWS(Ctor$LWS);
2062
+ interfaceBrandWitnessCache$LWS.set(Ctor$LWS, witness$LWS);
2063
+ }
2064
+ if (witness$LWS === null) {
2065
+ return false;
2066
+ }
2067
+ try {
2068
+ ReflectApply$LWS$1(witness$LWS, value$LWS, []);
2069
+ return true;
2070
+ } catch (_unused6$LWS) {
2071
+ return false;
2072
+ }
2073
+ }
1923
2074
  /**
1924
2075
  * Removes CSP nonce patterns from a string.
1925
2076
  *
@@ -1978,9 +2129,19 @@
1978
2129
  }
1979
2130
  const NodeProtoOwnerDocumentGetter$LWS = ObjectLookupOwnGetter$LWS$1(NodeProto$LWS$1, 'ownerDocument');
1980
2131
  ObjectLookupOwnGetter$LWS$1(NodeProto$LWS$1, 'parentNode');
1981
- ReflectGetOwnPropertyDescriptor$LWS(NodeProto$LWS$1, 'textContent');
2132
+ const {
2133
+ get: NodeProtoTextContentGetter$LWS,
2134
+ set: NodeProtoTextContentSetter$LWS
2135
+ } = ReflectGetOwnPropertyDescriptor$LWS(NodeProto$LWS$1, 'textContent');
1982
2136
  const rootDocumentDetachedFragment$LWS = ReflectApply$LWS$1(DocumentProtoCreateDocumentFragment$LWS, rootDocument$LWS, []);
1983
2137
  const rootDocumentDetachedContainer$LWS = ReflectApply$LWS$1(DocumentProtoCreateElement$LWS$1, rootDocument$LWS, ['div']);
2138
+ // Inert parse surface for the hidden-<script> heuristic (changesSince.266,
2139
+ // W-23595929). Template contents are parsed into an inert template-owner
2140
+ // document: custom elements are never upgraded, scripts never execute, and
2141
+ // resource-loading attributes never fire — so setting innerHTML here decodes
2142
+ // entities/obfuscation exactly like a live parse but has no observable side
2143
+ // effects in the shared realm.
2144
+ const rootDocumentDetachedTemplate$LWS = ReflectApply$LWS$1(DocumentProtoCreateElement$LWS$1, rootDocument$LWS, ['template']);
1984
2145
  // Regex to match null bytes and zero-width characters that browsers may strip or ignore
1985
2146
  // \x00 - Null byte
1986
2147
  // \u00AD - Soft Hyphen
@@ -2024,17 +2185,6 @@
2024
2185
  // bounded the token but left the regex free to roam the whole 30 KB–2 MB slice.)
2025
2186
  const PROLOG_DOCTYPE_INTERNAL_SUBSET_REGEX$LWS = /^<!doctype\s+[^>\s]+\s*\[/;
2026
2187
  const PROLOG_DOCTYPE_EXTERNAL_ENTITY_REGEX$LWS = /^<!doctype\s+[^>\s]+\s+(?:system|public)\s/;
2027
- // Regex to detect a namespaced <script> whose start tag carries an xmlns
2028
- // declaration. Matches <script or <prefix:script (the leading [<:]), then a
2029
- // whitespace or `/` separator so decoy tags like <scripting> or <scriptx> are
2030
- // not matched, then scans the start tag up to xmlns. The gap alternation treats
2031
- // quoted attribute values as opaque ("[^"]*" and '[^']*') so a `>` inside an
2032
- // attribute value (e.g. title=">") cannot prematurely end the start tag and let
2033
- // the real xmlns escape the scan. Requiring xmlns inside the script start tag —
2034
- // rather than anywhere in the body — is what distinguishes the executable XML
2035
- // namespaced-script vector from benign HTML that merely mentions "xmlns"
2036
- // elsewhere (e.g. a sanitizer's attribute allowlist).
2037
- const NAMESPACED_SCRIPT_XMLNS_REGEX$LWS = /[<:]script[\s/](?:[^>"']|"[^"]*"|'[^']*')*xmlns/;
2038
2188
  const DOCTYPE_OPENER$LWS = '<!doctype';
2039
2189
  const PI_OPENER$LWS = '<?';
2040
2190
  const PI_CLOSER$LWS = '?>';
@@ -2144,18 +2294,10 @@
2144
2294
  // when the namespace is XHTML or SVG. The namespace URL itself can be
2145
2295
  // obfuscated with XML character entities in attribute values, but the
2146
2296
  // xmlns attribute name cannot, so checking for "xmlns" is reliable.
2147
- //
2148
- // The xmlns must appear inside the script start tag for the namespace to
2149
- // apply to that script. An earlier form only checked for a <script> tag and
2150
- // the substring "xmlns" anywhere in the body; that false-positived on benign
2151
- // HTML that carries a plain <script> and also mentions "xmlns" in an
2152
- // unrelated place (a sanitizer's attribute allowlist, an SVG child element,
2153
- // a string literal). NAMESPACED_SCRIPT_XMLNS_REGEX ties the two together by
2154
- // scanning from the script start tag to xmlns within the same tag.
2155
2297
  // eslint-disable-next-line class-methods-use-this
2156
2298
  this.isXMLNamespacedScriptAttack = input$LWS => {
2157
- const normalizedInput$LWS = ReflectApply$LWS$1(StringProtoReplace$LWS, normalizeInput$LWS(input$LWS), [/\s+/g, ' ']);
2158
- return ReflectApply$LWS$1(RegExpProtoTest$LWS$1, NAMESPACED_SCRIPT_XMLNS_REGEX$LWS, [normalizedInput$LWS]);
2299
+ const normalizedInput$LWS = normalizeInput$LWS(input$LWS);
2300
+ return hasTag$LWS(normalizedInput$LWS, 'script') && ReflectApply$LWS$1(StringProtoIncludes$LWS, normalizedInput$LWS, ['xmlns']);
2159
2301
  };
2160
2302
  // Detects the iframe+srcdoc substring combination in raw input.
2161
2303
  // Any HTML or XML containing both <iframe> and the substring
@@ -2201,23 +2343,55 @@
2201
2343
  if (!hasScript$LWS) {
2202
2344
  return false;
2203
2345
  }
2346
+ // changesSince.266 (W-23595929): decide the hidden-<script> verdict by
2347
+ // parsing into an inert <template>, never a live <div> owned by the shared
2348
+ // root document. Setting innerHTML on a rootDocument-owned element runs the
2349
+ // HTML fragment parser in the shared realm, and that parse upgrades any
2350
+ // custom element it encounters — running the element's constructor
2351
+ // SYNCHRONOUSLY, before this inspection returns the verdict that would
2352
+ // reject the input. An attacker who replays a leaked `lskey` registry token
2353
+ // can route that upgrade to a sandbox-defined constructor and have it run in
2354
+ // the host realm as a side effect of this supposedly-inert text check (the
2355
+ // clone-a-live-<script> escape). Template contents are inert, so the parse
2356
+ // still decodes entities/obfuscation for an accurate innerHTML-vs-text
2357
+ // comparison but cannot upgrade custom elements, execute scripts, or fire
2358
+ // resource-loading attributes. Mirrors the ContentType.SVG template fix in
2359
+ // @locker/internal-policy.
2360
+ if (isGaterEnabledFeature$LWS('changesSince.266')) {
2361
+ ReflectApply$LWS$1(ElementProtoInnerHTMLSetter$LWS, rootDocumentDetachedTemplate$LWS, [normalizedInput$LWS]);
2362
+ // Element.prototype.innerHTML on a <template> reflects the serialized
2363
+ // template contents, but textContent must be read off the content
2364
+ // fragment: the parsed nodes live there, not as children of the
2365
+ // <template> element itself (template.textContent would be '').
2366
+ const innerHTML$LWS = ReflectApply$LWS$1(ElementProtoInnerHTMLGetter$LWS, rootDocumentDetachedTemplate$LWS, []);
2367
+ const content$LWS = ReflectApply$LWS$1(HTMLTemplateElementProtoContentGetter$LWS, rootDocumentDetachedTemplate$LWS, []);
2368
+ const textContent$LWS = toSafeStringValue$LWS(ReflectApply$LWS$1(NodeProtoTextContentGetter$LWS, content$LWS, []));
2369
+ // Release the parsed nodes so nothing lingers on the shared template
2370
+ // between calls.
2371
+ ReflectApply$LWS$1(ElementProtoInnerHTMLSetter$LWS, rootDocumentDetachedTemplate$LWS, ['']);
2372
+ // The legacy detached-<div> path reads innerText from an unrendered
2373
+ // element, which per spec is that element's textContent — the same value
2374
+ // read above. Strip < > : so a decoded entity such as &lt;script&gt; in
2375
+ // visible text cannot mask a genuinely hidden <script> (same rationale as
2376
+ // the changesSince.262 strip in the legacy path below).
2377
+ const checkableText$LWS = ReflectApply$LWS$1(StringProtoReplace$LWS, textContent$LWS, [/[<>:]/g, '']);
2378
+ return hasTag$LWS(innerHTML$LWS, 'script') && !hasTag$LWS(checkableText$LWS, 'script');
2379
+ }
2204
2380
  // This is obnoxious... jsdom doesn't implement HTMLElement.prototype.innerText
2205
2381
  if (!HTMLElementProtoInnerTextGetter$LWS) {
2206
2382
  return true;
2207
2383
  }
2208
- // If the input contained the word "script", then we need to confirm that the string
2209
- // that was seen is actually markup.
2210
- //
2211
- // IMPORTANT: We CANNOT reuse this.template.left/right for this check. Template elements
2212
- // do not return innerText or textContent, which makes the following innerHTML/innerText
2213
- // check useless.
2214
- ReflectApply$LWS$1(DocumentFragmentProtoAppend$LWS, rootDocumentDetachedFragment$LWS, [rootDocumentDetachedContainer$LWS]);
2215
- ReflectApply$LWS$1(ElementProtoInnerHTMLSetter$LWS, rootDocumentDetachedContainer$LWS, [normalizedInput$LWS]);
2216
- // This MUST BE CHECKED AFTER IT IS RENDERED. The nature of these attacks requires
2217
- // the actual source to be set to the innerHTML to allow the browser to render
2218
- const innerHTML$LWS = ReflectApply$LWS$1(ElementProtoInnerHTMLGetter$LWS, rootDocumentDetachedContainer$LWS, []);
2219
- const innerText$LWS = ReflectApply$LWS$1(HTMLElementProtoInnerTextGetter$LWS, rootDocumentDetachedContainer$LWS, []);
2220
- ReflectApply$LWS$1(ElementProtoRemove$LWS$1, rootDocumentDetachedContainer$LWS, []);
2384
+ // The input contains the word "script"; confirm it is actually markup by
2385
+ // rendering it on the shared detached container and comparing the parsed
2386
+ // innerHTML against the visible innerText. IMPORTANT: We CANNOT reuse
2387
+ // this._templates.left/right here — template elements return neither
2388
+ // innerText nor textContent, which would make the comparison useless. The
2389
+ // values MUST be read after rendering: the browser has to parse the source
2390
+ // for the hidden-script shape to surface.
2391
+ const {
2392
+ innerHTML: innerHTML$LWS,
2393
+ innerText: innerText$LWS
2394
+ } = htmlParserRoundTrip$LWS(normalizedInput$LWS);
2221
2395
  // If innerHTML contains "script", but innerText does not, then the string
2222
2396
  // was hiding a script element through some kind of obfuscation, and is unsecure.
2223
2397
  let checkableInnerText$LWS = innerText$LWS;
@@ -2229,6 +2403,41 @@
2229
2403
  }
2230
2404
  return hasTag$LWS(innerHTML$LWS, 'script') && !hasTag$LWS(checkableInnerText$LWS, 'script');
2231
2405
  };
2406
+ // Detect a <script> that the HTML parser hides inside a raw-text / RCDATA
2407
+ // element (textarea, title, style, xmp, ...) but the XML parser exposes as
2408
+ // a live element. XMLDocument-owned elements are parsed with the XML parser,
2409
+ // which has NO raw-text elements: <textarea><script>...</script></textarea>
2410
+ // is inert escaped text under HTML, but a live, clonable HTMLScriptElement
2411
+ // under XML. cloneNode + adoption into the HTML document then promotes it to
2412
+ // an executing script (W-23486666).
2413
+ //
2414
+ // isIframeSrcdocScriptAttack cannot see this: it renders through the HTML
2415
+ // parser, where the swallowed <script> becomes `&lt;script&gt;` text and no
2416
+ // live tag survives, so its `hasTag(innerHTML, 'script')` clause is false.
2417
+ // We instead flag the HTML-vs-XML divergence directly: the source text
2418
+ // contains a <script> tag, yet an HTML round-trip does NOT preserve it as a
2419
+ // live <script>. A bare or foster-parented <script> survives the round-trip
2420
+ // (and is already rejected by isIframeSrcdocScriptAttack); only one absorbed
2421
+ // into raw text disappears — the XML-only exploit. Intended for the
2422
+ // XMLDocument-owned branch of the HTML-injection sinks; HTML-owned elements
2423
+ // genuinely treat that content as inert text and must not reach this check.
2424
+ // eslint-disable-next-line class-methods-use-this
2425
+ this.isXMLScriptInRawTextElementAttack = input$LWS => {
2426
+ const normalizedInput$LWS = normalizeInput$LWS(input$LWS);
2427
+ // No <script> in the source text: nothing an XML parser could make live.
2428
+ if (!hasTag$LWS(normalizedInput$LWS, 'script')) {
2429
+ return false;
2430
+ }
2431
+ // Round-trip through the HTML parser (the same shared detached container
2432
+ // isIframeSrcdocScriptAttack uses). If the <script> survives as a live tag
2433
+ // it is caught by isIframeSrcdocScriptAttack; if it vanished, the HTML
2434
+ // parser absorbed it into a raw-text / RCDATA element where the XML parser
2435
+ // would not.
2436
+ const {
2437
+ innerHTML: innerHTML$LWS
2438
+ } = htmlParserRoundTrip$LWS(normalizedInput$LWS);
2439
+ return !hasTag$LWS(innerHTML$LWS, 'script');
2440
+ };
2232
2441
  this.isSharedElement = element$LWS => element$LWS === ReflectApply$LWS$1(DocumentProtoHeadGetter$LWS, this._document, []) || element$LWS === ReflectApply$LWS$1(DocumentProtoBodyGetter$LWS$1, this._document, []) || element$LWS === ReflectApply$LWS$1(DocumentProtoDocumentElementGetter$LWS, this._document, []);
2233
2442
  // Detects whether `node` belongs to a document that an attacker
2234
2443
  // could have populated with content bypassing LWS distortions.
@@ -2319,6 +2528,25 @@
2319
2528
  }
2320
2529
  return false;
2321
2530
  }
2531
+ // Render `normalizedInput` once through the HTML parser on the shared detached
2532
+ // container and return both its serialized innerHTML and its rendered innerText.
2533
+ // isIframeSrcdocScriptAttack (hidden-script: innerHTML has a script, innerText
2534
+ // does not) and isXMLScriptInRawTextElementAttack (HTML-vs-XML divergence: source
2535
+ // has a script, the round-tripped innerHTML does not) both derive their answer
2536
+ // from this single parse, so they share one setter invocation instead of two.
2537
+ // innerText is '' when the engine lacks the getter (jsdom); the only consumer of
2538
+ // innerText already short-circuits before reaching here in that case.
2539
+ function htmlParserRoundTrip$LWS(normalizedInput$LWS) {
2540
+ ReflectApply$LWS$1(DocumentFragmentProtoAppend$LWS, rootDocumentDetachedFragment$LWS, [rootDocumentDetachedContainer$LWS]);
2541
+ ReflectApply$LWS$1(ElementProtoInnerHTMLSetter$LWS, rootDocumentDetachedContainer$LWS, [normalizedInput$LWS]);
2542
+ const innerHTML$LWS = ReflectApply$LWS$1(ElementProtoInnerHTMLGetter$LWS, rootDocumentDetachedContainer$LWS, []);
2543
+ const innerText$LWS = HTMLElementProtoInnerTextGetter$LWS ? ReflectApply$LWS$1(HTMLElementProtoInnerTextGetter$LWS, rootDocumentDetachedContainer$LWS, []) : '';
2544
+ ReflectApply$LWS$1(ElementProtoRemove$LWS$1, rootDocumentDetachedContainer$LWS, []);
2545
+ return {
2546
+ innerHTML: innerHTML$LWS,
2547
+ innerText: innerText$LWS
2548
+ };
2549
+ }
2322
2550
  function hasTag$LWS(input$LWS, tag$LWS) {
2323
2551
  // Input is already lowercased and invisible chars stripped by caller
2324
2552
  const checkableInput$LWS = ReflectApply$LWS$1(StringProtoReplace$LWS, input$LWS, [/\s+/g, ' ']);
@@ -2436,6 +2664,10 @@
2436
2664
  prototype: HTMLMediaElementProto$LWS
2437
2665
  } = HTMLMediaElement;
2438
2666
  const HTMLMediaElementProtoSrcSetter$LWS = ObjectLookupOwnSetter$LWS(HTMLMediaElementProto$LWS, 'src');
2667
+ const {
2668
+ get: SVGScriptElementProtoHrefGetter$LWS,
2669
+ set: SVGScriptElementProtoHrefSetter$LWS
2670
+ } = ReflectGetOwnPropertyDescriptor$LWS(SVGScriptElement.prototype, 'href');
2439
2671
  const HTMLScriptElementCtor$LWS = HTMLScriptElement;
2440
2672
  const {
2441
2673
  prototype: HTMLScriptElementProto$LWS
@@ -2444,6 +2676,34 @@
2444
2676
  get: HTMLScriptElementProtoSrcGetter$LWS,
2445
2677
  set: HTMLScriptElementProtoSrcSetter$LWS
2446
2678
  } = ReflectGetOwnPropertyDescriptor$LWS(HTMLScriptElementProto$LWS, 'src');
2679
+ // Realm-generic structural check for a genuine script element (HTML or SVG):
2680
+ // recognizes a real `<script>`/SVG `<script>` minted from ANY realm, unlike
2681
+ // `instanceof HTMLScriptElement`, which is both realm-bound AND forgeable via an
2682
+ // attacker-controlled `newTarget` (e.g. `Reflect.construct(Audio, [],
2683
+ // HTMLScriptElement)` yields a real `<audio>` whose prototype is
2684
+ // `HTMLScriptElement.prototype`, so `instanceof` reports `true` while the object
2685
+ // parses markup like the `<audio>` it truly is). A genuine script element
2686
+ // carries the internal slot backing the native `src`/`href` accessor, so the
2687
+ // call succeeds; a forged element (or any other object) throws a TypeError
2688
+ // ("Illegal invocation") because the WebIDL brand check keys on the real
2689
+ // interface, not the prototype chain.
2690
+ function isScriptElement$LWS(value$LWS) {
2691
+ if (value$LWS === null || typeof value$LWS !== 'object' && typeof value$LWS !== 'function') {
2692
+ return false;
2693
+ }
2694
+ try {
2695
+ ReflectApply$LWS$1(HTMLScriptElementProtoSrcGetter$LWS, value$LWS, []);
2696
+ return true;
2697
+ } catch (_unused7$LWS) {
2698
+ // Not a genuine HTMLScriptElement; fall through to the SVG check.
2699
+ }
2700
+ try {
2701
+ ReflectApply$LWS$1(SVGScriptElementProtoHrefGetter$LWS, value$LWS, []);
2702
+ return true;
2703
+ } catch (_unused8$LWS) {
2704
+ return false;
2705
+ }
2706
+ }
2447
2707
  const {
2448
2708
  prototype: HTMLSourceElementProto$LWS
2449
2709
  } = HTMLSourceElement;
@@ -2502,11 +2762,30 @@
2502
2762
  configurable: true,
2503
2763
  // Create a bound function to obscure the getter source as "[native code]".
2504
2764
  get: ReflectApply$LWS$1(FunctionProtoBind$LWS, () => {
2765
+ const ownerDoc$LWS = ReflectApply$LWS$1(NodeProtoOwnerDocumentGetter$LWS, script$LWS, []);
2766
+ // W-23527275: this getter is the one-shot trigger LWS arms on the
2767
+ // raw script node; our injected trampoline source
2768
+ // (`document.currentScript.$evaluator$`) reads it when the browser
2769
+ // runs the script at insertion time. Sandboxed code that borrows a
2770
+ // native `text`/`src` setter via `descriptor.set.call(node, value)`
2771
+ // never trips the near-membrane `[[Set]]` trap, so the node's
2772
+ // proxy never goes static and keeps forwarding `has`/`get` to the
2773
+ // live raw node — letting that code poll `'$evaluator$' in node`
2774
+ // and read the property to pull the trigger EARLY, before the
2775
+ // genuine insertion. Only the real trampoline runs with the node
2776
+ // as `document.currentScript`; an early sandbox-side read sees a
2777
+ // different (or null) current script. Reject the read without
2778
+ // evaluating or disarming so the legitimate insertion still fires.
2779
+ if (isGaterEnabledFeature$LWS('changesSince.266')) {
2780
+ const currentScript$LWS = ReflectApply$LWS$1(DocumentProtoCurrentScriptGetter$LWS, ownerDoc$LWS, []);
2781
+ if (currentScript$LWS !== script$LWS) {
2782
+ return;
2783
+ }
2784
+ }
2505
2785
  // Track the script element evaluation to ensure the element
2506
2786
  // is evaluated only once.
2507
2787
  evaluatedScriptElements$LWS.add(script$LWS);
2508
2788
  deleteScriptEvaluatorProperty$LWS(script$LWS);
2509
- const ownerDoc$LWS = ReflectApply$LWS$1(NodeProtoOwnerDocumentGetter$LWS, script$LWS, []);
2510
2789
  const defaultView$LWS = ReflectApply$LWS$1(DocumentProtoDefaultViewGetter$LWS, ownerDoc$LWS, []);
2511
2790
  // We don't need to use something like `WindowLocationGetter()`
2512
2791
  // because the 'location' and 'top' property are non-configurable.
@@ -2637,7 +2916,6 @@
2637
2916
  removeItem: StorageProtoRemoveItem$LWS,
2638
2917
  setItem: StorageProtoSetItem$LWS
2639
2918
  } = Storage.prototype;
2640
- ReflectGetOwnPropertyDescriptor$LWS(SVGScriptElement.prototype, 'href');
2641
2919
 
2642
2920
  // This has to be done 1-by-1 because putting a full file ignore in this file
2643
2921
  // will result in dist/index.mjs.js containing the directive and subsequently being
@@ -2655,7 +2933,7 @@
2655
2933
  const XhrProtoResponseTextGetter$LWS = ObjectLookupOwnGetter$LWS$1(XhrProto$LWS, 'responseText');
2656
2934
  const XhrProtoStatusGetter$LWS = ObjectLookupOwnGetter$LWS$1(XhrProto$LWS, 'status');
2657
2935
  ObjectLookupOwnSetter$LWS(XhrProto$LWS, 'withCredentials');
2658
- /*! version: 0.28.7 */
2936
+ /*! version: 0.29.1 */
2659
2937
 
2660
2938
  /*!
2661
2939
  * Copyright (C) 2019 salesforce.com, inc.
@@ -2677,6 +2955,36 @@
2677
2955
  return false;
2678
2956
  }
2679
2957
  const DISALLOWED_ENDPOINTS_LIST$LWS = ['/aura', '/webruntime'];
2958
+ // Same-origin-only denylist (gated on changesSince.262). These platform-internal
2959
+ // endpoints are blocked only for same-origin requests: a cross-origin request
2960
+ // cannot carry the user's session credentials to this instance's internal
2961
+ // endpoints (W-23009170), so blocking them cross-origin would serve no purpose.
2962
+ // Kept as its own static list — iterated in place, never appended onto
2963
+ // DISALLOWED_ENDPOINTS_LIST — so repeated isAllowedEndpointURL() calls don't grow
2964
+ // the array.
2965
+ const DISALLOWED_SAME_ORIGIN_ENDPOINTS_LIST$LWS = ['/_nc_external', '/force', '/setup'];
2966
+ // Same-origin-only denylist gated on changesSince.266. Blocked same-origin for
2967
+ // the same credential-scoping reason as the 262 list above.
2968
+ //
2969
+ // /webconsole (Platform Web IDE / Web Console) embeds the session sid in a
2970
+ // DOM-readable property; a sandboxed component could open a same-origin iframe
2971
+ // to it (or fetch it) and walk the contentDocument to recover the sid
2972
+ // (W-23508868).
2973
+ //
2974
+ // /auraanalytics is an alias that reaches the same AuraServlet as the always-on
2975
+ // /aura entry, but the /aura string match ('/auraanalytics'.endsWith('/aura')
2976
+ // is false) never catches it. A sandboxed fetch/XHR to it mints a valid session
2977
+ // sid the same way /aura would (W-23858870). Lowercase because matching is done
2978
+ // against the lowercased pathname.
2979
+ //
2980
+ // /005 is the classic User object key-prefix. Its legacy same-origin UI routes
2981
+ // (the /005 list view and the /005/e create/edit form) hand a sandboxed
2982
+ // component a session-bound confirmation token and accept an authenticated POST
2983
+ // that can create an active Salesforce User (W-23891007). No modern LWC uses the
2984
+ // classic key-prefix UI, and the endsWith('/005') || includes('/005/') match
2985
+ // never touches a bare record-id path like /005B00000029kKc, so the
2986
+ // false-positive surface is nil.
2987
+ const DISALLOWED_SAME_ORIGIN_ENDPOINTS_LIST_266$LWS = ['/webconsole', '/auraanalytics', '/005'];
2680
2988
  // Endpoints that should not be used as browsing context targets (window.open, iframe.src)
2681
2989
  // because they return manipulable content. Unlike fetch/XHR which just return data,
2682
2990
  // browsing contexts can be manipulated by attackers to inject malicious DOM.
@@ -2721,24 +3029,42 @@
2721
3029
  const locationHref$LWS = rootWindow$LWS$1.location.href;
2722
3030
  return loweredResourceValue$LWS === '/' || loweredResourceValue$LWS[0] === '#' || loweredResourceValue$LWS[0] === '?' || ReflectApply$LWS$1(StringProtoStartsWith$LWS, loweredResourceValue$LWS, [`${locationHref$LWS}#`]) || ReflectApply$LWS$1(StringProtoStartsWith$LWS, loweredResourceValue$LWS, [`${locationHref$LWS}?`]);
2723
3031
  }
3032
+ // Returns true if loweredPathname targets any endpoint in the list, matching
3033
+ // either an exact tail (`.../aura`) or a subpath (`.../aura/...`).
3034
+ function pathnameTargetsDisallowedEndpoint$LWS(loweredPathname$LWS, disallowedEndpoints$LWS) {
3035
+ for (let i$LWS = 0, {
3036
+ length: length$LWS
3037
+ } = disallowedEndpoints$LWS; i$LWS < length$LWS; i$LWS += 1) {
3038
+ if (ReflectApply$LWS$1(StringProtoEndsWith$LWS, loweredPathname$LWS, [disallowedEndpoints$LWS[i$LWS]]) || ReflectApply$LWS$1(StringProtoIncludes$LWS, loweredPathname$LWS, [`${disallowedEndpoints$LWS[i$LWS]}/`])) {
3039
+ return true;
3040
+ }
3041
+ }
3042
+ return false;
3043
+ }
2724
3044
  // Validates that a URL doesn't target disallowed endpoints.
2725
3045
  // @TODO: W-7302311 Make paths and domains configurable.
2726
3046
  function isAllowedEndpointURL$LWS(parsedURL$LWS) {
2727
3047
  const loweredPathname$LWS = ReflectApply$LWS$1(StringProtoToLowerCase$LWS, parsedURL$LWS.pathname, []);
2728
- // This MUST be done inside the function because the gate may not be enabled when the
2729
- // module code is loaded and evaluated (as would be the case for test environments)
2730
- if (isGaterEnabledFeature$LWS('changesSince.262')) {
2731
- // Cross-origin URLs bypass the denylist — they cannot carry the user's session
2732
- // credentials to this instance's platform-internal endpoints (W-23009170).
2733
- if (!isSameOriginURL$LWS(parsedURL$LWS.normalizedURL)) {
2734
- return true;
2735
- }
2736
- DISALLOWED_ENDPOINTS_LIST$LWS.push('/_nc_external', '/force', '/setup');
3048
+ // The gate checks MUST be done inside the function because the gate may not be enabled
3049
+ // when the module code is loaded and evaluated (as would be the case for test environments).
3050
+ const isSince262Enabled$LWS = isGaterEnabledFeature$LWS('changesSince.262');
3051
+ // Under changesSince.262, cross-origin URLs bypass the denylist entirely — they cannot
3052
+ // carry the user's session credentials to this instance's platform-internal endpoints
3053
+ // (W-23009170). This short-circuit must run before the base denylist so cross-origin
3054
+ // requests to base-list endpoints stay allowed under the gate, matching prior behavior.
3055
+ if (isSince262Enabled$LWS && !isSameOriginURL$LWS(parsedURL$LWS.normalizedURL)) {
3056
+ return true;
2737
3057
  }
2738
- for (let i$LWS = 0, {
2739
- length: length$LWS
2740
- } = DISALLOWED_ENDPOINTS_LIST$LWS; i$LWS < length$LWS; i$LWS += 1) {
2741
- if (ReflectApply$LWS$1(StringProtoEndsWith$LWS, loweredPathname$LWS, [DISALLOWED_ENDPOINTS_LIST$LWS[i$LWS]]) || ReflectApply$LWS$1(StringProtoIncludes$LWS, loweredPathname$LWS, [`${DISALLOWED_ENDPOINTS_LIST$LWS[i$LWS]}/`])) {
3058
+ // The always-on base denylist. Reached for every origin when the gate is off, and for
3059
+ // same-origin URLs when it is on.
3060
+ if (pathnameTargetsDisallowedEndpoint$LWS(loweredPathname$LWS, DISALLOWED_ENDPOINTS_LIST$LWS)) {
3061
+ return false;
3062
+ }
3063
+ if (isSince262Enabled$LWS) {
3064
+ if (pathnameTargetsDisallowedEndpoint$LWS(loweredPathname$LWS, DISALLOWED_SAME_ORIGIN_ENDPOINTS_LIST$LWS)) {
3065
+ return false;
3066
+ }
3067
+ if (isGaterEnabledFeature$LWS('changesSince.266') && pathnameTargetsDisallowedEndpoint$LWS(loweredPathname$LWS, DISALLOWED_SAME_ORIGIN_ENDPOINTS_LIST_266$LWS)) {
2742
3068
  return false;
2743
3069
  }
2744
3070
  }
@@ -2823,7 +3149,7 @@
2823
3149
  }
2824
3150
  return sanitized$LWS;
2825
3151
  }
2826
- /*! version: 0.28.7 */
3152
+ /*! version: 0.29.1 */
2827
3153
 
2828
3154
  /*!
2829
3155
  * Copyright (C) 2023 salesforce.com, inc.
@@ -2899,7 +3225,7 @@
2899
3225
  // swallow
2900
3226
  }
2901
3227
  const trusted = createPolicy('trusted', policyOptions);
2902
- /*! version: 0.28.7 */
3228
+ /*! version: 0.29.1 */
2903
3229
 
2904
3230
  /*!
2905
3231
  * Copyright (C) 2019 salesforce.com, inc.
@@ -3208,7 +3534,7 @@
3208
3534
  }
3209
3535
  return getSanitizerForConfig$LWS(sandboxKey$LWS, 'STRING_BLOB_HTML');
3210
3536
  }
3211
- /*! version: 0.28.7 */
3537
+ /*! version: 0.29.1 */
3212
3538
 
3213
3539
  /*!
3214
3540
  * Copyright (C) 2023 salesforce.com, inc.
@@ -3328,12 +3654,34 @@
3328
3654
  const targetElementIsConnected$LWS = ReflectApply$LWS$1(NodeProtoIsConnectedGetter$LWS, targetElement$LWS, []);
3329
3655
  const resolvedURL$LWS = resolveURL$LWS(dirty$LWS);
3330
3656
  if (targetElementIsConnected$LWS) {
3331
- // When the script is connected and has a .src value it is safe to let the url passthrough
3332
- // because it will never be evaluated again.
3333
- if (getURL$LWS(targetElement$LWS)) {
3334
- evaluatedScripts$LWS.add(targetElement$LWS);
3335
- setScriptURL$LWS(dirty$LWS);
3336
- return dirty$LWS;
3657
+ // changesSince.266 (W-23745390): the legacy passthrough below trusts
3658
+ // "connected + has a src attribute" as a proxy for HTML's unobservable
3659
+ // "already started" flag, i.e. "this script already ran and will never
3660
+ // run again, so passing its raw url straight through is safe". That proxy
3661
+ // is unsound. A script whose `type` is not a JavaScript MIME type bails
3662
+ // out of the "prepare the script element" algorithm BEFORE "already
3663
+ // started" is set, so it is connected and carries a src yet has never
3664
+ // run. Sandboxed code arms such a script (the async path below always
3665
+ // ends up calling setScriptURL), re-assigns .src to a raw url — this
3666
+ // branch then wrote that RAW url to the element and marked it evaluated —
3667
+ // then corrects the type and re-inserts, running the raw url natively in
3668
+ // the MAIN realm with an undistorted document.cookie. The authoritative
3669
+ // `evaluatedScripts.has(targetElement)` check above already short-circuits
3670
+ // every script LWS actually evaluated, so removing this branch only
3671
+ // reroutes scripts we did NOT evaluate through the safe async
3672
+ // sandbox-evaluator path (the attacker's source still runs, but sandboxed).
3673
+ //
3674
+ // The whole block is gated OFF so a mechanical gate-cleanup removes the
3675
+ // hole, not the guard: DELETE THIS ENTIRE `if (!isGaterEnabledFeature(...))`
3676
+ // BLOCK when changesSince.266 graduates.
3677
+ if (!isGaterEnabledFeature$LWS('changesSince.266')) {
3678
+ // When the script is connected and has a .src value it is safe to let
3679
+ // the url passthrough because it will never be evaluated again.
3680
+ if (getURL$LWS(targetElement$LWS)) {
3681
+ evaluatedScripts$LWS.add(targetElement$LWS);
3682
+ setScriptURL$LWS(dirty$LWS);
3683
+ return dirty$LWS;
3684
+ }
3337
3685
  }
3338
3686
  // There is a small window while the source code is asynchronously fetched but the script may
3339
3687
  // have already been placed in the DOM without having yet our blob URL set as the .src value.
@@ -3350,6 +3698,26 @@
3350
3698
  __proto__: null,
3351
3699
  configurable: true,
3352
3700
  get: ReflectApply$LWS$1(FunctionProtoBind$LWS, () => {
3701
+ // W-23527275: this getter is the one-shot trigger armed on the
3702
+ // raw script node; our blob trampoline source
3703
+ // (`document.currentScript['$evaluator$']`) reads it when the
3704
+ // browser runs the injected script at insertion time.
3705
+ // Sandboxed code that borrows a native `src`/`text` setter via
3706
+ // `descriptor.set.call(node, value)` never trips the
3707
+ // near-membrane `[[Set]]` trap, so the node's proxy never goes
3708
+ // static and keeps forwarding `has`/`get` to the live raw node
3709
+ // — letting that code poll and read the property to pull the
3710
+ // trigger EARLY. Only the genuine trampoline runs with the node
3711
+ // as `document.currentScript`; reject an early sandbox-side
3712
+ // read without evaluating or disarming so the legitimate
3713
+ // insertion still fires.
3714
+ if (isGaterEnabledFeature$LWS('changesSince.266')) {
3715
+ const ownerDoc$LWS = ReflectApply$LWS$1(NodeProtoOwnerDocumentGetter$LWS, targetElement$LWS, []);
3716
+ const currentScript$LWS = ReflectApply$LWS$1(DocumentProtoCurrentScriptGetter$LWS, ownerDoc$LWS, []);
3717
+ if (currentScript$LWS !== targetElement$LWS) {
3718
+ return;
3719
+ }
3720
+ }
3353
3721
  ReflectDeleteProperty$LWS$1(targetElement$LWS, EVALUATOR_PROPERTY_KEY$LWS);
3354
3722
  URLRevokeObjectURL$LWS(safeURL$LWS);
3355
3723
  const cachedURL$LWS = scriptURLsCache$LWS.get(targetElement$LWS);
@@ -3380,13 +3748,39 @@
3380
3748
  // signed value and we are ok or we don't and the browser throws an error. We
3381
3749
  // want our 404 URL to be set and trigger the event handlers, hence we have to sign.
3382
3750
  setScriptURL$LWS('blob:http://localhost/not-found');
3383
- // This error event handler will get triggered after we set our 404 blob URL.
3384
- const errorEventHandler$LWS = () => {
3385
- // Similar to our wrappedEvaluator, we leave no traces.
3386
- setScriptURL$LWS(cachedURL$LWS);
3387
- ReflectApply$LWS$1(EventTargetProtoRemoveEventListener$LWS, targetElement$LWS, ['error', errorEventHandler$LWS]);
3388
- };
3389
- ReflectApply$LWS$1(EventTargetProtoAddEventListener$LWS, targetElement$LWS, ['error', errorEventHandler$LWS]);
3751
+ // changesSince.266 (W-23596014, Bug Bounty / H1): on the reject path we
3752
+ // no longer restore the developer's raw url to the NATIVE src content
3753
+ // attribute. That restoration was purely cosmetic ("leave no traces"),
3754
+ // but the browser's native "prepare a script element" algorithm reads
3755
+ // the src *content attribute* directly — it never routes through any
3756
+ // JS-level getter/setter, so no LWS distortion observes it. Unlike the
3757
+ // onFulfill path (which restores the raw url only AFTER the browser has
3758
+ // already run our injected safe blob, i.e. the script has "already
3759
+ // started" and can never re-run), a rejected fetch means the script was
3760
+ // NEVER sandbox-evaluated. Restoring a raw, never-evaluated url is thus
3761
+ // a native-execution primitive: an attacker aborts the first async
3762
+ // fetch with a second `.src=` write, then dispatches a synthetic `error`
3763
+ // while the script is still disconnected — firing this handler, writing
3764
+ // the raw attacker url into the native attribute — and appends the
3765
+ // element, so the browser's own loader fetches and executes it in the
3766
+ // MAIN realm with an undistorted document.cookie. (The sibling
3767
+ // SVGScriptElement/href path shares this code and the same fix.) The 404
3768
+ // placeholder set above still fires genuine developer `error` handlers;
3769
+ // only the raw-url restoration is dropped, since cosmetic DOM parity is
3770
+ // never worth an executable raw url.
3771
+ //
3772
+ // Gated OFF so a mechanical gate-cleanup removes the hole, not the
3773
+ // guard: DELETE THIS ENTIRE `if (!isGaterEnabledFeature(...))` BLOCK
3774
+ // when changesSince.266 graduates.
3775
+ if (!isGaterEnabledFeature$LWS('changesSince.266')) {
3776
+ // This error event handler will get triggered after we set our 404 blob URL.
3777
+ const errorEventHandler$LWS = () => {
3778
+ // Similar to our wrappedEvaluator, we leave no traces.
3779
+ setScriptURL$LWS(cachedURL$LWS);
3780
+ ReflectApply$LWS$1(EventTargetProtoRemoveEventListener$LWS, targetElement$LWS, ['error', errorEventHandler$LWS]);
3781
+ };
3782
+ ReflectApply$LWS$1(EventTargetProtoAddEventListener$LWS, targetElement$LWS, ['error', errorEventHandler$LWS]);
3783
+ }
3390
3784
  };
3391
3785
  ReflectApply$LWS$1(PromiseProtoThen$LWS, asyncRequest$LWS, [onFulfill$LWS, onReject$LWS]);
3392
3786
  return '';
@@ -3417,7 +3811,7 @@
3417
3811
  ReflectApply$LWS$1(ElementProtoSetAttributeNS$LWS, targetElement$LWS, [attributeNamespaceURI$LWS, attributeName$LWS, src$LWS]);
3418
3812
  };
3419
3813
  }
3420
- /*! version: 0.28.7 */
3814
+ /*! version: 0.29.1 */
3421
3815
 
3422
3816
  /*!
3423
3817
  * Copyright (C) 2019 salesforce.com, inc.
@@ -3985,6 +4379,19 @@
3985
4379
  }
3986
4380
  return returnValue$LWS;
3987
4381
  }, ElementProtoToggleAttribute$LWS);
4382
+ // These accessors resolve the reflected property against a prototype chain
4383
+ // (`ReflectGetPrototypeOf(...)`) and invoke the resolved getter/setter with
4384
+ // that same object as the receiver. Deriving that receiver from `this`
4385
+ // makes the accessor receiver-relative: because it is installed as an OWN
4386
+ // property on `instance`, sandbox code can lift it off the descriptor and
4387
+ // re-target it (`getter.call(document)`). The accessor then walks a foreign
4388
+ // object's prototype chain to a native, un-distorted getter — e.g.
4389
+ // `Document.prototype.cookie` — with that foreign object as the receiver,
4390
+ // returning the raw host value and bypassing the sandbox's distortion.
4391
+ // Pin the receiver to the `instance` the accessor was installed on so the
4392
+ // read/write can never be steered onto another host object. Gated so the
4393
+ // pre-existing behavior remains available while the change rolls out.
4394
+ const pinReceiverToInstance$LWS = isGaterEnabledFeature$LWS('changesSince.266');
3988
4395
  // `observedAttributesDifference` is a safe Set.
3989
4396
  for (const originalAttrName$LWS of observedAttributesDifference$LWS) {
3990
4397
  // Here we're ensuring support for attributes which have very explicit
@@ -4003,24 +4410,26 @@
4003
4410
  enumerable: true,
4004
4411
  configurable: true,
4005
4412
  get() {
4006
- return ReflectGet$LWS(ReflectGetPrototypeOf$LWS$1(this), attrPropName$LWS, this);
4413
+ const receiver$LWS = pinReceiverToInstance$LWS ? instance$LWS : this;
4414
+ return ReflectGet$LWS(ReflectGetPrototypeOf$LWS$1(receiver$LWS), attrPropName$LWS, receiver$LWS);
4007
4415
  },
4008
4416
  set(value$LWS) {
4417
+ const receiver$LWS = pinReceiverToInstance$LWS ? instance$LWS : this;
4009
4418
  // This is necessary for both comparing the old attribute
4010
4419
  // value to the new attribute value and then for use in the
4011
4420
  // arguments that are passed to attributeChangedCallback.
4012
- const oldValue$LWS = ReflectApply$LWS$1(ElementProtoGetAttribute$LWS, this, [originalAttrName$LWS]);
4421
+ const oldValue$LWS = ReflectApply$LWS$1(ElementProtoGetAttribute$LWS, receiver$LWS, [originalAttrName$LWS]);
4013
4422
  // Because property assignment to special built-in setters
4014
4423
  // may have "magic" behavior to determine the actual value
4015
4424
  // that gets set, we need to invoke the original setter,
4016
4425
  // then get the new attribute value for comparison.
4017
4426
  // If _that_ value is different from the old value, then we
4018
4427
  // trigger the attributeChangedCallback
4019
- // ReflectApply(originalSetter, this, [value]);
4020
- ReflectSet$LWS(ReflectGetPrototypeOf$LWS$1(this), attrPropName$LWS, value$LWS, this);
4021
- const newValue$LWS = ReflectApply$LWS$1(ElementProtoGetAttribute$LWS, this, [originalAttrName$LWS]);
4428
+ // ReflectApply(originalSetter, receiver, [value]);
4429
+ ReflectSet$LWS(ReflectGetPrototypeOf$LWS$1(receiver$LWS), attrPropName$LWS, value$LWS, receiver$LWS);
4430
+ const newValue$LWS = ReflectApply$LWS$1(ElementProtoGetAttribute$LWS, receiver$LWS, [originalAttrName$LWS]);
4022
4431
  if (oldValue$LWS !== newValue$LWS) {
4023
- ReflectApply$LWS$1(attributeChangedCallback$LWS, this, [originalAttrName$LWS, oldValue$LWS, newValue$LWS]);
4432
+ ReflectApply$LWS$1(attributeChangedCallback$LWS, receiver$LWS, [originalAttrName$LWS, oldValue$LWS, newValue$LWS]);
4024
4433
  }
4025
4434
  }
4026
4435
  });
@@ -4165,6 +4574,106 @@
4165
4574
  const DataTransferProtoBlockedProperties$LWS = ['mozCursor', 'mozSourceNode', 'mozUserCancelled'];
4166
4575
  const attributeDistortionFactoriesCache$LWS = toSafeMap$LWS$1(new MapCtor$LWS$1());
4167
4576
  const sandboxAttributeDistortionRegistryCache$LWS = toSafeWeakMap$LWS$1(new WeakMapCtor$LWS$1());
4577
+ const blockedTagInfoByCtor$LWS = toSafeWeakMap$LWS$1(new WeakMapCtor$LWS$1());
4578
+ // Associate a blocked attribute on `Ctor` with the HTML tag name a foreign
4579
+ // generic node would carry when it specializes into `Ctor`'s interface on HTML
4580
+ // reparse. Called from the block-list wiring for the interfaces that have a
4581
+ // single canonical tag (iframe, embed, script). Idempotent across sandboxes.
4582
+ function registerBlockedAttributeTagName$LWS(Ctor$LWS, tagName$LWS, attributeName$LWS) {
4583
+ const loweredTagName$LWS = ReflectApply$LWS$1(StringProtoToLowerCase$LWS, tagName$LWS, []);
4584
+ const loweredAttributeName$LWS = ReflectApply$LWS$1(StringProtoToLowerCase$LWS, attributeName$LWS, []);
4585
+ let info$LWS = blockedTagInfoByCtor$LWS.get(Ctor$LWS);
4586
+ if (info$LWS === undefined) {
4587
+ info$LWS = {
4588
+ tagName: loweredTagName$LWS,
4589
+ attributeNames: toSafeSet$LWS(new SetCtor$LWS$1())
4590
+ };
4591
+ blockedTagInfoByCtor$LWS.set(Ctor$LWS, info$LWS);
4592
+ }
4593
+ info$LWS.attributeNames.add(loweredAttributeName$LWS);
4594
+ }
4595
+ // =============================================================================
4596
+ // Prototype-independent, realm-generic element-kind matching
4597
+ // (W-23729707 + W-23768065)
4598
+ //
4599
+ // Attribute distortions are keyed by element constructor and were selected
4600
+ // purely via `element instanceof Ctor`, which walks the element's *live*
4601
+ // [[Prototype]] chain and is bound to the realm that captured `Ctor`. Two
4602
+ // distinct situations defeat that check while the browser still honors the
4603
+ // element's native internal slot, silently deselecting a security-relevant
4604
+ // distortion so the write/read falls through to the raw native accessor:
4605
+ //
4606
+ // 1. Repointed [[Prototype]] (W-23729707): a sandboxed caller repoints a
4607
+ // same-document native element's prototype (e.g. LWC's failed-hydration
4608
+ // recovery leaving a <script>'s prototype pointed at a component bridge,
4609
+ // W-23722850), so `instanceof` reports false for an element that still
4610
+ // lives in the sandbox's own document.
4611
+ // 2. Cross-realm orphan document (W-23768065): a genuine element minted in
4612
+ // another realm — e.g. a <script> from an iframe's
4613
+ // `document.implementation.createHTMLDocument()`, whose detached owner
4614
+ // document never receives an attribute-distortion registry — carries the
4615
+ // interface's internal slots but fails the sandbox realm's `instanceof`
4616
+ // and has no ownerDocument registry to fall back to.
4617
+ //
4618
+ // The internal slot cannot be moved by repointing [[Prototype]] and is not
4619
+ // realm-bound. `isElementOfInterface` (shared-dom) applies one of the
4620
+ // interface's own slot-backed accessors to the receiver: it succeeds for a
4621
+ // genuine instance of `Ctor`'s interface from ANY realm and throws for anything
4622
+ // lacking the slot (an unrelated interface, or a forged prototype chain).
4623
+ // `elementMatchesCtor` keeps `instanceof` as the fast path and, when the caller
4624
+ // opts in via `allowBrandCheck`, ADDS this brand-check as a fallback that only
4625
+ // ever grants additional matches — never removes one.
4626
+ //
4627
+ // The callers own where the fallback is allowed (see
4628
+ // getAttributeSetterDistortion / getAttributeGetterDistortion): a same-document
4629
+ // instanceof miss (case 1) and a cross-realm miss with no usable ownerDocument
4630
+ // registry (case 2). The established changesSince.262 cross-realm ownerDocument
4631
+ // fallback is still consulted first and unchanged, so navigated-iframe elements
4632
+ // keep selecting via their own document's registry exactly as before.
4633
+ //
4634
+ // Gated changesSince.266; when the gate is off the fallback is inert and
4635
+ // selection is byte-identical to the pre-fix instanceof-only behavior.
4636
+ // =============================================================================
4637
+ function elementMatchesCtor$LWS(element$LWS, Ctor$LWS, attributeName$LWS, allowBrandCheck$LWS) {
4638
+ // Fast path (all gates): an intact prototype chain answers definitively and
4639
+ // matches the pre-fix behavior exactly.
4640
+ if (element$LWS instanceof Ctor$LWS) {
4641
+ return true;
4642
+ }
4643
+ // Brand-check fallback: consulted only when the caller opts in
4644
+ // (allowBrandCheck) and changesSince.266 is enabled. `isElementOfInterface`
4645
+ // is realm-generic and tamper-resistant — it applies one of the interface's
4646
+ // own slot-backed accessors to `element`, succeeding for a genuine instance
4647
+ // of Ctor's interface from ANY realm and throwing otherwise. This single
4648
+ // check covers both opt-in callers: a same-document element whose
4649
+ // [[Prototype]] was repointed (W-23729707) and a genuinely cross-realm
4650
+ // element whose owning document carries no distortion registry (W-23768065).
4651
+ // Gate OFF: returns false, so selection stays instanceof-only.
4652
+ if (!allowBrandCheck$LWS || !isGaterEnabledFeature$LWS('changesSince.266')) {
4653
+ return false;
4654
+ }
4655
+ if (isElementOfInterface$LWS(element$LWS, Ctor$LWS)) {
4656
+ return true;
4657
+ }
4658
+ // Tag-name fallback (W-23590867): `element` is not (yet) an instance of
4659
+ // Ctor's interface and carries none of its slots, but if its tag name
4660
+ // matches Ctor's blocked HTML tag name — for one of the attributes recorded
4661
+ // as blocked on that tag — an HTML reparse would specialize it into the real
4662
+ // interface, inheriting the attribute value set on the generic node. Match
4663
+ // by tag name so the block fires before that promotion can occur.
4664
+ const blockedTagInfo$LWS = blockedTagInfoByCtor$LWS.get(Ctor$LWS);
4665
+ if (blockedTagInfo$LWS === undefined || !blockedTagInfo$LWS.attributeNames.has(attributeName$LWS)) {
4666
+ return false;
4667
+ }
4668
+ let tagName$LWS;
4669
+ try {
4670
+ tagName$LWS = ReflectApply$LWS$1(ElementProtoTagNameGetter$LWS, element$LWS, []);
4671
+ } catch (_unused2$LWS) {
4672
+ // Not a genuine Element (e.g. a forged receiver) — no reparse risk.
4673
+ return false;
4674
+ }
4675
+ return ReflectApply$LWS$1(StringProtoToLowerCase$LWS, tagName$LWS, []) === blockedTagInfo$LWS.tagName;
4676
+ }
4168
4677
  function finalizeAttributeSetterDistortions$LWS(record$LWS) {
4169
4678
  const attributeFactories$LWS = attributeDistortionFactoriesCache$LWS.get(record$LWS);
4170
4679
  // istanbul ignore if: currently unreachable via tests
@@ -4193,7 +4702,7 @@
4193
4702
  attributeFactories$LWS[i$LWS](attributeDistortionRegistry$LWS);
4194
4703
  }
4195
4704
  }
4196
- function lookupAttributeDistortion$LWS(document$LWS, key$LWS, element$LWS, attrName$LWS, attributeNamespace$LWS) {
4705
+ function lookupAttributeDistortion$LWS(document$LWS, key$LWS, element$LWS, attrName$LWS, attributeNamespace$LWS, allowBrandCheck$LWS) {
4197
4706
  const sandboxAttributeDistortionRegistry$LWS = sandboxAttributeDistortionRegistryCache$LWS.get(document$LWS);
4198
4707
  // istanbul ignore if: currently unreachable via tests
4199
4708
  if (sandboxAttributeDistortionRegistry$LWS === undefined) {
@@ -4204,7 +4713,8 @@
4204
4713
  if (attributeDistortionRegistry$LWS === undefined) {
4205
4714
  return undefined;
4206
4715
  }
4207
- const elementCtorMapByAttributeNamespaceRegistry$LWS = attributeDistortionRegistry$LWS[ReflectApply$LWS$1(StringProtoToLowerCase$LWS, attrName$LWS, [])];
4716
+ const loweredAttrName$LWS = ReflectApply$LWS$1(StringProtoToLowerCase$LWS, attrName$LWS, []);
4717
+ const elementCtorMapByAttributeNamespaceRegistry$LWS = attributeDistortionRegistry$LWS[loweredAttrName$LWS];
4208
4718
  if (elementCtorMapByAttributeNamespaceRegistry$LWS === undefined) {
4209
4719
  return undefined;
4210
4720
  }
@@ -4219,7 +4729,13 @@
4219
4729
  } of mapIterator$LWS) {
4220
4730
  // Element can inherit from Ctor but Ctor may not be the first entry in
4221
4731
  // the proto chain thus element.prototype checks are not sufficient.
4222
- if (element$LWS instanceof Ctor$LWS) {
4732
+ // elementMatchesCtor uses instanceof as the fast path and, when
4733
+ // allowBrandCheck is set (same-document element, changesSince.266), a
4734
+ // tamper-resistant brand-check fallback so a repointed [[Prototype]]
4735
+ // cannot deselect this distortion, plus a tag-name fallback so a foreign
4736
+ // generic node that would reparse into this interface (W-23590867) is
4737
+ // still matched for its blocked attributes.
4738
+ if (elementMatchesCtor$LWS(element$LWS, Ctor$LWS, loweredAttrName$LWS, allowBrandCheck$LWS)) {
4223
4739
  return distortion$LWS;
4224
4740
  }
4225
4741
  }
@@ -4230,26 +4746,55 @@
4230
4746
  document: document$LWS,
4231
4747
  key: key$LWS
4232
4748
  } = record$LWS;
4233
- const result$LWS = lookupAttributeDistortion$LWS(document$LWS, key$LWS, element$LWS, attrName$LWS, attributeNamespace$LWS);
4749
+ // Fast path: instanceof-only selection in the sandbox document. Legitimate
4750
+ // elements match here without any extra work, so the common path is
4751
+ // unchanged from the pre-fix behavior.
4752
+ const result$LWS = lookupAttributeDistortion$LWS(document$LWS, key$LWS, element$LWS, attrName$LWS, attributeNamespace$LWS, false);
4234
4753
  if (result$LWS !== undefined) {
4235
4754
  return result$LWS;
4236
4755
  }
4237
- // When an element is passed to a setAttribute function from a different
4238
- // realm (e.g. cross-realm setAttribute obtained via a navigated iframe),
4239
- // the instanceof check fails because the registry's constructors belong
4240
- // to the function's realm, not the element's. Fall back to the element's
4241
- // ownerDocument registry where constructors match the element's prototype
4242
- // chain.
4756
+ // instanceof missed. Read the element's owning document (a tamper-resistant
4757
+ // Node getter) to distinguish the two ways that can happen:
4758
+ const elementDocument$LWS = ReflectApply$LWS$1(NodeProtoOwnerDocumentGetter$LWS, element$LWS, []);
4759
+ if (elementDocument$LWS === document$LWS) {
4760
+ // Same document: in the sandbox's own document the only way instanceof
4761
+ // fails is a repointed [[Prototype]] (W-23722850's hydrateComponent
4762
+ // brand-strip). Re-select with the tamper-resistant brand-check so the
4763
+ // security-relevant distortion still fires. Gated changesSince.266.
4764
+ if (isGaterEnabledFeature$LWS('changesSince.266')) {
4765
+ return lookupAttributeDistortion$LWS(document$LWS, key$LWS, element$LWS, attrName$LWS, attributeNamespace$LWS, true);
4766
+ }
4767
+ return undefined;
4768
+ }
4769
+ // Different document: the element was passed to a setAttribute function
4770
+ // from a different realm (e.g. cross-realm setAttribute obtained via a
4771
+ // navigated iframe); the instanceof check fails because the registry's
4772
+ // constructors belong to the function's realm, not the element's. Fall back
4773
+ // to the element's ownerDocument registry where constructors match the
4774
+ // element's prototype chain — instanceof-only, exactly as before.
4243
4775
  //
4244
4776
  // Gated changesSince.262 because the cross-realm fallback was introduced
4245
4777
  // in the 262 train alongside the other cross-realm hardening; lowering
4246
4778
  // the gate here would re-expose 262 sandboxes to the cross-realm
4247
4779
  // bypass class this fallback closes.
4248
- if (isGaterEnabledFeature$LWS('changesSince.262')) {
4249
- const elementDocument$LWS = ReflectApply$LWS$1(NodeProtoOwnerDocumentGetter$LWS, element$LWS, []);
4250
- if (elementDocument$LWS && elementDocument$LWS !== document$LWS) {
4251
- return lookupAttributeDistortion$LWS(elementDocument$LWS, key$LWS, element$LWS, attrName$LWS, attributeNamespace$LWS);
4252
- }
4780
+ if (isGaterEnabledFeature$LWS('changesSince.262') && elementDocument$LWS) {
4781
+ const crossRealmResult$LWS = lookupAttributeDistortion$LWS(elementDocument$LWS, key$LWS, element$LWS, attrName$LWS, attributeNamespace$LWS, false);
4782
+ if (crossRealmResult$LWS !== undefined) {
4783
+ return crossRealmResult$LWS;
4784
+ }
4785
+ }
4786
+ // W-23768065: the cross-realm ownerDocument fallback found nothing — either
4787
+ // the element's owning document carries no distortion registry (an orphan
4788
+ // `createHTMLDocument()` document is never sandbox-registered) or its
4789
+ // instanceof-only lookup missed. Re-select against THIS sandbox document's
4790
+ // registry with the realm-generic brand-check so a genuine foreign-realm
4791
+ // element (e.g. that orphan document's <script>) still selects the
4792
+ // distortion instead of falling through to the raw native setter. Sound
4793
+ // because the brand witness is interface-specific and realm-agnostic (see
4794
+ // elementMatchesCtor). Gated changesSince.266; inert when off, leaving the
4795
+ // 262 behavior above unchanged.
4796
+ if (isGaterEnabledFeature$LWS('changesSince.266')) {
4797
+ return lookupAttributeDistortion$LWS(document$LWS, key$LWS, element$LWS, attrName$LWS, attributeNamespace$LWS, true);
4253
4798
  }
4254
4799
  return undefined;
4255
4800
  }
@@ -4259,6 +4804,23 @@
4259
4804
  function normalizeNamespace$LWS(ns$LWS) {
4260
4805
  return ns$LWS === null || ns$LWS === undefined || ns$LWS === '' ? NAMESPACE_DEFAULT$LWS : ns$LWS;
4261
4806
  }
4807
+ // W-23486664: An Attr minted via createAttributeNS carries a *qualified* name
4808
+ // (e.g. 'foo:href') whose localName the browser still resolves as 'href'. The
4809
+ // attribute-distortion registry keys on the canonical name, so a qualified
4810
+ // name has to be normalized before lookup or getAttributeSetterDistortion
4811
+ // misses the registered 'href' entry and the raw value reaches the native
4812
+ // slot unsanitized. The setAttribute* family already normalizes inline; this
4813
+ // helper gives the remaining Attr-value sinks (Attr.value, Node.nodeValue,
4814
+ // Node.textContent, NamedNodeMap.setNamedItem) the same normalization. It is
4815
+ // deliberately scoped to those sinks rather than folded into
4816
+ // getAttributeSetterDistortion because that function is also reached by
4817
+ // toggleAttribute and the SVG attributeName distortions, which must keep
4818
+ // their raw-name behavior. Gated on the active train so pre-266 sandboxes
4819
+ // preserve their existing lookup behavior; the read side already normalizes
4820
+ // unconditionally inside getAttributeGetterDistortion.
4821
+ function normalizeAttributeName$LWS(attrName$LWS) {
4822
+ return isGaterEnabledFeature$LWS('changesSince.266') ? normalizeNamespacedAttributeName$LWS(attrName$LWS) : attrName$LWS;
4823
+ }
4262
4824
  function registerAttributeSetterDistortion$LWS(record$LWS, ElementCtor$LWS, attributeName$LWS, attributeNamespace$LWS, distortion$LWS) {
4263
4825
  let attributeFactories$LWS = attributeDistortionFactoriesCache$LWS.get(record$LWS);
4264
4826
  if (attributeFactories$LWS === undefined) {
@@ -4311,7 +4873,7 @@
4311
4873
  factories$LWS[i$LWS](registry$LWS);
4312
4874
  }
4313
4875
  }
4314
- function lookupAttributeGetterIn$LWS(document$LWS, key$LWS, element$LWS, attrName$LWS, attributeNamespace$LWS) {
4876
+ function lookupAttributeGetterIn$LWS(document$LWS, key$LWS, element$LWS, attrName$LWS, attributeNamespace$LWS, allowBrandCheck$LWS) {
4315
4877
  const sandboxRegistry$LWS = sandboxAttributeGetterRegistryCache$LWS.get(document$LWS);
4316
4878
  if (sandboxRegistry$LWS === undefined) {
4317
4879
  return undefined;
@@ -4320,7 +4882,8 @@
4320
4882
  if (registry$LWS === undefined) {
4321
4883
  return undefined;
4322
4884
  }
4323
- const byNamespace$LWS = registry$LWS[ReflectApply$LWS$1(StringProtoToLowerCase$LWS, attrName$LWS, [])];
4885
+ const loweredAttrName$LWS = ReflectApply$LWS$1(StringProtoToLowerCase$LWS, attrName$LWS, []);
4886
+ const byNamespace$LWS = registry$LWS[loweredAttrName$LWS];
4324
4887
  if (byNamespace$LWS === undefined) {
4325
4888
  return undefined;
4326
4889
  }
@@ -4333,7 +4896,13 @@
4333
4896
  0: Ctor$LWS,
4334
4897
  1: getter$LWS
4335
4898
  } of it$LWS) {
4336
- if (element$LWS instanceof Ctor$LWS) {
4899
+ // Prototype-independent selection, mirroring the setter registry: a
4900
+ // repointed [[Prototype]] must not deselect a read-side (e.g. nonce)
4901
+ // getter distortion either, and a foreign generic node whose tag name
4902
+ // would reparse into this interface (W-23590867) is matched for its
4903
+ // blocked attributes. allowBrandCheck is scoped to same-document
4904
+ // elements by the caller. See elementMatchesCtor.
4905
+ if (elementMatchesCtor$LWS(element$LWS, Ctor$LWS, loweredAttrName$LWS, allowBrandCheck$LWS)) {
4337
4906
  return getter$LWS;
4338
4907
  }
4339
4908
  }
@@ -4348,20 +4917,43 @@
4348
4917
  document: document$LWS,
4349
4918
  key: key$LWS
4350
4919
  } = record$LWS;
4351
- const direct$LWS = lookupAttributeGetterIn$LWS(document$LWS, key$LWS, element$LWS, normalizedName$LWS, attributeNamespace$LWS);
4920
+ // Fast path: instanceof-only selection in the sandbox document (unchanged).
4921
+ const direct$LWS = lookupAttributeGetterIn$LWS(document$LWS, key$LWS, element$LWS, normalizedName$LWS, attributeNamespace$LWS, false);
4352
4922
  if (direct$LWS !== undefined) {
4353
4923
  return direct$LWS;
4354
4924
  }
4925
+ // instanceof missed. Distinguish a repointed same-document element from a
4926
+ // genuinely cross-realm one by comparing owning documents (see
4927
+ // getAttributeSetterDistortion for the full rationale).
4928
+ const elementDocument$LWS = ReflectApply$LWS$1(NodeProtoOwnerDocumentGetter$LWS, element$LWS, []);
4929
+ if (elementDocument$LWS === document$LWS) {
4930
+ // Same document: re-select with the tamper-resistant brand-check so a
4931
+ // repointed [[Prototype]] cannot deselect a read-side (e.g. nonce)
4932
+ // getter distortion. Gated changesSince.266.
4933
+ if (isGaterEnabledFeature$LWS('changesSince.266')) {
4934
+ return lookupAttributeGetterIn$LWS(document$LWS, key$LWS, element$LWS, normalizedName$LWS, attributeNamespace$LWS, true);
4935
+ }
4936
+ return undefined;
4937
+ }
4355
4938
  // Cross-realm fallback: same shape as the setter registry's, gated 262
4356
4939
  // for the same reason. Nonce protection on the getter side relies on
4357
4940
  // this fallback firing for cross-realm reads at 262 sandboxes;
4358
4941
  // raising this gate would re-leak nonce through cross-realm Element
4359
- // instances on that gate.
4360
- if (isGaterEnabledFeature$LWS('changesSince.262')) {
4361
- const elementDocument$LWS = ReflectApply$LWS$1(NodeProtoOwnerDocumentGetter$LWS, element$LWS, []);
4362
- if (elementDocument$LWS && elementDocument$LWS !== document$LWS) {
4363
- return lookupAttributeGetterIn$LWS(elementDocument$LWS, key$LWS, element$LWS, normalizedName$LWS, attributeNamespace$LWS);
4364
- }
4942
+ // instances on that gate. instanceof-only, exactly as before.
4943
+ if (isGaterEnabledFeature$LWS('changesSince.262') && elementDocument$LWS) {
4944
+ const crossRealmGetter$LWS = lookupAttributeGetterIn$LWS(elementDocument$LWS, key$LWS, element$LWS, normalizedName$LWS, attributeNamespace$LWS, false);
4945
+ if (crossRealmGetter$LWS !== undefined) {
4946
+ return crossRealmGetter$LWS;
4947
+ }
4948
+ }
4949
+ // W-23768065: mirror the setter side. When the cross-realm ownerDocument
4950
+ // fallback finds no getter (orphan/registry-less document), re-select
4951
+ // against THIS sandbox document's registry with the realm-generic
4952
+ // brand-check so read-side overrides (e.g. nonce masking, iframe pending
4953
+ // src) still fire for a genuine foreign-realm element. Gated
4954
+ // changesSince.266; inert when off.
4955
+ if (isGaterEnabledFeature$LWS('changesSince.266')) {
4956
+ return lookupAttributeGetterIn$LWS(document$LWS, key$LWS, element$LWS, normalizedName$LWS, attributeNamespace$LWS, true);
4365
4957
  }
4366
4958
  return undefined;
4367
4959
  }
@@ -4421,20 +5013,35 @@
4421
5013
  const originalAttrValueSetter$LWS = ObjectLookupOwnSetter$LWS(Attr$LWS.prototype, 'value');
4422
5014
  return function distortionAttrValueSetter$LWS(record$LWS) {
4423
5015
  return [originalAttrValueSetter$LWS, function value$LWS(val$LWS) {
5016
+ // W-23596015: coerce `val` to a string EXACTLY ONCE, up front —
5017
+ // before reading `ownerElement` — to close a reentrant TOCTOU.
5018
+ // A `{ toString() {...} }` argument would otherwise reach the
5019
+ // native setter unconverted, and native WebIDL DOMString
5020
+ // coercion runs the attacker's `toString()` AFTER LWS has
5021
+ // committed to its routing decision. That reentrant call can
5022
+ // attach this (until now detached) Attr to a <script> via
5023
+ // `setAttributeNode`, so when the native setter finally writes
5024
+ // the real URL the Attr is connected — yet LWS is never
5025
+ // re-entered, and the URL lands through a raw native write that
5026
+ // skips the script-`src` distortion. Coercing first makes any
5027
+ // such reentrant attach visible to the `ownerElement` read
5028
+ // below, so the resolved string is routed through the
5029
+ // registered distortion instead of a raw native write.
5030
+ const coercedVal$LWS = isGaterEnabledFeature$LWS('changesSince.266') ? toSafeStringValue$LWS(val$LWS) : val$LWS;
4424
5031
  const ownerElement$LWS = ReflectApply$LWS$1(AttrProtoOwnerElementGetter$LWS, this, []);
4425
5032
  // istanbul ignore else: needs default platform behavior test
4426
5033
  if (ownerElement$LWS) {
4427
- const attrName$LWS = ReflectApply$LWS$1(AttrProtoNameGetter$LWS, this, []);
5034
+ const attrName$LWS = normalizeAttributeName$LWS(ReflectApply$LWS$1(AttrProtoNameGetter$LWS, this, []));
4428
5035
  const attrNamespace$LWS = ReflectApply$LWS$1(AttrProtoNamespaceURIGetter$LWS, this, []);
4429
5036
  const normalizedNamespace$LWS = normalizeNamespace$LWS(attrNamespace$LWS);
4430
5037
  const distortion$LWS = getAttributeSetterDistortion$LWS(record$LWS, ownerElement$LWS, attrName$LWS, normalizedNamespace$LWS);
4431
5038
  // istanbul ignore if: coverage missing, needs investigation
4432
5039
  if (distortion$LWS) {
4433
- ReflectApply$LWS$1(distortion$LWS, ownerElement$LWS, [val$LWS]);
5040
+ ReflectApply$LWS$1(distortion$LWS, ownerElement$LWS, [coercedVal$LWS]);
4434
5041
  return;
4435
5042
  }
4436
5043
  }
4437
- ReflectApply$LWS$1(originalAttrValueSetter$LWS, this, [val$LWS]);
5044
+ ReflectApply$LWS$1(originalAttrValueSetter$LWS, this, [coercedVal$LWS]);
4438
5045
  }];
4439
5046
  };
4440
5047
  }
@@ -4867,6 +5474,7 @@
4867
5474
  return false;
4868
5475
  }
4869
5476
  let possiblyRestrictedConstructor$LWS = getUnmaskedFunction$LWS(eventTarget$LWS.constructor);
5477
+ const restrictedCtors$LWS = restrictedEventTargetRegistry$LWS[eventName$LWS];
4870
5478
  // Walk UP the proto chain to check if super classes have a restriction on this event.
4871
5479
  // This can happen in cases where HTMLElement is the event target constructor, but
4872
5480
  // the event listener is being added to HTMLDivElement. Since we obviously want to
@@ -4874,7 +5482,14 @@
4874
5482
  // walk up from the HTMLDivElement until we find the constructor for which we
4875
5483
  // registered a restriction.
4876
5484
  while (possiblyRestrictedConstructor$LWS !== null) {
4877
- if (restrictedEventTargetRegistry$LWS[eventName$LWS].has(possiblyRestrictedConstructor$LWS)) {
5485
+ // A custom element (every LWC component) extends a pivot class whose base
5486
+ // constructor is sourced from the sandbox custom-element registry. That
5487
+ // constructor is a DIFFERENT object than the one registered here from the
5488
+ // sandbox record, so a constructor-identity match misses at the HTMLElement
5489
+ // hop and the walk climbs past it. The two constructors share the SAME
5490
+ // `prototype` object, so we also match on the constructor's prototype, which
5491
+ // is stable across that boundary.
5492
+ if (restrictedCtors$LWS.has(possiblyRestrictedConstructor$LWS) || restrictedCtors$LWS.has(possiblyRestrictedConstructor$LWS.prototype)) {
4878
5493
  return true;
4879
5494
  }
4880
5495
  // eslint-disable-next-line no-proto
@@ -4900,6 +5515,16 @@
4900
5515
  [eventName$LWS]: restrictedEventTargetCtors$LWS = toSafeWeakSet$LWS$1(new WeakSetCtor$LWS$1())
4901
5516
  } = restrictedEventTargetRegistry$LWS;
4902
5517
  restrictedEventTargetCtors$LWS.add(unmaskedEventTargetCtor$LWS);
5518
+ // Also register the constructor's `prototype`. A custom element (every LWC
5519
+ // component) extends a pivot class whose base constructor is sourced from the
5520
+ // sandbox custom-element registry, which is a DIFFERENT object than the one
5521
+ // registered here from the sandbox record. A constructor-identity match
5522
+ // therefore misses at the HTMLElement hop and the walk climbs past it. The
5523
+ // two constructors share the SAME `prototype` object, so registering the
5524
+ // prototype lets `isEventTargetRestricted` match a custom element's chain.
5525
+ if (isGaterEnabledFeature$LWS('changesSince.266')) {
5526
+ restrictedEventTargetCtors$LWS.add(unmaskedEventTargetCtor$LWS.prototype);
5527
+ }
4903
5528
  restrictedEventTargetRegistry$LWS[eventName$LWS] = restrictedEventTargetCtors$LWS;
4904
5529
  restrictedEventTargetRegistryBySandboxKeyRegistry$LWS[key$LWS] = restrictedEventTargetRegistry$LWS;
4905
5530
  }
@@ -5820,6 +6445,28 @@
5820
6445
  key: key$LWS
5821
6446
  }) {
5822
6447
  return [originalAttachShadow$LWS, function attachShadow$LWS(...args$LWS) {
6448
+ // W-23486662: the receiver is delegated to the wrapped
6449
+ // `attachShadow` unchecked. Native `attachShadow` brand-checks
6450
+ // it (a non-Element receiver throws "Illegal invocation"), but
6451
+ // on the platform LWC synthetic shadow replaces this method
6452
+ // with a variant that skips the brand-check when the internal
6453
+ // '$$lwc-synthetic-mode' option is set, so a non-Element (e.g.
6454
+ // a forged `srcdoc` Attr) can be made a synthetic shadow host
6455
+ // and used to write markup outside the Attr distortion. Enforce
6456
+ // the receiver invariant here so the guard holds regardless of
6457
+ // whether the wrapped method is native or synthetic. The check
6458
+ // is the structural `isElement` probe (an internal-slot brand
6459
+ // check), NOT `instanceof`: a genuine Element from any
6460
+ // same-origin realm passes, while an `Attr` or a same-realm
6461
+ // impostor with a forged `Element.prototype` chain is rejected
6462
+ // -- the latter would satisfy `instanceof Element` yet still
6463
+ // lacks the slot, so relying on `instanceof` would leave the
6464
+ // gap open.
6465
+ if (isGaterEnabledFeature$LWS('changesSince.266')) {
6466
+ if (!isElement$LWS(this)) {
6467
+ throw new LockerSecurityError$LWS('Failed to execute "attachShadow": the receiver is not an Element.');
6468
+ }
6469
+ }
5823
6470
  const shadowRoot$LWS = ReflectApply$LWS$1(originalAttachShadow$LWS, this, args$LWS);
5824
6471
  registerShadowRootInSandbox$LWS(key$LWS, shadowRoot$LWS);
5825
6472
  return shadowRoot$LWS;
@@ -5837,7 +6484,7 @@
5837
6484
  const element$LWS = namedNodeMapToElementCache$LWS.get(nodeNameMap$LWS);
5838
6485
  // istanbul ignore else: nothing to do if there's no element
5839
6486
  if (element$LWS) {
5840
- const attrName$LWS = ReflectApply$LWS$1(AttrProtoNameGetter$LWS, attr$LWS, []);
6487
+ const attrName$LWS = normalizeAttributeName$LWS(ReflectApply$LWS$1(AttrProtoNameGetter$LWS, attr$LWS, []));
5841
6488
  const attrNamespace$LWS = ReflectApply$LWS$1(AttrProtoNamespaceURIGetter$LWS, attr$LWS, []);
5842
6489
  const normalizedNamespace$LWS = normalizeNamespace$LWS(attrNamespace$LWS);
5843
6490
  const distortion$LWS = getAttributeSetterDistortion$LWS(record$LWS, element$LWS, attrName$LWS, normalizedNamespace$LWS);
@@ -6126,6 +6773,22 @@
6126
6773
  };
6127
6774
  }
6128
6775
  function scriptPropertySetters$LWS(incomingThis$LWS, property$LWS, valueAsTrustedString$LWS, originalScriptPropertyGetter$LWS, originalScriptPropertySetter$LWS, distortions$LWS, sandboxEvaluator$LWS, signedScriptHookSourceText$LWS) {
6776
+ // W-23593711: every caller reaches this fast path after an `instanceof
6777
+ // HTMLScriptElement || instanceof SVGScriptElement` check, but `instanceof`
6778
+ // is forgeable via an attacker-controlled `newTarget` (e.g.
6779
+ // `Reflect.construct(Audio, [], HTMLScriptElement)` produces a real
6780
+ // `<audio>` element whose prototype is `HTMLScriptElement.prototype`). This
6781
+ // fast path deliberately restores the raw value through the captured native
6782
+ // setter WITHOUT running it through the HTML sanitizer, on the assumption
6783
+ // that a real `<script>` never parses that value as markup. A forged
6784
+ // element is NOT a script, so it WOULD parse the raw string as live,
6785
+ // unsanitized DOM. Confirm the receiver is a genuine script element via an
6786
+ // unforgeable internal-slot brand check; if not, bail so the caller falls
6787
+ // through to its sanitizing path (`createHTML` for markup sinks, the native
6788
+ // text setter for text sinks).
6789
+ if (isGaterEnabledFeature$LWS('changesSince.266') && !isScriptElement$LWS(incomingThis$LWS)) {
6790
+ return false;
6791
+ }
6129
6792
  const valueAsString$LWS = toSafeStringValue$LWS(valueAsTrustedString$LWS);
6130
6793
  if (!isScriptPropertyEvaluatorHookDefined$LWS(incomingThis$LWS)) {
6131
6794
  const distortedScriptPropertyGetter$LWS = distortions$LWS.get(originalScriptPropertyGetter$LWS);
@@ -6157,7 +6820,8 @@
6157
6820
  }
6158
6821
  const {
6159
6822
  isIframeSrcdocScriptAttack: isIframeSrcdocScriptAttack$7$LWS,
6160
- isSharedElement: isSharedElement$y$LWS
6823
+ isSharedElement: isSharedElement$y$LWS,
6824
+ isXMLScriptInRawTextElementAttack: isXMLScriptInRawTextElementAttack$1$LWS
6161
6825
  } = rootValidator$LWS;
6162
6826
  function initDistortionElementInnerHTMLSetter$LWS({
6163
6827
  document: document$LWS,
@@ -6211,7 +6875,13 @@
6211
6875
  // malicious markup on a later engine coercion (see toSafeStringValue() docs).
6212
6876
  value$LWS = toSafeStringValue$LWS(value$LWS);
6213
6877
  }
6214
- if (isIframeSrcdocScriptAttack$7$LWS(value$LWS)) {
6878
+ // isOwnerXMLDocument && !isSVGElement is exactly the permissive branch above: it
6879
+ // skips createHTML and is parsed by the XML parser, which has no raw-text / RCDATA
6880
+ // elements. A <script> nested in <textarea>/<title>/etc. is inert text under the
6881
+ // HTML parser (so isIframeSrcdocScriptAttack alone misses it) but a live, clonable
6882
+ // script under XML — cloneNode + adoption into the HTML document then executes it
6883
+ // (W-23486666).
6884
+ if (isIframeSrcdocScriptAttack$7$LWS(value$LWS) || isOwnerXMLDocument$LWS && !isSVGElement$LWS && isGaterEnabledFeature$LWS('changesSince.266') && isXMLScriptInRawTextElementAttack$1$LWS(value$LWS)) {
6215
6885
  throw new LockerSecurityError$LWS(`Cannot set 'innerHTML' using an unsecure ${toSafeTemplateStringValue$LWS(value$LWS)}.`);
6216
6886
  }
6217
6887
  ReflectApply$LWS$1(originalInnerHTMLSetter$LWS, this, [value$LWS]);
@@ -6576,7 +7246,14 @@
6576
7246
  return function distortionElementSetAttributeNode$LWS(record$LWS) {
6577
7247
  return [originalSetAttributeNode$LWS, function setAttributeNode$LWS(...args$LWS) {
6578
7248
  const attr$LWS = args$LWS.length ? args$LWS[0] : undefined;
6579
- if (!(attr$LWS instanceof Attr$LWS)) {
7249
+ // W-23439905: `instanceof Attr` only recognizes Attrs minted
7250
+ // in this realm. A genuine Attr from another same-origin
7251
+ // realm (e.g. a same-origin iframe's document) fails the
7252
+ // check and would otherwise fall through to the native
7253
+ // method with no interception. The structural fallback
7254
+ // recognizes a real Attr from any realm.
7255
+ const isRealAttr$LWS = attr$LWS instanceof Attr$LWS || isGaterEnabledFeature$LWS('changesSince.266') && isAttr$LWS(attr$LWS);
7256
+ if (!isRealAttr$LWS) {
6580
7257
  // Handle non-Attr values using the native API.
6581
7258
  return ReflectApply$LWS$1(originalSetAttributeNode$LWS, this, args$LWS);
6582
7259
  }
@@ -6634,7 +7311,14 @@
6634
7311
  return function distortionElementSetAttributeNodeNS$LWS(record$LWS) {
6635
7312
  return [originalSetAttributeNodeNS$LWS, function setAttributeNodeNS$LWS(...args$LWS) {
6636
7313
  const attr$LWS = args$LWS.length ? args$LWS[0] : undefined;
6637
- if (!(attr$LWS instanceof Attr$LWS)) {
7314
+ // W-23439905: `instanceof Attr` only recognizes Attrs minted
7315
+ // in this realm. A genuine Attr from another same-origin
7316
+ // realm (e.g. a same-origin iframe's document) fails the
7317
+ // check and would otherwise fall through to the native
7318
+ // method with no interception. The structural fallback
7319
+ // recognizes a real Attr from any realm.
7320
+ const isRealAttr$LWS = attr$LWS instanceof Attr$LWS || isGaterEnabledFeature$LWS('changesSince.266') && isAttr$LWS(attr$LWS);
7321
+ if (!isRealAttr$LWS) {
6638
7322
  // Handle non-Attr values using the native API.
6639
7323
  return ReflectApply$LWS$1(originalSetAttributeNodeNS$LWS, this, args$LWS);
6640
7324
  }
@@ -6785,7 +7469,8 @@
6785
7469
  }
6786
7470
  const {
6787
7471
  isIframeSrcdocScriptAttack: isIframeSrcdocScriptAttack$3$LWS,
6788
- isSharedElement: isSharedElement$p$LWS
7472
+ isSharedElement: isSharedElement$p$LWS,
7473
+ isXMLScriptInRawTextElementAttack: isXMLScriptInRawTextElementAttack$LWS
6789
7474
  } = rootValidator$LWS;
6790
7475
  function initDistortionElementSetHTMLUnsafe$LWS({
6791
7476
  document: document$LWS,
@@ -6845,7 +7530,13 @@
6845
7530
  const contentType$LWS = isSVGElement$LWS ? ContentType$LWS.SVG : ContentType$LWS.HTML;
6846
7531
  normalizedValue$LWS = lwsInternalPolicy$LWS.createHTML(normalizedValue$LWS, key$LWS, contentType$LWS);
6847
7532
  }
6848
- if (isIframeSrcdocScriptAttack$3$LWS(normalizedValue$LWS)) {
7533
+ // isOwnerXMLDocument && !isSVGElement is exactly the permissive branch above: it
7534
+ // skips createHTML and is parsed by the XML parser, which has no raw-text / RCDATA
7535
+ // elements. A <script> nested in <textarea>/<title>/etc. is inert text under the
7536
+ // HTML parser (so isIframeSrcdocScriptAttack alone misses it) but a live, clonable
7537
+ // script under XML — cloneNode + adoption into the HTML document then executes it
7538
+ // (W-23486666).
7539
+ if (isIframeSrcdocScriptAttack$3$LWS(normalizedValue$LWS) || isOwnerXMLDocument$LWS && !isSVGElement$LWS && isGaterEnabledFeature$LWS('changesSince.266') && isXMLScriptInRawTextElementAttack$LWS(normalizedValue$LWS)) {
6849
7540
  throw new LockerSecurityError$LWS(`Cannot 'setHTMLUnsafe' using an unsecure ${toSafeTemplateStringValue$LWS(normalizedValue$LWS)}.`);
6850
7541
  }
6851
7542
  ReflectApply$LWS$1(originalSetHTMLUnsafe$LWS, this, [normalizedValue$LWS]);
@@ -7058,28 +7749,35 @@
7058
7749
 
7059
7750
  // W-22602807: shared helper for distorting an iframe contentWindow realm's
7060
7751
  // function-invocation primitives (Function.prototype.call/apply/bind,
7061
- // Reflect.apply/construct).
7752
+ // Reflect.apply/construct) and, as of W-23748562, its CAPTURE primitives
7753
+ // (Proxy / Proxy.revocable — see Proxy/constructor-value.ts and
7754
+ // Proxy/revocable-value.ts) that mint a fresh identity around a callee
7755
+ // argument rather than invoking it directly.
7062
7756
  //
7063
7757
  // The cross-realm leak: sandbox code obtains a same-origin iframe's invocation
7064
7758
  // primitive and uses it to invoke a constructor/evaluator. The callee can
7065
7759
  // arrive as a RAW callable whose realm's `document` is undistorted, so
7066
7760
  // `document.cookie` in a compiled body resolves to the native getter and leaks
7067
- // the top-level cookie.
7761
+ // the top-level cookie. A capture primitive extends this: wrapping the callee
7762
+ // in a fresh Proxy identity BEFORE it reaches an invocation primitive defeats
7763
+ // the identity-keyed re-resolution below unless the wrapping itself is also
7764
+ // distorted (substitute the target at capture time, same as `bind` already
7765
+ // does for its callee).
7068
7766
  //
7069
7767
  // Containment tracks the OUTERMOST primitive actually invoked through the
7070
7768
  // membrane (composition depth is irrelevant: in `apply.call(F, ...)` only the
7071
- // outer `.call` is invoked). So every invocation primitive reachable on the
7072
- // iframe realm must be distorted. Each re-resolves the callee (the function
7073
- // being invoked) to its distorted counterpart in the ROOT record's map when
7074
- // one exists, then delegates to the native primitive — so a raw native
7075
- // Function/eval reached cross-realm becomes the sandbox-distorted version,
7076
- // while ordinary usage is an untouched passthrough.
7077
- // Returns the host iframe element if `globalObject
7078
- // ` is a same-origin iframe
7769
+ // outer `.call` is invoked). So every invocation AND capture primitive
7770
+ // reachable on the iframe realm must be distorted. Each re-resolves the
7771
+ // callee/target (the function or object being invoked or wrapped) to its
7772
+ // distorted counterpart in the ROOT record's map when one exists, then
7773
+ // delegates to the native primitive — so a raw native Function/eval reached
7774
+ // cross-realm (directly, or laundered through a Proxy) becomes the
7775
+ // sandbox-distorted version, while ordinary usage is an untouched passthrough.
7776
+ // Returns the host iframe element if `globalObject` is a same-origin iframe
7079
7777
  // contentWindow realm (the only realm we distort), else undefined. Gated on
7080
7778
  // changesSince.264: when the gate is off, no entry is installed and the
7081
- // primitive keeps its native behavior. One check here covers all five
7082
- // invocation-primitive distortions.
7779
+ // primitive keeps its native behavior. One check here covers every
7780
+ // invocation- and capture-primitive distortion in this family.
7083
7781
  function getDistortableFrameElement$LWS(globalObject$LWS) {
7084
7782
  if (!isGaterEnabledFeature$LWS('changesSince.264')) {
7085
7783
  return undefined;
@@ -7087,7 +7785,7 @@
7087
7785
  let frameElement$LWS;
7088
7786
  try {
7089
7787
  frameElement$LWS = ReflectApply$LWS$1(WindowFrameElementGetter$LWS, globalObject$LWS, []);
7090
- } catch (_unused2$LWS) {
7788
+ } catch (_unused3$LWS) {
7091
7789
  // Cross-origin / non-window realm: not our target.
7092
7790
  return undefined;
7093
7791
  }
@@ -7101,12 +7799,19 @@
7101
7799
  // foreign invocation primitive can deliver a callee (e.g. the sandbox `Function`
7102
7800
  // ctor) that has crossed the membrane as a RAW reference, bypassing the
7103
7801
  // distortion the membrane would normally apply on a direct call. Looking the
7104
- // callee up in the map re-attaches that distortion. We rely on the map's
7105
- // invariant that a callable key maps to a callable replacement; the
7106
- // `distorted !== callee` check skips identity mappings (e.g. `document`,
7107
- // `location`, the global object, which map to themselves), and the invocation
7108
- // primitives require a callable target regardless, so a non-callable could
7109
- // never be reached here without throwing at the call site.
7802
+ // callee up in the map re-attaches that distortion. The `distorted !== callee`
7803
+ // check skips identity mappings (e.g. `document`, `location`, the global
7804
+ // object, which map to themselves), so a non-distorted target simply passes
7805
+ // through unchanged.
7806
+ //
7807
+ // Despite the parameter name, `callee` need not be callable: the Proxy
7808
+ // capture distortions (Proxy/constructor-value.ts, Proxy/revocable-value.ts,
7809
+ // W-23748562) reuse this helper to substitute a Proxy's TARGET before the
7810
+ // Proxy is built, and a Proxy target is not required to be callable
7811
+ // (`new cw.Proxy(document, {})` is valid). `root.distortions.get` is safe for
7812
+ // any object, callable or not, so the reuse is correct — this is a naming
7813
+ // artifact of the helper predating that second caller, not a constraint on
7814
+ // what may be passed.
7110
7815
  function substituteDistortedCallee$LWS(root$LWS, callee$LWS) {
7111
7816
  const distorted$LWS = root$LWS.distortions.get(callee$LWS);
7112
7817
  if (distorted$LWS !== undefined && distorted$LWS !== callee$LWS) {
@@ -7625,6 +8330,335 @@
7625
8330
  return [originalActionSetter$LWS, originalActionSetter$LWS];
7626
8331
  };
7627
8332
  }
8333
+
8334
+ // Per-frame bookkeeping for the HTMLFrameElement.src async pre-flight
8335
+ const pendingURLs$1$LWS = toSafeWeakMap$LWS$1(new WeakMapCtor$LWS$1());
8336
+ const inflightControllers$1$LWS = toSafeWeakMap$LWS$1(new WeakMapCtor$LWS$1());
8337
+ // Frames whose pre-flight detected an attack pattern in the fetched
8338
+ // response body. The setter checks this set at entry and throws
8339
+ // synchronously on any subsequent write attempt, so the violation is
8340
+ // observable from sandboxed code on the *next* sync touchpoint after
8341
+ // the async pre-flight resolved hostile.
8342
+ const poisonedFrames$LWS = toSafeWeakSet$LWS$1(new WeakSetCtor$LWS$1());
8343
+ // Cross-frame URL rejection cache. When a pre-flight detects hostile,
8344
+ // the URL's pathname is added here. Any subsequent frame.src assignment
8345
+ // to a URL with the same pathname (regardless of the frame instance,
8346
+ // query string, or fragment) throws synchronously without re-fetching.
8347
+ // Pathname-keyed (not full URL) so query-string rotation can't evade
8348
+ // the cache.
8349
+ //
8350
+ // Like the iframe pipeline's equivalent cache, this Set is module-scoped
8351
+ // (shared across every sandbox) and entries are never evicted for the
8352
+ // process lifetime. The accepted tradeoff, shared with the iframe
8353
+ // pipeline: a validator false positive would keep every sandbox
8354
+ // rejecting that pathname until the page reloads. This is deemed
8355
+ // acceptable because a resource classified as carrying an attack pattern
8356
+ // is not expected to become benign within a session, and the fail-closed
8357
+ // direction favors security over availability.
8358
+ const rejectedPathnames$1$LWS = toSafeSet$LWS(new SetCtor$LWS$1());
8359
+ function getPendingURL$1$LWS(frame$LWS) {
8360
+ return pendingURLs$1$LWS.get(frame$LWS);
8361
+ }
8362
+ function setPendingURL$1$LWS(frame$LWS, url$LWS) {
8363
+ pendingURLs$1$LWS.set(frame$LWS, url$LWS);
8364
+ }
8365
+ function clearPendingURL$1$LWS(frame$LWS) {
8366
+ pendingURLs$1$LWS.delete(frame$LWS);
8367
+ }
8368
+ function abortInflightPreflight$1$LWS(frame$LWS) {
8369
+ const controller$LWS = inflightControllers$1$LWS.get(frame$LWS);
8370
+ if (controller$LWS !== undefined) {
8371
+ ReflectApply$LWS$1(AbortControllerProtoAbort$LWS, controller$LWS, []);
8372
+ inflightControllers$1$LWS.delete(frame$LWS);
8373
+ }
8374
+ }
8375
+ function trackInflightPreflight$1$LWS(frame$LWS, controller$LWS) {
8376
+ inflightControllers$1$LWS.set(frame$LWS, controller$LWS);
8377
+ }
8378
+ function clearInflightPreflight$1$LWS(frame$LWS) {
8379
+ inflightControllers$1$LWS.delete(frame$LWS);
8380
+ }
8381
+ // Compare-and-delete: drop the tracked controller only when it is still
8382
+ // the one this request installed. A superseded request's fetch settles
8383
+ // (or rejects from its own abort) AFTER a replacement request has already
8384
+ // stored its controller here; an unconditional delete from that stale
8385
+ // handler would evict the replacement's controller, leaving the newer
8386
+ // pre-flight untracked. An untracked pre-flight can no longer be aborted
8387
+ // by a subsequent assignment, so it could commit a superseded (stale)
8388
+ // URL. Deleting only on identity match keeps every clear scoped to the
8389
+ // request that owns it.
8390
+ function clearInflightPreflightIfCurrent$LWS(frame$LWS, controller$LWS) {
8391
+ if (inflightControllers$1$LWS.get(frame$LWS) === controller$LWS) {
8392
+ inflightControllers$1$LWS.delete(frame$LWS);
8393
+ }
8394
+ }
8395
+ function poisonFrame$LWS(frame$LWS) {
8396
+ poisonedFrames$LWS.add(frame$LWS);
8397
+ }
8398
+ function isPoisonedFrame$LWS(frame$LWS) {
8399
+ return poisonedFrames$LWS.has(frame$LWS);
8400
+ }
8401
+ function rejectPathname$1$LWS(pathname$LWS) {
8402
+ rejectedPathnames$1$LWS.add(pathname$LWS);
8403
+ }
8404
+ function isRejectedPathname$1$LWS(pathname$LWS) {
8405
+ return rejectedPathnames$1$LWS.has(pathname$LWS);
8406
+ }
8407
+
8408
+ // HTMLFrameElement.src getter distortion. Returns the pending URL
8409
+ // recorded by the src setter's same-origin pre-flight pipeline (see
8410
+ // src-setter.ts) when one exists, otherwise falls through to the native
8411
+ // getter.
8412
+ //
8413
+ // The same getter is registered into the read-side attribute getter
8414
+ // registry under (HTMLFrameElement, 'src'), so frame.getAttribute('src'),
8415
+ // frame.getAttributeNS, frame.attributes['src'].value, etc. all surface
8416
+ // the pending URL during the pre-flight inspection window.
8417
+ function initDistortionHTMLFrameElementSrcGetter$LWS({
8418
+ globalObject: {
8419
+ HTMLFrameElement: HTMLFrameElement$LWS
8420
+ }
8421
+ }) {
8422
+ const originalSrcGetter$LWS = ObjectLookupOwnGetter$LWS$1(HTMLFrameElement$LWS.prototype, 'src');
8423
+ return function distortionHTMLFrameElementSrcGetter$LWS(record$LWS) {
8424
+ function src$LWS() {
8425
+ if (isGaterEnabledFeature$LWS('changesSince.266')) {
8426
+ const pending$LWS = getPendingURL$1$LWS(this);
8427
+ if (pending$LWS !== undefined) {
8428
+ return pending$LWS;
8429
+ }
8430
+ }
8431
+ return ReflectApply$LWS$1(originalSrcGetter$LWS, this, []);
8432
+ }
8433
+ // The pending-URL pipeline that backs this getter is gate-266
8434
+ // work; only register into the read-side attribute getter registry
8435
+ // when the gate is on, otherwise ungated sandboxes pay the
8436
+ // registry-consultation cost on every frame.src read with no
8437
+ // behavior change to show for it.
8438
+ if (isGaterEnabledFeature$LWS('changesSince.266')) {
8439
+ registerAttributeGetterDistortion$LWS(record$LWS, HTMLFrameElement$LWS, 'src', NAMESPACE_DEFAULT$LWS, src$LWS);
8440
+ }
8441
+ return [originalSrcGetter$LWS, src$LWS];
8442
+ };
8443
+ }
8444
+
8445
+ // HTMLFrameElement.src coverage (W-23475830). Before this distortion,
8446
+ const {
8447
+ isIframeSrcdocAttack: isIframeSrcdocAttack$1$LWS,
8448
+ isXMLEntityAttack: isXMLEntityAttack$1$LWS,
8449
+ isXMLNamespacedScriptAttack: isXMLNamespacedScriptAttack$1$LWS
8450
+ } = rootValidator$LWS;
8451
+ const ABOUT_BLANK_TOKEN$1$LWS = 'about:blank';
8452
+ function initDistortionHTMLFrameElementSrcSetter$LWS({
8453
+ globalObject: {
8454
+ HTMLFrameElement: HTMLFrameElement$LWS,
8455
+ fetch: originalFetch$LWS
8456
+ }
8457
+ }) {
8458
+ const originalSrcSetter$LWS = ObjectLookupOwnSetter$LWS(HTMLFrameElement$LWS.prototype, 'src');
8459
+ return function distortionHTMLFrameElementSrcSetter$LWS(record$LWS) {
8460
+ function src$LWS(value$LWS) {
8461
+ // Brand-new distortion: the entire distorted behavior is
8462
+ // gated on the active train. When the gate is off, fall
8463
+ // through to the pristine native setter so ungated orgs see
8464
+ // the pre-existing (native) behavior.
8465
+ if (!isGaterEnabledFeature$LWS('changesSince.266')) {
8466
+ ReflectApply$LWS$1(originalSrcSetter$LWS, this, [value$LWS]);
8467
+ return;
8468
+ }
8469
+ // If a prior async pre-flight on this frame detected an
8470
+ // attack pattern in the fetched body, the frame is
8471
+ // permanently poisoned: any subsequent synchronous write
8472
+ // throws, so the security violation surfaces at the call
8473
+ // site of the FOLLOWING `frame.src = ...` (or
8474
+ // setAttribute('src', ...)) even though we cannot
8475
+ // synchronously propagate the original hostile detection
8476
+ // back to its triggering setter call.
8477
+ if (isPoisonedFrame$LWS(this)) {
8478
+ throw new LockerSecurityError$LWS('HTMLFrameElement is poisoned: a prior src assignment fetched a body containing an attack pattern. The frame cannot be reused.');
8479
+ }
8480
+ const normalizedSrcValue$LWS = toSafeStringValue$LWS(value$LWS);
8481
+ // This must run on the raw value before sanitization, because
8482
+ // sanitization can remove the exploit pattern.
8483
+ if (isAttemptingToExploitURL$LWS(normalizedSrcValue$LWS)) {
8484
+ throw new LockerSecurityError$LWS(`Cannot set src to "${toSafeTemplateStringValue$LWS(normalizedSrcValue$LWS)}"`);
8485
+ }
8486
+ // Sanitize non-empty values for assignment; leave the empty
8487
+ // string as-is.
8488
+ const urlString$LWS = normalizedSrcValue$LWS !== '' ? sanitizeURLForElement$LWS(normalizedSrcValue$LWS) : '';
8489
+ // Scheme allowlist. This is the gate that closes the reported
8490
+ // vector: `blob:` and `javascript:` are not valid schemes, so
8491
+ // a self-closing-root XML blob (or a javascript: URL) is
8492
+ // refused here before it can ever load.
8493
+ if (urlString$LWS && !isValidURLScheme$LWS(urlString$LWS)) {
8494
+ throw new LockerSecurityError$LWS('HTMLFrameElement.src supports http://, https:// schemes, relative urls and about:blank.');
8495
+ }
8496
+ const parsedURL$LWS = parseURL$LWS(urlString$LWS);
8497
+ if (!isAllowedEndpointURL$LWS(parsedURL$LWS)) {
8498
+ const {
8499
+ normalizedURL: normalizedURL$LWS
8500
+ } = parsedURL$LWS;
8501
+ throw new LockerSecurityError$LWS(`Cannot request disallowed endpoint: ${toSafeTemplateStringValue$LWS(normalizedURL$LWS)}`);
8502
+ }
8503
+ // Same-origin URLs go through an async pre-flight that fetches
8504
+ // the resource and runs its body through the rootValidator
8505
+ // attack-pattern checks (XML entity smuggling, iframe+srcdoc
8506
+ // combos, and XML-namespaced script payloads). Same-origin
8507
+ // guarantees the pre-flight body is byte-identical to what the
8508
+ // frame load would receive (attacker-controllable content
8509
+ // surfaces in this threat model are deployable static
8510
+ // resources, which serve identical bytes for every request).
8511
+ // Cross-origin URLs proceed through the synchronous path
8512
+ // unchanged because the JS layer cannot inspect cross-origin
8513
+ // response bodies and SOP already contains the cross-origin
8514
+ // contentDocument.
8515
+ //
8516
+ // isSameOriginURL parses the URL and can throw on
8517
+ // pathological inputs. A parse failure means we cannot prove
8518
+ // the URL is same-origin, so we fall through to the
8519
+ // non-pre-flight write path (the same path a cross-origin
8520
+ // URL takes) rather than surfacing a raw parser error to
8521
+ // sandboxed code. Mirrors the try/catch guard the iframe
8522
+ // pipeline puts around its own isSameOriginURL call.
8523
+ let isSameOrigin$LWS = false;
8524
+ try {
8525
+ isSameOrigin$LWS = isSameOriginURL$LWS(urlString$LWS);
8526
+ } catch (_unused4$LWS) {
8527
+ isSameOrigin$LWS = false;
8528
+ }
8529
+ if (urlString$LWS !== '' && urlString$LWS !== ABOUT_BLANK_TOKEN$1$LWS && isSameOrigin$LWS) {
8530
+ // Cross-frame rejection cache: if any prior pre-flight
8531
+ // detected an attack pattern at this URL's pathname,
8532
+ // refuse synchronously without re-fetching. Pathname-keyed
8533
+ // so query-string rotation can't evade it.
8534
+ if (isRejectedPathname$1$LWS(parsedURL$LWS.pathname)) {
8535
+ throw new LockerSecurityError$LWS(`Cannot set src to "${toSafeTemplateStringValue$LWS(urlString$LWS)}": pathname previously rejected as containing an attack pattern.`);
8536
+ }
8537
+ preflightSameOriginAndCommit$LWS(this, urlString$LWS, parsedURL$LWS.pathname);
8538
+ return;
8539
+ }
8540
+ // Any non-pre-flight write (cross-origin, empty, about:blank)
8541
+ // supersedes a pending pre-flight: abort it, clear pending
8542
+ // state, then write native.
8543
+ abortInflightPreflight$1$LWS(this);
8544
+ clearPendingURL$1$LWS(this);
8545
+ clearInflightPreflight$1$LWS(this);
8546
+ ReflectApply$LWS$1(originalSrcSetter$LWS, this, [urlString$LWS]);
8547
+ }
8548
+ // Same-origin async pre-flight. The setter stays synchronous from
8549
+ // sandboxed code's perspective: it returns after recording the
8550
+ // pending URL and kicking off the fetch. The native attribute is
8551
+ // NOT written until the pre-flight approves the body, so the
8552
+ // browser does not begin navigating until then. Read-after-write
8553
+ // surfaces (frame.src, getAttribute('src')) see the pending URL
8554
+ // during the inspection window via the src getter distortion +
8555
+ // read-side attribute getter registry.
8556
+ function preflightSameOriginAndCommit$LWS(frame$LWS, urlString$LWS, pathname$LWS) {
8557
+ // Re-assignment cancels any prior pre-flight in flight on this
8558
+ // frame and replaces it with the new URL.
8559
+ abortInflightPreflight$1$LWS(frame$LWS);
8560
+ setPendingURL$1$LWS(frame$LWS, urlString$LWS);
8561
+ const controller$LWS = new AbortControllerCtor$LWS();
8562
+ const signal$LWS = ReflectApply$LWS$1(AbortControllerProtoSignalGetter$LWS, controller$LWS, []);
8563
+ trackInflightPreflight$1$LWS(frame$LWS, controller$LWS);
8564
+ const isSupersededOrAborted$LWS = () => signal$LWS.aborted;
8565
+ const onSafe$LWS = () => {
8566
+ if (isSupersededOrAborted$LWS()) {
8567
+ return;
8568
+ }
8569
+ clearPendingURL$1$LWS(frame$LWS);
8570
+ clearInflightPreflightIfCurrent$LWS(frame$LWS, controller$LWS);
8571
+ ReflectApply$LWS$1(originalSrcSetter$LWS, frame$LWS, [urlString$LWS]);
8572
+ };
8573
+ const onHostile$LWS = () => {
8574
+ if (isSupersededOrAborted$LWS()) {
8575
+ return;
8576
+ }
8577
+ clearPendingURL$1$LWS(frame$LWS);
8578
+ clearInflightPreflightIfCurrent$LWS(frame$LWS, controller$LWS);
8579
+ // Native src is intentionally left unwritten; the frame
8580
+ // never navigates to the hostile URL. Mark it poisoned so
8581
+ // the next synchronous write throws, and add the pathname
8582
+ // to the cross-frame rejection cache so any future frame
8583
+ // whose src lands at the same pathname throws synchronously
8584
+ // without re-fetching.
8585
+ poisonFrame$LWS(frame$LWS);
8586
+ rejectPathname$1$LWS(pathname$LWS);
8587
+ };
8588
+ const onAborted$LWS = () => {
8589
+ // This handler runs for a request that was superseded, so
8590
+ // by the time it fires a replacement request has typically
8591
+ // already stored ITS controller. Clear on identity match
8592
+ // only: an unconditional delete here would evict the
8593
+ // replacement's controller, leaving the newer pre-flight
8594
+ // untracked (and therefore un-abortable by a later
8595
+ // assignment, which could then let a stale URL commit).
8596
+ clearInflightPreflightIfCurrent$LWS(frame$LWS, controller$LWS);
8597
+ };
8598
+ // Fail-closed handler for a pre-flight fetch that rejected
8599
+ // (network error, or — the security-critical case — a CSP
8600
+ // `connect-src` block). A same-origin `fetch` is governed by
8601
+ // `connect-src`, while a `<frame>` navigation is governed by
8602
+ // `frame-src` / `child-src`: a deployment can block the fetch
8603
+ // yet still permit the frame to navigate. Committing here would
8604
+ // hand the frame an UNVALIDATED same-origin body — the exact
8605
+ // escape this pipeline exists to close. Because the frame
8606
+ // setter never writes native `src` eagerly, failing closed is
8607
+ // simply "do not write": clear the pending/in-flight
8608
+ // bookkeeping and leave the frame un-navigated. We do NOT
8609
+ // poison — a transport failure is not proof of an attack
8610
+ // pattern, so a later assignment of the same URL may re-attempt
8611
+ // the pre-flight. (Deliberate divergence from the iframe
8612
+ // pipeline, which commits on fetch failure because it writes
8613
+ // native eagerly for detached iframes and cannot cleanly
8614
+ // withhold the write; `<frame>` never writes eagerly, so it
8615
+ // can.)
8616
+ const onUninspectable$LWS = () => {
8617
+ clearPendingURL$1$LWS(frame$LWS);
8618
+ clearInflightPreflightIfCurrent$LWS(frame$LWS, controller$LWS);
8619
+ };
8620
+ ReflectApply$LWS$1(originalFetch$LWS, undefined, [urlString$LWS, {
8621
+ __proto__: null,
8622
+ credentials: 'same-origin',
8623
+ signal: signal$LWS
8624
+ }])
8625
+ // Read the body regardless of HTTP status: a same-origin
8626
+ // 4xx/5xx whose error-page body carries a hostile pattern
8627
+ // must still poison the frame, because the browser would
8628
+ // render that error-page body into the frame too. (Only a
8629
+ // rejected fetch — network error, CSP `connect-src` block,
8630
+ // or abort — reaches .catch below; a non-abort rejection
8631
+ // fails closed there, leaving `src` unwritten rather than
8632
+ // committing an un-inspected body.)
8633
+ .then(response$LWS => response$LWS.text()).then(body$LWS => {
8634
+ if (isSupersededOrAborted$LWS()) {
8635
+ onAborted$LWS();
8636
+ return;
8637
+ }
8638
+ if (isIframeSrcdocAttack$1$LWS(body$LWS) || isXMLEntityAttack$1$LWS(body$LWS) || isXMLNamespacedScriptAttack$1$LWS(body$LWS)) {
8639
+ onHostile$LWS();
8640
+ } else {
8641
+ onSafe$LWS();
8642
+ }
8643
+ }).catch(() => {
8644
+ if (isSupersededOrAborted$LWS()) {
8645
+ onAborted$LWS();
8646
+ return;
8647
+ }
8648
+ // The pre-flight fetch rejected, so the body was never
8649
+ // inspected. Fail closed: leave native `src` unwritten
8650
+ // (see onUninspectable). We must NOT commit here — a CSP
8651
+ // `connect-src` block can reject the fetch while
8652
+ // `frame-src` still permits the navigation, so
8653
+ // committing would navigate the frame to an unvalidated
8654
+ // body and reopen the escape path.
8655
+ onUninspectable$LWS();
8656
+ });
8657
+ }
8658
+ registerAttributeSetterDistortion$LWS(record$LWS, HTMLFrameElement$LWS, 'src', NAMESPACE_DEFAULT$LWS, src$LWS);
8659
+ return [originalSrcSetter$LWS, src$LWS];
8660
+ };
8661
+ }
7628
8662
  function initDistortionHTMLFrameSetElementOnrejectionhandled$LWS({
7629
8663
  globalObject: {
7630
8664
  HTMLFrameSetElement: HTMLFrameSetElement$LWS
@@ -7854,7 +8888,7 @@
7854
8888
  if (!isSameOriginURL$LWS(srcValue$LWS)) {
7855
8889
  return;
7856
8890
  }
7857
- } catch (_unused3$LWS) {
8891
+ } catch (_unused5$LWS) {
7858
8892
  /* empty */
7859
8893
  }
7860
8894
  if (!ReflectApply$LWS$1(DOMTokenListProtoContains$LWS, sandboxTokenList$LWS, [ALLOW_SCRIPTS_TOKEN$LWS])) {
@@ -7893,7 +8927,7 @@
7893
8927
  // FOLLOWING `iframe.src = ...` (or setAttribute('src',...) etc.)
7894
8928
  // even though we cannot synchronously propagate the original
7895
8929
  // hostile-detection back to its triggering setter call.
7896
- if (isGaterEnabledFeature$LWS('changesSince.264') && isPoisonedIframe$LWS(this)) {
8930
+ if (isGaterEnabledFeature$LWS('iframeSrcSameOriginPreflightCheck') && isPoisonedIframe$LWS(this)) {
7897
8931
  throw new LockerSecurityError$LWS('HTMLIFrameElement is poisoned: a prior src assignment fetched a body containing an attack pattern. The iframe cannot be reused.');
7898
8932
  }
7899
8933
  const normalizedSrcValue$LWS = toSafeStringValue$LWS(value$LWS);
@@ -7944,7 +8978,7 @@
7944
8978
  // resolves. Pending URL is recorded normally so read paths
7945
8979
  // (iframe.src, getAttribute('src'), attributes['src'].value)
7946
8980
  // surface what sandbox code wrote.
7947
- if (isGaterEnabledFeature$LWS('changesSince.264') && urlString$LWS !== '' && urlString$LWS !== ABOUT_BLANK_TOKEN$LWS && isSameOriginURL$LWS(urlString$LWS)) {
8981
+ if (isGaterEnabledFeature$LWS('iframeSrcSameOriginPreflightCheck') && urlString$LWS !== '' && urlString$LWS !== ABOUT_BLANK_TOKEN$LWS && isSameOriginURL$LWS(urlString$LWS)) {
7948
8982
  // Cross-iframe rejection cache: if any prior pre-flight
7949
8983
  // (on this iframe or any other) detected an attack
7950
8984
  // pattern at this URL's pathname, refuse the assignment
@@ -8545,7 +9579,14 @@
8545
9579
  };
8546
9580
  }
8547
9581
  const descriptorCaches$LWS = toSafeWeakMap$LWS$1(new WeakMapCtor$LWS$1());
8548
- function createBlockedAttributeSetterDistortionFactoryInitializer$LWS(Ctor$LWS, ctorName$LWS, attributeName$LWS) {
9582
+ function createBlockedAttributeSetterDistortionFactoryInitializer$LWS(Ctor$LWS, ctorName$LWS, attributeName$LWS, blockedTagName$LWS) {
9583
+ // When the interface has a single canonical HTML tag name (iframe, embed,
9584
+ // script), record it so a foreign generic node that would reparse into this
9585
+ // interface is still matched for this blocked attribute. See W-23590867 and
9586
+ // elementMatchesCtor's tag-name fallback.
9587
+ if (blockedTagName$LWS !== undefined) {
9588
+ registerBlockedAttributeTagName$LWS(Ctor$LWS, blockedTagName$LWS, attributeName$LWS);
9589
+ }
8549
9590
  return function initDistortionBlockedAttribute$LWS() {
8550
9591
  const enquotedAttributeName$LWS = enquote$LWS(attributeName$LWS);
8551
9592
  const distortionName$LWS = `blocked${capitalizeFirstChar$LWS(attributeName$LWS)}Attribute`;
@@ -8604,14 +9645,14 @@
8604
9645
  return valueThrowerDistortionFactory$LWS;
8605
9646
  };
8606
9647
  }
8607
- function addBlockedAttributeSetterDistortionFactoryInitializers$LWS(Ctor$LWS, ctorName$LWS, attributes$LWS, factoryInitializers$LWS) {
9648
+ function addBlockedAttributeSetterDistortionFactoryInitializers$LWS(Ctor$LWS, ctorName$LWS, attributes$LWS, factoryInitializers$LWS, blockedTagName$LWS) {
8608
9649
  let {
8609
9650
  length: factoryInitializersOffset$LWS
8610
9651
  } = factoryInitializers$LWS;
8611
9652
  for (let i$LWS = 0, {
8612
9653
  length: length$LWS
8613
9654
  } = attributes$LWS; i$LWS < length$LWS; i$LWS += 1) {
8614
- factoryInitializers$LWS[factoryInitializersOffset$LWS++] = createBlockedAttributeSetterDistortionFactoryInitializer$LWS(Ctor$LWS, ctorName$LWS, attributes$LWS[i$LWS]);
9655
+ factoryInitializers$LWS[factoryInitializersOffset$LWS++] = createBlockedAttributeSetterDistortionFactoryInitializer$LWS(Ctor$LWS, ctorName$LWS, attributes$LWS[i$LWS], blockedTagName$LWS);
8615
9656
  }
8616
9657
  }
8617
9658
  // Read-side counterpart of createBlockedAttributeSetterDistortionFactoryInitializer:
@@ -9395,7 +10436,14 @@
9395
10436
  return function distortionNamedNodeMapSetNamedItem$LWS(record$LWS) {
9396
10437
  return [originalSetNamedItem$LWS, function setNamedItem$LWS(...args$LWS) {
9397
10438
  const attr$LWS = args$LWS.length ? args$LWS[0] : undefined;
9398
- if (attr$LWS && attr$LWS instanceof Attr$LWS) {
10439
+ // W-23439905: `instanceof Attr` only recognizes Attrs minted
10440
+ // in this realm. A genuine Attr from another same-origin
10441
+ // realm (e.g. a same-origin iframe's document) fails the
10442
+ // check and would otherwise fall through to the native
10443
+ // method with no interception. The structural fallback
10444
+ // recognizes a real Attr from any realm.
10445
+ const isRealAttr$LWS = attr$LWS && (attr$LWS instanceof Attr$LWS || isGaterEnabledFeature$LWS('changesSince.266') && isAttr$LWS(attr$LWS));
10446
+ if (isRealAttr$LWS) {
9399
10447
  return setNamedItemWithAttr$LWS(record$LWS, originalSetNamedItem$LWS, this, attr$LWS);
9400
10448
  }
9401
10449
  return ReflectApply$LWS$1(originalSetNamedItem$LWS, this, args$LWS);
@@ -9415,7 +10463,14 @@
9415
10463
  return function distortionNamedNodeMapSetNamedItemNS$LWS(record$LWS) {
9416
10464
  return [originalSetNamedItemNS$LWS, function setNamedItemNS$LWS(...args$LWS) {
9417
10465
  const attr$LWS = args$LWS.length ? args$LWS[0] : undefined;
9418
- if (attr$LWS && attr$LWS instanceof Attr$LWS) {
10466
+ // W-23439905: `instanceof Attr` only recognizes Attrs minted
10467
+ // in this realm. A genuine Attr from another same-origin
10468
+ // realm (e.g. a same-origin iframe's document) fails the
10469
+ // check and would otherwise fall through to the native
10470
+ // method with no interception. The structural fallback
10471
+ // recognizes a real Attr from any realm.
10472
+ const isRealAttr$LWS = attr$LWS && (attr$LWS instanceof Attr$LWS || isGaterEnabledFeature$LWS('changesSince.266') && isAttr$LWS(attr$LWS));
10473
+ if (isRealAttr$LWS) {
9419
10474
  return setNamedItemWithAttr$LWS(record$LWS, originalSetNamedItemNS$LWS, this, attr$LWS);
9420
10475
  }
9421
10476
  return ReflectApply$LWS$1(originalSetNamedItemNS$LWS, this, args$LWS);
@@ -9530,6 +10585,22 @@
9530
10585
  const originalNodeValueSetter$LWS = ObjectLookupOwnSetter$LWS(Node$LWS.prototype, 'nodeValue');
9531
10586
  return function distortionNodeValueSetter$LWS(record$LWS) {
9532
10587
  return [originalNodeValueSetter$LWS, function nodeValue$LWS(value$LWS) {
10588
+ // W-23596015: `nodeValue` aliases `Attr.prototype.value`, so it
10589
+ // shares the same reentrant Attr owner-state TOCTOU. Coerce
10590
+ // `value` to a string EXACTLY ONCE, up front — before reading
10591
+ // `ownerElement` — so the routing decision is made against the
10592
+ // resolved string. Otherwise a `{ toString() {...} }` value
10593
+ // reaches the native setter unconverted, and native WebIDL
10594
+ // DOMString coercion runs the attacker's `toString()` AFTER LWS
10595
+ // has committed to a route (native passthrough for a detached
10596
+ // Attr, or a no-distortion element); that reentrant call can
10597
+ // attach the Attr to a <script> so the final value lands via a
10598
+ // raw native write that skips the script-`src` distortion.
10599
+ // Coercing first makes any such reentrant attach visible to the
10600
+ // `ownerElement` read below. `null`/`undefined` pass through
10601
+ // untouched so the native setter keeps its nullable-`DOMString?`
10602
+ // "treat as the empty string" behavior.
10603
+ const coercedValue$LWS = isGaterEnabledFeature$LWS('changesSince.266') && value$LWS !== null && value$LWS !== undefined ? toSafeStringValue$LWS(value$LWS) : value$LWS;
9533
10604
  // W-10476944 Window access via nodeValue/textContent:
9534
10605
  // This distortion sanitizes the given text to prevent window
9535
10606
  // access from being achieved via the nodeValue property.
@@ -9537,21 +10608,21 @@
9537
10608
  if (this instanceof Attr$LWS) {
9538
10609
  const ownerEl$LWS = ReflectApply$LWS$1(AttrProtoOwnerElementGetter$LWS, this, []);
9539
10610
  if (ownerEl$LWS === null) {
9540
- ReflectApply$LWS$1(originalNodeValueSetter$LWS, this, [value$LWS]);
10611
+ ReflectApply$LWS$1(originalNodeValueSetter$LWS, this, [coercedValue$LWS]);
9541
10612
  return;
9542
10613
  }
9543
- const attrName$LWS = ReflectApply$LWS$1(AttrProtoNameGetter$LWS, this, []);
10614
+ const attrName$LWS = normalizeAttributeName$LWS(ReflectApply$LWS$1(AttrProtoNameGetter$LWS, this, []));
9544
10615
  const attrNamespace$LWS = ReflectApply$LWS$1(AttrProtoNamespaceURIGetter$LWS, this, []);
9545
10616
  const normalizedNamespace$LWS = normalizeNamespace$LWS(attrNamespace$LWS);
9546
10617
  const distortion$LWS = getAttributeSetterDistortion$LWS(record$LWS, ownerEl$LWS, attrName$LWS, normalizedNamespace$LWS);
9547
10618
  // istanbul ignore next: needs default platform behavior test
9548
10619
  if (distortion$LWS) {
9549
- ReflectApply$LWS$1(distortion$LWS, ownerEl$LWS, [value$LWS]);
10620
+ ReflectApply$LWS$1(distortion$LWS, ownerEl$LWS, [coercedValue$LWS]);
9550
10621
  return;
9551
10622
  }
9552
10623
  }
9553
10624
  // istanbul ignore next: needs default platform behavior test
9554
- ReflectApply$LWS$1(originalNodeValueSetter$LWS, this, [value$LWS]);
10625
+ ReflectApply$LWS$1(originalNodeValueSetter$LWS, this, [coercedValue$LWS]);
9555
10626
  }];
9556
10627
  };
9557
10628
  }
@@ -9734,7 +10805,24 @@
9734
10805
  sandboxEvaluator: sandboxEvaluator$LWS
9735
10806
  } = record$LWS;
9736
10807
  return [originalTextContentSetter$LWS, function textContent$LWS(value$LWS) {
9737
- const valueAsString$LWS = trusted.createScript(value$LWS);
10808
+ // W-23596015: `textContent` aliases `Attr.prototype.value` on an
10809
+ // Attr, so it shares the same reentrant Attr owner-state TOCTOU.
10810
+ // `trusted.createScript` only performs a DOMString coercion on
10811
+ // engines that support Trusted Types; on a TT-less engine the
10812
+ // fallback policy returns its argument unchanged, so a
10813
+ // `{ toString() {...} }` value would reach the native setter
10814
+ // unconverted and native WebIDL DOMString coercion would run the
10815
+ // attacker's `toString()` AFTER LWS committed to a route,
10816
+ // letting it reentrantly attach the Attr to a <script> and land
10817
+ // the final value via a raw native write that skips the
10818
+ // script-`src` distortion. Coerce `value` to a string EXACTLY
10819
+ // ONCE, up front, so the coercion is DOMString-strength on every
10820
+ // engine and any reentrant attach is visible to the
10821
+ // `ownerElement` read below. `null`/`undefined` pass through
10822
+ // untouched so the native setter keeps its nullable-`DOMString?`
10823
+ // "treat as the empty string" behavior.
10824
+ const coercedValue$LWS = isGaterEnabledFeature$LWS('changesSince.266') && value$LWS !== null && value$LWS !== undefined ? toSafeStringValue$LWS(value$LWS) : value$LWS;
10825
+ const valueAsString$LWS = trusted.createScript(coercedValue$LWS);
9738
10826
  // There are two existence of the attribute textContent, one on
9739
10827
  // Attr and one on Node. This first if statement is checking to
9740
10828
  // figure out which distortion should be applied. The instanceof
@@ -9751,7 +10839,7 @@
9751
10839
  ReflectApply$LWS$1(originalTextContentSetter$LWS, this, [valueAsString$LWS]);
9752
10840
  return;
9753
10841
  }
9754
- const attrName$LWS = ReflectApply$LWS$1(AttrProtoNameGetter$LWS, this, []);
10842
+ const attrName$LWS = normalizeAttributeName$LWS(ReflectApply$LWS$1(AttrProtoNameGetter$LWS, this, []));
9755
10843
  const attrNamespace$LWS = ReflectApply$LWS$1(AttrProtoNamespaceURIGetter$LWS, this, []);
9756
10844
  const normalizedNamespace$LWS = normalizeNamespace$LWS(attrNamespace$LWS);
9757
10845
  const distortion$LWS = getAttributeSetterDistortion$LWS(record$LWS, ownerEl$LWS, attrName$LWS, normalizedNamespace$LWS);
@@ -9813,14 +10901,345 @@
9813
10901
  return distortionEntry$LWS;
9814
10902
  };
9815
10903
  }
9816
- function initDistortionObservableForEach$LWS({
10904
+
10905
+ // W-23748456 (Bug Bounty / H1): shared machinery for containing the V8-only
10906
+ // `Error.prepareStackTrace` cross-realm evaluator channel. See
10907
+ // Function/cross-realm-invocation.ts for the broader cross-realm threat model.
10908
+ //
10909
+ // `Error.prepareStackTrace` is a non-standard V8 hook: reading an error's
10910
+ // `.stack` makes V8 NATIVELY invoke whatever callable is stored in that slot as
10911
+ // `prepareStackTrace(error, structuredStackTrace)`. Sandbox code reaches a
10912
+ // same-origin iframe's `Error`, stores the sandbox's own `Function` there, and
10913
+ // crafts `error.name`/`message` plus a poisoned `Array.prototype.toString` so
10914
+ // the native invocation compiles `function <name>() { return document.cookie }`
10915
+ // whose ambient `document` resolves to the real top document -- leaking its
10916
+ // cookie. The escape is NOT that the iframe realm is undistorted (the multi-doc
10917
+ // patcher does distort a managed same-origin iframe's intrinsics); it is that
10918
+ // V8 invokes this hook INTERNALLY, so the compiled callee runs in a realm the
10919
+ // near-membrane never linked to the sandbox. Because that invocation is
10920
+ // internal, there is NO call site for an
10921
+ // invocation-primitive distortion (Reflect.apply/construct, Function.prototype
10922
+ // call/apply/bind -- the W-22602807 five) to intercept the callee: the only
10923
+ // observable seam is the STORE of the hook.
10924
+ //
10925
+ // Containment therefore guards the store rather than the (invisible) invocation.
10926
+ // `prepareStackTrace` is a debugging-only V8 extension with no legitimate
10927
+ // LWC/Aura use, so any attempt to (re)define it through a same-origin iframe
10928
+ // realm's property-definition primitives is BLOCKED outright -- by throwing,
10929
+ // never by silently dropping the value -- so the failure is an unmistakable
10930
+ // security refusal and can never be mistaken for ordinary platform behavior.
10931
+ // The distorted primitives live next to the objects they belong to:
10932
+ // Object/defineProperty-value.ts, Object/defineProperties-value.ts, and
10933
+ // Reflect/defineProperty-value.ts. Guarding the store primitives rather than
10934
+ // `Error` identity also covers the raw intrinsic reached via
10935
+ // `new Error().constructor`; the target object is irrelevant. Plain assignment
10936
+ // (`Error.prepareStackTrace = fn`) needs no entry: the membrane hands the setter
10937
+ // the raw iframe `Function`, which V8's hook rejects with a SyntaxError, so that
10938
+ // path is already inert.
10939
+ // The distortion entry KEY (the first element of the `[original, replacement]`
10940
+ // pair each value file returns) MUST be the iframe realm's OWN native, read off
10941
+ // `record.globalObject`. The membrane's distortion map is a WeakMap keyed by
10942
+ // object IDENTITY (see createDistortionEntries / createDistortionMap in
10943
+ // sandbox/src/util/distortion.ts), so the key must be the exact function object
10944
+ // that crosses the membrane at runtime -- which, for a same-origin iframe, is
10945
+ // `iframe.contentWindow.Object.defineProperty` (etc.). That is a DISTINCT object
10946
+ // from the system realm's `@locker/shared` copy: a same-origin iframe has its
10947
+ // own, un-distorted set of intrinsics, which is the whole basis of this vector.
10948
+ // Keying on the shared/system copy would never match what the sandbox pulls off
10949
+ // the iframe, so the substitution would never fire -- dead code. Hence each
10950
+ // value file reads the KEY off `globalObject` while using the pinned
10951
+ // `@locker/shared` reference for the pass-through INVOCATION: realm-native for
10952
+ // the KEY (identity match), shared-pinned for the WORK (tamper-proof).
10953
+ const PREPARE_STACK_TRACE$LWS = 'prepareStackTrace';
10954
+ // V8-ONLY capability check. `Error.prepareStackTrace` has no default property
10955
+ // (it is `undefined` even on V8), so it cannot be feature-detected directly;
10956
+ // its sibling static `Error.captureStackTrace` is the reliable V8 stack-trace
10957
+ // API marker. JavaScriptCore (Safari) and SpiderMonkey (Firefox) that never
10958
+ // invoke the hook are handled the same way -- when the marker is absent the
10959
+ // vector cannot exist, so each initializer returns `noop` and installs nothing.
10960
+ function platformSupportsPrepareStackTrace$LWS(ErrorCtor$LWS) {
10961
+ return typeof (ErrorCtor$LWS == null ? void 0 : ErrorCtor$LWS.captureStackTrace) === 'function';
10962
+ }
10963
+ // This cross-realm vector only exists on a same-origin iframe realm, and the
10964
+ // containment ships under changesSince.266. One predicate for all three
10965
+ // distorted store primitives; `getDistortableFrameElement` carries its own
10966
+ // changesSince.264 gate on the underlying cross-realm scoping helper.
10967
+ function isPrepareStackTraceStoreDistortable$LWS(globalObject$LWS) {
10968
+ return isGaterEnabledFeature$LWS('changesSince.266') && Boolean(getDistortableFrameElement$LWS(globalObject$LWS));
10969
+ }
10970
+ // Resolve `key` to a property key ONCE. Symbols are never our string key;
10971
+ // everything else is coerced with a single template read so an adversarial
10972
+ // `toString` cannot answer the equality check with a benign key and the native
10973
+ // pass-through with `prepareStackTrace` (a TOCTOU). Callers forward the resolved
10974
+ // value to the native primitive, so the two can never diverge.
10975
+ function resolvePropertyKey$LWS(key$LWS) {
10976
+ return typeof key$LWS === 'symbol' ? key$LWS : `${key$LWS}`;
10977
+ }
10978
+ // The refusal. A dedicated `never`-returning helper keeps the throw identical
10979
+ // across all three store primitives.
10980
+ function throwPrepareStackTraceBlocked$LWS() {
10981
+ throw new LockerSecurityError$LWS('Cannot redefine Error.prepareStackTrace');
10982
+ }
10983
+
10984
+ // W-23748456: block cross-realm redefinition of `Error.prepareStackTrace` via a
10985
+ // same-origin iframe realm's `Object.defineProperties` (the bulk form). Full
10986
+ // threat model and the KEY-identity reasoning live in
10987
+ // Error/prepareStackTrace-shared.ts.
10988
+ function initDistortionObjectDefineProperties$LWS({
10989
+ globalObject: {
10990
+ Error: ErrorCtor$LWS,
10991
+ Object: {
10992
+ defineProperties: originalObjectDefineProperties$LWS
10993
+ }
10994
+ }
10995
+ }) {
10996
+ // No V8 prepareStackTrace hook on this platform => nothing to contain.
10997
+ if (!platformSupportsPrepareStackTrace$LWS(ErrorCtor$LWS)) {
10998
+ return noop$LWS$1;
10999
+ }
11000
+ return function distortionObjectDefineProperties$LWS({
11001
+ globalObject: globalObject$LWS
11002
+ }) {
11003
+ if (!isPrepareStackTraceStoreDistortable$LWS(globalObject$LWS)) {
11004
+ return undefined;
11005
+ }
11006
+ return [
11007
+ // KEY: the iframe realm's OWN native, identity-matched across the
11008
+ // membrane. See Error/prepareStackTrace-shared.ts.
11009
+ originalObjectDefineProperties$LWS, function defineProperties$LWS(target$LWS, properties$LWS) {
11010
+ // The bulk form must not be a TOCTOU seam. A single up-front
11011
+ // key check (e.g. ObjectHasOwn) triggers ONE [[GetOwnProperty]]
11012
+ // trap, but then handing the SAME map to the native primitive
11013
+ // lets it RE-trap [[OwnPropertyKeys]]/[[GetOwnProperty]] to
11014
+ // decide what it defines -- so a stateful Proxy could report no
11015
+ // `prepareStackTrace` to the check and surface it to the native
11016
+ // pass, installing the hook without ever throwing. Instead,
11017
+ // materialize the map's own slots ONCE into a plain,
11018
+ // prototype-free snapshot and hand the native primitive the
11019
+ // SNAPSHOT, never the caller's (possibly exotic) map: the guard
11020
+ // decision and the native define now read from the same
11021
+ // immutable object, so no trap can diverge between them. This is
11022
+ // the bulk-form analogue of the singular guard's single-read
11023
+ // discipline (resolvePropertyKey in defineProperty-value.ts).
11024
+ if (isObjectLike$LWS(properties$LWS)) {
11025
+ const snapshot$LWS = {
11026
+ __proto__: null
11027
+ };
11028
+ const keys$LWS = ReflectOwnKeys$LWS$1(properties$LWS);
11029
+ for (let i$LWS = 0, {
11030
+ length: length$LWS
11031
+ } = keys$LWS; i$LWS < length$LWS; i$LWS += 1) {
11032
+ const key$LWS = keys$LWS[i$LWS];
11033
+ // Refuse the moment the hook key appears among the map's
11034
+ // OWN keys -- decided on the same single [[OwnPropertyKeys]]
11035
+ // read that feeds the snapshot, so there is no window for
11036
+ // a stateful `ownKeys` to hide it here and reveal it to
11037
+ // the native define. prepareStackTrace has no legitimate
11038
+ // LWC/Aura use, so failing closed on its mere presence is
11039
+ // correct.
11040
+ if (key$LWS === PREPARE_STACK_TRACE$LWS) {
11041
+ throwPrepareStackTraceBlocked$LWS();
11042
+ }
11043
+ const descriptor$LWS = ReflectGetOwnPropertyDescriptor$LWS(properties$LWS, key$LWS);
11044
+ // Object.defineProperties only consumes OWN ENUMERABLE
11045
+ // slots; mirror that exactly, reading each descriptor
11046
+ // object once and pinning it onto the snapshot as an own
11047
+ // enumerable data property.
11048
+ if (descriptor$LWS !== undefined && descriptor$LWS.enumerable) {
11049
+ snapshot$LWS[key$LWS] = ReflectGet$LWS(properties$LWS, key$LWS);
11050
+ }
11051
+ }
11052
+ return ObjectDefineProperties$LWS(target$LWS, snapshot$LWS);
11053
+ }
11054
+ // Non-object map: hand it straight to the pinned primitive so
11055
+ // callers still get the native TypeError (ToObject(null/undefined)
11056
+ // throws).
11057
+ return ObjectDefineProperties$LWS(target$LWS, properties$LWS);
11058
+ }];
11059
+ };
11060
+ }
11061
+
11062
+ // W-23748456: block cross-realm redefinition of `Error.prepareStackTrace` via a
11063
+ // same-origin iframe realm's `Object.defineProperty`. Full threat model and the
11064
+ // KEY-identity reasoning live in Error/prepareStackTrace-shared.ts.
11065
+ function initDistortionObjectDefineProperty$LWS({
11066
+ globalObject: {
11067
+ Error: ErrorCtor$LWS,
11068
+ Object: {
11069
+ defineProperty: originalObjectDefineProperty$LWS
11070
+ }
11071
+ }
11072
+ }) {
11073
+ // No V8 prepareStackTrace hook on this platform => nothing to contain.
11074
+ if (!platformSupportsPrepareStackTrace$LWS(ErrorCtor$LWS)) {
11075
+ return noop$LWS$1;
11076
+ }
11077
+ return function distortionObjectDefineProperty$LWS({
11078
+ globalObject: globalObject$LWS
11079
+ }) {
11080
+ if (!isPrepareStackTraceStoreDistortable$LWS(globalObject$LWS)) {
11081
+ return undefined;
11082
+ }
11083
+ return [
11084
+ // KEY: the iframe realm's OWN native, identity-matched across the
11085
+ // membrane. See Error/prepareStackTrace-shared.ts.
11086
+ originalObjectDefineProperty$LWS, function defineProperty$LWS(target$LWS, key$LWS, descriptor$LWS) {
11087
+ const resolvedKey$LWS = resolvePropertyKey$LWS(key$LWS);
11088
+ if (resolvedKey$LWS === PREPARE_STACK_TRACE$LWS) {
11089
+ throwPrepareStackTraceBlocked$LWS();
11090
+ }
11091
+ // Any other key: an ordinary define, via the pinned shared
11092
+ // primitive with the already-resolved key (TOCTOU-safe).
11093
+ return ObjectDefineProperty$LWS(target$LWS, resolvedKey$LWS, descriptor$LWS);
11094
+ }];
11095
+ };
11096
+ }
11097
+ function initDistortionObservableCatch$LWS({
9817
11098
  globalObject: {
9818
11099
  Observable: OriginalObservable$LWS
9819
11100
  }
9820
11101
  }) {
9821
11102
  var _OriginalObservable$p$LWS;
9822
11103
  // istanbul ignore next: optional chaining and nullish coalescing results in an expansion that contains an unreachable "void 0" branch for every occurrence of the operator
9823
- const originalForEach$LWS = OriginalObservable$LWS == null || (_OriginalObservable$p$LWS = OriginalObservable$LWS.prototype) == null ? void 0 : _OriginalObservable$p$LWS.forEach;
11104
+ const originalCatch$LWS = OriginalObservable$LWS == null || (_OriginalObservable$p$LWS = OriginalObservable$LWS.prototype) == null ? void 0 : _OriginalObservable$p$LWS.catch;
11105
+ // istanbul ignore if: Observable is always available in coverage environments
11106
+ if (typeof originalCatch$LWS !== 'function') {
11107
+ return noop$LWS$1;
11108
+ }
11109
+ const distortionEntry$LWS = [originalCatch$LWS,
11110
+ // `catch` is a reserved word, so the replacement is an anonymous
11111
+ // function expression (mirroring the Promise.prototype.catch distortion).
11112
+ function (...args$LWS) {
11113
+ if (isGaterEnabledFeature$LWS('changesSince.266')) {
11114
+ throwIfUnsafeCallbackReference$LWS(args$LWS[0]);
11115
+ }
11116
+ return ReflectApply$LWS$1(originalCatch$LWS, this, args$LWS);
11117
+ }];
11118
+ return function distortionObservableCatch$LWS() {
11119
+ return distortionEntry$LWS;
11120
+ };
11121
+ }
11122
+ function initDistortionObservableEvery$LWS({
11123
+ globalObject: {
11124
+ Observable: OriginalObservable$LWS
11125
+ }
11126
+ }) {
11127
+ var _OriginalObservable$p2$LWS;
11128
+ // istanbul ignore next: optional chaining and nullish coalescing results in an expansion that contains an unreachable "void 0" branch for every occurrence of the operator
11129
+ const originalEvery$LWS = OriginalObservable$LWS == null || (_OriginalObservable$p2$LWS = OriginalObservable$LWS.prototype) == null ? void 0 : _OriginalObservable$p2$LWS.every;
11130
+ // istanbul ignore if: Observable is always available in coverage environments
11131
+ if (typeof originalEvery$LWS !== 'function') {
11132
+ return noop$LWS$1;
11133
+ }
11134
+ const distortionEntry$LWS = [originalEvery$LWS, function every$LWS(...args$LWS) {
11135
+ if (isGaterEnabledFeature$LWS('changesSince.266')) {
11136
+ throwIfUnsafeCallbackReference$LWS(args$LWS[0]);
11137
+ }
11138
+ return ReflectApply$LWS$1(originalEvery$LWS, this, args$LWS);
11139
+ }];
11140
+ return function distortionObservableEvery$LWS() {
11141
+ return distortionEntry$LWS;
11142
+ };
11143
+ }
11144
+ function initDistortionObservableFilter$LWS({
11145
+ globalObject: {
11146
+ Observable: OriginalObservable$LWS
11147
+ }
11148
+ }) {
11149
+ var _OriginalObservable$p3$LWS;
11150
+ // istanbul ignore next: optional chaining and nullish coalescing results in an expansion that contains an unreachable "void 0" branch for every occurrence of the operator
11151
+ const originalFilter$LWS = OriginalObservable$LWS == null || (_OriginalObservable$p3$LWS = OriginalObservable$LWS.prototype) == null ? void 0 : _OriginalObservable$p3$LWS.filter;
11152
+ // istanbul ignore if: Observable is always available in coverage environments
11153
+ if (typeof originalFilter$LWS !== 'function') {
11154
+ return noop$LWS$1;
11155
+ }
11156
+ const distortionEntry$LWS = [originalFilter$LWS, function filter$LWS(...args$LWS) {
11157
+ if (isGaterEnabledFeature$LWS('changesSince.266')) {
11158
+ throwIfUnsafeCallbackReference$LWS(args$LWS[0]);
11159
+ }
11160
+ return ReflectApply$LWS$1(originalFilter$LWS, this, args$LWS);
11161
+ }];
11162
+ return function distortionObservableFilter$LWS() {
11163
+ return distortionEntry$LWS;
11164
+ };
11165
+ }
11166
+ function initDistortionObservableFinally$LWS({
11167
+ globalObject: {
11168
+ Observable: OriginalObservable$LWS
11169
+ }
11170
+ }) {
11171
+ var _OriginalObservable$p4$LWS;
11172
+ // istanbul ignore next: optional chaining and nullish coalescing results in an expansion that contains an unreachable "void 0" branch for every occurrence of the operator
11173
+ const originalFinally$LWS = OriginalObservable$LWS == null || (_OriginalObservable$p4$LWS = OriginalObservable$LWS.prototype) == null ? void 0 : _OriginalObservable$p4$LWS.finally;
11174
+ // istanbul ignore if: Observable is always available in coverage environments
11175
+ if (typeof originalFinally$LWS !== 'function') {
11176
+ return noop$LWS$1;
11177
+ }
11178
+ const distortionEntry$LWS = [originalFinally$LWS,
11179
+ // `finally` is a reserved word, so the replacement is an anonymous
11180
+ // function expression (mirroring the Promise.prototype.finally distortion).
11181
+ function (...args$LWS) {
11182
+ if (isGaterEnabledFeature$LWS('changesSince.266')) {
11183
+ throwIfUnsafeCallbackReference$LWS(args$LWS[0]);
11184
+ }
11185
+ return ReflectApply$LWS$1(originalFinally$LWS, this, args$LWS);
11186
+ }];
11187
+ return function distortionObservableFinally$LWS() {
11188
+ return distortionEntry$LWS;
11189
+ };
11190
+ }
11191
+ function initDistortionObservableFind$LWS({
11192
+ globalObject: {
11193
+ Observable: OriginalObservable$LWS
11194
+ }
11195
+ }) {
11196
+ var _OriginalObservable$p5$LWS;
11197
+ // istanbul ignore next: optional chaining and nullish coalescing results in an expansion that contains an unreachable "void 0" branch for every occurrence of the operator
11198
+ const originalFind$LWS = OriginalObservable$LWS == null || (_OriginalObservable$p5$LWS = OriginalObservable$LWS.prototype) == null ? void 0 : _OriginalObservable$p5$LWS.find;
11199
+ // istanbul ignore if: Observable is always available in coverage environments
11200
+ if (typeof originalFind$LWS !== 'function') {
11201
+ return noop$LWS$1;
11202
+ }
11203
+ const distortionEntry$LWS = [originalFind$LWS, function find$LWS(...args$LWS) {
11204
+ if (isGaterEnabledFeature$LWS('changesSince.266')) {
11205
+ throwIfUnsafeCallbackReference$LWS(args$LWS[0]);
11206
+ }
11207
+ return ReflectApply$LWS$1(originalFind$LWS, this, args$LWS);
11208
+ }];
11209
+ return function distortionObservableFind$LWS() {
11210
+ return distortionEntry$LWS;
11211
+ };
11212
+ }
11213
+ function initDistortionObservableFlatMap$LWS({
11214
+ globalObject: {
11215
+ Observable: OriginalObservable$LWS
11216
+ }
11217
+ }) {
11218
+ var _OriginalObservable$p6$LWS;
11219
+ // istanbul ignore next: optional chaining and nullish coalescing results in an expansion that contains an unreachable "void 0" branch for every occurrence of the operator
11220
+ const originalFlatMap$LWS = OriginalObservable$LWS == null || (_OriginalObservable$p6$LWS = OriginalObservable$LWS.prototype) == null ? void 0 : _OriginalObservable$p6$LWS.flatMap;
11221
+ // istanbul ignore if: Observable is always available in coverage environments
11222
+ if (typeof originalFlatMap$LWS !== 'function') {
11223
+ return noop$LWS$1;
11224
+ }
11225
+ const distortionEntry$LWS = [originalFlatMap$LWS, function flatMap$LWS(...args$LWS) {
11226
+ if (isGaterEnabledFeature$LWS('changesSince.266')) {
11227
+ throwIfUnsafeCallbackReference$LWS(args$LWS[0]);
11228
+ }
11229
+ return ReflectApply$LWS$1(originalFlatMap$LWS, this, args$LWS);
11230
+ }];
11231
+ return function distortionObservableFlatMap$LWS() {
11232
+ return distortionEntry$LWS;
11233
+ };
11234
+ }
11235
+ function initDistortionObservableForEach$LWS({
11236
+ globalObject: {
11237
+ Observable: OriginalObservable$LWS
11238
+ }
11239
+ }) {
11240
+ var _OriginalObservable$p7$LWS;
11241
+ // istanbul ignore next: optional chaining and nullish coalescing results in an expansion that contains an unreachable "void 0" branch for every occurrence of the operator
11242
+ const originalForEach$LWS = OriginalObservable$LWS == null || (_OriginalObservable$p7$LWS = OriginalObservable$LWS.prototype) == null ? void 0 : _OriginalObservable$p7$LWS.forEach;
9824
11243
  // istanbul ignore if: Observable is always available in coverage environments
9825
11244
  if (typeof originalForEach$LWS !== 'function') {
9826
11245
  return noop$LWS$1;
@@ -9835,14 +11254,132 @@
9835
11254
  return distortionEntry$LWS;
9836
11255
  };
9837
11256
  }
11257
+ function initDistortionObservableInspect$LWS({
11258
+ globalObject: {
11259
+ Observable: OriginalObservable$LWS
11260
+ }
11261
+ }) {
11262
+ var _OriginalObservable$p8$LWS;
11263
+ // istanbul ignore next: optional chaining and nullish coalescing results in an expansion that contains an unreachable "void 0" branch for every occurrence of the operator
11264
+ const originalInspect$LWS = OriginalObservable$LWS == null || (_OriginalObservable$p8$LWS = OriginalObservable$LWS.prototype) == null ? void 0 : _OriginalObservable$p8$LWS.inspect;
11265
+ // istanbul ignore if: Observable is always available in coverage environments
11266
+ if (typeof originalInspect$LWS !== 'function') {
11267
+ return noop$LWS$1;
11268
+ }
11269
+ const distortionEntry$LWS = [originalInspect$LWS,
11270
+ // `inspect` accepts either a plain function or an observer object with
11271
+ // `next`/`error`/`complete` callbacks, mirroring `subscribe`.
11272
+ function inspect$LWS(...args$LWS) {
11273
+ if (isGaterEnabledFeature$LWS('changesSince.266')) {
11274
+ const {
11275
+ 0: observerOrCallback$LWS
11276
+ } = args$LWS;
11277
+ if (observerOrCallback$LWS !== null && observerOrCallback$LWS !== undefined) {
11278
+ if (typeof observerOrCallback$LWS === 'function') {
11279
+ throwIfUnsafeCallbackReference$LWS(observerOrCallback$LWS);
11280
+ } else if (typeof observerOrCallback$LWS === 'object') {
11281
+ // Snapshot properties to prevent TOCTOU: attacker-controlled
11282
+ // getters could return a safe value during the check but
11283
+ // return Function when Observable reads them internally.
11284
+ const {
11285
+ next: next$LWS,
11286
+ error,
11287
+ complete: complete$LWS
11288
+ } = observerOrCallback$LWS;
11289
+ throwIfUnsafeCallbackReference$LWS(next$LWS);
11290
+ throwIfUnsafeCallbackReference$LWS(error);
11291
+ throwIfUnsafeCallbackReference$LWS(complete$LWS);
11292
+ args$LWS[0] = {
11293
+ next: next$LWS,
11294
+ error,
11295
+ complete: complete$LWS
11296
+ };
11297
+ }
11298
+ }
11299
+ }
11300
+ return ReflectApply$LWS$1(originalInspect$LWS, this, args$LWS);
11301
+ }];
11302
+ return function distortionObservableInspect$LWS() {
11303
+ return distortionEntry$LWS;
11304
+ };
11305
+ }
11306
+ function initDistortionObservableMap$LWS({
11307
+ globalObject: {
11308
+ Observable: OriginalObservable$LWS
11309
+ }
11310
+ }) {
11311
+ var _OriginalObservable$p9$LWS;
11312
+ // istanbul ignore next: optional chaining and nullish coalescing results in an expansion that contains an unreachable "void 0" branch for every occurrence of the operator
11313
+ const originalMap$LWS = OriginalObservable$LWS == null || (_OriginalObservable$p9$LWS = OriginalObservable$LWS.prototype) == null ? void 0 : _OriginalObservable$p9$LWS.map;
11314
+ // istanbul ignore if: Observable is always available in coverage environments
11315
+ if (typeof originalMap$LWS !== 'function') {
11316
+ return noop$LWS$1;
11317
+ }
11318
+ const distortionEntry$LWS = [originalMap$LWS, function map$LWS(...args$LWS) {
11319
+ if (isGaterEnabledFeature$LWS('changesSince.266')) {
11320
+ throwIfUnsafeCallbackReference$LWS(args$LWS[0]);
11321
+ }
11322
+ return ReflectApply$LWS$1(originalMap$LWS, this, args$LWS);
11323
+ }];
11324
+ return function distortionObservableMap$LWS() {
11325
+ return distortionEntry$LWS;
11326
+ };
11327
+ }
11328
+ function initDistortionObservableReduce$LWS({
11329
+ globalObject: {
11330
+ Observable: OriginalObservable$LWS
11331
+ }
11332
+ }) {
11333
+ var _OriginalObservable$p0$LWS;
11334
+ // istanbul ignore next: optional chaining and nullish coalescing results in an expansion that contains an unreachable "void 0" branch for every occurrence of the operator
11335
+ const originalReduce$LWS = OriginalObservable$LWS == null || (_OriginalObservable$p0$LWS = OriginalObservable$LWS.prototype) == null ? void 0 : _OriginalObservable$p0$LWS.reduce;
11336
+ // istanbul ignore if: Observable is always available in coverage environments
11337
+ if (typeof originalReduce$LWS !== 'function') {
11338
+ return noop$LWS$1;
11339
+ }
11340
+ const distortionEntry$LWS = [originalReduce$LWS,
11341
+ // The reducer callback is args[0]; args[1] is the optional seed value
11342
+ // and is never invoked, so only args[0] needs the identity check.
11343
+ function reduce$LWS(...args$LWS) {
11344
+ if (isGaterEnabledFeature$LWS('changesSince.266')) {
11345
+ throwIfUnsafeCallbackReference$LWS(args$LWS[0]);
11346
+ }
11347
+ return ReflectApply$LWS$1(originalReduce$LWS, this, args$LWS);
11348
+ }];
11349
+ return function distortionObservableReduce$LWS() {
11350
+ return distortionEntry$LWS;
11351
+ };
11352
+ }
11353
+ function initDistortionObservableSome$LWS({
11354
+ globalObject: {
11355
+ Observable: OriginalObservable$LWS
11356
+ }
11357
+ }) {
11358
+ var _OriginalObservable$p1$LWS;
11359
+ // istanbul ignore next: optional chaining and nullish coalescing results in an expansion that contains an unreachable "void 0" branch for every occurrence of the operator
11360
+ const originalSome$LWS = OriginalObservable$LWS == null || (_OriginalObservable$p1$LWS = OriginalObservable$LWS.prototype) == null ? void 0 : _OriginalObservable$p1$LWS.some;
11361
+ // istanbul ignore if: Observable is always available in coverage environments
11362
+ if (typeof originalSome$LWS !== 'function') {
11363
+ return noop$LWS$1;
11364
+ }
11365
+ const distortionEntry$LWS = [originalSome$LWS, function some$LWS(...args$LWS) {
11366
+ if (isGaterEnabledFeature$LWS('changesSince.266')) {
11367
+ throwIfUnsafeCallbackReference$LWS(args$LWS[0]);
11368
+ }
11369
+ return ReflectApply$LWS$1(originalSome$LWS, this, args$LWS);
11370
+ }];
11371
+ return function distortionObservableSome$LWS() {
11372
+ return distortionEntry$LWS;
11373
+ };
11374
+ }
9838
11375
  function initDistortionObservableSubscribe$LWS({
9839
11376
  globalObject: {
9840
11377
  Observable: OriginalObservable$LWS
9841
11378
  }
9842
11379
  }) {
9843
- var _OriginalObservable$p2$LWS;
11380
+ var _OriginalObservable$p10$LWS;
9844
11381
  // istanbul ignore next: optional chaining and nullish coalescing results in an expansion that contains an unreachable "void 0" branch for every occurrence of the operator
9845
- const originalSubscribe$LWS = OriginalObservable$LWS == null || (_OriginalObservable$p2$LWS = OriginalObservable$LWS.prototype) == null ? void 0 : _OriginalObservable$p2$LWS.subscribe;
11382
+ const originalSubscribe$LWS = OriginalObservable$LWS == null || (_OriginalObservable$p10$LWS = OriginalObservable$LWS.prototype) == null ? void 0 : _OriginalObservable$p10$LWS.subscribe;
9846
11383
  // istanbul ignore if: Observable is always available in coverage environments
9847
11384
  if (typeof originalSubscribe$LWS !== 'function') {
9848
11385
  return noop$LWS$1;
@@ -9875,9 +11412,31 @@
9875
11412
  }
9876
11413
  }
9877
11414
  }
9878
- return ReflectApply$LWS$1(originalSubscribe$LWS, this, args$LWS);
11415
+ return ReflectApply$LWS$1(originalSubscribe$LWS, this, args$LWS);
11416
+ }];
11417
+ return function distortionObservableSubscribe$LWS() {
11418
+ return distortionEntry$LWS;
11419
+ };
11420
+ }
11421
+ function initDistortionObservableSwitchMap$LWS({
11422
+ globalObject: {
11423
+ Observable: OriginalObservable$LWS
11424
+ }
11425
+ }) {
11426
+ var _OriginalObservable$p11$LWS;
11427
+ // istanbul ignore next: optional chaining and nullish coalescing results in an expansion that contains an unreachable "void 0" branch for every occurrence of the operator
11428
+ const originalSwitchMap$LWS = OriginalObservable$LWS == null || (_OriginalObservable$p11$LWS = OriginalObservable$LWS.prototype) == null ? void 0 : _OriginalObservable$p11$LWS.switchMap;
11429
+ // istanbul ignore if: Observable is always available in coverage environments
11430
+ if (typeof originalSwitchMap$LWS !== 'function') {
11431
+ return noop$LWS$1;
11432
+ }
11433
+ const distortionEntry$LWS = [originalSwitchMap$LWS, function switchMap$LWS(...args$LWS) {
11434
+ if (isGaterEnabledFeature$LWS('changesSince.266')) {
11435
+ throwIfUnsafeCallbackReference$LWS(args$LWS[0]);
11436
+ }
11437
+ return ReflectApply$LWS$1(originalSwitchMap$LWS, this, args$LWS);
9879
11438
  }];
9880
- return function distortionObservableSubscribe$LWS() {
11439
+ return function distortionObservableSwitchMap$LWS() {
9881
11440
  return distortionEntry$LWS;
9882
11441
  };
9883
11442
  }
@@ -10316,6 +11875,80 @@
10316
11875
  return distortionEntry$LWS;
10317
11876
  };
10318
11877
  }
11878
+
11879
+ // W-23748562: distort an iframe contentWindow realm's Proxy constructor.
11880
+ // See Function/cross-realm-invocation.ts for the threat model.
11881
+ //
11882
+ // Proxy is a CAPTURE primitive, in the same family as Function.prototype.bind
11883
+ // (Function/bind-value.ts): it mints a fresh object identity around whatever
11884
+ // `target` it is given, and that identity is opaque to script from then on
11885
+ // ([[ProxyTarget]] is not observable). Once a dangerous callee (e.g. the
11886
+ // sandbox Function ctor) is wrapped this way, the identity-keyed lookup in
11887
+ // substituteDistortedCallee can no longer recognize it when it later reaches
11888
+ // Reflect.construct / .call / .apply — the map misses on the Proxy, not on
11889
+ // the callee it wraps.
11890
+ //
11891
+ // The fix substitutes the target BEFORE the Proxy is built, exactly as bind
11892
+ // substitutes the callee before binding it. Returning an object from a
11893
+ // constructor call short-circuits [[Construct]] (ECMAScript 10.2.2) so this
11894
+ // behaves identically whether reached via `new`, Reflect.construct, or a
11895
+ // .call/.apply/.bind chain on the constructor itself.
11896
+ //
11897
+ // Gated on changesSince.266: this is new distortion behavior, distinct from
11898
+ // getDistortableFrameElement's own changesSince.264 gate on the underlying
11899
+ // cross-realm scoping helper.
11900
+ function initDistortionProxyCtor$LWS({
11901
+ globalObject: {
11902
+ Proxy: originalProxyCtor$LWS
11903
+ }
11904
+ }) {
11905
+ return function distortionProxyCtor$LWS({
11906
+ globalObject: globalObject$LWS,
11907
+ root: root$LWS
11908
+ }) {
11909
+ if (!isGaterEnabledFeature$LWS('changesSince.266') || !getDistortableFrameElement$LWS(globalObject$LWS)) {
11910
+ return undefined;
11911
+ }
11912
+ return [originalProxyCtor$LWS, function Proxy$LWS(target$LWS, handler$LWS) {
11913
+ return new ProxyCtor$LWS(substituteDistortedCallee$LWS(root$LWS, target$LWS), handler$LWS);
11914
+ }];
11915
+ };
11916
+ }
11917
+
11918
+ // W-23748562: distort an iframe contentWindow realm's Proxy.revocable.
11919
+ // See Function/cross-realm-invocation.ts for the threat model and
11920
+ // constructor-value.ts for why Proxy is a capture primitive that needs its
11921
+ // target substituted before the wrapping identity is minted.
11922
+ //
11923
+ // Proxy.revocable needs its OWN entry: per spec (26.2.2.1 Proxy.revocable),
11924
+ // it constructs the exotic Proxy object directly rather than re-invoking the
11925
+ // public Proxy constructor, so distorting the constructor above does not
11926
+ // cover this entry point. We delegate to the original revocable with the
11927
+ // substituted target so the returned { proxy, revoke } pair keeps its native
11928
+ // shape and revocation semantics; only the wrapped target changes.
11929
+ //
11930
+ // Gated on changesSince.266: this is new distortion behavior, distinct from
11931
+ // getDistortableFrameElement's own changesSince.264 gate on the underlying
11932
+ // cross-realm scoping helper.
11933
+ function initDistortionProxyRevocable$LWS({
11934
+ globalObject: {
11935
+ Proxy: {
11936
+ revocable: originalRevocable$LWS
11937
+ }
11938
+ }
11939
+ }) {
11940
+ return function distortionProxyRevocable$LWS({
11941
+ globalObject: globalObject$LWS,
11942
+ root: root$LWS
11943
+ }) {
11944
+ if (!isGaterEnabledFeature$LWS('changesSince.266') || !getDistortableFrameElement$LWS(globalObject$LWS)) {
11945
+ return undefined;
11946
+ }
11947
+ return [originalRevocable$LWS, function revocable$LWS(target$LWS, handler$LWS) {
11948
+ return ReflectApply$LWS$1(originalRevocable$LWS, undefined, [substituteDistortedCallee$LWS(root$LWS, target$LWS), handler$LWS]);
11949
+ }];
11950
+ };
11951
+ }
10319
11952
  const {
10320
11953
  isSharedElement: isSharedElement$g$LWS
10321
11954
  } = rootValidator$LWS;
@@ -10717,6 +12350,142 @@
10717
12350
  }];
10718
12351
  };
10719
12352
  }
12353
+
12354
+ // W-23748456: block cross-realm redefinition of `Error.prepareStackTrace` via a
12355
+ // same-origin iframe realm's `Reflect.defineProperty`. Full threat model and the
12356
+ // KEY-identity reasoning live in Error/prepareStackTrace-shared.ts.
12357
+ function initDistortionReflectDefineProperty$LWS({
12358
+ globalObject: {
12359
+ Error: ErrorCtor$LWS,
12360
+ Reflect: {
12361
+ defineProperty: originalReflectDefineProperty$LWS
12362
+ }
12363
+ }
12364
+ }) {
12365
+ // No V8 prepareStackTrace hook on this platform => nothing to contain.
12366
+ if (!platformSupportsPrepareStackTrace$LWS(ErrorCtor$LWS)) {
12367
+ return noop$LWS$1;
12368
+ }
12369
+ return function distortionReflectDefineProperty$LWS({
12370
+ globalObject: globalObject$LWS
12371
+ }) {
12372
+ if (!isPrepareStackTraceStoreDistortable$LWS(globalObject$LWS)) {
12373
+ return undefined;
12374
+ }
12375
+ return [
12376
+ // KEY: the iframe realm's OWN native, identity-matched across the
12377
+ // membrane. See Error/prepareStackTrace-shared.ts.
12378
+ originalReflectDefineProperty$LWS, function defineProperty$LWS(target$LWS, key$LWS, descriptor$LWS) {
12379
+ const resolvedKey$LWS = resolvePropertyKey$LWS(key$LWS);
12380
+ if (resolvedKey$LWS === PREPARE_STACK_TRACE$LWS) {
12381
+ // Deliberately THROW rather than return `false`. A normal
12382
+ // failed Reflect.defineProperty returns `false`, which is
12383
+ // indistinguishable from ordinary platform behavior; a
12384
+ // throw makes it unmistakable that this is a security
12385
+ // refusal, so the failure is never masked as a routine
12386
+ // define failure.
12387
+ throwPrepareStackTraceBlocked$LWS();
12388
+ }
12389
+ // Any other key: an ordinary define, via the pinned shared
12390
+ // primitive with the already-resolved key (TOCTOU-safe).
12391
+ return ReflectDefineProperty$LWS$1(target$LWS, resolvedKey$LWS, descriptor$LWS);
12392
+ }];
12393
+ };
12394
+ }
12395
+
12396
+ // W-23439899: distort an iframe contentWindow realm's Reflect.get.
12397
+ //
12398
+ // The cross-realm confused-deputy read: sandbox code obtains a same-origin
12399
+ // iframe's blue-realm Reflect.get and applies it to its OWN sandbox document
12400
+ // proxy, e.g. `iframe.contentWindow.Reflect.get(document, 'cookie')`. The
12401
+ // near-membrane apply machinery transfers the red proxy argument back to its
12402
+ // raw blue pointer before the native operation runs, so blue's Reflect.get
12403
+ // performs `[[Get]]` on the UNWRAPPED raw Document and resolves the NATIVE
12404
+ // cookie getter — returning the raw, unfiltered cookie string instead of the
12405
+ // sandbox's namespace-filtered view.
12406
+ //
12407
+ // Unlike Reflect.apply / Reflect.construct (W-22602807), the leaked thing is
12408
+ // not a callee to be swapped: the target object (`document`) maps to itself in
12409
+ // the distortion map, so substituting it is a no-op. The distorted thing is the
12410
+ // resolved ACCESSOR — the distortion map holds `rawCookieGetter -> distorted
12411
+ // (namespace-filtering) getter`. So this replacement resolves the property's
12412
+ // accessor along the target's prototype chain and, when that getter has a
12413
+ // distorted counterpart, invokes the distorted getter against the receiver.
12414
+ // Every other case (data property, non-distorted accessor, missing key) falls
12415
+ // straight through to the native Reflect.get, so behavior is otherwise
12416
+ // byte-identical.
12417
+ function initDistortionReflectGet$LWS({
12418
+ globalObject: {
12419
+ Reflect: {
12420
+ get: originalReflectGet$LWS
12421
+ }
12422
+ }
12423
+ }) {
12424
+ return function distortionReflectGet$LWS({
12425
+ globalObject: globalObject$LWS,
12426
+ root: root$LWS
12427
+ }) {
12428
+ if (!isGaterEnabledFeature$LWS('changesSince.266') || !getDistortableFrameElement$LWS(globalObject$LWS)) {
12429
+ return undefined;
12430
+ }
12431
+ return [originalReflectGet$LWS, function get$LWS(target$LWS, propertyKey$LWS, ...rest$LWS) {
12432
+ // Preserve Reflect.get arity: receiver defaults to target only
12433
+ // when the caller omitted it. An explicit `undefined` third
12434
+ // argument is a distinct receiver per spec, so `rest.length`
12435
+ // (not the value) decides. For the passthrough this is moot
12436
+ // (`Reflect.get(target, key, target)` === `Reflect.get(target,
12437
+ // key)`), but a distorted accessor is invoked against exactly
12438
+ // the caller's receiver.
12439
+ const receiver$LWS = rest$LWS.length > 0 ? rest$LWS[0] : target$LWS;
12440
+ // Resolve the property's accessor along the prototype chain. If
12441
+ // its getter has a distorted counterpart in the sandbox's map,
12442
+ // run THAT against the receiver so the distorted getter (e.g.
12443
+ // the namespace-filtering cookie getter) fires instead of the
12444
+ // raw native one the membrane would otherwise reach on the
12445
+ // unwrapped blue object.
12446
+ //
12447
+ // Proxy fidelity: this walk calls [[GetOwnProperty]] and
12448
+ // [[GetPrototypeOf]] on `target`. Native Reflect.get on a Proxy
12449
+ // WITH a `get` trap invokes only that trap, never these, so a
12450
+ // throwing getOwnPropertyDescriptor/getPrototypeOf trap could
12451
+ // otherwise turn a would-succeed read into a throw. The
12452
+ // confused-deputy target is never a Proxy — the membrane unwraps
12453
+ // the red document proxy to the raw blue host object, whose
12454
+ // own-property and prototype lookups run no sandbox code — so a
12455
+ // throw here means we are NOT on the leak path. Swallow it and
12456
+ // let native Reflect.get decide (re-raising any genuine error),
12457
+ // keeping behavior identical to native for Proxy targets that
12458
+ // resolve without a distorted accessor. The walk only RESOLVES
12459
+ // the distorted getter inside the guard; invoking it happens
12460
+ // after, so an error from the distorted getter itself never
12461
+ // falls through to the raw native read.
12462
+ let distortedGetter$LWS;
12463
+ try {
12464
+ let current$LWS = target$LWS;
12465
+ while (current$LWS !== null && current$LWS !== undefined) {
12466
+ const descriptor$LWS = ReflectGetOwnPropertyDescriptor$LWS(current$LWS, propertyKey$LWS);
12467
+ if (descriptor$LWS !== undefined) {
12468
+ const getter$LWS = descriptor$LWS.get;
12469
+ if (getter$LWS !== undefined) {
12470
+ const candidate$LWS = substituteDistortedCallee$LWS(root$LWS, getter$LWS);
12471
+ if (candidate$LWS !== getter$LWS) {
12472
+ distortedGetter$LWS = candidate$LWS;
12473
+ }
12474
+ }
12475
+ break;
12476
+ }
12477
+ current$LWS = ReflectGetPrototypeOf$LWS$1(current$LWS);
12478
+ }
12479
+ } catch (_unused6$LWS) {
12480
+ // Not the confused-deputy path: defer to native below.
12481
+ }
12482
+ if (distortedGetter$LWS !== undefined) {
12483
+ return ReflectApply$LWS$1(distortedGetter$LWS, receiver$LWS, []);
12484
+ }
12485
+ return originalReflectGet$LWS(target$LWS, propertyKey$LWS, receiver$LWS);
12486
+ }];
12487
+ };
12488
+ }
10720
12489
  function initDistortionReportingObserverCtor$LWS({
10721
12490
  globalObject: {
10722
12491
  ReportingObserver: originalReportingObserverCtor$LWS
@@ -10782,6 +12551,57 @@
10782
12551
  return distortionEntry$LWS;
10783
12552
  };
10784
12553
  }
12554
+
12555
+ // W-23526613. `Response.json(data)` is an un-distorted, blue-realm native that
12556
+ // serializes `data` to JSON using the engine's own value-to-JSON-bytes walk.
12557
+ // That walk enumerates the argument's real own properties in native code,
12558
+ // below the near-membrane's `get`/`ownKeys` traps, so handing it a raw host
12559
+ // object (e.g. `document`) lets HTML's named-element-access algorithm fall back
12560
+ // to `Document.prototype.cookie` and leak the raw, un-namespaced cookie -- a
12561
+ // bypass of the property-access filtering the sandbox applies to ordinary
12562
+ // sandboxed JS reads.
12563
+ //
12564
+ // A `JSON.stringify` replacer neutralizes the leak. Values the sandbox itself
12565
+ // created round-trip to the blue realm as near-membrane proxies, whose native
12566
+ // walk goes through the membrane's proxy traps and is therefore already
12567
+ // filtered; any other object reachable from `data` is a raw blue host
12568
+ // reference the sandbox merely holds, and is replaced with an empty object so
12569
+ // the native serializer never enumerates it. The replacer runs before native
12570
+ // enumeration of each node, so it closes both the reported top-level
12571
+ // `Response.json(document)` call and nested carriers such as
12572
+ // `Response.json({ leak: document })`.
12573
+ function neutralizeHostObjectReplacer$LWS(_key$LWS, value$LWS) {
12574
+ if (value$LWS !== null && typeof value$LWS === 'object' && !isNearMembraneProxy$LWS$1(value$LWS)) {
12575
+ return {};
12576
+ }
12577
+ return value$LWS;
12578
+ }
12579
+ function initDistortionResponseJson$LWS({
12580
+ globalObject: {
12581
+ Response: Response$LWS
12582
+ }
12583
+ }) {
12584
+ const originalJson$LWS = Response$LWS == null ? void 0 : Response$LWS.json;
12585
+ // istanbul ignore if: Response.json is unavailable in some coverage environments
12586
+ if (typeof originalJson$LWS !== 'function') {
12587
+ return noop$LWS$1;
12588
+ }
12589
+ const distortionEntry$LWS = [originalJson$LWS, function json$LWS(...args$LWS) {
12590
+ if (isGaterEnabledFeature$LWS('changesSince.266') && args$LWS.length) {
12591
+ const safeString$LWS = JSONStringify$LWS$1(args$LWS[0], neutralizeHostObjectReplacer$LWS);
12592
+ // A top-level value that JSON serialization drops (undefined, a
12593
+ // function, a symbol) produces no bytes. Delegate to the native
12594
+ // implementation with `undefined` -- never the raw argument --
12595
+ // so it throws its own TypeError without a raw host object ever
12596
+ // reaching the native serializer.
12597
+ args$LWS[0] = safeString$LWS === undefined ? undefined : JSONParse$LWS(safeString$LWS);
12598
+ }
12599
+ return ReflectApply$LWS$1(originalJson$LWS, this, args$LWS);
12600
+ }];
12601
+ return function distortionResponseJson$LWS() {
12602
+ return distortionEntry$LWS;
12603
+ };
12604
+ }
10785
12605
  const {
10786
12606
  isSharedElement: isSharedElement$7$LWS
10787
12607
  } = rootValidator$LWS;
@@ -11364,7 +13184,7 @@
11364
13184
  try {
11365
13185
  originalStorageObject$LWS = globalObject$LWS[storageName$LWS];
11366
13186
  // eslint-disable-next-line no-empty
11367
- } catch (_unused4$LWS) {}
13187
+ } catch (_unused7$LWS) {}
11368
13188
  // istanbul ignore if: currently unreachable via tests
11369
13189
  if (!isObject$LWS$1(originalStorageObject$LWS)) {
11370
13190
  return noop$LWS$1;
@@ -11592,6 +13412,63 @@
11592
13412
  registerAttributeSetterDistortion$LWS(record$LWS, SVGAnimateElement$LWS, 'values', NAMESPACE_DEFAULT$LWS, values$LWS);
11593
13413
  };
11594
13414
  }
13415
+
13416
+ // W-23525040: SMIL animation of a script element's `href`/`xlink:href` is a
13417
+ // script-execution primitive that bypasses LWS's script-URL gate. LWS routes
13418
+ // every JS-level script-href write (attribute setter, property setter,
13419
+ // `SVGAnimatedString.baseVal`) through `createScriptDistortion` ->
13420
+ // `lwsInternalPolicy.createScriptURL`. Starting a SMIL animation via
13421
+ // `beginElement()`/`beginElementAt()` makes the engine write the target's
13422
+ // animated `href` inside its own implementation, never surfacing as a
13423
+ // JS-observable attribute mutation, so none of those gates ever see it and the
13424
+ // resolved URL loads and executes outside the membrane.
13425
+ //
13426
+ // A `<script>` is the only SVG element whose `href` is executable, and there is
13427
+ // no legitimate reason to SMIL-animate a script element, so both programmatic
13428
+ // begin methods refuse to start when the resolved animation target is a script
13429
+ // element. This is scheme-agnostic: legitimate script loading (including
13430
+ // `blob:` URLs) continues to work through the normal, gated `href` setter.
13431
+ const CANNOT_ANIMATE_SCRIPT_ELEMENT$LWS = 'Cannot begin an SVG animation that targets a script element.';
13432
+ // `beginElement()` and `beginElementAt(offset)` are the two programmatic SMIL
13433
+ // begin methods, and both need the identical guard: refuse to start when the
13434
+ // resolved animation target is a script element. `makeGuard` builds the init
13435
+ // function for either one so the guard exists as a single audited code path --
13436
+ // keeping future extensions (e.g. `endElement`/`endElementAt`, or the
13437
+ // declarative-trigger surface called out in the commit message) in lockstep
13438
+ // instead of drifting across copy-pasted bodies.
13439
+ function makeGuard$LWS(methodName$LWS) {
13440
+ return function initDistortionSVGAnimationElementBegin$LWS({
13441
+ globalObject: {
13442
+ SVGAnimationElement: SVGAnimationElement$LWS
13443
+ }
13444
+ }) {
13445
+ const SVGAnimationElementProto$LWS = SVGAnimationElement$LWS == null ? void 0 : SVGAnimationElement$LWS.prototype;
13446
+ // Defensive: if a future engine drops the begin method or the
13447
+ // `targetElement` getter off the prototype, install no distortion
13448
+ // rather than capture `undefined` and later crash on invocation.
13449
+ // Consistent with the `typeof ... !== 'function'` init guards used by
13450
+ // the CookieStore / Notification / TrustedTypePolicy distortions.
13451
+ if (!SVGAnimationElementProto$LWS) {
13452
+ return noop$LWS$1;
13453
+ }
13454
+ const originalBegin$LWS = SVGAnimationElementProto$LWS[methodName$LWS];
13455
+ const originalTargetElementGetter$LWS = ObjectLookupOwnGetter$LWS$1(SVGAnimationElementProto$LWS, 'targetElement');
13456
+ if (typeof originalBegin$LWS !== 'function' || typeof originalTargetElementGetter$LWS !== 'function') {
13457
+ return noop$LWS$1;
13458
+ }
13459
+ const distortionEntry$LWS = [originalBegin$LWS, function begin$LWS(...args$LWS) {
13460
+ if (isGaterEnabledFeature$LWS('changesSince.266') && isScriptElement$LWS(ReflectApply$LWS$1(originalTargetElementGetter$LWS, this, []))) {
13461
+ throw new LockerSecurityError$LWS(CANNOT_ANIMATE_SCRIPT_ELEMENT$LWS);
13462
+ }
13463
+ ReflectApply$LWS$1(originalBegin$LWS, this, args$LWS);
13464
+ }];
13465
+ return function distortionSVGAnimationElementBegin$LWS() {
13466
+ return distortionEntry$LWS;
13467
+ };
13468
+ };
13469
+ }
13470
+ const initDistortionSVGAnimationElementBeginElement$LWS = makeGuard$LWS('beginElement');
13471
+ const initDistortionSVGAnimationElementBeginElementAt$LWS = makeGuard$LWS('beginElementAt');
11595
13472
  function initDistortionSVGElementDatasetGetter$LWS({
11596
13473
  globalObject: {
11597
13474
  SVGElement: SVGElement$LWS
@@ -11790,7 +13667,7 @@
11790
13667
  try {
11791
13668
  // istanbul ignore next: needs default platform behavior test
11792
13669
  return ReflectApply$LWS$1(originalCreatePolicy$LWS, this, args$LWS);
11793
- } catch (_unused5$LWS) {
13670
+ } catch (_unused8$LWS) {
11794
13671
  // istanbul ignore next: this is tested, but currently cannot be tested in the coverage environment
11795
13672
  consoleWarn$LWS(`${createTrustedTypesExceptionMessage$LWS(name$LWS)} Substituting with Lightning Web Security policy.`);
11796
13673
  }
@@ -11801,6 +13678,68 @@
11801
13678
  return distortionEntry$LWS;
11802
13679
  };
11803
13680
  }
13681
+
13682
+ // W-23749358: %TypedArray%.prototype's iteration / reduction / sort methods take
13683
+ // a caller-supplied callback. Unlike Array (a sandbox-realm intrinsic whose
13684
+ // methods run in-realm, so the callback never leaves the sandbox), the typed
13685
+ // array intrinsics are served to sandbox code across the membrane. A callback
13686
+ // argument therefore arrives already unwrapped to its RAW blue reference, and
13687
+ // when that callback is the Function constructor the native method invokes the
13688
+ // raw blue Function — which compiles its body in the undistorted realm and can
13689
+ // read the real document.cookie:
13690
+ //
13691
+ // const value = new Uint8Array([0]);
13692
+ // value.toString = () => 'return document.cookie';
13693
+ // Uint8Array.prototype.reduce.call(value, Function, 'a//')();
13694
+ //
13695
+ // reduce/reduceRight are the directly exploitable pair: the first callback
13696
+ // argument is the caller's arbitrary initialValue (a usable Function
13697
+ // parameter-name string), while a later argument (the array) is String()-coerced
13698
+ // into the body. The element-iterating methods pass a numeric element first,
13699
+ // which is not a valid parameter name, so they cannot form the gadget today.
13700
+ // Every callback-taking method is distorted regardless: re-resolving the callback
13701
+ // through the root distortion map swaps a raw blue evaluator for its
13702
+ // sandbox-distorted counterpart, and is an untouched passthrough for any ordinary
13703
+ // callback (substituteDistortedCallee returns non-distorted values unchanged).
13704
+ //
13705
+ // The callback is argument 0 for all of these methods, so one replacement shape
13706
+ // covers them all: substitute args[0], then delegate to the native method with
13707
+ // the receiver and remaining arguments intact.
13708
+ function makeTypedArrayCallbackDistortion$LWS(methodName$LWS) {
13709
+ return function initTypedArrayCallbackDistortion$LWS({
13710
+ globalObject: globalObject$LWS
13711
+ }) {
13712
+ // %TypedArray%.prototype is not a nameable global; every typed-array
13713
+ // constructor inherits the same methods from it, so read the original off
13714
+ // Uint8Array.prototype — the resolved function IS %TypedArray%.prototype's
13715
+ // own method, identity preserved.
13716
+ const original$LWS = globalObject$LWS.Uint8Array.prototype[methodName$LWS];
13717
+ return function distortTypedArrayCallback$LWS({
13718
+ root: root$LWS
13719
+ }) {
13720
+ if (!isGaterEnabledFeature$LWS('changesSince.266') || typeof original$LWS !== 'function') {
13721
+ return undefined;
13722
+ }
13723
+ const distortionEntry$LWS = [original$LWS, function (callback$LWS, ...rest$LWS) {
13724
+ return ReflectApply$LWS$1(original$LWS, this, [substituteDistortedCallee$LWS(root$LWS, callback$LWS), ...rest$LWS]);
13725
+ }];
13726
+ return distortionEntry$LWS;
13727
+ };
13728
+ };
13729
+ }
13730
+ const initDistortionTypedArrayEvery$LWS = makeTypedArrayCallbackDistortion$LWS('every');
13731
+ const initDistortionTypedArrayFilter$LWS = makeTypedArrayCallbackDistortion$LWS('filter');
13732
+ const initDistortionTypedArrayFind$LWS = makeTypedArrayCallbackDistortion$LWS('find');
13733
+ const initDistortionTypedArrayFindIndex$LWS = makeTypedArrayCallbackDistortion$LWS('findIndex');
13734
+ const initDistortionTypedArrayFindLast$LWS = makeTypedArrayCallbackDistortion$LWS('findLast');
13735
+ const initDistortionTypedArrayFindLastIndex$LWS = makeTypedArrayCallbackDistortion$LWS('findLastIndex');
13736
+ const initDistortionTypedArrayForEach$LWS = makeTypedArrayCallbackDistortion$LWS('forEach');
13737
+ const initDistortionTypedArrayMap$LWS = makeTypedArrayCallbackDistortion$LWS('map');
13738
+ const initDistortionTypedArrayReduce$LWS = makeTypedArrayCallbackDistortion$LWS('reduce');
13739
+ const initDistortionTypedArrayReduceRight$LWS = makeTypedArrayCallbackDistortion$LWS('reduceRight');
13740
+ const initDistortionTypedArraySome$LWS = makeTypedArrayCallbackDistortion$LWS('some');
13741
+ const initDistortionTypedArraySort$LWS = makeTypedArrayCallbackDistortion$LWS('sort');
13742
+ const initDistortionTypedArrayToSorted$LWS = makeTypedArrayCallbackDistortion$LWS('toSorted');
11804
13743
  const HTML_MIME_TYPES_LIST$LWS = toSafeArray$LWS$1(['text/html', 'image/svg+xml', 'text/xml']);
11805
13744
  const createInsecureBlobErrorMessage$LWS = input$LWS => `Cannot 'createObjectURL' using an unsecure ${toSafeTemplateStringValue$LWS(input$LWS)}.`;
11806
13745
  function initDistortionURLCreateObjectURL$LWS({
@@ -11855,15 +13794,25 @@
11855
13794
  }
11856
13795
  const loweredBlobType$LWS = ReflectApply$LWS$1(StringProtoToLowerCase$LWS, blobType$LWS, []);
11857
13796
  if (HTML_MIME_TYPES_LIST$LWS.includes(loweredBlobType$LWS)) {
13797
+ // The `includes` gate above is an exact-string match against
13798
+ // HTML_MIME_TYPES_LIST, whose entries carry no parameters
13799
+ // (`text/html`, `image/svg+xml`, `text/xml`). A blob type that
13800
+ // arrived with a `;charset=` parameter (e.g.
13801
+ // `text/html;charset=utf-16`) fails that exact match and never
13802
+ // reaches this branch, so `loweredBlobType` here is always bare
13803
+ // and appending `;charset=utf-8` cannot produce a doubled
13804
+ // charset parameter. Both the validation slice and the
13805
+ // re-issued Blob reuse this one normalized content type.
13806
+ const normalizedContentType$LWS = `${loweredBlobType$LWS};charset=utf-8`;
11858
13807
  const blobSize$LWS = ReflectApply$LWS$1(BlobProtoSizeGetter$LWS, blobObject$LWS, []);
11859
- const normalizedBlob$LWS = ReflectApply$LWS$1(BlobProtoSlice$LWS, blobObject$LWS, [0, blobSize$LWS, `${loweredBlobType$LWS};charset=utf-8`]);
13808
+ const normalizedBlob$LWS = ReflectApply$LWS$1(BlobProtoSlice$LWS, blobObject$LWS, [0, blobSize$LWS, normalizedContentType$LWS]);
11860
13809
  URLRevokeObjectURL$LWS(outURL$LWS);
11861
13810
  outURL$LWS = ReflectApply$LWS$1(originalCreateObjectURL$LWS, this, [normalizedBlob$LWS]);
11862
13811
  const xhr$LWS = new XhrCtor$LWS();
11863
13812
  ReflectApply$LWS$1(XhrProtoOpen$LWS, xhr$LWS, ['GET', outURL$LWS, false]);
11864
13813
  try {
11865
13814
  ReflectApply$LWS$1(XhrProtoSend$LWS, xhr$LWS, []);
11866
- } catch (_unused6$LWS) {
13815
+ } catch (_unused9$LWS) {
11867
13816
  throw new LockerSecurityError$LWS(`Unable to verify ${toSafeTemplateStringValue$LWS(blobObject$LWS)} is secure.`);
11868
13817
  }
11869
13818
  const responseText$LWS = ReflectApply$LWS$1(XhrProtoResponseTextGetter$LWS, xhr$LWS, []);
@@ -11876,6 +13825,27 @@
11876
13825
  URLRevokeObjectURL$LWS(outURL$LWS);
11877
13826
  throw new LockerSecurityError$LWS(createInsecureBlobErrorMessage$LWS(blobObject$LWS));
11878
13827
  }
13828
+ // W-23558036: the validated bytes were read from a URL over
13829
+ // `normalizedBlob`, which is a `slice()` of the caller's
13830
+ // original Blob/File. For a filesystem-backed File (e.g. an
13831
+ // OPFS-derived File on WebKit) that slice can stay bound to
13832
+ // the live on-disk resource rather than an immutable snapshot,
13833
+ // so the bytes the URL resolves to can be swapped AFTER this
13834
+ // validation returns — the classic time-of-check/time-of-use
13835
+ // gap. Re-issue the URL over a fresh in-memory Blob built from
13836
+ // the exact `responseText` we just validated. An in-memory Blob
13837
+ // has no backing filesystem path to mutate, so the returned URL
13838
+ // is anchored to the validated bytes regardless of how the
13839
+ // input Blob/File was obtained (OPFS, <input type=file>,
13840
+ // drag-drop, etc.).
13841
+ if (isGaterEnabledFeature$LWS('changesSince.266')) {
13842
+ URLRevokeObjectURL$LWS(outURL$LWS);
13843
+ const validatedBlob$LWS = new BlobCtor$LWS([responseText$LWS], {
13844
+ __proto__: null,
13845
+ type: normalizedContentType$LWS
13846
+ });
13847
+ outURL$LWS = ReflectApply$LWS$1(originalCreateObjectURL$LWS, this, [validatedBlob$LWS]);
13848
+ }
11879
13849
  return outURL$LWS;
11880
13850
  }
11881
13851
  if (isMIMETypeAllowed$LWS(loweredBlobType$LWS)) {
@@ -11886,6 +13856,246 @@
11886
13856
  }];
11887
13857
  };
11888
13858
  }
13859
+
13860
+ // Walk the own and inherited property chain of `host` looking for a descriptor
13861
+ // for `key`, returning its getter (or undefined for a data property, an absent
13862
+ // property, or a setter-only accessor). The walk stops at the first descriptor
13863
+ // found so a shadowing data property correctly masks an inherited accessor.
13864
+ function lookupAccessorGetter$LWS(host$LWS, key$LWS) {
13865
+ let current$LWS = host$LWS;
13866
+ while (current$LWS !== null && current$LWS !== undefined) {
13867
+ const descriptor$LWS = ReflectGetOwnPropertyDescriptor$LWS(current$LWS, key$LWS);
13868
+ if (descriptor$LWS !== undefined) {
13869
+ return descriptor$LWS.get;
13870
+ }
13871
+ current$LWS = ReflectGetPrototypeOf$LWS$1(current$LWS);
13872
+ }
13873
+ return undefined;
13874
+ }
13875
+ // Resolve `host[key]` to the value the SANDBOX would observe, given that `host`
13876
+ // is a RAW blue-realm object. The membrane unwraps a distorted function's
13877
+ // arguments to their blue targets before the distortion runs, so a plain read
13878
+ // here would fire native getters and bypass the distortions. This is the
13879
+ // object-graph analog of `substituteDistortedCallee`: it consults the same
13880
+ // `root.distortions` map the membrane's distortionCallback uses.
13881
+ //
13882
+ // - Accessor properties (e.g. `document.cookie`): the native getter is
13883
+ // re-resolved to its distorted replacement in the map before being applied
13884
+ // to the raw receiver, so the distorted getter runs instead of the native
13885
+ // one and returns the sandboxed value.
13886
+ // - Object values (e.g. `window.localStorage`): the resulting object is
13887
+ // re-resolved through the map, yielding the per-sandbox replacement (the
13888
+ // key-namespacing Storage proxy) when one exists.
13889
+ // - Everything else (a real WebAssembly.Memory / Table / Global, a plain
13890
+ // numeric or string value) is returned unchanged, so legitimate imports
13891
+ // keep passing the native linker's brand checks.
13892
+ function readSandboxed$LWS(distortions$LWS, host$LWS, key$LWS) {
13893
+ const getter$LWS = lookupAccessorGetter$LWS(host$LWS, key$LWS);
13894
+ let value$LWS;
13895
+ if (typeof getter$LWS === 'function') {
13896
+ const distortedGetter$LWS = distortions$LWS.get(getter$LWS);
13897
+ const effectiveGetter$LWS = distortedGetter$LWS !== undefined && distortedGetter$LWS !== getter$LWS ? distortedGetter$LWS : getter$LWS;
13898
+ value$LWS = ReflectApply$LWS$1(effectiveGetter$LWS, host$LWS, []);
13899
+ } else {
13900
+ // A data property (or absent property) fires no native getter, so a
13901
+ // plain read cannot expose a lazily computed secret. When `host` is
13902
+ // itself a sandbox replacement proxy (e.g. the namespacing Storage
13903
+ // proxy) this plain read routes through that proxy's trap and is
13904
+ // already sandboxed.
13905
+ value$LWS = host$LWS[key$LWS];
13906
+ }
13907
+ const distortedValue$LWS = distortions$LWS.get(value$LWS);
13908
+ return distortedValue$LWS !== undefined && distortedValue$LWS !== value$LWS ? distortedValue$LWS : value$LWS;
13909
+ }
13910
+ // An own property that is both non-configurable and non-writable (what
13911
+ // `Object.freeze` produces) is bound by the Proxy `[[Get]]` invariant: the trap
13912
+ // MUST return the target's exact stored value, so the property can be neither
13913
+ // substituted nor wrapped. Returning anything else throws a `TypeError`, so a
13914
+ // frozen import object — e.g. `new WebAssembly.Instance(mod, Object.freeze(…))`
13915
+ // — would break where it instantiates natively today. Returns the descriptor
13916
+ // when the invariant binds, `undefined` otherwise (accessors, configurable or
13917
+ // writable data, and absent properties all stay sanitized).
13918
+ //
13919
+ // Honoring the invariant here does not reopen the leak: the exfiltration paths
13920
+ // (`document.cookie`, `window.localStorage`) are INHERITED accessors on the raw
13921
+ // host object, never frozen own data, so this guard never short-circuits them.
13922
+ // The only values it returns verbatim are a target's own frozen data — either
13923
+ // leaves of a sandbox-authored object (already membrane-filtered, since the
13924
+ // sandbox holds no raw host references) or real WebAssembly values — none of
13925
+ // which carry a raw host secret.
13926
+ function sealedOwnDataDescriptor$LWS(target$LWS, key$LWS) {
13927
+ const descriptor$LWS = ReflectGetOwnPropertyDescriptor$LWS(target$LWS, key$LWS);
13928
+ if (descriptor$LWS !== undefined && descriptor$LWS.writable === false && descriptor$LWS.configurable === false) {
13929
+ return descriptor$LWS;
13930
+ }
13931
+ return undefined;
13932
+ }
13933
+ // Wrap a single module-namespace object so the second linking read,
13934
+ // `Get(namespace, field)`, is sanitized in the same way as the first.
13935
+ function createNamespaceProxy$LWS(distortions$LWS, namespace$LWS) {
13936
+ return new ProxyCtor$LWS(namespace$LWS, {
13937
+ get(target$LWS, key$LWS) {
13938
+ const sealed$LWS = sealedOwnDataDescriptor$LWS(target$LWS, key$LWS);
13939
+ if (sealed$LWS !== undefined) {
13940
+ return sealed$LWS.value;
13941
+ }
13942
+ return readSandboxed$LWS(distortions$LWS, target$LWS, key$LWS);
13943
+ }
13944
+ });
13945
+ }
13946
+ // Replace a WebAssembly import object with a Proxy that exposes ONLY sandboxed
13947
+ // values to the native linker. WebAssembly resolves each two-level import
13948
+ // (`module`.`field`) by reading `Get(importObject, module)` then
13949
+ // `Get(namespace, field)`; both reads funnel through `readSandboxed`, so a
13950
+ // hand-crafted import naming a host property path (the W-23439980 bypass) can
13951
+ // only ever observe the membrane-filtered value.
13952
+ function sanitizeWasmImportObject$LWS(root$LWS, importObject$LWS) {
13953
+ const {
13954
+ distortions: distortions$LWS
13955
+ } = root$LWS;
13956
+ return new ProxyCtor$LWS(importObject$LWS, {
13957
+ get(target$LWS, moduleKey$LWS) {
13958
+ // A frozen own module entry is bound by the `[[Get]]` invariant and
13959
+ // must be returned verbatim (see `sealedOwnDataDescriptor`). It is a
13960
+ // sandbox-authored value, so it is already membrane-filtered.
13961
+ const sealed$LWS = sealedOwnDataDescriptor$LWS(target$LWS, moduleKey$LWS);
13962
+ if (sealed$LWS !== undefined) {
13963
+ return sealed$LWS.value;
13964
+ }
13965
+ const namespace$LWS = readSandboxed$LWS(distortions$LWS, target$LWS, moduleKey$LWS);
13966
+ // Wrap object namespaces so their field reads are sanitized too. A
13967
+ // non-object namespace is an invalid import that the native linker
13968
+ // will reject, so it passes through unwrapped.
13969
+ return isObject$LWS$1(namespace$LWS) ? createNamespaceProxy$LWS(distortions$LWS, namespace$LWS) : namespace$LWS;
13970
+ }
13971
+ });
13972
+ }
13973
+
13974
+ // W-23439980: a sandboxed module can hand-craft a WebAssembly module whose
13975
+ // two-level import name is a host property path (e.g. module="document",
13976
+ // field="cookie") typed as an immutable externref global, then re-export it.
13977
+ // `new WebAssembly.Instance(module, importObject)` makes the NATIVE linker
13978
+ // perform the nested property reads in C++. The membrane unwraps `importObject`
13979
+ // to the raw blue-realm object before the native call, so those reads never
13980
+ // pass through the sandbox proxy traps that fire the distortions. Sanitizing
13981
+ // the import object closes that path for the synchronous entry point.
13982
+ function initDistortionWebAssemblyInstanceCtor$LWS({
13983
+ globalObject: {
13984
+ WebAssembly: WebAssembly$LWS
13985
+ }
13986
+ }) {
13987
+ const originalInstanceCtor$LWS = WebAssembly$LWS == null ? void 0 : WebAssembly$LWS.Instance;
13988
+ // istanbul ignore if: WebAssembly is always available in coverage environments
13989
+ if (typeof originalInstanceCtor$LWS !== 'function') {
13990
+ return noop$LWS$1;
13991
+ }
13992
+ return function distortionWebAssemblyInstanceCtor$LWS({
13993
+ root: root$LWS
13994
+ }) {
13995
+ return [originalInstanceCtor$LWS, function Instance$LWS(...args$LWS) {
13996
+ if (isGaterEnabledFeature$LWS('changesSince.266') && args$LWS.length > 1 && args$LWS[1] != null) {
13997
+ args$LWS[1] = sanitizeWasmImportObject$LWS(root$LWS, args$LWS[1]);
13998
+ }
13999
+ return ReflectConstruct$LWS(originalInstanceCtor$LWS, args$LWS);
14000
+ }];
14001
+ };
14002
+ }
14003
+
14004
+ // W-23439980 (async entry point). `WebAssembly.instantiate` accepts either a
14005
+ // compiled `WebAssembly.Module` or a `BufferSource` as its first argument; in
14006
+ // both overloads the import object is the second argument. Distorting it here
14007
+ // closes the same raw-import leak covered by the `WebAssembly.Instance`
14008
+ // constructor distortion for asynchronous instantiation. The import object is
14009
+ // sanitized synchronously before delegating to the native function, so the
14010
+ // returned promise is the native promise unchanged.
14011
+ function initDistortionWebAssemblyInstantiate$LWS({
14012
+ globalObject: {
14013
+ WebAssembly: WebAssembly$LWS
14014
+ }
14015
+ }) {
14016
+ const originalInstantiate$LWS = WebAssembly$LWS == null ? void 0 : WebAssembly$LWS.instantiate;
14017
+ // istanbul ignore if: WebAssembly is always available in coverage environments
14018
+ if (typeof originalInstantiate$LWS !== 'function') {
14019
+ return noop$LWS$1;
14020
+ }
14021
+ return function distortionWebAssemblyInstantiate$LWS({
14022
+ root: root$LWS
14023
+ }) {
14024
+ return [originalInstantiate$LWS, function instantiate$LWS(...args$LWS) {
14025
+ if (isGaterEnabledFeature$LWS('changesSince.266') && args$LWS.length > 1 && args$LWS[1] != null) {
14026
+ args$LWS[1] = sanitizeWasmImportObject$LWS(root$LWS, args$LWS[1]);
14027
+ }
14028
+ return ReflectApply$LWS$1(originalInstantiate$LWS, this, args$LWS);
14029
+ }];
14030
+ };
14031
+ }
14032
+
14033
+ // W-23439980 (streaming entry point). `WebAssembly.instantiateStreaming` takes
14034
+ // a `Response` (or promise of one) as its first argument and the import object
14035
+ // as its second. It compiles and instantiates in one step, so it is a distinct
14036
+ // doorway to the raw-import leak and must be distorted separately from
14037
+ // `instantiate`. The import object is sanitized synchronously before delegating
14038
+ // to the native function.
14039
+ function initDistortionWebAssemblyInstantiateStreaming$LWS({
14040
+ globalObject: {
14041
+ WebAssembly: WebAssembly$LWS
14042
+ }
14043
+ }) {
14044
+ const originalInstantiateStreaming$LWS = WebAssembly$LWS == null ? void 0 : WebAssembly$LWS.instantiateStreaming;
14045
+ // istanbul ignore if: instantiateStreaming is unavailable in some coverage environments
14046
+ if (typeof originalInstantiateStreaming$LWS !== 'function') {
14047
+ return noop$LWS$1;
14048
+ }
14049
+ return function distortionWebAssemblyInstantiateStreaming$LWS({
14050
+ root: root$LWS
14051
+ }) {
14052
+ return [originalInstantiateStreaming$LWS, function instantiateStreaming$LWS(...args$LWS) {
14053
+ if (isGaterEnabledFeature$LWS('changesSince.266') && args$LWS.length > 1 && args$LWS[1] != null) {
14054
+ args$LWS[1] = sanitizeWasmImportObject$LWS(root$LWS, args$LWS[1]);
14055
+ }
14056
+ return ReflectApply$LWS$1(originalInstantiateStreaming$LWS, this, args$LWS);
14057
+ }];
14058
+ };
14059
+ }
14060
+
14061
+ // W-23768151: JSPI's `WebAssembly.Suspending` boxes a callable so a wasm module
14062
+ // can call it across a stack switch (resumed later via `WebAssembly.promising`).
14063
+ // Sandbox code can pass its own `Function` global to
14064
+ // `new WebAssembly.Suspending(fn)`. The membrane unwraps `fn` to its RAW
14065
+ // blue-realm target before this distortion runs, so the native constructor
14066
+ // would otherwise box the undistorted `Function`; a wasm module linked with
14067
+ // that boxed import then compiles a body like `return document.cookie` in the
14068
+ // blue realm and reads the real top-level value outside the sandbox view.
14069
+ //
14070
+ // This is a distinct doorway from the import-object scan the `Instance`/
14071
+ // `instantiate`/`instantiateStreaming` distortions perform: the callable is
14072
+ // handed directly to `Suspending`, never read through a `Get` on an import
14073
+ // object, so that scan never sees it. Re-resolving the argument through
14074
+ // `root.distortions` — the same map the membrane's distortionCallback consults —
14075
+ // swaps a laundered evaluator back to its sandbox-distorted counterpart, so the
14076
+ // boxed callable compiles in the sandbox realm. An ordinary sandbox closure is
14077
+ // not in the map, so it passes through unchanged.
14078
+ function initDistortionWebAssemblySuspending$LWS({
14079
+ globalObject: {
14080
+ WebAssembly: WebAssembly$LWS
14081
+ }
14082
+ }) {
14083
+ const originalSuspending$LWS = WebAssembly$LWS == null ? void 0 : WebAssembly$LWS.Suspending;
14084
+ // istanbul ignore if: JSPI is unavailable in some coverage environments
14085
+ if (typeof originalSuspending$LWS !== 'function') {
14086
+ return noop$LWS$1;
14087
+ }
14088
+ return function distortionWebAssemblySuspending$LWS({
14089
+ root: root$LWS
14090
+ }) {
14091
+ return [originalSuspending$LWS, function Suspending$LWS(...args$LWS) {
14092
+ if (isGaterEnabledFeature$LWS('changesSince.266') && args$LWS.length > 0) {
14093
+ args$LWS[0] = substituteDistortedCallee$LWS(root$LWS, args$LWS[0]);
14094
+ }
14095
+ return ReflectConstruct$LWS(originalSuspending$LWS, args$LWS);
14096
+ }];
14097
+ };
14098
+ }
11889
14099
  function initDistortionWindowFetch$LWS({
11890
14100
  globalObject: {
11891
14101
  fetch: originalFetch$LWS
@@ -12145,7 +14355,18 @@
12145
14355
  const windowPropertiesProxy$LWS = new ProxyCtor$LWS(shadowWindowProperties$LWS, shadowWindowPropertiesHandler$LWS);
12146
14356
  ReflectSetPrototypeOf$LWS$1(shadowFrames$LWS, framesPrototypeProxy$LWS);
12147
14357
  ReflectSetPrototypeOf$LWS$1(shadowFramesPrototype$LWS, windowPropertiesProxy$LWS);
12148
- return new ProxyCtor$LWS(shadowFrames$LWS, shadowFramesHandler$LWS);
14358
+ // Each proxy in this chain re-points its immediate prototype away from
14359
+ // `Object.prototype` to emulate the real `frames` -> `FrameList` ->
14360
+ // `WindowProperties` lookup chain. `isTargetLive` treats a
14361
+ // `constructor === Object` target as live only when its *immediate*
14362
+ // prototype is `Object.prototype`, so without an explicit signal these
14363
+ // proxies would be classified as static and the membrane would wrap
14364
+ // them, breaking the pass-through `set`/`deleteProperty` traps and
14365
+ // `window.frames === window.frames` identity. Track them so
14366
+ // `isTargetLive`'s live-target short-circuit fires first.
14367
+ trackAsLiveTarget$LWS(framesPrototypeProxy$LWS);
14368
+ trackAsLiveTarget$LWS(windowPropertiesProxy$LWS);
14369
+ return trackAsLiveTarget$LWS(new ProxyCtor$LWS(shadowFrames$LWS, shadowFramesHandler$LWS));
12149
14370
  };
12150
14371
  let framesProxy$LWS;
12151
14372
  const distortionEntry$LWS = [originalWindowFramesGetter$LWS, function frames$LWS() {
@@ -12522,6 +14743,53 @@
12522
14743
  return distortionEntry$LWS;
12523
14744
  };
12524
14745
  }
14746
+
14747
+ // A genuine `Document` (from any realm) carries the internal slot that backs
14748
+ // `Document.prototype.documentElement`, so reading it through the raw getter
14749
+ // succeeds; every other value (plain object, primitive, null, a foreign sink
14750
+ // object) throws and is treated as not-a-Document. This is also exactly the
14751
+ // set of objects for which the exploit is live: the Streams sink protocol
14752
+ // invokes the captured `write` algorithm with the sink as its `this`, so only
14753
+ // an object that actually owns the `Document` internal slot can drive the
14754
+ // native `Document.write`.
14755
+ function isDocument$LWS(value$LWS) {
14756
+ try {
14757
+ ReflectApply$LWS$1(DocumentProtoDocumentElementGetter$LWS, value$LWS, []);
14758
+ return true;
14759
+ } catch (_unused0$LWS) {
14760
+ return false;
14761
+ }
14762
+ }
14763
+ function initDistortionWritableStreamCtor$LWS({
14764
+ globalObject: {
14765
+ WritableStream: originalWritableStreamCtor$LWS
14766
+ }
14767
+ }) {
14768
+ // istanbul ignore if: WritableStream is always available in coverage environments
14769
+ if (typeof originalWritableStreamCtor$LWS !== 'function') {
14770
+ return noop$LWS$1;
14771
+ }
14772
+ function WritableStream$LWS(...args$LWS) {
14773
+ // A `WritableStream` extracts its `start`/`write`/`close`/`abort` sink
14774
+ // algorithms off the underlying sink object at construction time, via
14775
+ // WebIDL member reads on the raw host object that happen outside the
14776
+ // near-membrane's call-interception layer. Passing a `Document` as the
14777
+ // sink captures the native `Document.prototype.write` (which LWS blocks
14778
+ // with a value-thrower on the method itself) as the stream's write
14779
+ // algorithm; each later `writer.write(chunk)` then runs the raw
14780
+ // `Document.write` through the browser's internal stream machinery,
14781
+ // never re-entering the thrower. Refuse a `Document` sink so the blocked
14782
+ // method cannot be laundered into a live reference.
14783
+ if (isGaterEnabledFeature$LWS('changesSince.266') && args$LWS.length && isDocument$LWS(args$LWS[0])) {
14784
+ throw new LockerSecurityError$LWS('Cannot create WritableStream with a Document sink.');
14785
+ }
14786
+ return ReflectConstruct$LWS(originalWritableStreamCtor$LWS, args$LWS);
14787
+ }
14788
+ const distortionEntry$LWS = [originalWritableStreamCtor$LWS, WritableStream$LWS];
14789
+ return function distortionWritableStreamCtor$LWS() {
14790
+ return distortionEntry$LWS;
14791
+ };
14792
+ }
12525
14793
  function initDistortionXMLHttpRequestOpen$LWS({
12526
14794
  globalObject: {
12527
14795
  XMLHttpRequest: {
@@ -12577,8 +14845,31 @@
12577
14845
  // MAY CONTAIN a custom element, which must be marked for
12578
14846
  // association to this sandbox.
12579
14847
  setCustomElementsRegistry$LWS(document$LWS, key$LWS);
12580
- if (rawResponse$LWS instanceof Document$LWS) {
12581
- const docEl$LWS = ReflectApply$LWS$1(DocumentProtoDocumentElementGetter$LWS, rawResponse$LWS, []);
14848
+ // W-23439992: `instanceof Document` only recognizes a Document
14849
+ // from this realm. When the XHR is constructed in another
14850
+ // same-origin realm (e.g. a same-origin iframe's
14851
+ // `XMLHttpRequest`), a `responseType='document'` response is a
14852
+ // genuine Document from that other realm and fails the
14853
+ // realm-bound check, so sanitization is skipped and the raw
14854
+ // (unsanitized) response is returned. The structural fallback
14855
+ // recognizes a Document from any realm by reading a native
14856
+ // `Document.prototype` accessor: a real Document (any realm)
14857
+ // has the backing internal slot and the call succeeds, while a
14858
+ // non-Document response (JSON, text, Blob, ArrayBuffer, null)
14859
+ // throws and is passed through untouched, as before.
14860
+ let docEl$LWS;
14861
+ let isDocument$LWS = rawResponse$LWS instanceof Document$LWS;
14862
+ if (isDocument$LWS) {
14863
+ docEl$LWS = ReflectApply$LWS$1(DocumentProtoDocumentElementGetter$LWS, rawResponse$LWS, []);
14864
+ } else if (isGaterEnabledFeature$LWS('changesSince.266')) {
14865
+ try {
14866
+ docEl$LWS = ReflectApply$LWS$1(DocumentProtoDocumentElementGetter$LWS, rawResponse$LWS, []);
14867
+ isDocument$LWS = true;
14868
+ } catch (_unused1$LWS) {
14869
+ isDocument$LWS = false;
14870
+ }
14871
+ }
14872
+ if (isDocument$LWS) {
12582
14873
  const content$LWS = ReflectApply$LWS$1(ElementProtoOuterHTMLGetter$LWS, docEl$LWS, []);
12583
14874
  if (isGaterEnabledFeature$LWS('changesSince.262') && (isXMLEntityAttack$LWS(content$LWS) || isXMLNamespacedScriptAttack$LWS(content$LWS))) {
12584
14875
  throw new LockerSecurityError$LWS(`Cannot access XMLHttpRequest response using an unsecure ${toSafeTemplateStringValue$LWS(rawResponse$LWS)}.`);
@@ -12646,6 +14937,8 @@
12646
14937
  initDistortionHistoryPushState$LWS, initDistortionHistoryReplaceState$LWS,
12647
14938
  // HTMLElement
12648
14939
  initDistortionHTMLElementDatasetGetter$LWS, initDistortionHTMLElementInnerTextGetter$LWS, initDistortionHTMLElementInnerTextSetter$LWS, initDistortionHTMLElementOuterTextSetter$LWS, initDistortionHTMLElementStyleGetter$LWS,
14940
+ // HTMLFrameElement
14941
+ initDistortionHTMLFrameElementSrcGetter$LWS, initDistortionHTMLFrameElementSrcSetter$LWS,
12649
14942
  // HTMLIFrameElement
12650
14943
  initDistortionIFrameElementContentDocumentGetter$LWS, initDistortionIFrameElementContentWindowGetter$LWS, initDistortionHTMLIFrameElementSandboxGetter$LWS, initDistortionHTMLIFrameElementSandboxSetter$LWS, initDistortionHTMLIFrameElementSrcGetter$LWS, initDistortionHTMLIFrameElementSrcSetter$LWS,
12651
14944
  // HTMLImageElement
@@ -12681,7 +14974,7 @@
12681
14974
  // Navigator
12682
14975
  initDistortionNavigatorSendBeacon$LWS, initDistortionNavigatorServiceWorkerGetter$LWS,
12683
14976
  // Observable
12684
- initDistortionObservableForEach$LWS, initDistortionObservableSubscribe$LWS,
14977
+ initDistortionObservableCatch$LWS, initDistortionObservableEvery$LWS, initDistortionObservableFilter$LWS, initDistortionObservableFinally$LWS, initDistortionObservableFind$LWS, initDistortionObservableFlatMap$LWS, initDistortionObservableForEach$LWS, initDistortionObservableInspect$LWS, initDistortionObservableMap$LWS, initDistortionObservableReduce$LWS, initDistortionObservableSome$LWS, initDistortionObservableSubscribe$LWS, initDistortionObservableSwitchMap$LWS,
12685
14978
  // Node
12686
14979
  initDistortionNodeGetRootNode$LWS, initDistortionNodeParentElementGetter$LWS, initDistortionNodeParentNodeGetter$LWS, initDistortionNodeRemoveChild$LWS, initDistortionNodeReplaceChild$LWS,
12687
14980
  // Performance
@@ -12692,10 +14985,16 @@
12692
14985
  initDistortionPromiseAll$LWS, initDistortionPromiseAllSettled$LWS, initDistortionPromiseAny$LWS, initDistortionPromiseCatch$LWS, initDistortionPromiseFinally$LWS, initDistortionPromiseRace$LWS, initDistortionPromiseReject$LWS, initDistortionPromiseResolve$LWS, initDistortionPromiseThen$LWS, initDistortionPromiseTry$LWS, initDistortionPromiseWithResolvers$LWS,
12693
14986
  // Notification
12694
14987
  initDistortionNotificationCtor$LWS,
14988
+ // Object
14989
+ initDistortionObjectDefineProperties$LWS, initDistortionObjectDefineProperty$LWS,
14990
+ // Proxy
14991
+ initDistortionProxyCtor$LWS, initDistortionProxyRevocable$LWS,
12695
14992
  // Range
12696
14993
  initDistortionRangeCloneContents$LWS, initDistortionRangeCloneRange$LWS, initDistortionRangeDeleteContents$LWS, initDistortionRangeExtractContents$LWS, initDistortionRangeGetBoundingClientRect$LWS, initDistortionRangeInsertNode$LWS, initDistortionRangeSelectNode$LWS, initDistortionRangeSelectNodeContents$LWS, initDistortionRangeSetEnd$LWS, initDistortionRangeSetEndAfter$LWS, initDistortionRangeSetEndBefore$LWS, initDistortionRangeSetStart$LWS, initDistortionRangeSetStartAfter$LWS, initDistortionRangeSetStartBefore$LWS, initDistortionRangeSurroundContents$LWS, initDistortionRangeToString$LWS,
12697
14994
  // Reflect
12698
- initDistortionReflectApply$LWS, initDistortionReflectConstruct$LWS,
14995
+ initDistortionReflectApply$LWS, initDistortionReflectConstruct$LWS, initDistortionReflectDefineProperty$LWS, initDistortionReflectGet$LWS,
14996
+ // Response
14997
+ initDistortionResponseJson$LWS,
12699
14998
  // Selection
12700
14999
  initDistortionSelectionAnchorNodeGetter$LWS, initDistortionSelectionCollapse$LWS, initDistortionSelectionExtend$LWS, initDistortionSelectionFocusNodeGetter$LWS, initDistortionSelectionSelectAllChildren$LWS, initDistortionSelectionSetBaseAndExtent$LWS, initDistortionSelectionSetPosition$LWS, initDistortionSelectionToString$LWS,
12701
15000
  // ServiceWorkerContainer
@@ -12708,6 +15007,8 @@
12708
15007
  initDistortionSVGAnimatedStringBaseValSetter$LWS,
12709
15008
  // SVGAnimateElement
12710
15009
  initDistortionSVGAnimateElementFromAttribute$LWS, initDistortionSVGAnimateElementToAttribute$LWS, initDistortionSVGAnimateElementValuesAttribute$LWS,
15010
+ // SVGAnimationElement
15011
+ initDistortionSVGAnimationElementBeginElement$LWS, initDistortionSVGAnimationElementBeginElementAt$LWS,
12711
15012
  // SVGElement
12712
15013
  initDistortionSVGElementDatasetGetter$LWS, initDistortionSVGElementStyleGetter$LWS,
12713
15014
  // SVGSetElement
@@ -12716,10 +15017,16 @@
12716
15017
  initDistortionSVGUseElementHrefAttribute$LWS, initDistortionSVGUseElementXlinkHrefAttribute$LWS,
12717
15018
  // TrustedTypePolicyFactory
12718
15019
  initDistortionTrustedTypePolicyFactoryCreatePolicy$LWS,
15020
+ // TypedArray
15021
+ initDistortionTypedArrayEvery$LWS, initDistortionTypedArrayFilter$LWS, initDistortionTypedArrayFind$LWS, initDistortionTypedArrayFindIndex$LWS, initDistortionTypedArrayFindLast$LWS, initDistortionTypedArrayFindLastIndex$LWS, initDistortionTypedArrayForEach$LWS, initDistortionTypedArrayMap$LWS, initDistortionTypedArrayReduce$LWS, initDistortionTypedArrayReduceRight$LWS, initDistortionTypedArraySome$LWS, initDistortionTypedArraySort$LWS, initDistortionTypedArrayToSorted$LWS,
15022
+ // WebAssembly
15023
+ initDistortionWebAssemblyInstanceCtor$LWS, initDistortionWebAssemblyInstantiate$LWS, initDistortionWebAssemblyInstantiateStreaming$LWS, initDistortionWebAssemblySuspending$LWS,
12719
15024
  // Window
12720
15025
  initDistortionWindowFetch$LWS, initDistortionWindowFetchLater$LWS, initDistortionWindowFramesGetter$LWS, initDistortionWindowGetComputedStyle$LWS, initDistortionWindowLengthGetter$LWS, initDistortionWindowNameGetter$LWS, initDistortionWindowNameSetter$LWS, initDistortionWindowOpen$LWS, initDistortionWindowPostMessage$LWS, initDistortionWindowStructuredClone$LWS,
12721
15026
  // Worker
12722
15027
  initDistortionWorkerCtor$LWS, initDistortionWorkerProto$LWS,
15028
+ // WritableStream
15029
+ initDistortionWritableStreamCtor$LWS,
12723
15030
  // XHR
12724
15031
  initDistortionXMLHttpRequestOpen$LWS];
12725
15032
  const internalKeyedDistortionFactoryInitializers$LWS = [
@@ -12800,7 +15107,7 @@
12800
15107
  // initDistortionNodeAppendChild,
12801
15108
  initDistortionNodeInsertBefore$LWS]);
12802
15109
  const externalKeyedDistortionFactoryInitializers$LWS = internalKeyedDistortionFactoryInitializers$LWS;
12803
- const distortionFactoryInitializerToggleSwitches$LWS = toSafeMap$LWS$1(new MapCtor$LWS$1([[initDistortionBroadcastChannelCtor$LWS, 'broadcastChannel'], [initDistortionBroadcastChannelNameGetter$LWS, 'broadcastChannel'], [initDistortionCacheStorageDelete$LWS, 'caches'], [initDistortionCacheStorageHas$LWS, 'caches'], [initDistortionCacheStorageKeys$LWS, 'caches'], [initDistortionCacheStorageMatch$LWS, 'caches'], [initDistortionCacheStorageOpen$LWS, 'caches'], [initDistortionCookieStoreDelete$LWS, 'cookieStore'], [initDistortionCookieStoreGet$LWS, 'cookieStore'], [initDistortionCookieStoreGetAll$LWS, 'cookieStore'], [initDistortionCookieStoreOnChange$LWS, 'cookieStore'], [initDistortionCookieStoreSet$LWS, 'cookieStore'], [initDistortionCSSStyleRuleStyleGetter$LWS, 'style'], [initDistortionCustomElementRegistryDefine$LWS, 'customElements'], [initDistortionCustomElementRegistryGet$LWS, 'customElements'], [initDistortionCustomElementRegistryUpgrade$LWS, 'customElements'], [initDistortionCustomElementRegistryWhenDefined$LWS, 'customElements'], [initDistortionDocumentCookieGetter$LWS, 'documentCookie'], [initDistortionDocumentCookieSetter$LWS, 'documentCookie'], [initDistortionDocumentDomainSetter$LWS, 'documentDomain'], [initDistortionDocumentExecCommand$LWS, 'documentExecCommand'], [initDistortionDOMParserParseFromString$LWS, 'domParserParseFromString'], [initDistortionDOMTokenListAdd$LWS, 'domTokenList'], [initDistortionDOMTokenListReplace$LWS, 'domTokenList'], [initDistortionDOMTokenListToggle$LWS, 'domTokenList'], [initDistortionDOMTokenListValueSetter$LWS, 'domTokenList'], [initDistortionElementAfter$LWS, 'element'], [initDistortionElementAppend$LWS, 'element'], [initDistortionElementAttributesGetter$LWS, 'attributes'], [initDistortionElementBefore$LWS, 'element'], [initDistortionElementGetInnerHTML$LWS, 'innerHTML'], [initDistortionElementInnerHTMLSetter$LWS, 'innerHTML'], [initDistortionElementInsertAdjacentElement$LWS, 'element'], [initDistortionElementInsertAdjacentHTML$LWS, 'element'], [initDistortionElementOuterHTMLSetter$LWS, 'element'], [initDistortionElementPrepend$LWS, 'element'], [initDistortionElementRemove$LWS, 'element'], [initDistortionElementReplaceChildren$LWS, 'element'], [initDistortionElementReplaceWith$LWS, 'element'], [initDistortionElementGetAttribute$LWS, 'attributes'], [initDistortionElementGetAttributeNode$LWS, 'attributes'], [initDistortionElementGetAttributeNodeNS$LWS, 'attributes'], [initDistortionElementGetAttributeNS$LWS, 'attributes'], [initDistortionElementSetAttribute$LWS, 'attributes'], [initDistortionElementSetAttributeNode$LWS, 'attributes'], [initDistortionElementSetAttributeNodeNS$LWS, 'attributes'], [initDistortionElementSetAttributeNS$LWS, 'attributes'], [initDistortionElementRemoveAttribute$LWS, 'attributes'], [initDistortionElementRemoveAttributeNS$LWS, 'attributes'], [initDistortionElementRemoveAttributeNode$LWS, 'attributes'], [initDistortionElementSetHTML$LWS, 'element'], [initDistortionElementToggleAttribute$LWS, 'attributes'], [initDistortionHTMLButtonElementFormActionSetter$LWS, 'form'], [initDistortionHTMLFormElementActionSetter$LWS, 'form'], [initDistortionHTMLInputElementFormActionSetter$LWS, 'form'], [initDistortionHistoryPushState$LWS, 'history'], [initDistortionHistoryReplaceState$LWS, 'history'], [initDistortionHTMLElementDatasetGetter$LWS, 'dataset'], [initDistortionHTMLElementStyleGetter$LWS, 'style'], [initDistortionHTMLImageElementSrcSetter$LWS, 'networkSrc'], [initDistortionHTMLImageElementSrcsetSetter$LWS, 'networkSrc'], [initDistortionHTMLLinkElementHrefSetter$LWS, 'networkSrc'], [initDistortionHTMLMediaElementSrcSetter$LWS, 'networkSrc'], [initDistortionHTMLSourceElementSrcSetter$LWS, 'networkSrc'], [initDistortionHTMLSourceElementSrcsetSetter$LWS, 'networkSrc'], [initDistortionHTMLTrackElementSrcSetter$LWS, 'networkSrc'], [initDistortionHTMLScriptElementInnerTextGetter$LWS, 'script'], [initDistortionHTMLScriptElementInnerTextSetter$LWS, 'script'], [initDistortionHTMLScriptElementSrcGetter$LWS, 'script'], [initDistortionHTMLScriptElementSrcSetter$LWS, 'script'], [initDistortionHTMLScriptElementTextGetter$LWS, 'script'], [initDistortionHTMLScriptElementTextSetter$LWS, 'script'], [initDistortionIDBFactoryDatabases$LWS, 'indexedDB'], [initDistortionIDBFactoryDeleteDatabase$LWS, 'indexedDB'], [initDistortionIDBFactoryOpen$LWS, 'indexedDB'], [initDistortionIDBObjectStoreAdd$LWS, 'indexedDB'], [initDistortionIDBObjectStorePut$LWS, 'indexedDB'], [initDistortionLocalStorage$LWS, 'storage'], [initDistortionMessagePortPostMessage$LWS, 'postMessage'], [initDistortionIntersectionObserverObserve$LWS, 'observers'], [initDistortionMutationObserverObserve$LWS, 'mutationObserver'], [initDistortionPerformanceObserverObserve$LWS, 'observers'], [initDistortionResizeObserverObserve$LWS, 'observers'], [initDistortionAttrValueGetter$LWS, 'attributes'], [initDistortionAttrValueSetter$LWS, 'attributes'], [initDistortionNamedNodeMapGetNamedItem$LWS, 'attributes'], [initDistortionNamedNodeMapGetNamedItemNS$LWS, 'attributes'], [initDistortionNamedNodeMapRemoveNamedItem$LWS, 'attributes'], [initDistortionNamedNodeMapRemoveNamedItemNS$LWS, 'attributes'], [initDistortionNamedNodeMapSetNamedItem$LWS, 'attributes'], [initDistortionNamedNodeMapSetNamedItemNS$LWS, 'attributes'], [initDistortionNavigatorSendBeacon$LWS, 'navigatorSendBeacon'], [initDistortionObservableForEach$LWS, 'observable'], [initDistortionObservableSubscribe$LWS, 'observable'], [initDistortionNodeGetRootNode$LWS, 'node'], [initDistortionNodeInsertBefore$LWS, 'node'], [initDistortionNodeParentElementGetter$LWS, 'node'], [initDistortionNodeParentNodeGetter$LWS, 'node'], [initDistortionNodeRemoveChild$LWS, 'node'], [initDistortionNodeReplaceChild$LWS, 'node'], [initDistortionNodeTextContentGetter$LWS, 'node'], [initDistortionNodeTextContentSetter$LWS, 'node'], [initDistortionNodeValueSetter$LWS, 'node'], [initDistortionNotificationCtor$LWS, 'notification'], [initDistortionPerformanceMark$LWS, 'performance'], [initDistortionPerformanceMarkCtor$LWS, 'performance'], [initDistortionPerformanceMeasure$LWS, 'performance'], [initDistortionRangeCloneContents$LWS, 'range'], [initDistortionRangeCloneRange$LWS, 'range'], [initDistortionRangeCreateContextualFragment$LWS, 'range'], [initDistortionRangeDeleteContents$LWS, 'range'], [initDistortionRangeExtractContents$LWS, 'range'], [initDistortionRangeGetBoundingClientRect$LWS, 'range'], [initDistortionRangeInsertNode$LWS, 'range'], [initDistortionRangeSelectNode$LWS, 'range'], [initDistortionRangeSelectNodeContents$LWS, 'range'], [initDistortionRangeSetEnd$LWS, 'range'], [initDistortionRangeSetEndAfter$LWS, 'range'], [initDistortionRangeSetEndBefore$LWS, 'range'], [initDistortionRangeSetStart$LWS, 'range'], [initDistortionRangeSetStartAfter$LWS, 'range'], [initDistortionRangeSetStartBefore$LWS, 'range'], [initDistortionRangeSurroundContents$LWS, 'range'], [initDistortionRangeToString$LWS, 'range'], [initDistortionSelectionAnchorNodeGetter$LWS, 'selection'], [initDistortionSelectionCollapse$LWS, 'selection'], [initDistortionSelectionExtend$LWS, 'selection'], [initDistortionSelectionFocusNodeGetter$LWS, 'selection'], [initDistortionSelectionSelectAllChildren$LWS, 'selection'], [initDistortionSelectionSetBaseAndExtent$LWS, 'selection'], [initDistortionSelectionSetPosition$LWS, 'selection'], [initDistortionSelectionToString$LWS, 'selection'], [initDistortionSessionStorage$LWS, 'storage'], [initDistortionShadowRootInnerHTMLSetter$LWS, 'innerHTML'], [initDistortionStorage$LWS, 'storage'], [initDistortionStorageClear$LWS, 'storage'], [initDistortionStorageGetItem$LWS, 'storage'], [initDistortionStorageKey$LWS, 'storage'], [initDistortionStorageLength$LWS, 'storage'], [initDistortionStorageRemoveItem$LWS, 'storage'], [initDistortionStorageSetItem$LWS, 'storage'], [initDistortionSVGElementDatasetGetter$LWS, 'dataset'], [initDistortionSVGElementStyleGetter$LWS, 'style'], [initDistortionSVGAnimatedStringBaseValSetter$LWS, 'script'], [initDistortionSVGScriptElementHrefGetter$LWS, 'script'], [initDistortionSVGScriptElementHrefSetter$LWS, 'script'], [initDistortionWindowFetch$LWS, 'windowFetch'], [initDistortionWindowFetchLater$LWS, 'windowFetchLater'], [initDistortionWindowFramesGetter$LWS, 'windowFrames'], [initDistortionWindowGetComputedStyle$LWS, 'style'], [initDistortionWindowLengthGetter$LWS, 'windowFrames'], [initDistortionWindowNameGetter$LWS, 'windowName'], [initDistortionWindowNameSetter$LWS, 'windowName'], [initDistortionWindowPostMessage$LWS, 'postMessage'], [initDistortionWindowSetInterval$LWS, 'setInterval'], [initDistortionWindowSetTimeout$LWS, 'setTimeout'], [initDistortionXMLHttpRequestResponseGetter$LWS, 'xhr'], [initDistortionXMLHttpRequestResponseXMLGetter$LWS, 'xhr']]));
15110
+ const distortionFactoryInitializerToggleSwitches$LWS = toSafeMap$LWS$1(new MapCtor$LWS$1([[initDistortionBroadcastChannelCtor$LWS, 'broadcastChannel'], [initDistortionBroadcastChannelNameGetter$LWS, 'broadcastChannel'], [initDistortionCacheStorageDelete$LWS, 'caches'], [initDistortionCacheStorageHas$LWS, 'caches'], [initDistortionCacheStorageKeys$LWS, 'caches'], [initDistortionCacheStorageMatch$LWS, 'caches'], [initDistortionCacheStorageOpen$LWS, 'caches'], [initDistortionCookieStoreDelete$LWS, 'cookieStore'], [initDistortionCookieStoreGet$LWS, 'cookieStore'], [initDistortionCookieStoreGetAll$LWS, 'cookieStore'], [initDistortionCookieStoreOnChange$LWS, 'cookieStore'], [initDistortionCookieStoreSet$LWS, 'cookieStore'], [initDistortionCSSStyleRuleStyleGetter$LWS, 'style'], [initDistortionCustomElementRegistryDefine$LWS, 'customElements'], [initDistortionCustomElementRegistryGet$LWS, 'customElements'], [initDistortionCustomElementRegistryUpgrade$LWS, 'customElements'], [initDistortionCustomElementRegistryWhenDefined$LWS, 'customElements'], [initDistortionDocumentCookieGetter$LWS, 'documentCookie'], [initDistortionDocumentCookieSetter$LWS, 'documentCookie'], [initDistortionDocumentDomainSetter$LWS, 'documentDomain'], [initDistortionDocumentExecCommand$LWS, 'documentExecCommand'], [initDistortionDOMParserParseFromString$LWS, 'domParserParseFromString'], [initDistortionDOMTokenListAdd$LWS, 'domTokenList'], [initDistortionDOMTokenListReplace$LWS, 'domTokenList'], [initDistortionDOMTokenListToggle$LWS, 'domTokenList'], [initDistortionDOMTokenListValueSetter$LWS, 'domTokenList'], [initDistortionElementAfter$LWS, 'element'], [initDistortionElementAppend$LWS, 'element'], [initDistortionElementAttributesGetter$LWS, 'attributes'], [initDistortionElementBefore$LWS, 'element'], [initDistortionElementGetInnerHTML$LWS, 'innerHTML'], [initDistortionElementInnerHTMLSetter$LWS, 'innerHTML'], [initDistortionElementInsertAdjacentElement$LWS, 'element'], [initDistortionElementInsertAdjacentHTML$LWS, 'element'], [initDistortionElementOuterHTMLSetter$LWS, 'element'], [initDistortionElementPrepend$LWS, 'element'], [initDistortionElementRemove$LWS, 'element'], [initDistortionElementReplaceChildren$LWS, 'element'], [initDistortionElementReplaceWith$LWS, 'element'], [initDistortionElementGetAttribute$LWS, 'attributes'], [initDistortionElementGetAttributeNode$LWS, 'attributes'], [initDistortionElementGetAttributeNodeNS$LWS, 'attributes'], [initDistortionElementGetAttributeNS$LWS, 'attributes'], [initDistortionElementSetAttribute$LWS, 'attributes'], [initDistortionElementSetAttributeNode$LWS, 'attributes'], [initDistortionElementSetAttributeNodeNS$LWS, 'attributes'], [initDistortionElementSetAttributeNS$LWS, 'attributes'], [initDistortionElementRemoveAttribute$LWS, 'attributes'], [initDistortionElementRemoveAttributeNS$LWS, 'attributes'], [initDistortionElementRemoveAttributeNode$LWS, 'attributes'], [initDistortionElementSetHTML$LWS, 'element'], [initDistortionElementToggleAttribute$LWS, 'attributes'], [initDistortionHTMLButtonElementFormActionSetter$LWS, 'form'], [initDistortionHTMLFormElementActionSetter$LWS, 'form'], [initDistortionHTMLInputElementFormActionSetter$LWS, 'form'], [initDistortionHistoryPushState$LWS, 'history'], [initDistortionHistoryReplaceState$LWS, 'history'], [initDistortionHTMLElementDatasetGetter$LWS, 'dataset'], [initDistortionHTMLElementStyleGetter$LWS, 'style'], [initDistortionHTMLImageElementSrcSetter$LWS, 'networkSrc'], [initDistortionHTMLImageElementSrcsetSetter$LWS, 'networkSrc'], [initDistortionHTMLLinkElementHrefSetter$LWS, 'networkSrc'], [initDistortionHTMLMediaElementSrcSetter$LWS, 'networkSrc'], [initDistortionHTMLSourceElementSrcSetter$LWS, 'networkSrc'], [initDistortionHTMLSourceElementSrcsetSetter$LWS, 'networkSrc'], [initDistortionHTMLTrackElementSrcSetter$LWS, 'networkSrc'], [initDistortionHTMLScriptElementInnerTextGetter$LWS, 'script'], [initDistortionHTMLScriptElementInnerTextSetter$LWS, 'script'], [initDistortionHTMLScriptElementSrcGetter$LWS, 'script'], [initDistortionHTMLScriptElementSrcSetter$LWS, 'script'], [initDistortionHTMLScriptElementTextGetter$LWS, 'script'], [initDistortionHTMLScriptElementTextSetter$LWS, 'script'], [initDistortionIDBFactoryDatabases$LWS, 'indexedDB'], [initDistortionIDBFactoryDeleteDatabase$LWS, 'indexedDB'], [initDistortionIDBFactoryOpen$LWS, 'indexedDB'], [initDistortionIDBObjectStoreAdd$LWS, 'indexedDB'], [initDistortionIDBObjectStorePut$LWS, 'indexedDB'], [initDistortionLocalStorage$LWS, 'storage'], [initDistortionMessagePortPostMessage$LWS, 'postMessage'], [initDistortionIntersectionObserverObserve$LWS, 'observers'], [initDistortionMutationObserverObserve$LWS, 'mutationObserver'], [initDistortionPerformanceObserverObserve$LWS, 'observers'], [initDistortionResizeObserverObserve$LWS, 'observers'], [initDistortionAttrValueGetter$LWS, 'attributes'], [initDistortionAttrValueSetter$LWS, 'attributes'], [initDistortionNamedNodeMapGetNamedItem$LWS, 'attributes'], [initDistortionNamedNodeMapGetNamedItemNS$LWS, 'attributes'], [initDistortionNamedNodeMapRemoveNamedItem$LWS, 'attributes'], [initDistortionNamedNodeMapRemoveNamedItemNS$LWS, 'attributes'], [initDistortionNamedNodeMapSetNamedItem$LWS, 'attributes'], [initDistortionNamedNodeMapSetNamedItemNS$LWS, 'attributes'], [initDistortionNavigatorSendBeacon$LWS, 'navigatorSendBeacon'], [initDistortionObservableCatch$LWS, 'observable'], [initDistortionObservableEvery$LWS, 'observable'], [initDistortionObservableFilter$LWS, 'observable'], [initDistortionObservableFinally$LWS, 'observable'], [initDistortionObservableFind$LWS, 'observable'], [initDistortionObservableFlatMap$LWS, 'observable'], [initDistortionObservableForEach$LWS, 'observable'], [initDistortionObservableInspect$LWS, 'observable'], [initDistortionObservableMap$LWS, 'observable'], [initDistortionObservableReduce$LWS, 'observable'], [initDistortionObservableSome$LWS, 'observable'], [initDistortionObservableSubscribe$LWS, 'observable'], [initDistortionObservableSwitchMap$LWS, 'observable'], [initDistortionNodeGetRootNode$LWS, 'node'], [initDistortionNodeInsertBefore$LWS, 'node'], [initDistortionNodeParentElementGetter$LWS, 'node'], [initDistortionNodeParentNodeGetter$LWS, 'node'], [initDistortionNodeRemoveChild$LWS, 'node'], [initDistortionNodeReplaceChild$LWS, 'node'], [initDistortionNodeTextContentGetter$LWS, 'node'], [initDistortionNodeTextContentSetter$LWS, 'node'], [initDistortionNodeValueSetter$LWS, 'node'], [initDistortionNotificationCtor$LWS, 'notification'], [initDistortionPerformanceMark$LWS, 'performance'], [initDistortionPerformanceMarkCtor$LWS, 'performance'], [initDistortionPerformanceMeasure$LWS, 'performance'], [initDistortionRangeCloneContents$LWS, 'range'], [initDistortionRangeCloneRange$LWS, 'range'], [initDistortionRangeCreateContextualFragment$LWS, 'range'], [initDistortionRangeDeleteContents$LWS, 'range'], [initDistortionRangeExtractContents$LWS, 'range'], [initDistortionRangeGetBoundingClientRect$LWS, 'range'], [initDistortionRangeInsertNode$LWS, 'range'], [initDistortionRangeSelectNode$LWS, 'range'], [initDistortionRangeSelectNodeContents$LWS, 'range'], [initDistortionRangeSetEnd$LWS, 'range'], [initDistortionRangeSetEndAfter$LWS, 'range'], [initDistortionRangeSetEndBefore$LWS, 'range'], [initDistortionRangeSetStart$LWS, 'range'], [initDistortionRangeSetStartAfter$LWS, 'range'], [initDistortionRangeSetStartBefore$LWS, 'range'], [initDistortionRangeSurroundContents$LWS, 'range'], [initDistortionRangeToString$LWS, 'range'], [initDistortionSelectionAnchorNodeGetter$LWS, 'selection'], [initDistortionSelectionCollapse$LWS, 'selection'], [initDistortionSelectionExtend$LWS, 'selection'], [initDistortionSelectionFocusNodeGetter$LWS, 'selection'], [initDistortionSelectionSelectAllChildren$LWS, 'selection'], [initDistortionSelectionSetBaseAndExtent$LWS, 'selection'], [initDistortionSelectionSetPosition$LWS, 'selection'], [initDistortionSelectionToString$LWS, 'selection'], [initDistortionSessionStorage$LWS, 'storage'], [initDistortionShadowRootInnerHTMLSetter$LWS, 'innerHTML'], [initDistortionStorage$LWS, 'storage'], [initDistortionStorageClear$LWS, 'storage'], [initDistortionStorageGetItem$LWS, 'storage'], [initDistortionStorageKey$LWS, 'storage'], [initDistortionStorageLength$LWS, 'storage'], [initDistortionStorageRemoveItem$LWS, 'storage'], [initDistortionStorageSetItem$LWS, 'storage'], [initDistortionSVGElementDatasetGetter$LWS, 'dataset'], [initDistortionSVGElementStyleGetter$LWS, 'style'], [initDistortionSVGAnimatedStringBaseValSetter$LWS, 'script'], [initDistortionSVGScriptElementHrefGetter$LWS, 'script'], [initDistortionSVGScriptElementHrefSetter$LWS, 'script'], [initDistortionSVGAnimationElementBeginElement$LWS, 'script'], [initDistortionSVGAnimationElementBeginElementAt$LWS, 'script'], [initDistortionWindowFetch$LWS, 'windowFetch'], [initDistortionWindowFetchLater$LWS, 'windowFetchLater'], [initDistortionWindowFramesGetter$LWS, 'windowFrames'], [initDistortionWindowGetComputedStyle$LWS, 'style'], [initDistortionWindowLengthGetter$LWS, 'windowFrames'], [initDistortionWindowNameGetter$LWS, 'windowName'], [initDistortionWindowNameSetter$LWS, 'windowName'], [initDistortionWindowPostMessage$LWS, 'postMessage'], [initDistortionWindowSetInterval$LWS, 'setInterval'], [initDistortionWindowSetTimeout$LWS, 'setTimeout'], [initDistortionXMLHttpRequestResponseGetter$LWS, 'xhr'], [initDistortionXMLHttpRequestResponseXMLGetter$LWS, 'xhr']]));
12804
15111
  const DocumentBlockedProperties$LWS = ['parseHTMLUnsafe'];
12805
15112
  const DocumentProtoBlockedProperties$LWS = ['createProcessingInstruction', 'exitFullscreen', 'fullscreen', 'fullscreenElement', 'fullscreenEnabled', 'mozCancelFullScreen', 'mozFullScreen', 'mozFullScreenElement', 'mozFullScreenEnabled', 'onfullscreenchange', 'onfullscreenerror', 'onmozfullscreenchange', 'onmozfullscreenerror', 'onrejectionhandled', 'onunhandledrejection', 'parseHTMLUnsafe', 'releaseCapture', 'releaseEvents', 'requestStorageAccess', 'webkitFullScreenKeyboardInputAllowed', 'write', 'writeln'];
12806
15113
  const ElementProtoBlockedProperties$LWS = ['mozRequestFullScreen', 'onfullscreenchange', 'onfullscreenerror', 'requestFullscreen', 'webkitRequestFullScreen', 'webkitRequestFullscreen'];
@@ -12810,18 +15117,29 @@
12810
15117
  const HTMLEmbedElementBlockedAttributes$LWS = ['src'];
12811
15118
  const HTMLEmbedElementProtoBlockedProperties$LWS = ['getSVGDocument', 'src'];
12812
15119
 
15120
+ // https://developer.mozilla.org/en-US/docs/Web/HTML/Element/frame
15121
+ const HTMLFrameElementBlockedAttributes$LWS = ['srcdoc'];
15122
+
12813
15123
  // https://www.w3schools.com/tags/tag_iframe.asp
12814
15124
  const HTMLIFrameElementBlockedAttributes$LWS = ['srcdoc'];
12815
15125
  const HTMLIFrameElementProtoBlockedProperties$LWS = ['getSVGDocument', 'srcdoc'];
12816
15126
  const HTMLObjectElementProtoBlockedProperties$LWS = ['getSVGDocument'];
12817
15127
  const HTMLScriptElementBlockedAttributes$LWS = ['nonce'];
12818
15128
  const HTMLScriptElementProtoBlockedProperties$LWS = ['nonce'];
15129
+
15130
+ // `originalPolicy` serializes the page's full Content-Security-Policy text,
15131
+ // including any `script-src 'nonce-...'` source expression. A sandboxed
15132
+ // listener that reads it can lift the live CSP nonce and forge markup the
15133
+ // page's CSP would otherwise reject. Block the read so the nonce cannot leak
15134
+ // through a SecurityPolicyViolationEvent, complementing the already-blocked
15135
+ // `nonce` attribute/property and the ReportingObserver lockdown.
15136
+ const SecurityPolicyViolationEventProtoBlockedProperties$LWS = ['originalPolicy'];
12819
15137
  const SVGElementBlockedAttributes$LWS = ['nonce'];
12820
15138
  const SVGElementProtoBlockedProperties$LWS = ['nonce'];
12821
15139
  const UIEventProtoBlockedProperties$LWS = ['rangeParent'];
12822
15140
  const WindowBlockedProperties$LWS = ['find', 'requestFileSystem', 'webkitRequestFileSystem'];
12823
15141
  const XSLTProcessorProtoBlockedProperties$LWS = ['transformToDocument', 'transformToFragment'];
12824
- /*! version: 0.28.7 */
15142
+ /*! version: 0.29.1 */
12825
15143
 
12826
15144
  /*!
12827
15145
  * Copyright (C) 2021 salesforce.com, inc.
@@ -12830,7 +15148,7 @@
12830
15148
  function getPdpSchema$LWS() {
12831
15149
  return pdpSchema$LWS;
12832
15150
  }
12833
- /*! version: 0.28.7 */
15151
+ /*! version: 0.29.1 */
12834
15152
 
12835
15153
  /*!
12836
15154
  * Copyright (C) 2019 salesforce.com, inc.
@@ -13081,6 +15399,7 @@
13081
15399
  Element: Element$LWS,
13082
15400
  Event: Event$LWS,
13083
15401
  HTMLElement: HTMLElement$LWS,
15402
+ HTMLFrameElement: HTMLFrameElement$LWS,
13084
15403
  HTMLIFrameElement: HTMLIFrameElement$LWS,
13085
15404
  HTMLScriptElement: HTMLScriptElement$LWS,
13086
15405
  SVGElement: SVGElement$LWS,
@@ -13091,9 +15410,16 @@
13091
15410
  // instanbul ignore next: coverage is collected on the external sandbox test run
13092
15411
  ArrayConcat$LWS(internalDistortionFactoryInitializers$LWS, internalKeyedDistortionFactoryInitializers$LWS) : ArrayConcat$LWS(externalDistortionFactoryInitializers$LWS, externalKeyedDistortionFactoryInitializers$LWS);
13093
15412
  addBlockedAttributeSetterDistortionFactoryInitializers$LWS(HTMLElement$LWS, 'HTMLElement', HTMLElementBlockedAttributes$LWS, initializers$LWS);
13094
- addBlockedAttributeSetterDistortionFactoryInitializers$LWS(HTMLEmbedElement, 'HTMLEmbedElement', HTMLEmbedElementBlockedAttributes$LWS, initializers$LWS);
13095
- addBlockedAttributeSetterDistortionFactoryInitializers$LWS(HTMLIFrameElement$LWS, 'HTMLIFrameElement', HTMLIFrameElementBlockedAttributes$LWS, initializers$LWS);
13096
- addBlockedAttributeSetterDistortionFactoryInitializers$LWS(HTMLScriptElement$LWS, 'HTMLScriptElement', HTMLScriptElementBlockedAttributes$LWS, initializers$LWS);
15413
+ addBlockedAttributeSetterDistortionFactoryInitializers$LWS(HTMLEmbedElement, 'HTMLEmbedElement', HTMLEmbedElementBlockedAttributes$LWS, initializers$LWS, 'embed');
15414
+ addBlockedAttributeSetterDistortionFactoryInitializers$LWS(HTMLIFrameElement$LWS, 'HTMLIFrameElement', HTMLIFrameElementBlockedAttributes$LWS, initializers$LWS, 'iframe');
15415
+ // A legacy `<frame>` is an HTMLFrameElement (sibling of HTMLIFrameElement),
15416
+ // never `instanceof HTMLIFrameElement`, so the iframe `srcdoc` block above
15417
+ // does not cover it. Without this, `setAttribute('srcdoc', ...)` on a
15418
+ // `<frame>` reparses into an unmembraned same-origin browsing context.
15419
+ if (isGaterEnabledFeature$LWS('changesSince.266')) {
15420
+ addBlockedAttributeSetterDistortionFactoryInitializers$LWS(HTMLFrameElement$LWS, 'HTMLFrameElement', HTMLFrameElementBlockedAttributes$LWS, initializers$LWS);
15421
+ }
15422
+ addBlockedAttributeSetterDistortionFactoryInitializers$LWS(HTMLScriptElement$LWS, 'HTMLScriptElement', HTMLScriptElementBlockedAttributes$LWS, initializers$LWS, 'script');
13097
15423
  addBlockedAttributeSetterDistortionFactoryInitializers$LWS(SVGElement$LWS, 'SVGElement', SVGElementBlockedAttributes$LWS, initializers$LWS);
13098
15424
  // Read-side block list: only the subset of write-blocked attributes that
13099
15425
  // ALSO must not be readable. Today this is `nonce` only; attributes like
@@ -13117,6 +15443,11 @@
13117
15443
  addBlockedPropertyDistortionFactoryInitializers$LWS(record$LWS, HTMLScriptElement$LWS.prototype, HTMLScriptElementProtoBlockedProperties$LWS, initializers$LWS);
13118
15444
  addBlockedPropertyDistortionFactoryInitializers$LWS(record$LWS, SVGElement$LWS.prototype, SVGElementProtoBlockedProperties$LWS, initializers$LWS);
13119
15445
  addBlockedPropertyDistortionFactoryInitializers$LWS(record$LWS, UIEvent$LWS.prototype, UIEventProtoBlockedProperties$LWS, initializers$LWS);
15446
+ // istanbul ignore else: SecurityPolicyViolationEvent is not implemented in
15447
+ // every engine (e.g. jsdom), so guard on its presence like XSLTProcessor below.
15448
+ if (isGaterEnabledFeature$LWS('changesSince.266') && typeof SecurityPolicyViolationEvent === 'function') {
15449
+ addBlockedPropertyDistortionFactoryInitializers$LWS(record$LWS, SecurityPolicyViolationEvent.prototype, SecurityPolicyViolationEventProtoBlockedProperties$LWS, initializers$LWS);
15450
+ }
13120
15451
  addBlockedPropertyDistortionFactoryInitializers$LWS(record$LWS, globalObject$LWS, WindowBlockedProperties$LWS, initializers$LWS);
13121
15452
  // istanbul ignore else: this is a safety precaution that is unreachable via tests
13122
15453
  if (typeof XSLTProcessor$LWS === 'function') {
@@ -14968,22 +17299,40 @@
14968
17299
  const thisArgOrNewTarget$LWS = isApplyTrap$LWS ? thisArgOrArgs$LWS : argsOrNewTarget$LWS;
14969
17300
  let combinedOffset$LWS = 2;
14970
17301
  const combinedArgs$LWS = new ArrayCtor$LWS(length$LWS + combinedOffset$LWS);
14971
- combinedArgs$LWS[0] = foreignTargetPointer$LWS;
17302
+ // Use `[[DefineOwnProperty]]` (via `ReflectDefineProperty`) rather than
17303
+ // `[[Set]]` (`combinedArgs[i] = value`) to populate the combined arguments.
17304
+ // A plain array still inherits from `Array.prototype`, so a `[[Set]]` on a
17305
+ // numeric index would invoke an inherited accessor if sandboxed code has
17306
+ // installed one (e.g. `Object.defineProperty(Array.prototype, '2', { set })`).
17307
+ // Such a setter can observe and overwrite the pointers marshalled here —
17308
+ // including `combinedArgs[0]`, the foreign target pointer — redirecting the
17309
+ // call to a different foreign callable. Defining own data properties bypasses
17310
+ // the prototype chain entirely and is immune to prototype pollution.
17311
+ ReflectDefineProperty$LWS(combinedArgs$LWS, 0, {
17312
+ __proto__: null,
17313
+ value: foreignTargetPointer$LWS
17314
+ });
14972
17315
  let pointerOrPrimitive$LWS;
14973
17316
  try {
14974
- combinedArgs$LWS[1] = typeof thisArgOrNewTarget$LWS === 'object' && thisArgOrNewTarget$LWS !== null || typeof thisArgOrNewTarget$LWS === 'function' ? getTransferablePointer$LWS(thisArgOrNewTarget$LWS) :
14975
- // Intentionally ignoring `document.all`.
14976
- // https://developer.mozilla.org/en-US/docs/Web/API/Document/all
14977
- // https://tc39.es/ecma262/#sec-IsHTMLDDA-internal-slot
14978
- typeof thisArgOrNewTarget$LWS === 'undefined' ? undefined : thisArgOrNewTarget$LWS;
14979
- for (let i$LWS = 0; i$LWS < length$LWS; i$LWS += 1) {
14980
- const arg$LWS = args$LWS[i$LWS];
14981
- // Inlining `getTransferableValue()`.
14982
- combinedArgs$LWS[combinedOffset$LWS++] = typeof arg$LWS === 'object' && arg$LWS !== null || typeof arg$LWS === 'function' ? getTransferablePointer$LWS(arg$LWS) :
17317
+ ReflectDefineProperty$LWS(combinedArgs$LWS, 1, {
17318
+ __proto__: null,
17319
+ value: typeof thisArgOrNewTarget$LWS === 'object' && thisArgOrNewTarget$LWS !== null || typeof thisArgOrNewTarget$LWS === 'function' ? getTransferablePointer$LWS(thisArgOrNewTarget$LWS) :
14983
17320
  // Intentionally ignoring `document.all`.
14984
17321
  // https://developer.mozilla.org/en-US/docs/Web/API/Document/all
14985
17322
  // https://tc39.es/ecma262/#sec-IsHTMLDDA-internal-slot
14986
- typeof arg$LWS === 'undefined' ? undefined : arg$LWS;
17323
+ typeof thisArgOrNewTarget$LWS === 'undefined' ? undefined : thisArgOrNewTarget$LWS
17324
+ });
17325
+ for (let i$LWS = 0; i$LWS < length$LWS; i$LWS += 1) {
17326
+ const arg$LWS = args$LWS[i$LWS];
17327
+ // Inlining `getTransferableValue()`.
17328
+ ReflectDefineProperty$LWS(combinedArgs$LWS, combinedOffset$LWS++, {
17329
+ __proto__: null,
17330
+ value: typeof arg$LWS === 'object' && arg$LWS !== null || typeof arg$LWS === 'function' ? getTransferablePointer$LWS(arg$LWS) :
17331
+ // Intentionally ignoring `document.all`.
17332
+ // https://developer.mozilla.org/en-US/docs/Web/API/Document/all
17333
+ // https://tc39.es/ecma262/#sec-IsHTMLDDA-internal-slot
17334
+ typeof arg$LWS === 'undefined' ? undefined : arg$LWS
17335
+ });
14987
17336
  }
14988
17337
  pointerOrPrimitive$LWS = ReflectApply$LWS(foreignCallableApplyOrConstruct$LWS, undefined, combinedArgs$LWS);
14989
17338
  } catch (error) {
@@ -15566,10 +17915,36 @@
15566
17915
  // Replace pending traps with live traps that can work with the
15567
17916
  // target without taking snapshots.
15568
17917
  this.deleteProperty = BoundaryProxyHandler$LWS.passthruDeletePropertyTrap;
15569
- this.defineProperty = BoundaryProxyHandler$LWS.passthruDefinePropertyTrap;
15570
17918
  this.preventExtensions = BoundaryProxyHandler$LWS.passthruPreventExtensionsTrap;
15571
17919
  this.set = BoundaryProxyHandler$LWS.passthruSetTrap;
15572
- this.setPrototypeOf = BoundaryProxyHandler$LWS.passthruSetPrototypeOfTrap;
17920
+ // `[[DefineOwnProperty]]` is passthru for DATA descriptors
17921
+ // (the expando capability live targets actually need) but
17922
+ // accessor descriptors are scoped to the shadow target. The
17923
+ // passthru variant calls `foreignCallableDefineProperty` on the
17924
+ // RAW foreign target; for an accessor that plants a
17925
+ // sandbox-authored getter/setter directly onto a host-shared
17926
+ // object. Because the descriptor's functions are marshalled as
17927
+ // pointers back into the sandbox, any later access from the
17928
+ // primary realm (a confused deputy reading the planted key)
17929
+ // would execute sandbox code with the RAW object as `this` and
17930
+ // read raw-global-only state through it. Data expandos carry no
17931
+ // such callback, so they remain passthru; only accessors are
17932
+ // contained. See `liveAccessorGuardedDefinePropertyTrap`.
17933
+ this.defineProperty = BoundaryProxyHandler$LWS.liveAccessorGuardedDefinePropertyTrap;
17934
+ // `[[SetPrototypeOf]]` is the one live trap we do not
17935
+ // passthru. The passthru variant calls `ReflectSetPrototypeOf`
17936
+ // on the RAW foreign target, which lets sandbox code splice a
17937
+ // foreign prototype (e.g. the primary-realm global) onto a live
17938
+ // target and then read foreign globals through inherited
17939
+ // lookups: live reads resolve against the RAW prototype chain
17940
+ // (`hybridGetTrap` -> `lookupForeignDescriptor`), never the
17941
+ // shadow target. It also lets sandbox code wipe a host-shared
17942
+ // object's prototype to `null`. Scoping the proto change to the
17943
+ // shadow target makes both observably inert while leaving
17944
+ // `set`/`deleteProperty` passthru (the capabilities live targets
17945
+ // actually need) untouched. No legitimate live target re-parents
17946
+ // itself across the membrane.
17947
+ this.setPrototypeOf = BoundaryProxyHandler$LWS.staticSetPrototypeOfTrap;
15573
17948
  } : noop$LWS;
15574
17949
  this.makeProxyStatic = IS_IN_SHADOW_REALM$LWS ? function () {
15575
17950
  // Reset all traps except apply and construct for static proxies
@@ -15921,6 +18296,25 @@
15921
18296
  if (IS_NOT_IN_SHADOW_REALM$LWS && (key$LWS === LOCKER_NEAR_MEMBRANE_SYMBOL$LWS || key$LWS === LOCKER_NEAR_MEMBRANE_SERIALIZED_VALUE_SYMBOL$LWS)) {
15922
18297
  throw new TypeErrorCtor$LWS(ERR_ILLEGAL_PROPERTY_ACCESS$LWS);
15923
18298
  }
18299
+ // `x.__proto__ = value` triggers the `Object.prototype.__proto__`
18300
+ // accessor, whose setter performs `[[SetPrototypeOf]]` on the
18301
+ // target. This is the live target's `set` trap, and its passthru
18302
+ // below would forward the write to the RAW foreign target,
18303
+ // running the raw realm's `__proto__` setter and reparenting the
18304
+ // raw object. That reintroduces the `setPrototypeOf` isolation
18305
+ // leak (W-23623814) through property-assignment syntax: a
18306
+ // subsequent inherited read would resolve foreign members
18307
+ // against the spliced prototype. Confine an own `__proto__`
18308
+ // write to the shadow target by delegating to `ReflectSet` on
18309
+ // it, exactly as static proxies do via `staticSetTrap`; the red
18310
+ // realm's own `__proto__` accessor then applies the correct
18311
+ // ordinary semantics (primitive no-op, Object/Null reparent)
18312
+ // scoped to the shadow target. A non-own write
18313
+ // (`proxy !== receiver`) targets the other receiver, not the
18314
+ // raw foreign target, so it is left to the passthru path.
18315
+ if (IS_IN_SHADOW_REALM$LWS && key$LWS === '__proto__' && proxy$LWS === receiver$LWS) {
18316
+ return ReflectSet$LWS(shadowTarget$LWS, key$LWS, value$LWS, shadowTarget$LWS);
18317
+ }
15924
18318
  const isFastPath$LWS = proxy$LWS === receiver$LWS;
15925
18319
  let result$LWS = false;
15926
18320
  try {
@@ -16155,6 +18549,76 @@
16155
18549
  }
16156
18550
  return result$LWS;
16157
18551
  } : alwaysFalse$LWS;
18552
+ // `[[DefineOwnProperty]]` trap for LIVE targets. Data descriptors are the
18553
+ // expando capability live targets rely on and stay passthru to the RAW
18554
+ // foreign target via `passthruDefinePropertyTrap`. Accessor descriptors
18555
+ // (a `get` and/or `set`), however, would install sandbox-authored
18556
+ // functions onto a host-shared object; a subsequent access from the
18557
+ // primary realm would run that sandbox code with the RAW target as
18558
+ // receiver and expose raw-global-only state. We contain accessors on the
18559
+ // inert shadow target instead. This mirrors the `staticSetPrototypeOfTrap`
18560
+ // contract: the operation is observably inert from every side. A live
18561
+ // `get` resolves against the RAW foreign target (`lookupForeignDescriptor`
18562
+ // reads the raw own descriptor and walks the RAW prototype chain; it only
18563
+ // ever writes the shadow target, never reads its own properties), so the
18564
+ // sandbox reads back `undefined` for a shadow-scoped accessor too. The
18565
+ // security-relevant guarantee is that no sandbox-authored callback ever
18566
+ // reaches the raw host-shared object.
18567
+ //
18568
+ // The shadow-scoped copy is always written with `configurable: true`,
18569
+ // regardless of what the sandbox asked for. A live proxy's `has`,
18570
+ // `ownKeys`, and `getOwnPropertyDescriptor` traps are NOT overridden by
18571
+ // `makeProxyLive()` (see `hybridHasTrap`, `passthruOwnKeysTrap`,
18572
+ // `passthruGetOwnPropertyDescriptorTrap`): they all resolve against the
18573
+ // RAW foreign target and never consult the shadow target's own
18574
+ // properties. `Object.defineProperty` defaults `configurable` to
18575
+ // `false`, so the common `{ get() {...} }` shape would otherwise leave
18576
+ // the shadow target — the proxy's actual `[[ProxyTarget]]` — holding a
18577
+ // NON-CONFIGURABLE own key that those raw-resolving traps can never
18578
+ // mirror. The engine's proxy invariants then throw on the very next
18579
+ // `has`/`ownKeys`/`getOwnPropertyDescriptor` (`in`, `Object.keys`,
18580
+ // spread, `JSON.stringify`, `Object.getOwnPropertyDescriptor`, ...)
18581
+ // because a non-configurable target key must be reported by those traps
18582
+ // and it never can be. Since the accessor is invisible through the
18583
+ // proxy either way (reads resolve against the raw target), forcing
18584
+ // `configurable: true` is not observable to the sandbox, and it keeps
18585
+ // every read-side invariant satisfiable. An explicit `configurable:
18586
+ // false` request cannot be honored while preserving that invisibility;
18587
+ // it now fails fast with a native TypeError raised by the engine's own
18588
+ // `defineProperty` trap-result invariant check (requested
18589
+ // non-configurable vs. an actually-configurable target descriptor) at
18590
+ // the `defineProperty` call site itself, rather than deferring the
18591
+ // detonation to a later, unrelated read.
18592
+ BoundaryProxyHandler$LWS.liveAccessorGuardedDefinePropertyTrap = IS_IN_SHADOW_REALM$LWS ? function (shadowTarget$LWS, key$LWS, unsafePartialDesc$LWS) {
18593
+ // A descriptor is an accessor iff it carries a `get` or `set`.
18594
+ // Read membership before detaching the prototype so a poisoned
18595
+ // `Object.prototype` getter cannot forge the answer.
18596
+ const isAccessorDescriptor$LWS = 'get' in unsafePartialDesc$LWS || 'set' in unsafePartialDesc$LWS;
18597
+ if (isAccessorDescriptor$LWS) {
18598
+ lastProxyTrapCalled$LWS = 4 /* ProxyHandlerTraps.DefineProperty */;
18599
+ // Build a fresh descriptor rather than writing the
18600
+ // sandbox's `unsafePartialDesc` object directly, and
18601
+ // force `configurable: true` on the shadow-scoped copy
18602
+ // (see the block comment above).
18603
+ const shadowDesc$LWS = {
18604
+ __proto__: null
18605
+ };
18606
+ if ('get' in unsafePartialDesc$LWS) {
18607
+ shadowDesc$LWS.get = unsafePartialDesc$LWS.get;
18608
+ }
18609
+ if ('set' in unsafePartialDesc$LWS) {
18610
+ shadowDesc$LWS.set = unsafePartialDesc$LWS.set;
18611
+ }
18612
+ if ('enumerable' in unsafePartialDesc$LWS) {
18613
+ shadowDesc$LWS.enumerable = unsafePartialDesc$LWS.enumerable;
18614
+ }
18615
+ shadowDesc$LWS.configurable = true;
18616
+ // Scope the accessor to the shadow target: observably
18617
+ // defined for the sandbox, never planted on the raw object.
18618
+ return ReflectDefineProperty$LWS(shadowTarget$LWS, key$LWS, shadowDesc$LWS);
18619
+ }
18620
+ return ReflectApply$LWS(BoundaryProxyHandler$LWS.passthruDefinePropertyTrap, this, [shadowTarget$LWS, key$LWS, unsafePartialDesc$LWS]);
18621
+ } : alwaysFalse$LWS;
16158
18622
  BoundaryProxyHandler$LWS.passthruGetTrap = IS_NOT_IN_SHADOW_REALM$LWS ? function (_shadowTarget$LWS, key$LWS, receiver$LWS) {
16159
18623
  // Only allow accessing handshake property values if the
16160
18624
  // "has" trap has been triggered immediately BEFORE and
@@ -16455,7 +18919,17 @@
16455
18919
  const pointerOrPrimitive$LWS = args$LWS[i$LWS];
16456
18920
  if (typeof pointerOrPrimitive$LWS === 'function') {
16457
18921
  pointerOrPrimitive$LWS();
16458
- args$LWS[i$LWS] = selectedTarget$LWS;
18922
+ // Use `[[DefineOwnProperty]]` rather than `[[Set]]` (`args[i] = ...`).
18923
+ // `args` is a rest-parameter array that still inherits from
18924
+ // `Array.prototype`, so a plain assignment to a numeric index would
18925
+ // invoke an inherited accessor installed by sandboxed code (e.g.
18926
+ // `Object.defineProperty(Array.prototype, '2', { set })`). Such a
18927
+ // setter could observe and overwrite the un-marshalled arguments
18928
+ // before they reach the target function. See W-23789302.
18929
+ ReflectDefineProperty$LWS(args$LWS, i$LWS, {
18930
+ __proto__: null,
18931
+ value: selectedTarget$LWS
18932
+ });
16459
18933
  selectedTarget$LWS = undefined;
16460
18934
  }
16461
18935
  }
@@ -18212,6 +20686,163 @@
18212
20686
  return loadPromise$LWS(link$LWS, urlResolved$LWS);
18213
20687
  }];
18214
20688
  }
20689
+
20690
+ // Red-realm bootstrap overrides.
20691
+ //
20692
+ // Each export in this module is a self-contained source-text string that is
20693
+ // evaluated in the sandbox (red) realm via `virtualEnvironment.evaluate(...)`
20694
+ // from `record.ts`, immediately after `EVAL_HELPERS_SOURCE_TEXT` and before any
20695
+ // user code runs. Evaluating in the red realm is what lets these overrides
20696
+ // reassign the sandbox's OWN intrinsics (e.g. `Reflect.construct`) — bindings a
20697
+ // blue-side distortion can never see, because the sandbox's own intrinsics never
20698
+ // cross the membrane.
20699
+ //
20700
+ // Conventions for anything added here:
20701
+ // - Use only direct `===` comparisons and bootstrap-captured native references.
20702
+ // Never call a method (`.includes`, `.indexOf`, ...) that sandboxed code could
20703
+ // monkeypatch after the override installs.
20704
+ // - Throw a plain `TypeError`. `LockerSecurityError` is a blue-realm class and is
20705
+ // not lexically available in this red-realm source text; the containment is
20706
+ // that the offending operation never completes, not the error type or its
20707
+ // catchability.
20708
+ // - Keep each override independently gated at its `virtualEnvironment.evaluate`
20709
+ // call site in `record.ts`.
20710
+ // W-23552771: contain the window-prototype construct pivot.
20711
+ //
20712
+ // Inside the sandbox, `window.$A` (Aura) is `undefined` — the red (iframe) window
20713
+ // does not carry `$A`, so there is no direct route to it. The reported PoC reaches
20714
+ // it anyway:
20715
+ //
20716
+ // function C() {}
20717
+ // C.prototype = window;
20718
+ // Reflect.construct(Event, [0], C).$A.util.copy(document).cookie;
20719
+ //
20720
+ // Feeding a `newTarget` whose `.prototype` is the sandbox window into a DOM
20721
+ // constructor's [[Construct]] yields an object whose property lookups resolve
20722
+ // against the BLUE window — where `$A` actually lives. The construct pivot is
20723
+ // therefore a blue-window-reach primitive, not obfuscation: `$A.util.copy(...)`
20724
+ // is merely what the attacker does once the blue window is in hand. Because the
20725
+ // direct read (`window.$A`) is already dead, this pivot is the sole doorway, and
20726
+ // rejecting a `newTarget.prototype` that is the sandbox window (or globalThis)
20727
+ // closes it.
20728
+ //
20729
+ // The sandbox's own `Reflect.construct` is red-native and never crosses the
20730
+ // membrane, so a distortion cannot intercept it; overriding the red global at
20731
+ // bootstrap is the only place this can be done. near-membrane captured
20732
+ // `Reflect.construct` into a const at connector-init, so the membrane's internal
20733
+ // construct-forwarding is unaffected — only sandboxed code that resolves
20734
+ // `Reflect.construct` from the red global sees this guard.
20735
+ const OVERRIDE_REFLECT_CONSTRUCT$LWS = `'use strict';
20736
+ (function () {
20737
+ const nativeConstruct = Reflect.construct;
20738
+ const nativeGetPrototypeOf = Object.getPrototypeOf;
20739
+ const nativeGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
20740
+ const nativeReflectGet = Reflect.get;
20741
+ const ProxyCtor = Proxy;
20742
+ const sandboxGlobalThis = globalThis;
20743
+ const sandboxWindow = typeof window === 'undefined' ? sandboxGlobalThis : window;
20744
+ // Bound the prototype-chain walk so a newTarget.prototype that is (or is a
20745
+ // Proxy exposing) a pathological [[GetPrototypeOf]] cannot spin the guard.
20746
+ const MAX_PROTO_CHAIN_DEPTH = 100;
20747
+ Reflect.construct = function construct(target, argumentsList, newTarget) {
20748
+ if (arguments.length > 2) {
20749
+ if (typeof newTarget === 'function') {
20750
+ // Read newTarget.prototype EXACTLY ONCE into a snapshot. Native
20751
+ // [[Construct]] below reads it a SECOND time to seat the new
20752
+ // object's [[Prototype]] -- and a callable Proxy newTarget (or an
20753
+ // accessor .prototype) can answer this validation read with a
20754
+ // benign object and that construction read with the sandbox window
20755
+ // (a TOCTOU), passing the guard while still seating the window. A
20756
+ // post-construction check is no defense either: a base
20757
+ // constructor's this-value is created from newTarget.prototype
20758
+ // BEFORE the constructor body runs, so attacker-controlled target
20759
+ // code can capture the poisoned this-value the instant it is
20760
+ // seated. The snapshot is validated below, then construction either
20761
+ // passes the ORIGINAL newTarget through (only when the engine
20762
+ // itself guarantees native's second read cannot diverge) or pins
20763
+ // this snapshot through a wrapper for every other newTarget.
20764
+ const prototype = newTarget.prototype;
20765
+ // Reject if the sandbox window (or globalThis) is the snapshot OR
20766
+ // appears anywhere on its prototype chain. An object that merely
20767
+ // inherits from the window (e.g. Object.create(window)) is a
20768
+ // distinct identity but preserves the same blue-window reach
20769
+ // through the new object's [[Prototype]], so an identity-only
20770
+ // check would let the pivot through. Reachability, not identity,
20771
+ // is the invariant.
20772
+ let cursor = prototype;
20773
+ let depth = 0;
20774
+ while (
20775
+ cursor !== null &&
20776
+ (typeof cursor === 'object' || typeof cursor === 'function') &&
20777
+ depth < MAX_PROTO_CHAIN_DEPTH
20778
+ ) {
20779
+ if (cursor === sandboxGlobalThis || cursor === sandboxWindow) {
20780
+ throw new TypeError(
20781
+ 'Reflect.construct: newTarget.prototype must not reach the sandbox window.'
20782
+ );
20783
+ }
20784
+ cursor = nativeGetPrototypeOf(cursor);
20785
+ depth += 1;
20786
+ }
20787
+ // Decide whether native's SECOND read is forced -- by the engine's
20788
+ // own Proxy [[Get]] invariant -- to equal this validated snapshot.
20789
+ // That holds exactly when newTarget.prototype is an own DATA
20790
+ // property that is non-configurable AND non-writable. For such a
20791
+ // property a Proxy get trap may not return anything other than the
20792
+ // real value (it throws instead), and a getOwnPropertyDescriptor
20793
+ // trap may not even claim those attributes unless the underlying
20794
+ // target genuinely has them. So a real class or a native
20795
+ // constructor -- and essentially only those -- can present this
20796
+ // shape, and native's re-read provably cannot diverge. Hand native
20797
+ // the ORIGINAL newTarget untouched: new.target inside the
20798
+ // constructor stays the caller-supplied constructor and native's
20799
+ // own error text is unchanged (this is why HTMLElement still
20800
+ // reports the bare Illegal constructor).
20801
+ const prototypeDescriptor = nativeGetOwnPropertyDescriptor(
20802
+ newTarget,
20803
+ 'prototype'
20804
+ );
20805
+ if (
20806
+ prototypeDescriptor !== undefined &&
20807
+ 'value' in prototypeDescriptor &&
20808
+ prototypeDescriptor.value === prototype &&
20809
+ prototypeDescriptor.writable === false &&
20810
+ prototypeDescriptor.configurable === false
20811
+ ) {
20812
+ return nativeConstruct(target, argumentsList, newTarget);
20813
+ }
20814
+ // Otherwise native's second read is NOT forced to match: a writable
20815
+ // data .prototype, an accessor .prototype, a Proxy get trap, or no
20816
+ // own .prototype at all (a bound constructor) each let native read
20817
+ // a value that diverges from the validated snapshot. A dual-trap
20818
+ // Proxy exploits precisely this: a forwarded descriptor shows a
20819
+ // benign writable data property while the get trap answers native
20820
+ // with the window. Pin the snapshot by constructing through a
20821
+ // wrapper whose only intercept is the prototype read; every other
20822
+ // operation forwards untouched, so [[Construct]] presence, argument
20823
+ // handling, and the realm-default-prototype fallback for a missing
20824
+ // or non-object .prototype (the benign bound-constructor path) are
20825
+ // all preserved. new.target is the wrapper for these dynamic cases,
20826
+ // which is the necessary cost of containing an attacker-controlled
20827
+ // re-read; the common class and native-constructor cases keep their
20828
+ // identity through the pass-through branch above.
20829
+ const pinnedNewTarget = new ProxyCtor(newTarget, {
20830
+ get(pinnedTarget, key, receiver) {
20831
+ if (key === 'prototype') {
20832
+ return prototype;
20833
+ }
20834
+ return nativeReflectGet(pinnedTarget, key, receiver);
20835
+ }
20836
+ });
20837
+ return nativeConstruct(target, argumentsList, pinnedNewTarget);
20838
+ }
20839
+ // newTarget supplied but not callable: defer to native, which throws
20840
+ // because newTarget must be a constructor. Preserves spec semantics.
20841
+ return nativeConstruct(target, argumentsList, newTarget);
20842
+ }
20843
+ return nativeConstruct(target, argumentsList);
20844
+ };
20845
+ }());`;
18215
20846
  function toSourceText$LWS(value$LWS, sourceType$LWS) {
18216
20847
  let sourceText$LWS = typeof value$LWS === 'function' ? extractFunctionBodySource$LWS(value$LWS) : toSafeStringValue$LWS(value$LWS);
18217
20848
  // We workaround bundlers, like Rollup, aggressively stripping inline source
@@ -18222,7 +20853,7 @@
18222
20853
  // tools from mistaking the regexp or the replacement string for an
18223
20854
  // actual source mapping URL.
18224
20855
  /\/\/# sandbox(?=MappingURL=.*?\s*$)/, '//# source']);
18225
- sourceText$LWS = `\n//# LWS Version = "0.28.7"\n${sourceText$LWS}`;
20856
+ sourceText$LWS = `\n//# LWS Version = "0.29.1"\n${sourceText$LWS}`;
18226
20857
  return sourceType$LWS === 1 /* SourceType.Module */ && indexOfPragma$LWS(sourceText$LWS, 'use strict') === -1 ?
18227
20858
  // Append "'use strict'" to the extracted function body so it is
18228
20859
  // evaluated in strict mode.
@@ -18244,6 +20875,15 @@
18244
20875
  // causing the check to bail out and the DOMContentLoaded listener to never be
18245
20876
  // attached.
18246
20877
  const childWindowDocuments$LWS = toSafeMap$LWS$1(new MapCtor$LWS$1());
20878
+ // Sentinel "last document" recorded in childWindowDocuments for opaque child
20879
+ // windows whose real document cannot be read (cross-origin access throws). It
20880
+ // is a fresh object identity, so it is guaranteed distinct from any real
20881
+ // Document. The first same-origin document observed after an
20882
+ // opaque→same-origin transition therefore fails the `currentDoc !==
20883
+ // lastDocument` check in distortionCallback, causing a fresh secondary record
20884
+ // to be created for the new realm before its raw built-ins can be handed to
20885
+ // sandboxed code.
20886
+ const OPAQUE_CHILD_WINDOW_DOCUMENT_SENTINEL$LWS = {};
18247
20887
  function createGetVirtualEnvironment$LWS(record$LWS) {
18248
20888
  let virtualEnvironment$LWS;
18249
20889
  return () => {
@@ -18269,6 +20909,13 @@
18269
20909
  setEvalHelpers$LWS(helpers$LWS);
18270
20910
  });
18271
20911
  virtualEnvironment$LWS.evaluate(EVAL_HELPERS_SOURCE_TEXT$LWS);
20912
+ // W-23552771: install red-realm bootstrap overrides now that the
20913
+ // eval helpers are in place and before any user code runs. Each
20914
+ // override is independently gated here in the blue realm, where the
20915
+ // gater is available (the red-realm source text cannot see it).
20916
+ if (isGaterEnabledFeature$LWS('changesSince.266')) {
20917
+ virtualEnvironment$LWS.evaluate(OVERRIDE_REFLECT_CONSTRUCT$LWS);
20918
+ }
18272
20919
  if (typeof context$LWS === 'object' && context$LWS !== null) {
18273
20920
  // Track the `context` object and its properties as a fast
18274
20921
  // targets because it may contain things like `blueGet` and
@@ -18391,6 +21038,13 @@
18391
21038
  // map with entries for the new realm's objects so the
18392
21039
  // re-lookup below can succeed.
18393
21040
  if (isGaterEnabledFeature$LWS('changesSince.262') && childWindowDocuments$LWS.size > 0) {
21041
+ // `lastDocument` is typed Document but may be
21042
+ // OPAQUE_CHILD_WINDOW_DOCUMENT_SENTINEL (a fresh `{}` cast to
21043
+ // Document) for an opaque child window whose real document
21044
+ // could not be read. It is a type-lie: only ever compare it
21045
+ // by identity (below); never read a property off it, or a
21046
+ // sentinel entry would fault instead of tripping the swap
21047
+ // check. See createOpaqueSecondaryWindowSandboxRecord.
18394
21048
  for (const [childGlobalObject$LWS, lastDocument$LWS] of childWindowDocuments$LWS) {
18395
21049
  // Only process child windows belonging to this
18396
21050
  // sandbox (each sandbox has its own distortion map).
@@ -18628,6 +21282,31 @@
18628
21282
  if (!seenGlobalObjects$LWS.has(globalObject$LWS)) {
18629
21283
  distortions$LWS.set(globalObject$LWS, globalObject$LWS);
18630
21284
  }
21285
+ // W-23475955: Track this opaque child window for document-swap detection,
21286
+ // mirroring the same-origin path in createSecondaryWindowSandboxRecord.
21287
+ // Without this, an opaque→same-origin transition (a cross-origin/opaque
21288
+ // browsing context later navigated to a same-origin document) is invisible
21289
+ // to the swap-detection loop in distortionCallback, which only walks
21290
+ // windows present in childWindowDocuments. The near-membrane caches the
21291
+ // WindowProxy's proxy pointer, so distortionCallback is never re-invoked
21292
+ // for the WindowProxy itself; the loop is the mechanism that eagerly
21293
+ // creates a secondary record for the new realm before its undistorted
21294
+ // built-ins can be reached. The opaque document is unreadable
21295
+ // (cross-origin access throws), so a sentinel is stored; the first
21296
+ // same-origin document observed after the transition differs from it and
21297
+ // trips the loop. The globalObject is not added to seenGlobalObjects here
21298
+ // so that, upon transition, createSecondaryWindowSandboxRecord still wires
21299
+ // up event-based navigation detection for the now-same-origin realm.
21300
+ //
21301
+ // Note on map growth: childWindowDocuments is a strong Map with no delete
21302
+ // path (pre-existing since the same-origin producer below, added in #2078).
21303
+ // This line adds one more producer of entries and inherits that same
21304
+ // characteristic — it does not change the growth profile. Bounding the map
21305
+ // is a separate, cross-cutting concern that also covers the same-origin
21306
+ // producer and is out of scope for this record-tracking fix.
21307
+ if (isGaterEnabledFeature$LWS('changesSince.266')) {
21308
+ childWindowDocuments$LWS.set(globalObject$LWS, OPAQUE_CHILD_WINDOW_DOCUMENT_SENTINEL$LWS);
21309
+ }
18631
21310
  // Add opaque window postMessage distortion for the child window to the root
18632
21311
  // window's distortion map.
18633
21312
  const opaqueWindowPostMessageDistortionFactory$LWS = getOpaqueWindowPostMessageDistortionFactory$LWS(record$LWS);
@@ -18902,7 +21581,19 @@
18902
21581
  }
18903
21582
  toSafeMap$LWS$1(new MapCtor$LWS$1());
18904
21583
  toSafeSet$LWS(new SetCtor$LWS$1(['lightning/platformResourceLoader', 'lightning:platformResourceLoader', 'lightningmobileruntime/platformResourceLoader', 'lightningmobileruntime:platformResourceLoader']));
18905
- /*! version: 0.28.7 */
21584
+ // The case-folded forms of every entry in `lprDepNames` above (kept 1:1 with
21585
+ // that set). The dynamic module resolver can hand LWS a dependency name whose
21586
+ // casing differs from the exact strings above (e.g.
21587
+ // 'lightning/PlatformResourceLoader'). A case-variant name misses the exact
21588
+ // `lprDepNames.has` check and would otherwise fall through to `return dep` —
21589
+ // handing out the raw platformResourceLoader, whose `loadScript` appends a
21590
+ // <script> to the host document with no sandboxing (a native host-realm
21591
+ // script-injection primitive). Matching a lower-cased, whitespace-trimmed copy
21592
+ // of the incoming name against these canonical keys collapses every case and
21593
+ // surrounding-whitespace variant of the two known separators back onto the
21594
+ // sandbox-scoped facade.
21595
+ toSafeSet$LWS(new SetCtor$LWS$1(['lightning/platformresourceloader', 'lightning:platformresourceloader', 'lightningmobileruntime/platformresourceloader', 'lightningmobileruntime:platformresourceloader']));
21596
+ /*! version: 0.29.1 */
18906
21597
 
18907
21598
  // Expose evaluateInSandbox on the window global so the browser harness page
18908
21599
  // (eval.html / component.html) can invoke it against source delivered by the