Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

validate signed headers #2497

Merged
merged 2 commits into from
Nov 27, 2023
Merged

validate signed headers #2497

merged 2 commits into from
Nov 27, 2023

Conversation

mei23
Copy link
Owner

@mei23 mei23 commented Nov 27, 2023

Summary

Fix mei23/misskey#4748

inboxのサイズリミットが1mb=>64kbになります
AP inboxでdigest headerとbodyとを検証していないのを修正。
AP inboxでhost headerと自ホストとを検証していないのを修正。
HTTP Signatureの署名対象ヘッダに、(request-target), digest, host, date が含まれてない場合はエラーにするように。

dateが300秒以上ずれている場合 (主にどちらかの時計が狂っている場合) 弾かれるようになります。
この仕様はhttp-signatureのclock-skewによるもの
https://github.com/TritonDataCenter/node-http-signature/blob/master/http_signing.md#clock-skew

rawBodyの取得について

digest計算のためにJSON parse前の生のbodyが必要になるが、ctx.request.rawBodyは型定義的に使用できそうに見えるものの、実際はkoa-bodyparserの機能なためそれを使用してなければ使用できません。(現在はkoa-json-bodyを使用)

koa-bodyparserでもいいものの、JSON parseが回りくどいのと型周りが嫌なので、依存先のco-bodyを使用しています。
また、オプションについてはraw-bodyも見ると良いです。

@mei23 mei23 merged commit 5e385d5 into mei-v11 Nov 27, 2023
3 checks passed
mgmn pushed a commit to mgmn/misskey-v11 that referenced this pull request Nov 27, 2023
* validate signed headers

* リクエストホスト

Co-authored-by: perillamint <[email protected]>
Co-authored-by: yunochi <[email protected]>
Co-authored-by: Laura Hausmann <[email protected]>
fs5m8 referenced this pull request in sakura-tel/areionskey Nov 28, 2023
* validate signed headers

* リクエストホスト

Co-authored-by: perillamint <[email protected]>
Co-authored-by: yunochi <[email protected]>
Co-authored-by: Laura Hausmann <[email protected]>
@mei23
Copy link
Owner Author

mei23 commented Dec 2, 2023

ee8a039

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.

GHSA-3f39-6537-3cgc
1 participant