Repository navigation
fix(federation): 署名者と actor の厳密な紐付けとオブジェクト起源の検証 - #292
Merged
Merged
Conversation
…ce object origin
- verifySignature: validate keyId (http(s), no dot segments/backslashes,
not local host), require fetched document's publicKey.id === keyId and
owner === document id (or same-origin standalone Key doc), cache
{publicKeyPem, owner} (legacy string entries treated as a miss), and
expose the verified owner as c.get("signatureActor")
- activityValidation/inbox: replace keyId.startsWith(actor) with exact
activity.actor === verified owner; reject local-host actors
- CreateHandler: require attributedTo === actor and same-origin http(s) id
- AnnounceHandler: require fetched id same-origin with requested URI,
reject local authors, resolve local notes by id instead of self-fetch
- RemoteNoteService.processNote: reject non-http(s) ids (stored XSS via
note.uri), local attributedTo, cross-origin id/author; return existing
local note for local ids instead of creating
- Update/DeleteHandler: refuse to modify local users/notes
- Add unit tests for all of the above
Claude-Session: https://claude.ai/code/session_01Y29fBeRP344FME6de48wUv
Contributor
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 9 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
- verifySignature: replace same-origin trust with Mastodon-style owner verification. Accept the key document directly only when it is the owner's actor document served from exactly the requested URL (no redirect); otherwise fetch the owner actor (no redirect, id === owner) and require it to list a key with id === keyId and identical PEM. Covers GoToSocial /main-key stubs and /publickey Key documents. - safeFetch: add safeFetchWithFinalUrl; RemoteFetchService exposes finalUrl and rejects cross-origin redirects by default (allowCrossOriginRedirect opt-in, used for WebFinger) - AnnounceHandler: require fetched id === requested URI, otherwise refetch once by canonical id and require an exact match; reject cross-origin final URLs; reject non-public/home, localOnly or deleted targets; derive renote visibility from to/cc; require activity.id to be http(s) on the actor's origin - activityValidation: activity.id must be http(s) and same origin as the actor (prevents javascript: ids and dedup/URI squatting) - federationUrl/RemoteActorService: normalize hostnames (lowercase, trailing dot) for local-host detection - Tests for all of the above Claude-Session: https://claude.ai/code/session_01Y29fBeRP344FME6de48wUv
Member
Author
|
再レビューの指摘に対応しました(01687f1)。
|
This was referenced Oct 14, 2026
Merged
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.
変更
middleware/verifySignature.tsvalidateKeyId(): http(s) 以外、ドットセグメント(%2e含む)、バックスラッシュ、制御文字、ローカルホストを指す keyId を fetch 前に拒否extractVerifiedPublicKey(): 取得したドキュメントのpublicKey.id === keyId、owner === ドキュメント id、ドキュメント id が取得 URL と同一オリジンであることを検証(GoToSocial の/main-keyスタブや/publickey形式の Key ドキュメントにも対応){publicKeyPem, owner}に変更(旧形式はミス扱い)し、signatureActorをコンテキストに設定utils/activityValidation.ts/routes/ap/inbox.ts:keyId.startsWith(actor)を廃止し、activity.actor === 検証済み ownerを必須に。ローカルホストの actor は拒否CreateHandler:attributedTo === actorとobject.idが actor と同一オリジンの http(s) であることを必須にAnnounceHandler: 取得したドキュメントの id が要求 URL と同一オリジンであること、attributedToがローカルでないことを検証。uri が null の古いローカルノートは/notes/:idから引くようにRemoteNoteService.processNote: http(s) 以外の id を拒否、ローカル id では既存ノートを返すのみで作成しない、ローカルユーザー名義・id と作者のオリジン不一致を拒否UpdateHandler/DeleteHandler: actor がローカルユーザーに解決される場合は拒否互換性
確認
https://claude.ai/code/session_01Y29fBeRP344FME6de48wUv