Skip to content

新チャレンジ: Path Traversal via attachment download (CWE-22) #6

Description

@exe-dev-github-integration

概要

download_attachment アクションで params[:filename] を受け取り send_file に直接渡す脆弱版を注入する。../../etc/passwd 等のパスで任意ファイルを読み出せる。

詳細

項目
slug path_traversal
カテゴリ File Access
難易度 Medium
CWE CWE-22

安全版(現在の実装)

Active Storage の redirect_to rails_blob_path のみを使用。ファイルパスを直接扱わない。

脆弱版(注入する実装)

params[:filename] をパス結合して send_file で返す。ディレクトリトラバーサルの検証なし。

def download_attachment
  path = Rails.root.join("storage", params[:filename])
  send_file path
end

テスト方針

  • SAFE: ../../etc/passwd を含むリクエストが拒否される
  • VULN: ../../etc/passwd でファイル内容が返る

注入方式

Module#prependTasksController#download_attachment を上書き

参考

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions