Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RPCRequest] Replay protection #1143

Open
wants to merge 8 commits into
base: develop
Choose a base branch
from
Open

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
@@ -193,7 +193,15 @@ public class NetworkingInteractor: NetworkInteracting {

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?

Copy link

sonarcloud bot commented Feb 26, 2024

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 join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants