Skip to content

Custom native elements skip attribute validation, and a prop named __proto__ then diverges between the lynx and universal encodings #71

Open

Description

@Huxpro

Found by an adversarial audit of the #58 L0–L3 equivalence claims, against the #65 stack head 2fe14465f. Counterexample to the #63 claim that "a module compiled under target: 'lynx' renders a first-screen batch deep-equal to the target: 'universal' encoding".

There are two defects here; the first is what makes the second reachable.

1. Attribute validation is skipped entirely for custom elements

packages/octane/src/compiler/compile-universal.js:1817:

if (isHost && hostProps !== undefined && Object.hasOwn(hostProps, name)) {
  // ...renderer attribute allowlist enforced HERE ONLY
}

The allowlist is consulted only for tags present in the renderer's own hostProps map — the ten declared Lynx intrinsics (view, text, image, scroll-view, …). Every tag outside that map, i.e. every custom native element declared through the documented LynxCustomIntrinsicElements augmentation (packages/lynx/README.md, example at packages/lynx/examples/native-capabilities/src/native-capabilities.d.ts), skips attribute validation wholesale.

Demonstrated by contrast, both executed:

source result
<view __proto__={x} /> rejected: renderer "lynx" does not allow static attribute "__proto__" on <view>
<octane-badge __proto__={x} /> compiles

2. The two encodings then disagree on what that prop means

  • TEMPLATE_ENV.p writes props with a raw assignment, packages/lynx/src/main-renderer.ts:720. For the name __proto__ that is an Object.prototype accessor call: it mutates the record's [[Prototype]] and creates no own key.
  • renderPlanNode builds the same poisoned object, but reads props.children through the poisoned prototype chain at packages/lynx/src/main-renderer.ts:802 — before hostNode launders it with {...rawProps} at :643.

The asymmetry is precise: children is read pre-spread and so is inherited; key and ref are read post-spread and so are not. One inherited key becomes a real host node, the others silently vanish.

Reproduction

Committed as a red test on claude/octane-issue-58-adversarial-audit (f70f46aa3):
packages/octane/tests/lynx-target-template-equivalence.test.ts → renders the same batch when a custom element carries an inherited prop name

With props.spec = { children: 'hijacked' }:

[lynx=TEMPLATE]   hostCount=1  batch = create x-panel | insert
                  props [[Prototype]] = POISONED {"children":"hijacked",...}
[universal=PLAN]  hostCount=2  batch = create x-panel | create #text{value:"hijacked"} | insert | insert
                  props [[Prototype]] = Object.prototype

Also reproduces at the bare descriptor ABI with no compiler involved, by pairing a kind:'host' plan carrying a __proto__ binding against the kind:'template' create program the backend emits for it.

Consumer impact

An app using a custom native element with a vendor-chosen attribute named __proto__ paints a different first screen depending only on the compiler target — an extra raw-text child under one encoding. hostCount, logicalCount, the batch, and the adoption snapshot node set all differ, so background adoption and mismatch repair see a different tree.

Likelihood is low: it needs that specific attribute name. Defect 1 is the broader concern — custom elements accept any attribute name unchecked, and __proto__ is simply the one with observable accessor behavior.

Notes for the fix

The committed test asserts only that the two encodings agree, so any consistent repair passes: make both paths use Object.defineProperty, or reject prototype-accessor names in lynxTemplateEligible and the plan binding loop alike. Extending attribute validation to custom elements would close the reachable path but leave the descriptor-ABI divergence.

Verification performed

Reproduced independently of the finding agent, at both the compile level and the descriptor-ABI level. The reachability question was contested between two finder agents — one reported __proto__ unreachable using a <view> fixture, which is correct for standard intrinsics — and resolved against the source at compile-universal.js:1817. Adversarial refuter panel had not yet adjudicated this candidate at time of filing.

Activity

  1. added
    bug
    on Aug 18, 2026
  2. Huxpro commented on Aug 18, 2026

    @Huxpro
    OwnerAuthor

    Adversarial panel result: survives, and the framing above understated it

    An adversarial refuter has since attempted to kill this candidate and failed on all four routes. Two corrections to the original report follow — one that strengthens the finding, several that narrow it.

    Correction 1 — this is not a cross-target artifact; it diverges inside the single shipped target

    The report above frames this as target: 'lynx' vs target: 'universal'. That understates it. lynxMainThreadRenderer ships target: 'lynx' (packages/lynx/src/config.ts:236), and lynxTemplateEligible is evaluated per plan root, recursively — so the interpreted plan encoding is emitted inside target: 'lynx' whenever any node in a plan carries key/ref/children/an event.

    Compiling one module under the single production target, with a ref on a sibling element, the whole plan falls back to the interpreted encoding and the same element materializes:

    {"op":"create","id":3,"type":"#text","props":{"value":"hijacked"}}
    

    while the template-encoded arm materializes no child at all for that element. Both encodings ship in the same production target and disagree with each other. The universal arm is a convenience for the differential harness, not a precondition for the bug.

    Correction 2 — narrower reachable shape than implied

    All executed:

    • The poison object must carry a children key. __proto__={{foo: 1}} is equivalent in hostCount, logicalCount, and batch; only the props record's [[Prototype]] differs (FOREIGN vs Object.prototype) — which the staged applier rejects and the direct applier ignores.
    • A static __proto__="poison" is equivalent — setting a non-object prototype is a silent no-op.
    • The spread route is not reachable: <x-foo {...JSON.parse('{"__proto__":{...}}')} /> is rejected — "main-thread render-only host spreads are unsupported because first-screen event and ref props must be statically named for callback erasure."
    • Standard declared tags are not reachable, confirming the compile-universal.js:1817 analysis: <view __proto__={...}> is rejected with "renderer "lynx" does not allow static attribute "proto" on <view>".
    • A control case (an ordinary attribute on the same custom tag) stays equivalent, so the harness is not manufacturing failures.

    Type-level reachability, checked properly

    With the augmentation shaped like the shipped example ('x-foo': LynxStandardProps & { label?: string }) the fixture is rejected — TS2322 Property '__proto__' does not exist on type .... But TypeScript accepts '__proto__'?: unknown as an interface member, and once an app declares it in its own LynxCustomIntrinsicElements, the fixture typechecks with zero errors under tsrx-tsc --noEmit with skipLibCheck: false.

    So the reachable shape is: an app-declared custom native element + a literal __proto__= attribute the app declared in its own augmentation + a dynamic object value carrying children. Narrow — but type-legal, and no layer downstream rejects it (applyLynxFirstScreenDirect checks only renderer id, version, and firstScreenTreeHasList).

    Not an intentional divergence

    Nothing in docs/differences-from-react.md or docs/lynx-specialized-target-l0.md mentions __proto__. The codebase treats it as a hazard class it guards systematically elsewhere — defineProtoProp (main-renderer.ts:275) used by assignSpread (:293) and universalProps (:311), plus guards in universal-core.ts, client-driver.ts, host-driver.ts, and a dozen sites in compile.js/compile-universal.js. The two sites that miss it — TEMPLATE_ENV.p (main-renderer.ts:720) and the renderPlanNode bindings loop (main-renderer.ts:799, reading props.children at :802 before hostNode's laundering spread at :643) — are gaps in an otherwise deliberate defense, not a declared divergence.

    Panel status

    1 of 3 refuters reported: not refuted, reproduced independently after discarding the original probe and rebuilding the differential harness from scratch. The remaining two panel slots had not reported when this was written.


    Generated by Claude Code

  3. Huxpro commented on Aug 18, 2026

    @Huxpro
    OwnerAuthor

    Correction: the causal attribution in this issue is inverted, and the offending line predates the stack

    A second adversarial refuter challenged this candidate's attribution and is correct. I have verified both of its load-bearing claims directly. The divergence is real and the red test stays valid, but the root cause and the owning PR named above are both wrong.

    The template path is the correct one; the plan path is the deviant

    packages/octane/src/universal-core.ts:3695 — the generic universal core that drives the background thread and every non-Lynx universal renderer — reads dynamic children behind an own-property guard:

    staticProps === null && hasOwnProp.call(props, 'children') ? props.children : undefined

    A prototype-inherited children is therefore invisible to it. One host, no ghost child. The refuter confirmed this by running the byte-equivalent host plan through createObjectContainer/createObjectDriver/createUniversalRoot with the same poison object, plus a positive control with an own children binding that does produce the child — so the absence is the guard working, not the plan being inert.

    TEMPLATE_ENV.p (main-renderer.ts:720), which this issue names as the root cause, produces exactly the core's answer. The deviant line is in the interpreted plan path:

    // packages/lynx/src/main-renderer.ts:802
    const dynamicChildren = props.children;   // bare prototype-chain read, no hasOwnProp guard

    It predates this stack

    $ git log -L 800,806:packages/lynx/src/main-renderer.ts
    f3c4781dd bench(lynx): gate the dual-thread commit wire cost against a changed-rows floor (#660)
    

    Nothing in #59→#63→#64→#65 touches that line. The owningPR: #63 and fileLine: main-renderer.ts:720 in the original report are both misattributed.

    What survives, and what changes

    Survives:

    • The equivalence break is real. The first refuter established (and I reproduced) that it occurs within the single shipped target 'lynx', because lynxTemplateEligible falls back per plan root — so a ref on a sibling puts both encodings in the same module, disagreeing. CLAIM 1 is still falsified.
    • The committed red test (packages/octane/tests/lynx-target-template-equivalence.test.ts) asserts only that the two encodings agree; it encodes no attribution and remains correctly red.
    • Defect 1 in the original report is untouched: custom native elements skip attribute validation entirely (compile-universal.js:1817 gates on Object.hasOwn(hostProps, name)). That remains a real, separate finding and is what makes any of this reachable.

    Changes:

    Panel status

    3 of 3 refuters have now reported on this candidate: two not refuted (independent reproduction; reachability confirmed through tsrx-tsc --noEmit), one refuted on attribution — which is what this comment records. The defect is not in dispute; its ownership was.

    I am leaving the issue open rather than closing it: main-renderer.ts:802 still needs the guard, and the custom-element validation gap still needs a decision. The title and body above should be read with this correction applied.


    Generated by Claude Code

  4. Huxpro commented on Aug 18, 2026

    @Huxpro
    OwnerAuthor

    Final panel result: two distinct defects here, and the second one is stack-introduced and crashes the first screen

    The previous comment corrected the attribution for the children half of this report. A third refuter then attacked the other half and could not kill it — and rebuilt it into a production-shaped end-to-end demonstration. Separating the two properly, because my earlier correction blurred them:

    Defect A — inherited children materializes an extra host

    Pre-existing, not this stack. Root cause is the unguarded const dynamicChildren = props.children at packages/lynx/src/main-renderer.ts:802, which lacks the hasOwnProp guard that universal-core.ts:3695 has. Introduced in f3c4781dd (octanejs#660). Fix belongs at :802. This is what the previous comment covers.

    Defect B — the template path leaves a foreign [[Prototype]] on the frozen props record, and the staged applier then refuses to paint

    This one is #63's, and it is a hard crash, not a divergence.

    Chain, all verified:

    1. TEMPLATE_ENV.p (main-renderer.ts:720) does props[name] = value; for __proto__ that mutates [[Prototype]] and creates no own key.
    2. freezeTemplateHostProps (main-renderer.ts:743) then freezes the record with the foreign prototype intact.
    3. cloneProps (host-driver.ts:1011) gates on hasCrossRealmPlainPrototype (core/plain-object.ts:20), which requires prototype === null or a prototype one hop from null. A {foo: 1} poison object is two hops, so it fails.
    4. Result: Octane Lynx host: host props require plain objects, received [object Object].

    The plan path never hits this, because hostNode's {...rawProps} spread (main-renderer.ts:643) launders the prototype away before the driver sees it.

    Why it is production-reachable — the refuter improved on the original repro

    The original probe called prepareLynxHostBatch on a container that applyLynxFirstScreenDirect had already accepted — a sequence production never performs, and the weakest point in the report. The refuter attacked exactly that and it backfired: they rebuilt the real shape from packages/lynx/src/main-thread.ts:1896-1911 (direct first, staged only when direct declines) using a compiled .tsrx page carrying a native <list>, which is precisely what makes firstScreenTreeHasList (host-driver.ts:2882) return false and hand the tree to the staged applier.

    Result: lynx target takes path=staged and THROWS; universal target takes path=staged and paints 3 hosts. Same module, same applier, opposite outcome.

    So on any page containing a native <list> — the one shape the direct path deliberately declines — a __proto__-named prop on a custom element crashes the first screen under target: 'lynx' and renders fine under target: 'universal'. target: 'lynx' is what lynxMainThreadRenderer ships.

    Net severity

    My earlier correction said severity "drops accordingly". That is true of Defect A only. Defect B raises it: it is introduced by the template lowering this stack added, it is reachable through the shipped renderer preset on the shipped code path, and its failure mode is a thrown first screen rather than a wrong one.

    Fix direction for B: either have TEMPLATE_ENV.p write via Object.defineProperty (so __proto__ becomes an own data property, matching what {...rawProps} yields on the plan path), or reject prototype-accessor names in lynxTemplateEligible. Fixing A alone leaves B.

    Panel tally

    4 verdicts across this candidate family: 3 not refuted, 1 refuted-on-attribution. Under 2-of-3 the defect stands; what the panel changed is that it is now correctly split into a pre-existing bug (A) and a stack-introduced crash (B).


    Generated by Claude Code

  5. Huxpro commented on Aug 18, 2026

    @Huxpro
    OwnerAuthor

    Final panel tally: split on severity, not on mechanism

    Closing the loop on this issue so the record is complete rather than favourable. Six refuter verdicts landed across the two defects reported here.

    4 not refuted, 2 refuted. Nobody disputed the mechanism; the disagreement is entirely about whether a consumer would ever write the triggering code.

    The strongest dissent (invalidFixture: true) argues, with executed evidence:

    • __proto__ is a compile error on every standard Lynx intrinsic under both targets — view, text, image, scroll-view, list. Main-thread host spreads are rejected outright too.
    • The only surviving route is an app-registered custom element, because compile-universal.js:1817 validates attributes solely for tags present in hostProps.
    • Even there, tsrx-tsc --noEmit rejects it — TS2322: Property '__proto__' does not exist on type '{ class?: string; spec?: unknown; }' — unless the consumer declares an explicit __proto__?: unknown field or an untyped [key: string]: unknown index signature.
    • No real Lynx native element has a __proto__ attribute.

    The strongest defence, also executed, is the production-shape demonstration already recorded above: with a native <list> forcing the staged path, target: 'lynx' throws the first screen where target: 'universal' paints it.

    How I would triage this

    Both are right. The accurate framing is: real defect, contrived trigger.

    • The mechanism is not in dispute and is not guarded anywhere, in a codebase that guards __proto__ systematically elsewhere (~20 sites, incl. defineProtoProp at main-renderer.ts:275).
    • Reaching it requires an app to deliberately declare a native-element attribute named __proto__, which no shipped element has and no reasonable consumer writes.
    • So: low likelihood, hard failure when hit (a thrown first screen, not a wrong one).

    I would not prioritise this above #70, #76, #81, or #82, all of which trigger on ordinary code. It is worth fixing as hardening — one Object.defineProperty in TEMPLATE_ENV.p and one hasOwnProp guard at main-renderer.ts:802 close both halves — rather than as an urgent correctness bug.

    Record

    verdict outcome ground
    1 not refuted four attack routes failed; repro exact
    2 not refuted six routes failed; reachability confirmed via tsrx-tsc
    3 refuted attribution inverted — corrected above; defect A is pre-existing (octanejs#660)
    4 not refuted rebuilt production shape, made it stronger
    5 not refuted list-forced staged path; lynx throws, universal paints
    6 refuted fixture requires a consumer-declared __proto__ attribute

    The two committed red tests are unaffected — they assert only that the encodings agree, and remain red.


    Generated by Claude Code

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent-authoredbug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions