Skip to content

fix(mtproxy): decrypt only bytes actually read in Obfuscated2.Read#1694

Merged
ernado merged 1 commit intogotd:mainfrom
lavr:bug/mtproxy-large-response-corruption
Mar 17, 2026
Merged

fix(mtproxy): decrypt only bytes actually read in Obfuscated2.Read#1694
ernado merged 1 commit intogotd:mainfrom
lavr:bug/mtproxy-large-response-corruption

Conversation

@lavr
Copy link

@lavr lavr commented Mar 15, 2026

XORKeyStream(b, b) advanced the AES-CTR stream by len(b) instead of n, desyncing decryption when FakeTLS returns partial reads (one TLS record at a time). This corrupted all large MTProxy responses spanning multiple TLS records.

Fixes #1139

XORKeyStream(b, b) advanced the AES-CTR stream by len(b) instead of n,
desyncing decryption when FakeTLS returns partial reads (one TLS record
at a time). This corrupted all large MTProxy responses spanning multiple
TLS records.

Fixes #1139
@codecov
Copy link

codecov bot commented Mar 17, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 68.46%. Comparing base (36ad1b1) to head (17a06a5).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1694      +/-   ##
==========================================
- Coverage   68.51%   68.46%   -0.06%     
==========================================
  Files         452      452              
  Lines       18910    18910              
==========================================
- Hits        12957    12947      -10     
- Misses       4987     4995       +8     
- Partials      966      968       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ernado
Copy link
Member

ernado commented Mar 17, 2026

This is great, thank you!
For some reason TestExternalE2EMTProxy/Tls now fails, need to investigate.

Upd: the reason was in mtg version

@ernado ernado merged commit f37cb63 into gotd:main Mar 17, 2026
13 of 14 checks passed
@lavr lavr deleted the bug/mtproxy-large-response-corruption branch March 17, 2026 14:43
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.

The utilization of an MTP proxy will invariably result in the failure of 'MessagesGetDialogs'.

2 participants