Skip to content
This repository was archived by the owner on Nov 27, 2025. It is now read-only.

[RPCRequest] Replay protection#1143

Open
alexander-lsvk wants to merge 8 commits intodevelopfrom
replay-protection
Open

[RPCRequest] Replay protection#1143
alexander-lsvk wants to merge 8 commits intodevelopfrom
replay-protection

Conversation

@alexander-lsvk
Copy link
Contributor

Description

Gist: https://gist.github.com/jakubuid/4d111f02503a48508d22ff7cb2dcca32
Thread: https://walletconnect.slack.com/archives/C04E3TVLHU7/p1694246632728979

How Has This Been Tested?

Due Dilligence

  • Breaking change
  • Requires a documentation update

@alexander-lsvk alexander-lsvk temporarily deployed to internal September 28, 2023 09:48 — with GitHub Actions Inactive
@alexander-lsvk alexander-lsvk temporarily deployed to internal September 28, 2023 09:50 — with GitHub Actions Inactive
private func manageSubscription(_ topic: String, _ encodedEnvelope: String, _ publishedAt: Date) {
if let (deserializedJsonRpcRequest, derivedTopic, decryptedPayload): (RPCRequest, String?, Data) = serializer.tryDeserialize(topic: topic, encodedEnvelope: encodedEnvelope) {
handleRequest(topic: topic, request: deserializedJsonRpcRequest, decryptedPayload: decryptedPayload, publishedAt: publishedAt, derivedTopic: derivedTopic)
if let rpcRequestTopic = deserializedJsonRpcRequest.topic {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check if the subscription topic matches the request's topic.
If there is no request topic - the request will be handled to support backward compatibility.

@alexander-lsvk alexander-lsvk temporarily deployed to internal September 28, 2023 10:03 — with GitHub Actions Inactive
@alexander-lsvk alexander-lsvk temporarily deployed to internal September 28, 2023 10:15 — with GitHub Actions Inactive
@alexander-lsvk alexander-lsvk temporarily deployed to internal September 28, 2023 10:17 — with GitHub Actions Inactive
@alexander-lsvk alexander-lsvk temporarily deployed to internal September 28, 2023 10:23 — with GitHub Actions Inactive
@alexander-lsvk alexander-lsvk temporarily deployed to internal September 28, 2023 10:29 — with GitHub Actions Inactive
@llbartekll
Copy link
Contributor

@alexander-lsvk can you add the section, how it's been tested?

Copy link
Contributor

@llbartekll llbartekll left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good but need to be manually tested with all the platforms.
also, how about writing a unit test to ensure backward compatibility?

if rpcRequestTopic == topic {
handleRequest(topic: topic, request: deserializedJsonRpcRequest, decryptedPayload: decryptedPayload, publishedAt: publishedAt, derivedTopic: derivedTopic)
} else {
logger.debug("Networking Interactor - Mismatched topic decoded from message")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we log it as an error or warning?

@sonarqubecloud
Copy link

Quality Gate Passed Quality Gate passed

Issues
3 New issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants