Compare addresses case-insensitively: identity checks and SQL visibility - #44
Merged
Conversation
fmsg addresses are case-insensitive (SPECIFICATION.md: case folding), but the from/ownership checks compared bytes, so a first-party token whose identity keeps the case a sub-account was created with (e.g. @user_Agent@domain) was refused with 403 "from address must match authenticated user" when a client sent the folded form. All six identity checks in the message handlers now use sameAddr (EqualFold). Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AoApk9grYkP1EMd4F4GVMv
The msg tables already carry lower(from_addr) / lower(addr) expression indexes (fmsgd dd.sql), so every visibility, read-state, ownership and attachment query now compares lower(col) against a lower-cased identity or lower($n). A mixed-case identity now sees messages whose stored recipient entries use any case. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AoApk9grYkP1EMd4F4GVMv
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
fmsg addresses are case-insensitive (SPECIFICATION.md, case folding), but the webapi compared them byte-for-byte in two places. A first-party token's identity keeps the case the sub-account was created with (e.g.
@markmnl_ChatGPT@fmsg.io), so a client that folded the address was refused with403 from address must match authenticated user, and a mixed-case identity could miss messages whose stored recipient entries used another case. Seen live via fmsg-mcp on fmsg.io today.sameAddr(strings.EqualFold) at the six sites ininternal/handlers/messages.go(fromon create/update; ownership on update/delete/send/add-to), matchingisRecipientwhich already compared that way. Unit test added.msg/msg_to/msg_add_tonow compareslower(col)against a lower-cased identity (visibleAddrslower-cases) orlower($n). fmsgd's schema already providesmsg_lower_idx,msg_to_lower_idxandmsg_add_to_lower_idxexpression indexes for exactly this, so the queries stay indexed.resolveLocalDelivery's UPDATE keeps an exact match because it targets rows this handler inserted with the same string.push_subscription(webapi's own table, IdP identities) is unchanged.Test plan
go vet ./... && go test ./...FMSG_WEBAPI_REF=address-case-insensitive: 14/14 passed locally (podman)@alice_Mixed@hairpin.local(registered in fmsgid by hand: the CLIapi-key createpath does not register derived addresses, unlikePOST /fmsg/sub-accounts) receives a message sent to the lower-case form, lists it, marks it read, sees the full thread, and sends withfromin either casing;/fmsg/sentlists both🤖 Generated with Claude Code
https://claude.ai/code/session_01AoApk9grYkP1EMd4F4GVMv