Conversation
…throwing parseInitData called decodeURIComponent on every field with no guard, and verifyInitData called it with no try/catch. A Mini App request carrying a field like user=%ZZ raised a URIError that the route did not catch, so the caller got a 500 instead of the 401 a bad signature already returns. Skip the bad pair and let the signature check fail. Signed-off-by: Minxi Hou <houminxi@gmail.com>
HouMinXi
force-pushed
the
fix/telegram-initdata-decode
branch
from
September 29, 2026 14:32
4ef7f68 to
edbe964
Compare
Owner
|
Thanks @HouMinXi! This fix landed in the frozen release/v3.8.51 via #15121 (your commit cherry-picked with authorship preserved, red->green proven on the tip). I'm leaving this PR open on release/v3.8.52: the change reaches .52 through the post-release sync-back, so it can be closed once that lands. |
Merged
This branch has not been deployed
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.
Summary
parseInitDatacalleddecodeURIComponenton every field with no guard, andverifyInitDatacalled it with no try/catch. A Mini App request carrying a field likeuser=%ZZraised aURIErrorthat the route did not catch, so the caller got a 500 instead of the 401 a bad signature already returns. Skip the bad pair and let the signature check fail.Related Issues
Validation
tests/unit/telegram-init-data.test.tsnpm run typecheck:corerelease/v3.8.52at666ea59b4c)The new test was run against the change reverted (it throws) and restored (it passes).
Tests Added Or Updated
tests/unit/telegram-init-data.test.tsCoverage Notes
The new test covers the malformed-percent path in both
parseInitData(the bad pair is dropped, the good pairs survive) andverifyInitData(returns false instead of throwing).Reviewer Notes
A malformed pair is skipped, not rejected wholesale. The remaining fields still go through the HMAC check, which fails because the data-check string no longer matches what was signed. The caller sees the same 401 as any other bad signature.