Repository navigation
Conversation
Redeem() concatenated the bst:// code straight into {"code":"..."}.
A quote, backslash, or control character in that value terminates the
JSON string and changes the request. The handler receives the URL
argument verbatim, so the value is not a locally typed literal.
Escape per RFC 8259 before embedding. One call site; response parsing
is unchanged.
…ache - Percent-decode bst:// arguments, then JSON-escape the redeem code. - Parse JSON string replies with escapes, so a quote inside "reason" does not truncate it. - Achievement refresh deletes only a decimal appid (or all), so the URL cannot path-escape the stats cache. - Stop the HTTP reader from allocating past maxBodyBytes. - Lock and cap the achievement jobid map so unanswered jobs cannot race the recv thread or grow for the session. - Replace pattern-cache writes atomically so a crash or overlapping refresh cannot leave a partial TOML that cache-first will trust. - Drop expired manifest 404s so the negative cache cannot grow for a whole session.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hardening pass on the
bst://redeem path, the shared HTTP reader, the achievement job map, and the pattern cache. Five files. No behavior change for a normal redeem code, a normal manifest fetch, or a cache file that was written completely.Supersedes the unmerged #6 (JSON escape only). Based on current
main.Tokeer (
src/Utils/Tokeer/TokeerBridge.cpp)Redeem()builtPOST /drm/redeemby concatenating the code into{"code":"..."}. The value comes frombst://, registered underHKCU\Software\Classes\bst, so it is not a locally typed literal. A",\, or control character terminates the JSON string and changes the request (RFC 8259).JsonEscape()escapes"and\, maps\b \f \n \r \t, and writes the remaining controls as\u00XX. Bytes>= 0x20, including UTF-8, pass through. Nosnprintf.HandleUri()percent-decodes the argument first (%22becomes a quote, then gets escaped).+is not treated as a space. A broken%sequence is left as-is.JsonString()used to stop at the first", so an escaped quote inreason/errortruncated the value. It now walks escapes (\",\\,\/, the named controls,\uXXXXas UTF-8) and returns the unescaped string. Hex ticket fields are unchanged.bst://refreshachievements/<arg>deletedappcache/stats/UserGameStatsSchema_<arg>.bin.argis a URL segment, so..or a slash walked out of the stats directory. Onlyallor a decimal appid (1–10 digits) is accepted now.HTTP body cap (
src/OSTPlatform/Windows/Http.cpp)Executedocumented that reading stops atmaxBodyBytes, but it resized the buffer by the fullWinHttpQueryDataAvailablechunk and only checked afterwards. One chunk could allocate past the cap (manifest fetch is capped at 64 MB, the updater at 16 MB). The read is now clamped to the remaining room beforeWinHttpReadData.Achievement job map (
src/Hook/Hooks_NetPacket.cpp)g_JobIdToAppIdis written on the stats/achievements send path and erased on recv. Those hooks run on Steam's network threads and the map had no lock. A job whose reply never arrives stayed in the map for the session.RememberJob/TakeJobtake a mutex around the map only. The protobuf work stays outside the lock.Pattern cache (
src/Utils/SteamMetadata/RemoteToml.cpp)Cache-first loads
<sha>.tomland then refreshes it on a detached thread. That refresh opened the cache path withofstream, which truncates the good file before the new bytes land. A crash, or a second launch in that window, then trusts a partial TOML (file_size > 0is the only check).The write now goes to a per-thread
*.tmpandMoveFileEx(MOVEFILE_REPLACE_EXISTING)publishes it. A failed write leaves the previous cache in place.Manifest 404 cache (
src/Utils/SteamMetadata/ManifestCache.cpp)A definitive 404 is remembered for 10 minutes, but an entry was only erased the next time that same key was looked up. A long session of distinct missing manifests grew the map for the life of the process. On insert, once the map reaches 512 keys, expired entries are dropped and the rest is trimmed back to 256.
Verification
Host-side C++20 checks of the Tokeer logic (not the Windows DLL):
",\, CR/LF/TAB,\0,\x1F;/and UTF-8 unchanged.%22becomes a quoted JSON string,+stays+, a short%is left alone.JsonStringonsay \"hi\", a plainapp_id,\n,\u0043, and anullvalue (rejected)...,../x, and12a.A full MSVC build was not run here (Windows-only tree).