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

ReDos攻撃対応 #19

Open
ver-1000000 opened this issue Jan 4, 2022 · 3 comments
Open

ReDos攻撃対応 #19

ver-1000000 opened this issue Jan 4, 2022 · 3 comments

Comments

@ver-1000000
Copy link
Owner

https://twitter.com/kawaz/status/1477809915729448961?t=yDJcv4_ZsnpbLKiBoUmpbw&s=19

正規表現登録時に時間計算して長過ぎたら弾くバリデーションとか入れる……?

@s3-odara
Copy link

Rustの正規表現って後方参照とか先読みのない素朴な正規表現なんだけど、潜在的に危険な機能の制限のおかげで線形時間での実行が保証されてるらしい(=redos攻撃の可能性がない?)

https://gihyo.jp/dev/serial/01/perl-hackers-hub/007402
https://medium.com/veltra-engineering/regexp-library-re2-for-fragility-risk-7c28310838e0

C++の安全な正規表現の実装がnode.isにも移植されてるらしいから、今ある正規表現をそれに変換するのが根本的な解決策になるかもしれない

@ver-1000000
Copy link
Owner Author

ほえー
ということは「既存の安全な正規表現の手法がある」ということなので、
その観点でいうと「なんかいい感じの安全正規表現ライブラリを探して使う」ってアプローチ取れそう。

@s3-odara
Copy link

Discordは最近デフォルトの荒らし対策みたいなやつが導入されて、ユーザーが正規表現書けるようになったんだけどそれはrustの正規表現使うのと、コンパイルサイズ制限で安全にしてる

でも安全な正規表現を使うなら、マッチリスト/マッチさせないリストの両方を用意するのと、それぞれ複数の正規表現を入れられるようにしないと表現力が落ちる。

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

No branches or pull requests

2 participants