Skip to content

Add opt-in session-origin enforcement for suppressed-flow callbacks - #28

Merged
ReneeGA2020 merged 9 commits into
mainfrom
feature/session-origin-integration-20261112
Nov 12, 2026
Merged

ReneeGA2020 merged 9 commits into
mainfrom
feature/session-origin-integration-20261112

Conversation

@ReneeGA2020

Copy link
Copy Markdown
Owner

Problem

An author callback running on a thread whose ExecutionContext does not flow (a Task or Thread created inside a UGC session) had no policy origin, so reflection and managed-load checks could fall through to the trusted path.

Change (19 files, 2146 insertions)

  • CoreLib-owned session origin: when no ambient scope exists, the reflection policy resolves the session from the actual executing frames (runtime-owned AssemblyLoadContext instances), with the existing core recovery candidate check as the single compatibility predicate.
  • Opt-in only: RuneCLR.EnableReflectionPolicyOriginScan defaults to disabled. Enabling requires the process runtimeconfig switch true plus the host capability assertion PrototypeRequireOriginScan = true; a runtime without capability bit 0 rejects before any author file is opened.
  • The host option only asserts the capability; it does not turn scanning on or off.
  • Tests and verifier: tests/RuneCLR.SessionOrigin.Tests plus author/chain/compiled fixtures; eng/verify-runtime-session-origin.py --runtime-committed-source validates the committed integration source (clean tree, exact parent, five-file delta, per-file raw vs normalized-canonical relation), pins the consumed receipt before and after, and fails on receipt or runtime drift. The existing dirty-source mode is unchanged.

Verification

  • Host build: dotnet 11.0.100 (ambient SDK, captured in local evidence), Release, exit 0.
  • Stock reflection suites pass; stock lifecycle 156/156. The matching private Checked runtime additionally passes lifecycle 156/156 in ordinary mode and 156/156 with explicit --require-interpreter; source clean at 2077f147 and all five binary hashes match the receipt.
  • Stable committed run on the matching private runtime: 16 modes / 696 pins (includes the consumed receipt), drift 0; default-off reports capability 0, the enabled process reports 1, and the required-origin gate rejects before author loading.
  • Six checker negatives: wrong build-source hash, wrong parent, inconsistent parent, wrong binary, unexpected dirty tree, and a receipt rewritten mid-run are all rejected.
  • Tooling tests: eng/test-session-origin-provenance.py (24 synthetic cases) covers the dirty-manifest and committed-source modes, including the four-raw/one-normalized relation and the receipt drift path.

Provenance

  • Runtime build source: 474eb8ad7230122cc0d34318b25d673da63fd138 plus five raw files (recorded hashes); the private Checked x64 native output and CoreLib were built there.
  • Paired runtime commit: 2077f1478f2b43533d368dd7521a04bf6c52809a on runeclr/session-origin-integration-20261112; the published blobs equal the tested bytes 5/5 after CRLF to LF normalization. The binaries are not rebuilt from that commit and are not labelled as such.
  • Runtime toolchain: SDK 12.0.100-alpha.1.26480.102, CMake 4.2.1, MSVC 19.44.
  • Against the archived experiment commit only 3/5 runtime files are byte-identical: assemblynative.cpp, assemblynative.hpp and the ILLink descriptor; qcallentrypoints.cpp is re-applied onto the newer dev upstream and RuneCLRReflectionPolicy.cs differs by the deliberate default-off change.
  • Host source: 12 of 16 archived files are byte-identical; the verifier and the fail-closed message changed intentionally, and two integration fixture project files were normalized to LF. The archived snapshot keeps its original bytes.

Scope and limits

Opt-in and scoped; no public policy or default execution change. Upstream focused dotnet/runtime tests pass on the matching Checked runtime with origin-scan off: ContextualReflection, CollectibleAssemblies/Statics and CollectibleAssemblies/GenericVirtualMethod (expected 100, actual 100). A switch-on ContextualReflection run also succeeds, but those tests do not attach a RuneCLR session, so it shows switch parsing only; enforcement evidence remains the 16-mode host matrix. Not covered: device/AOT/mobile, unmanaged entry, global all-load, direct native status 1/2 observation, the compiled-only child case, walk-cost measurement, sandbox or unload. The private test layout reuses the dev Release facades (not rebuilt). The two session-origin fixture project files were normalized to LF in this branch (integration-only line-ending change); the archived snapshot bytes stay on the archive branch.

Review-tool note: the verifier's RUNTIME_BASE (7cbdad39) is a historical ancestor check, not the PR base; PR base resolution is done separately against current main with an explicit merge-base/diff check.

Paired runtime branch: https://github.com/ReneeGA2020/runtime/tree/runeclr/session-origin-integration-20261112 (2077f147). The two branches must land together. No merge or CI claim.

Assisted-by: Cindy (https://cindy.app)

Port the archived session-origin host side onto origin/main
(cbac2a6):

- PrototypeRequireOriginScan on MapRunOptions and HostContractSessionOptions,
  requiring RequireInterpreter plus an API policy
- PrototypeReflectionPolicy.PrepareOriginScan binds the runtime capability
  before author loading and fails closed with PlatformNotSupportedException
- session-origin test projects, verifier and the default-off matrix mode
- integration notes in docs/validation/session-origin-integration-20261112.md
  and short pointers in development.md and ugc-session-policy.md

Paired runtime branch: runeclr/session-origin-integration-20261112 in
ReneeGA2020/runtime, commit 2077f1478f2b43533d368dd7521a04bf6c52809a. The
runtime switch defaults to disabled, so a host that does not opt in keeps the
existing reflection-policy behavior.

Verified: host build, stock reflection tests, lifecycle 156/156, and the
16-mode matrix against a fresh Checked runtime build. Not merged into main.

Assisted-by: Cindy (https://cindy.app)
- Distinguish the three runtime relations: tested tree 5/5 raw against the
  manifest, published blobs 5/5 after CRLF to LF normalization, and only 3/5
  byte-identical to the archived experiment (qcall entry re-applied onto dev,
  CoreLib changed for default-off). Host: 14 of 16 archived files identical,
  two changed intentionally.
- Record the host toolchain (ambient dotnet 11.0.100), the explicit rebuild and
  the fact that rebuilt outputs embed the source revision, plus the post-commit
  matrix / stock / lifecycle re-run.
- State that upstream targeted tests are owned by a separate worker and remain
  pending; no pass is claimed here.

Docs only; no source, test, policy or runtime commit changes.

Assisted-by: Cindy (https://cindy.app)
Add --runtime-committed-source: validate the exact integration commit against a
recorded build-source receipt instead of requiring a dirty worktree.

- receipt splits buildSource (head + raw file hashes that were built),
  integration (commit, its exact parent, canonical blob hashes) and the private
  runtime binary hashes
- require a clean worktree at the receipt commit, the exact parent, a five-file
  modification-only delta, per-file committed blob hash and parent difference
- per file, accept the working bytes only when their hash equals the recorded
  build source (raw) or when the build read the canonical form while the
  checkout materialises CRLF (normalized-canonical); mismatches are rejected
- verify the fresh build outputs and CoreLib against the receipt binaries
- the existing source-manifest (dirty build) and clean-commit modes stay
  unchanged

This removes the need to check out the build-time dirty state; the shared
runtime tree stays clean at the integration commit. No runtime source, binary
or facades change.

Assisted-by: Cindy (https://cindy.app)
Describe --runtime-committed-source (clean commit and parent, five-file
modification-only delta, per-file raw vs normalized-canonical relations,
binary receipt), record the 5/5 negative checks, and record the stable run:
runtime clean at 2077f147, host clean at 24e5a8f, 16 modes / 695 pins, with
no HEAD switching. The earlier dev+dirty run stays as history.

Docs only; no source, test, policy or runtime change.

Assisted-by: Cindy (https://cindy.app)
The committed-source mode read the receipt but never froze it: inputs only
included the dirty-mode manifest, so the run could not prove which authoritative
receipt it validated.

- read the receipt bytes once, parse those bytes, and keep their sha256 and length
- add the committed-source receipt to the before/after input pins, alongside the
  manifest path in the existing dirty mode
- reject a receipt that changes between load and pin
- write the consumed receipt bytes into the run output as
  consumed-source-receipt.json and record its sha256/bytes in the summary
- re-check the consumed file hash, the copy hash and the runtime commit/parent/
  clean state after the run; any drift fails the run
- apply the same consumed-bytes identity and post-run re-check to the dirty
  source-manifest mode without relaxing its existing checks

No runtime source, binary, layout or host business code change.

Assisted-by: Cindy (https://cindy.app)
Record that the committed-source receipt is a frozen input (single read, pinned
before/after, consumed bytes copied into the run output with its sha256), that a
receipt change between load and pin or during the run fails the run, and that the
same identity applies to the dirty manifest mode. Add the receipt-drift negative
(6/6) and the new stable run: runtime clean at 2077f147, host clean at 49fc6df,
16 modes, 696 pins (the receipt pin), drift 0. The earlier 695-pin run is kept
as history and marked superseded.

Docs only; no source, test, policy or runtime change.

Assisted-by: Cindy (https://cindy.app)
- Extract check_consumed_source and check_binary_identity from the verifier so the
  consumed-receipt drift, copy mismatch and binary mismatch paths are shared with
  the tests instead of reimplemented.
- Extend eng/test-session-origin-provenance.py with a synthetic committed-source
  fixture: one positive with four raw and one normalized-canonical file, and
  rejections for wrong build source, wrong parent, inconsistent parent,
  unexpected dirty tree, binary mismatch, receipt drift and receipt copy
  mismatch. All cases are tooling fixtures; the historical native negative stays
  in the artifact evidence.
- Convert the two session-origin fixture project files to LF so git diff --check
  no longer reports trailing CR. This is an integration-only line-ending change:
  the archived snapshot bytes are preserved in the archive branch and evidence.

No runtime source, binary, layout or host policy change.

Assisted-by: Cindy (https://cindy.app)
- Replace the pending upstream statement with the focused dotnet/runtime
  results (ContextualReflection, CollectibleAssemblies/Statics,
  GenericVirtualMethod pass with origin-scan off; the switch-on contextual run
  is parsing-only, not enforcement).
- Key runs by provenance, host commit and consumed source sha instead of pin
  count; explain the self-declared receipt versus build-log provenance boundary
  and the four-raw/one-normalized basis.
- Describe the 24-case tooling suite and the integration-only LF normalization
  of the two fixture project files.
- Separate PR base resolution from the verifier's historical ancestor check.

Docs only; no source, runtime or policy change.

Assisted-by: Cindy (https://cindy.app)
Record separate ordinary and RequireInterpreter lifecycle passes on the matching private runtime, with unchanged binary identities. Documentation only; no build or epoch performance claim.

Assisted-by: Cindy (https://cindy.app)
@ReneeGA2020
ReneeGA2020 merged commit aa31875 into main Nov 12, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant