# ファイルインクルードの脆弱性 ## 対策 - 権限を設定して閲覧などを行えなくする - そもそも直接ファイルパスを埋め込まないようにする - 特殊文字を禁止する - パスを正規化してパスの先頭が正常な値かを確かめる ## 事例 - https://jvndb.jvn.jp/ja/contents/2020/JVNDB-2020-006079.html ```diff - return $this->theme->getPath().'/'.$this->dirName.'/'.$fileName; + // Limit paths to those under the assets directory + $directory = $this->theme->getPath() . '/' . $this->dirName . '/'; + $path = realpath($directory . $fileName); + if (!starts_with($path, $directory)) { + return false; + } + + return $path; ```