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

攻撃文字列生成 #26

Merged
merged 24 commits into from
Dec 6, 2020
Merged

攻撃文字列生成 #26

merged 24 commits into from
Dec 6, 2020

Conversation

n4o847
Copy link
Owner

@n4o847 n4o847 commented Nov 27, 2020

実装途中ですが経過が見えたほうがいい気がするのでプルリクにします。

@n4o847
Copy link
Owner Author

n4o847 commented Nov 27, 2020

こちらも redefine_state_2 を取り込みましたが、差分をわかりやすくするため redefine_state_2 をベースにして最後に master に戻します

@n4o847 n4o847 changed the base branch from master to redefine_state_2 November 27, 2020 10:17
@n4o847
Copy link
Owner Author

n4o847 commented Nov 27, 2020

む、master も取り込んじゃってるせいであんまりきれいに差分表示できなかった

@n4o847 n4o847 changed the base branch from redefine_state_2 to master November 27, 2020 10:19
@n4o847
Copy link
Owner Author

n4o847 commented Nov 27, 2020

いま showMessageEDAshowMessageIDA が判定のみに特化していて、それと処理が重複するのでどう統合するかが現時点での問題ですね

@n4o847 n4o847 mentioned this pull request Nov 27, 2020
@n4o847
Copy link
Owner Author

n4o847 commented Nov 27, 2020

変更点

  • Message の定義に攻撃文字列を付け加えた(プロパティ名など要相談)
  • eda.ts と ida.ts で共通化したい処理があったため attack.ts に寄せた(ここの構造はまだ悩み中)

まだできていない点

  • 「EDA/IDA 構造から始まってバックトラックを起こす文字列の探索」が多分まだ不十分

@n4o847
Copy link
Owner Author

n4o847 commented Nov 27, 2020

ところで検出メッセージについて、

  • "Detected EDA."
    • 受動態文の be 動詞を省略した形である "EDA detected." のほうがよく見る形な気がする?(好みかもしれませんが)
  • "Don't have IDA."
    • 三単現にしたほうがよいのでは?
    • 構文を上と揃えたほうがいいのでは?

と思いました

@yapatta
Copy link
Collaborator

yapatta commented Nov 27, 2020

僕のこのメッセージ結構適当に決めたので、適切に変えていただけるとありがたいです

@n4o847
Copy link
Owner Author

n4o847 commented Nov 27, 2020

いうて自分も決めかねるので、直接話し合うとき決めましょう~

@n4o847
Copy link
Owner Author

n4o847 commented Nov 28, 2020

// (a*)* has EDA?:  {
  status: 'Vulnerable',
  message: 'Detected EDA.',
  attack: 'aaaaaaaaaaaaaaaaaaaaa\u0000'
}

// (a+)+ has EDA?:  {
  status: 'Vulnerable',
  message: 'Detected EDA.',
  attack: 'aaaaaaaaaaaaaaaaaaaaa\u0000'
}

// (\w|\d)* has EDA?:  {
  status: 'Vulnerable',
  message: 'Detected EDA.',
  attack: '00000000000000000000000000000000000000000\u0000'
}

// a*a* has IDA?:  {
  status: 'Vulnerable',
  message: 'Detected IDA.',
  attack: 'aaaaaaaaaaaaaaaaaaaaa\u0000'
}

// (.*)="(.*)" has IDA?:  {
  status: 'Vulnerable',
  message: 'Detected IDA.',
  attack: '\u0000="\u0000="\u0000="\u0000="\u0000="\u0000="\u0000="\u0000="\u0000="\u0000="\u0000="\u0000="\u0000="\u0000="\u0000="\u0000="\u0000="\u0000="\u0000="\u0000="\u0000'
}

@n4o847
Copy link
Owner Author

n4o847 commented Nov 29, 2020

アルゴリズム自体はできているんですが、 #38 が終わってから各種コンフリクトを直す必要があるのでそしたら WIP を外します。

@n4o847
Copy link
Owner Author

n4o847 commented Dec 1, 2020

PrunedNFA に置き換えたら suffix が作れなくなってしまったので考え中です

@n4o847
Copy link
Owner Author

n4o847 commented Dec 2, 2020

アルゴリズムを変えたらいい感じになりました。

$ git checkout master
$ npm test > out/master
$ git checkout add_attacker
$ npm test > out/attack
$ diff out/master out/attack 
834c834,838
< // (a*)* has EDA?:  { status: 'Vulnerable', message: 'Detected EDA.' }
---
> // (a*)* has EDA?:  {
>   status: 'Vulnerable',
>   message: 'Detected EDA.',
>   attack: 'aaaaaaaaaaaaaaaaaaaaa\x00'
> }
915c919,923
< // (a+)+ has EDA?:  { status: 'Vulnerable', message: 'Detected EDA.' }
---
> // (a+)+ has EDA?:  {
>   status: 'Vulnerable',
>   message: 'Detected EDA.',
>   attack: 'aaaaaaaaaaaaaaaaaaaaa\x00'
> }
2041c2049,2053
< // (\w|\d)* has EDA?:  { status: 'Vulnerable', message: 'Detected EDA.' }
---
> // (\w|\d)* has EDA?:  {
>   status: 'Vulnerable',
>   message: 'Detected EDA.',
>   attack: '00000000000000000000000000000000000000000\x00'
> }
3225c3237,3241
< // a*a* has IDA?:  { status: 'Vulnerable', message: 'Detected IDA.' }
---
> // a*a* has IDA?:  {
>   status: 'Vulnerable',
>   message: 'Detected IDA.',
>   attack: 'aaaaaaaaaaaaaaaaaaaaa\x00'
> }
3472c3488,3492
< // (.*)="(.*)" has IDA?:  { status: 'Vulnerable', message: 'Detected IDA.' }
---
> // (.*)="(.*)" has IDA?:  {
>   status: 'Vulnerable',
>   message: 'Detected IDA.',
>   attack: '\x00="\x00="\x00="\x00="\x00="\x00="\x00="\x00="\x00="\x00="\x00="\x00="\x00="\x00="\x00="\x00="\x00="\x00="\x00="\x00="\x00\x00'
> }

@n4o847 n4o847 changed the title [WIP] 攻撃文字列生成 攻撃文字列生成 Dec 2, 2020
@n4o847 n4o847 requested review from yapatta and masa5555 December 2, 2020 09:37
@yapatta
Copy link
Collaborator

yapatta commented Dec 2, 2020

EDA判定のバグ修正してくださりありがとうございます。
以前(n,n)(m,k)(m!==k)の場合EDA検出をしたが、nとmとkが違うかという判定をしていなかった気がする。。。(m!==kだけ判定していたので, (a,a)(a,b)(a!==b)のようなグラフを通してしまっていた)
全部見るのにもう少しかかります、お待ちを

@yapatta
Copy link
Collaborator

yapatta commented Dec 3, 2020

コードの方はいい感じです!
しかし自分が攻撃文字列生成について納得できない部分(getSuffixの空集合からQ_fに遷移してしまうところ)があったので、一旦スラックに投げました。

@n4o847 n4o847 changed the base branch from master to develop December 6, 2020 05:38
@n4o847 n4o847 merged commit 1331ad0 into develop Dec 6, 2020
@n4o847 n4o847 deleted the add_attacker branch December 6, 2020 06:59
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.

EDA構造が存在するときの脆弱性を持つ文字列の具体例を表示する
3 participants