mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-10-09 13:48:19 +00:00
core: limit the number of skipped keys during remote access (#7622)
* core: limit the number of skipped keys during remote access * simplify * core: restrict body size for XRCP commands and responses, limit decompressed size (#7616) Co-authored-by: Evgeny @ SimpleX Chat <259188159+evgeny-simplex@users.noreply.github.com> --------- Co-authored-by: Evgeny @ SimpleX Chat <259188159+evgeny-simplex@users.noreply.github.com>
This commit is contained in:
co-authored by
Evgeny @ SimpleX Chat
parent
8b804a4fba
commit
be39a42121
@@ -18,6 +18,7 @@ import Control.Monad (when)
|
||||
import qualified Data.Aeson.TH as J
|
||||
import Data.ByteString (ByteString)
|
||||
import Data.Int (Int64)
|
||||
import qualified Data.Map.Strict as M
|
||||
import Data.Text (Text)
|
||||
import Data.Word (Word16, Word32)
|
||||
import Simplex.Chat.Remote.AppVersion
|
||||
@@ -73,8 +74,10 @@ getRemoteRcvKeys RemoteCrypto {rcvCounter, chainKeys = TSbChainKeys {rcvKey}, sk
|
||||
| otherwise = do -- prevCorrId < corrId
|
||||
writeTVar rcvCounter corrId
|
||||
skipKeys (prevCorrId + 1)
|
||||
modifyTVar' skippedKeys $ \m -> M.drop (M.size m - maxSkippedKeys) m
|
||||
Right <$> getKeys
|
||||
maxSkip = 256
|
||||
maxSkippedKeys = 1024
|
||||
getKeys = (,) <$> stateTVar rcvKey C.sbcHkdf <*> stateTVar rcvKey C.sbcHkdf
|
||||
skipKeys !cId =
|
||||
when (cId < corrId) $ do
|
||||
|
||||
Reference in New Issue
Block a user