XSystemGetXboxLiveSandboxId accepts a buffer smaller than XSystemXboxLiveSandboxIdMaxBytes #862
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory#862
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@BastienRodz on GitHub · 2026-11-24 12:54 UTC · original
What's wrong
Microsoft's XSystemGetXboxLiveSandboxId reference specifies a minimum buffer size of
XSystemXboxLiveSandboxIdMaxBytes(16inXSystem.h):sandboxIdSize: "This value must be equal to or greater than the XSystemXboxLiveSandboxIdMaxBytes constant defined in XSystem.h."In
crates/victory-hle/src/modules/xsystem.rs(lines 37 and 64–66),sandbox_idcallsput_string(SANDBOX, size, buffer, used)withconst SANDBOX: &str = "RETAIL";.put_string(crates/victory-hle/src/modules/xgameruntime.rs, lines 145–149) only checkssize < text.len() + 1(7 bytes).As a result, calling
XSystemGetXboxLiveSandboxId(7, buf, &used)returns0x8007007A(HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER)) on Xbox regardless of the sandbox's length, but returnsS_OKhere, writing"RETAIL\0"and settingused = 7.Impact
Low impact: titles that follow the GDK documentation allocate at least
XSystemXboxLiveSandboxIdMaxBytes(16 bytes), so only a title passing a short buffer (7–15 bytes) diverges—it succeeds here and fails on Xbox.Fix
Define
SANDBOX_ID_MAX_BYTES: usize = 16(XSystemXboxLiveSandboxIdMaxBytes) incrates/victory-hle/src/modules/xsystem.rsand havesandbox_idreturnxasync::E_NOT_SUFFICIENT_BUFFER(0x8007007A) wheneversize < SANDBOX_ID_MAX_BYTES, before callingput_string. Leaveput_stringitself unchanged; the other two getters inxsystem.rs(console_id, 39 bytes, anddevice_id, 45 bytes) already match their documented minimums because their strings fill them exactly.The fix is ready on a branch of my fork, since PR creation is limited to collaborators: https://github.com/BastienRodz/VIctory/commits/hle/sandbox-id-buffer-minimum (one commit on
mainffe310e,xsystem.rs+26).Tests
a_sandbox_id_buffer_under_the_documented_minimum_is_refused: sizes 7 and 15 are refused withE_NOT_SUFFICIENT_BUFFERand the buffer is left untouched; size 16 givesS_OK,"RETAIL\0"andused = 7.main: it fails at the first case,size 7,left: 0,right: -2147024774(0x8007007A).windows-latestwith the upstream CI's commands (clippy-D warningswith and without--all-features, thencargo test --workspace --locked): everything passes;victory-hle95 passed, 0 failed (https://github.com/BastienRodz/VIctory/actions/runs/45397649553).No game data used. AI-assisted: found with GPT-6.2 Astra, written with Gemini 4 Neon, reviewed and verified with Claude Code.
@pushkarreddyy on GitHub · 2026-11-24 13:37 UTC · original
Claiming this issue.
Technical Analysis
In crates/victory-hle/src/modules/xsystem.rs:
sandbox_id delegates to put_string(SANDBOX, size, buffer, used) with const SANDBOX = RETAIL. Because put_string only checks size < text.len() + 1 (7 bytes), buffer sizes 7..15 erroneously succeed with S_OK.
However, the official GDK specification for XSystemGetXboxLiveSandboxId specifies:
Proposed Fix
Define const SANDBOX_ID_MAX_BYTES: usize = 16 in xsystem.rs and guard sandbox_id with:
if size < SANDBOX_ID_MAX_BYTES { return xasync::E_NOT_SUFFICIENT_BUFFER; }
before calling put_string. Add regression tests asserting that buffer sizes 7 and 15 return E_NOT_SUFFICIENT_BUFFER with unchanged buffers, while size 16 succeeds.
Preparing clean branch with Rust 2024 compliance on fork.
@pushkarreddyy on GitHub · 2026-11-24 13:39 UTC · original · edited 2026-11-24 14:22 UTC
Verified Implementation Ready on Fork
The implementation enforcing XSystemXboxLiveSandboxIdMaxBytes (16 bytes) on sandbox_id is complete and pushed to my fork:
ffe310e)Compare: https://github.com/Marvisak/VIctory/compare/main...pushkarreddyy:VIctory:fix/hle-sandbox-id-buffer-minimum
Changes (crates/victory-hle/src/modules/xsystem.rs):
@pushkarreddyy on GitHub · 2026-11-24 14:37 UTC · original
Pull request is now open for review: #972.
@winne42 on GitHub · 2026-11-24 20:03 UTC · original
I tested the four fixes side by side, as Windows builds run under Wine 10.0 on Linux: BastienRodz's branch (
460e4c6), #939 (d4306f4), #972 (886a867, the same commit as pushkarreddyy's fork branch) and thexsystem.rspart of #1330 (fb40a8f). They make the same code change:SANDBOX_ID_MAX_BYTES = 16and asize < 16guard beforeput_string. Only their tests differ.The value 16 is right. Microsoft's docs refer to the constant but don't state its value. Microsoft's own
XBOX-GDK-dotnetinterop does:XSystemXboxLiveSandboxIdMaxBytes` from XSystem.h: includes null terminator→16, next toConsoleIdBytes = 39andAppSpecificDeviceIdBytes = 45, which match the other two getters here. The SystemInfo sample useschar sandbox[XSystemXboxLiveSandboxIdMaxBytes]with anullptrsandboxIdUsed.mainxsystem::testsusedS_OK)-D warningsThe probe checks two things. Below the minimum, the call must return
E_NOT_SUFFICIENT_BUFFERand leave the buffer anduseduntouched. At or above it, it must returnS_OKwith a NUL-terminated string and nothing written pastused.Since the fixes are identical, only one needs to land. #939 is the oldest open PR, and its test checks that both the buffer and
usedstay untouched. #972's test also covers size 0. Either is fine, and the others can be closed as duplicates.AI-assisted (Claude Code). Tests were synthetic, with no game files.
@Marvisak on GitHub · 2026-11-25 06:50 UTC · original
Automated triage for the maintainers.
Confirmed on current
main: incrates/victory-hle/src/modules/xsystem.rs,sandbox_idpasses straight toput_string(xgameruntime.rs), which only checks that"RETAIL"and its terminator fit, so a 7–15 byte buffer succeeds where the console refuses it. Open PR #939 makes this change (a 16-byte minimum beforeput_string); #972 and the bundle #1330 were closed without merging. Per the comparison in this thread the fork branches are the same change, so review can go to #939.Generated by Claude Code