Skip to content

fix(utils): reject CR/LF in CACAO SIWE single-line fields - #345

Open
SashaMIT wants to merge 1 commit into
reown-com:developfrom
SashaMIT:fix/siwe-reject-crlf-single-line-fields
Open

fix(utils): reject CR/LF in CACAO SIWE single-line fields#345
SashaMIT wants to merge 1 commit into
reown-com:developfrom
SashaMIT:fix/siwe-reject-crlf-single-line-fields

Conversation

@SashaMIT

Copy link
Copy Markdown

Description

SIWEFromCacaoPayloadFormatter.formatMessage interpolated CACAO domain / statement / aud / version / nonce / iat / optional exp / nbf / requestId into the EIP-4361 (CAIP-122) message without rejecting embedded \r / \n.

A crafted domain like example.com\nURI: https://evil.example forges additional message lines (same class as statement smuggling).

Fail closed: reject CR/LF in those single-line fields before formatting. Sibling of walletconnect-monorepo#7311 and walletconnect-utils#280.

Resolves # (issue) n/a (hardening)

How Has This Been Tested?

  • Added unit tests that assert domain / statement / aud with embedded breaks throw invalidSingleLineField
  • Existing formatter fixtures unchanged
  • Full swift test not run locally (SwiftPM yttrium binary download blocked here); CI is the gate

Due Dilligence

  • Breaking change (callers that previously smuggled line breaks into single-line fields will now throw)
  • Requires a documentation update

Attacker model

Party that supplies CACAO payload fields used for sign/verify message reconstruction (malicious or compromised auth-request builder). No private key required. Gap is structured-field to SIWE-text integrity.

Made with Cursor

EIP-4361 / CAIP-122 single-line fields (domain, statement, aud, version,
nonce, iat, exp, nbf, requestId) must not embed carriage returns or
newlines, or a caller can forge later message lines. Fail closed before
formatting. Parity with walletconnect-monorepo#7311 / utils#280.
@sonarqubecloud

Copy link
Copy Markdown

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant