What is Nostr?
Misskey GitHub Notifier @p1.a9z.dev /
npub1egx…0wqy
2024-11-19 12:29:53

Misskey GitHub Notifier @p1.a9z.dev on Nostr: 💬 Commented on "CSPを導入する": eternal-flame-AD ...

💬 Commented on "CSPを導入する": eternal-flame-AD "Googleのアナライザーからのヒント:

Relavant warnings for #9863 on https://csp-evaluator.withgoogle.com/ :

> ⚠ 'self' can be problematic if you host JSONP, AngularJS or user uploaded files. - Misskey hosts user uploaded files.
> ⚠ 'unsafe-eval' allows the execution of code injected into DOM APIs such as eval().
>


先週に自分のインスタンスに最小権限の CSP を実装しました。「unsafe-eval」 を使用せず、初期化が完了した後のインジェクションを防ぐためにすべてのインライン スクリプト/SVG の SRI を初期化時に計算します。

これは Self-XSS ( rel: #14839 ) に対する保護も提供します。これにより、コンソールを開いて情報を漏らすことさえできなくなります。他のドメインにfetch() は許可されません。プロキシされた画像 URL でデータを漏らすには、画像を挿入してデータをエンコードする必要があります。

ただし、これはアップストリームには厳しすぎるかもしれません。これと #9863 の中間が良さそう (インライン スクリプトを事前にハッシュして「unsafe-eval」を削除します)。

I implemented a least-privilege CSP last week on my instance that do not use 'unsafe-eval' (which significantly hampers the effect of CSP) and precomputes during initialization all inline script/SVG SRIs to prevent any injection after initialization is complete.

This also provides good protection against Self-XSS ( rel: #14839 ) . With this you can't even open the console and leak information out: no fetch() will be allowed. You have to insert an image and encode your data to exfiltrate in a proxied image URL.

This might be too strict for upstream though, I think a middleground between this and #9863 is a good idea (maybe pre hash the inline scripts and remove 'unsafe-eval' but don't be too worried about strict CSS safety.

---

Related commits:

Initial implementation: https://forge.yumechi.jp/yume/yumechi-no-kuni/commits/branch/master/search?q=csp&all=
Configuration: https://forge.yumechi.jp/yume/yumechi-no-kuni/pulls/15

✅ Tested Working: WebUI (Admin+User use), "cli", Bull Dashboard, code highlighting
🚫 Currently Not Working:
- Some hardcoded images in about-misskey need to be proxied to be allowed.
- `/api-doc` need to have the CDN dependency removed

Analysis (no true positive warnings!):

![Image](https://github.com/user-attachments/assets/b25ffb1f-79ad-44d8-8e18-45d79fd37e25)"
https://github.com/misskey-dev/misskey/issues/9848#issuecomment-2485584653
Author Public Key
npub1egx9tyfa0tg4ymes76aa5m6hhgzvmhg2xhj0lv59txp3chn253yqee0wqy