From bc95aa561ef441b2a14f49971901c2a0376e92c3 Mon Sep 17 00:00:00 2001 From: shwoop Date: Thu, 18 Sep 2025 16:37:34 +0200 Subject: [PATCH] tweaks --- signer/core/siwevalidation.go | 5 +++-- signer/core/testdata/siwe/error_spoofing.json | 2 +- signer/core/testdata/siwe/valid_messages.json | 4 ++-- signer/core/testdata/siwe/warnings.json | 3 +-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/signer/core/siwevalidation.go b/signer/core/siwevalidation.go index f188d79694..0a6c9dff79 100644 --- a/signer/core/siwevalidation.go +++ b/signer/core/siwevalidation.go @@ -39,7 +39,6 @@ var wantsMsg = ` wants you to sign in with your Ethereum account:\n` var address = `(0x[a-fA-F0-9]{40})\n` // Optional statement (any line not containing "\n\n") -// var statement = `(?:[^\n]+\n)?` var statement = `(?:.*\n)?` // URI @@ -77,13 +76,15 @@ var siweMessageRegex = regexp.MustCompile(`(?m)^` + scheme + domain + wantsMsg + var ErrMalformedSIWEMessage = errors.New("the message is asking to sign in with Ethereum but does not conform to EIP-4361") +const suggestiveLanguage = "wants you to sign in with your Ethereum account" + func validateSIWE(req *SignDataRequest) error { for _, message := range req.Messages { s, ok := message.Value.(string) if !ok { continue } - if !strings.Contains(s, "wants you to sign in with your Ethereum account") { + if !strings.Contains(s, suggestiveLanguage) { continue } diff --git a/signer/core/testdata/siwe/error_spoofing.json b/signer/core/testdata/siwe/error_spoofing.json index 563a0ddaf7..6daf804cce 100644 --- a/signer/core/testdata/siwe/error_spoofing.json +++ b/signer/core/testdata/siwe/error_spoofing.json @@ -24,4 +24,4 @@ }, "error_msg_pattern": "sign in request address \\(0x1234567890123456789012345678901234567890\\) does not match source: 0x.*" } -} +} \ No newline at end of file diff --git a/signer/core/testdata/siwe/valid_messages.json b/signer/core/testdata/siwe/valid_messages.json index 34581af638..8373e0ace2 100644 --- a/signer/core/testdata/siwe/valid_messages.json +++ b/signer/core/testdata/siwe/valid_messages.json @@ -92,7 +92,7 @@ }, "domain is RFC 3986 authority with userinfo and port": { "msg": "test@127.0.0.1:8080 wants you to sign in with your Ethereum account:\n{{Account}}\n\nI accept the ServiceOrg Terms of Service: https://service.org/tos\n\nURI: https://service.org/login\nVersion: 1\nChain ID: 1\nNonce: 32891757\nIssued At: 2021-09-30T16:25:24.000Z", - "request_context":{ + "request_context": { "transport": "https", "source": "test@127.0.0.1:8080" } @@ -105,7 +105,7 @@ "request_context": { "transport": "https", "source": "[::cafe]" - } + } }, "uri ipv6": { "msg": "service.org wants you to sign in with your Ethereum account:\n{{Account}}\n\n\nURI: https://[::cafe]\nVersion: 1\nChain ID: 1\nNonce: 32891757\nIssued At: 2021-09-30T16:25:24.000Z" diff --git a/signer/core/testdata/siwe/warnings.json b/signer/core/testdata/siwe/warnings.json index 1925e12cfa..d25dc0adfc 100644 --- a/signer/core/testdata/siwe/warnings.json +++ b/signer/core/testdata/siwe/warnings.json @@ -32,5 +32,4 @@ "No scheme - ://user:pass@example.com:123/one/two.three?q1=a1&q2=a2#body": "service.org wants you to sign in with your Ethereum account:\n0x{{Account}}\n\n\nURI: ://user:pass@example.com:123/one/two.three?q1=a1&q2=a2#body\nVersion: 1\nChain ID: 1\nNonce: 32891757\nIssued At: 2021-09-30T16:25:24.000Z", "bad query - uri://user:pass@example.com:123/one/two.three ?q1=a1&q2=a2#body": "service.org wants you to sign in with your Ethereum account:\n0x{{Account}}\n\n\nURI: uri://user:pass@example.com:123/one/two.three ?q1=a1&q2=a2#body\nVersion: 1\nChain ID: 1\nNonce: 32891757\nIssued At: 2021-09-30T16:25:24.000Z", "bad fragment - uri://user:pass@example.com:123/one/two.three?q1=a1&q2=a2 #body": "service.org wants you to sign in with your Ethereum account:\n0x{{Account}}\n\n\nURI: uri://user:pass@example.com:123/one/two.three?q1=a1&q2=a2 #body\nVersion: 1\nChain ID: 1\nNonce: 32891757\nIssued At: 2021-09-30T16:25:24.000Z" - -} +} \ No newline at end of file