Code-level解析とIoTの調査1 / 2

解析方法の選択

PE Checker等のheader解析はsection、import、entry、署名等から異常候補を捉える。高entropyだけでは圧縮した正規fileとも区別できない。Burpは許可したWeb対象のrequest/responseをProxy/Repeater等で比較し、異なるuserでのobjectアクセスや入力処理の弱点を調べる。認証後も、各objectに対する操作の認可を検査する。

Semgrepはsourceをpattern/taintで解析する。次はPythonのshell=True呼出しを候補にするruleである。入力が外部由来かを別に追うため、全一致が即脆弱性確定とはならない。

rules:
  - id: python-shell-call
    languages: [python]
    message: Review shell argument and input origin
    severity: WARNING
    pattern: subprocess.run(..., shell=True, ...)
semgrep scan --config rules.yml target.py

ローカルのrules.ymlを使い、target.pyを検査する例である。

Command引数の配列化とshell=Falseは、shell展開を必要としない処理の改善候補となる。

学習パスへ
参考資料