====== ファイルのパーミッションを検証する ====== 共有システムの場合、アクセスしているファイルのアクセス権限を確認し、不正に書き換えなどが行えない状態であることを確認する必要があります。アクセスパーミッション権限とファイルオーナー、ファイルグループを検証する必要があります。 ===== 非適合コード例 ===== **検証なしのファイルデータ利用** $file = '/tmp/useranme/secret_data'; $important_data = file_get_contents($file); ===== 適合コード例 ===== **検証後にファイルデータを取得** $file = '/tmp/useranme/secret_data'; $myuid = 1234; $mygid = 4567; $perm = 0600; $stat = stat($file); if (($stat['mode'] & 0777) !== 0600) { throw new Exception('Invalid file permission'); } if ($stat['uid'] !== $myuid) { throw new Exception('Invalid uid'); } if ($stat['gid'] !== $mygid) { throw new Exception('Invalid gid'); } $important_data = file_get_contents($file); ===== 例外 ===== 外部からの改ざんが無いと保証できる場合は検証を省略できる。 ===== リスク評価 ===== [ルール/推奨事項のリスク評価] [評価例 - 英語表記に統一] ^ Rule ^ Severity ^ Likelihood ^ Remediation Cost ^ Priority ^ Level ^ | IDS05-J | medium | unlikely | medium | P4 | L3 | ===== 関連ガイドライン ===== ===== 参考文献 =====