Commit 16faddb
committed
fix(siwe): normalize Ethereum address to lowercase to prevent duplicate identities
Ethereum addresses are protocol-level case-insensitive: 0xABC... and
0xabc... refer to the same wallet. EIP-55 mixed-case is a visual
checksum, not a distinct identifier.
Before this change, internal/utilities/siwe/parser.go stored the address
verbatim from the SIWE message body. internal/api/web3.go then composed
the identity provider_id directly from that string, and
models.FindIdentityByIdAndProvider does case-sensitive equality on
provider_id. The result: the same wallet signing in with different case
variants of its address produced two distinct auth.identities rows
pointing to two separate users. Fixes #2264.
The fix is a single strings.ToLower call at parser entry, immediately
after the address pattern matches. Normalizing at the parser layer
gives every caller a single canonical form with no extra knowledge
required, and matches the existing email lowercase-normalization
precedent in internal/models/identity.go (BeforeUpdate). VerifySignature
already used strings.EqualFold, so signature recovery is unaffected.
Scope is intentionally limited to SIWE (Ethereum). The SIWS (Solana)
parser is left untouched: Solana addresses are base58, which is
case-sensitive, and lowercasing them would corrupt valid addresses.
Operational note: this fix prevents NEW duplicate identities. Existing
rows with mixed-case provider_id values are not migrated by this
patch; operators who have already accumulated duplicates will need a
separate backfill that lowercases auth.identities.provider_id for
provider='ethereum' rows and merges the resulting collisions. Flagged
as out of scope here.
Signed-off-by: Manas Srivastava <mastermanas805@gmail.com>1 parent 7f88985 commit 16faddb
2 files changed
Lines changed: 60 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
60 | 70 | | |
61 | 71 | | |
62 | 72 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
116 | 116 | | |
117 | 117 | | |
118 | 118 | | |
119 | | - | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
120 | 123 | | |
121 | 124 | | |
122 | 125 | | |
| |||
134 | 137 | | |
135 | 138 | | |
136 | 139 | | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
0 commit comments