XGameRuntime: keep embedded URLs in XSTS canonical query paths #1676

Open
github-bot wants to merge 1 commit from github-bot/gh-1676 into main AGit
Owner

@⁠eizispark on GitHub · 2026-11-24 19:12 UTC · original
eizispark:fix/xsign-canonical-url → main · +105 −11 · 1 files · 1 commits · open

xsign::canonical_path_and_query previously ran url.split_once("://") across the entire URL before stripping #fragment and without checking that a RFC 3986 scheme:// prefix precedes any / or ?. As a result, relative paths with callback/redirect URLs in query parameters (e.g. /oauth/authorize?redirect_uri=https://title.example/cb) or fragments containing :// were split inside the query or fragment, signing /cb instead of the actual request path and query, and scheme-relative //authority/... URLs kept the host inside the path.

In addition, signer() leaked CNG handles on initialization failure and did not track ecdsa_alg alongside its child ecdsa_key (per Windows CNG rules, a BCRYPT_KEY_HANDLE must be destroyed via BCryptDestroyKey before closing its parent BCRYPT_ALG_HANDLE via BCryptCloseAlgorithmProvider).

What is in it

  • crates/xcl/src/hle/xgameruntime/xsign.rs: strip #fragment first in canonical_path_and_query, strip only a leading // or RFC 3986 scheme:// authority prefix before normalizing the path-and-query, clean up CNG key/algorithm handles in reverse order on initialization failure and in Drop for EphemeralSigner, and add canonical_url_preserves_embedded_query_urls_and_strips_fragments_first covering embedded query/fragment URLs, scheme-relative URLs, and end-to-end sign_request_at + BCryptVerifySignature verification.

Tested

  • Hardware / toolchain: AMD Radeon RX 9070 XT (driver 32.0.32015.16001), AMD Ryzen 7 9800X3D, Windows 11 x64, rustc 1.100.0 (0ef1bc386 2026-11-09) (stable-x86_64-pc-windows-msvc), debug (unit + workspace tests) and release (60 s title smoke).
  • cargo test -p xcl --lib xsign: 5 passed, 0 failed, 0 ignored (canonical_url_preserves_embedded_query_urls_and_strips_fragments_first verified failing with "/cb" before the fix).
  • cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4: 777 passed, 0 failed, 41 ignored (SKIPPED GPU/SDK tests: 3 — test_title_draws_with_a_root_signature_under_the_debug_layer: no d3d12SDKLayers.dll; heap_window_out_of_memory_falls_back_to_the_switch_form: no heap windows; uploads_start_from_each_subresources_state: no D3D12 debug layer).

Regression run

main (9e3831e1f570d3646e53ab753b19ec07eb8f1485):

xcl-smoke v1
commit: 9e3831e1f570d3646e53ab753b19ec07eb8f1485
gpu: AMD Radeon RX 9070 XT
title: 9cc6a39e
seconds: 60
exit: 0x0
frames shown: 1677 (PresentX 1677)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14728 MB

PR (3c13a5a8de3c10a59527f8d875518fe259935fdf):

xcl-smoke v1
commit: 3c13a5a8de3c10a59527f8d875518fe259935fdf
gpu: AMD Radeon RX 9070 XT
title: 9cc6a39e
seconds: 60
exit: 0x0
frames shown: 1672 (PresentX 1673)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14855 MB

Not tested

  • Live Xbox Live / GDK titles calling XUserGetTokenAndSignature* with embedded redirect URLs in query strings; Linux / Wine (bcrypt.dll).
  • D3D12 SDK debug-layer tests (d3d12SDKLayers.dll not installed on this machine).

AI use

  • Antigravity (Google DeepMind, Gemini 4 Carbon): audited xsign.rs, wrote the regression test and fix, ran the workspace test suite and scripts/smoke.ps1 runs, and drafted this PR description.
**@⁠eizispark** on GitHub · 2026-11-24 19:12 UTC · [original](https://github.com/xcl-dev/xcl/pull/1676) `eizispark:fix/xsign-canonical-url` → `main` · +105 −11 · 1 files · 1 commits · open `xsign::canonical_path_and_query` previously ran `url.split_once("://")` across the entire URL before stripping `#fragment` and without checking that a RFC 3986 `scheme://` prefix precedes any `/` or `?`. As a result, relative paths with callback/redirect URLs in query parameters (e.g. `/oauth/authorize?redirect_uri=https://title.example/cb`) or fragments containing `://` were split inside the query or fragment, signing `/cb` instead of the actual request path and query, and scheme-relative `//authority/...` URLs kept the host inside the path. In addition, `signer()` leaked CNG handles on initialization failure and did not track `ecdsa_alg` alongside its child `ecdsa_key` (per Windows CNG rules, a `BCRYPT_KEY_HANDLE` must be destroyed via `BCryptDestroyKey` before closing its parent `BCRYPT_ALG_HANDLE` via `BCryptCloseAlgorithmProvider`). **What is in it** - `crates/xcl/src/hle/xgameruntime/xsign.rs`: strip `#fragment` first in `canonical_path_and_query`, strip only a leading `//` or RFC 3986 `scheme://` authority prefix before normalizing the path-and-query, clean up CNG key/algorithm handles in reverse order on initialization failure and in `Drop for EphemeralSigner`, and add `canonical_url_preserves_embedded_query_urls_and_strips_fragments_first` covering embedded query/fragment URLs, scheme-relative URLs, and end-to-end `sign_request_at` + `BCryptVerifySignature` verification. **Tested** - Hardware / toolchain: AMD Radeon RX 9070 XT (driver `32.0.32015.16001`), AMD Ryzen 7 9800X3D, Windows 11 x64, `rustc 1.100.0 (0ef1bc386 2026-11-09)` (`stable-x86_64-pc-windows-msvc`), debug (unit + workspace tests) and release (60 s title smoke). - `cargo test -p xcl --lib xsign`: 5 passed, 0 failed, 0 ignored (`canonical_url_preserves_embedded_query_urls_and_strips_fragments_first` verified failing with `"/cb"` before the fix). - `cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4`: 777 passed, 0 failed, 41 ignored (SKIPPED GPU/SDK tests: 3 — `test_title_draws_with_a_root_signature_under_the_debug_layer`: no `d3d12SDKLayers.dll`; `heap_window_out_of_memory_falls_back_to_the_switch_form`: no heap windows; `uploads_start_from_each_subresources_state`: no D3D12 debug layer). **Regression run** `main` (`9e3831e1f570d3646e53ab753b19ec07eb8f1485`): ``` xcl-smoke v1 commit: 9e3831e1f570d3646e53ab753b19ec07eb8f1485 gpu: AMD Radeon RX 9070 XT title: 9cc6a39e seconds: 60 exit: 0x0 frames shown: 1677 (PresentX 1677) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14728 MB ``` PR (`3c13a5a8de3c10a59527f8d875518fe259935fdf`): ``` xcl-smoke v1 commit: 3c13a5a8de3c10a59527f8d875518fe259935fdf gpu: AMD Radeon RX 9070 XT title: 9cc6a39e seconds: 60 exit: 0x0 frames shown: 1672 (PresentX 1673) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14855 MB ``` **Not tested** - Live Xbox Live / GDK titles calling `XUserGetTokenAndSignature*` with embedded redirect URLs in query strings; Linux / Wine (`bcrypt.dll`). - D3D12 SDK debug-layer tests (`d3d12SDKLayers.dll` not installed on this machine). **AI use** - Antigravity (Google DeepMind, Gemini 4 Carbon): audited `xsign.rs`, wrote the regression test and fix, ran the workspace test suite and `scripts/smoke.ps1` runs, and drafted this PR description.
`xsign::canonical_path_and_query` previously called `url.split_once("://")`
across the entire URL before stripping `#fragment` and without checking that
a RFC 3986 `scheme://` prefix precedes any `/` or `?`. Relative paths with
callback/redirect URLs in query parameters (for example
`/oauth/authorize?redirect_uri=https://title.example/cb`) or fragments with
`://` were split inside the query/fragment, signing `/cb` instead of the
actual request path and query, and scheme-relative `//authority/...` URLs
kept the host inside the path.

In addition, `signer()` leaked CNG handles on initialization failure and did
not track `ecdsa_alg` alongside its child `ecdsa_key` (per Windows CNG
rules, `BCRYPT_KEY_HANDLE` must be destroyed before closing its parent
`BCRYPT_ALG_HANDLE`).

Strip `#fragment` first, strip only a leading `//` or RFC 3986 `scheme://`
authority prefix, and release CNG key and algorithm handles in reverse order
on initialization errors and drop.

Assisted-by: Antigravity (Google DeepMind, Gemini 4 Carbon)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:01:16 +00:00
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-24 21:37 UTC · original

Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, ~22 ignored. (Intermittent single-test flake under parallel scheduling; clean on single-threaded rerun — same flake seen on unmodified main.)

Thanks!

**@⁠DavidM1911** on GitHub · 2026-11-24 21:37 UTC · [original](https://github.com/xcl-dev/xcl/pull/1676#issuecomment-7145180298) Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, ~22 ignored. (Intermittent single-test flake under parallel scheduling; clean on single-threaded rerun — same flake seen on unmodified `main`.) Thanks!
Author
Owner

@⁠JJAutoCompare on GitHub · 2026-11-25 03:55 UTC · original

PR #1676 — STOR-WINLAB verification

Tested 3c13a5a8de3c10a59527f8d875518fe259935fdf at detached HEAD, matching the fetched PR head.

Environment

STOR-WINLAB, Windows 11 Enterprise Evaluation build 26200.9974, Ryzen 7 3800X, Intel Arc A770 16 GiB (driver 32.0.101.9175, DoublePrecisionFloatShaderOps=0, wave range 8–32). DXC/DXIL 1.9.2609.5. Rust 1.100.0 (0ef1bc386, 2026-11-09). Unoptimized build and test profiles with debug info disabled.

Tested

  • cargo build --workspace and cargo test --workspace --no-run completed successfully. Every Cargo test invocation used the shared Arc lock.
  • cargo test -p xcl xgameruntime -- --nocapture exited 0. Libtest reported 74 unit tests passed, 0 failed, 0 ignored. One sample-dependent integration test also reported a pass with its sample unset. All five xsign tests passed. The new regression test checks that canonicalization keeps embedded query URLs, strips fragments, handles relative and scheme-relative inputs, and produces equivalent signing payloads for relative and absolute URLs. BCrypt verified the ephemeral P-256 signature.
  • One full run of cargo test --workspace --no-fail-fast -- --test-threads=4 exited 101. The 20 summaries in pr1676-suite.log report 761 passed, 16 failed, 41 ignored. The signing regression test passed again.

Workspace failures and skips

  • 15 GPU recompiler failures. Eleven tests involving FP64 hit CreateComputePipelineState error 0x80070057. Four assertions failed in FMA overflow, implicit mip LOD sampling, FP16 high-half preservation, and pixel-shader wave reduction.
  • One test-title failure. The dynamic depth bias RSSetDepthBiasX check read a blue pixel where it expected green.
  • Three explicit SKIPPED lines in the suite log, two for no wave64 and one for no heap windows. These paths contribute no coverage.

Not tested

Live XSTS service acceptance, retail-title smoke tests, a main baseline, and other GPUs. Optional game-data paths had no XCL_SAMPLE_* inputs. The D3D12 debug layer, system Gaming Services paths, and audio endpoint paths were unavailable.

AI use

T3 Code / Codex (gpt-6.2-sol, reasoningEffort: high) ran the build and verification. Coordinator #2 (T3 Code / Antigravity, gemini-4-neon) verified counts against pr1676-suite.log and published.

**@⁠JJAutoCompare** on GitHub · 2026-11-25 03:55 UTC · [original](https://github.com/xcl-dev/xcl/pull/1676#issuecomment-7152364734) # PR #1676 — STOR-WINLAB verification Tested `3c13a5a8de3c10a59527f8d875518fe259935fdf` at detached HEAD, matching the fetched PR head. **Environment** STOR-WINLAB, Windows 11 Enterprise Evaluation build 26200.9974, Ryzen 7 3800X, Intel Arc A770 16 GiB (driver 32.0.101.9175, `DoublePrecisionFloatShaderOps=0`, wave range 8–32). DXC/DXIL 1.9.2609.5. Rust 1.100.0 (`0ef1bc386`, 2026-11-09). Unoptimized build and test profiles with debug info disabled. **Tested** - `cargo build --workspace` and `cargo test --workspace --no-run` completed successfully. Every Cargo test invocation used the shared Arc lock. - `cargo test -p xcl xgameruntime -- --nocapture` exited 0. Libtest reported 74 unit tests passed, 0 failed, 0 ignored. One sample-dependent integration test also reported a pass with its sample unset. All five `xsign` tests passed. The new regression test checks that canonicalization keeps embedded query URLs, strips fragments, handles relative and scheme-relative inputs, and produces equivalent signing payloads for relative and absolute URLs. BCrypt verified the ephemeral P-256 signature. - One full run of `cargo test --workspace --no-fail-fast -- --test-threads=4` exited 101. The 20 summaries in `pr1676-suite.log` report **761 passed, 16 failed, 41 ignored**. The signing regression test passed again. **Workspace failures and skips** - 15 GPU recompiler failures. Eleven tests involving FP64 hit `CreateComputePipelineState` error `0x80070057`. Four assertions failed in FMA overflow, implicit mip LOD sampling, FP16 high-half preservation, and pixel-shader wave reduction. - One test-title failure. The dynamic depth bias `RSSetDepthBiasX` check read a blue pixel where it expected green. - Three explicit `SKIPPED` lines in the suite log, two for `no wave64` and one for `no heap windows`. These paths contribute no coverage. **Not tested** Live XSTS service acceptance, retail-title smoke tests, a `main` baseline, and other GPUs. Optional game-data paths had no `XCL_SAMPLE_*` inputs. The D3D12 debug layer, system Gaming Services paths, and audio endpoint paths were unavailable. **AI use** T3 Code / Codex (gpt-6.2-sol, reasoningEffort: high) ran the build and verification. Coordinator #2 (T3 Code / Antigravity, gemini-4-neon) verified counts against `pr1676-suite.log` and published.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/1676/head:github-bot/gh-1676'
git switch 'github-bot/gh-1676'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1676'
git switch 'github-bot/gh-1676'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1676'
git switch 'github-bot/gh-1676'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1676'
git switch 'main'
git merge --squash 'github-bot/gh-1676'
git switch 'main'
git merge --ff-only 'github-bot/gh-1676'
git switch 'main'
git merge 'github-bot/gh-1676'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.