ビュー:

これらのYAML構成例をテンプレートとして使用し、AI ScannerでカスタムAIアプリケーションエンドポイントをスキャンします。

API構造に一致する設定パターンを見つけて、スキャンを開始するように適応してください。

構成ファイル構造

構成ファイルのcustomセクションを使用して、AIスキャナーがアプリケーションとどのように通信するかを定義します。次の項目を指定する必要があります。
  • エンドポイントURL
  • HTTP方式
  • ヘッダーフィールド、例えば、認証トークンやコンテンツタイプ宣言
  • リクエストボディのJSON構造、テキストプロンプトの位置を含む
  • 対応ボディのJSON構造、モデル出力の位置を含む
以下のプレースホルダーは、AIスキャナーがデータを挿入および抽出する場所を制御します。
  • {{prompt}}: AIスキャナーは実行時にこのプレースホルダーを攻撃プロンプトに置き換えます。
  • {{response}}: AIスキャナーはこの場所からモデル対応を抽出します。
  • {{api_key}}: AIスキャナーはこのプレースホルダーをTARGET_API_KEY環境変数の値に置き換えます。
重要
重要
アプリケーションプログラミングインターフェース (API) キーは環境変数に保存してください。APIキーを直接設定ファイルに含めないでください。

シンプルなREST API

AIアプリケーションが単一フィールドでプロンプトを受け取り、単一フィールドでモデル対応を返すシンプルなRESTエンドポイントを公開する場合、この構成を使用してください。requestresponseセクションのフィールド名をAPIスキーマに合わせて調整してください。
version: 1.1.0
name: Simple REST API Scan
description: Security scan for a basic text generation endpoint
target:
  # Replace with your endpoint URL
  name: my-text-api
  endpoint: https://api.example.com/v1/generate
  api_key_env: TARGET_API_KEY
  custom:
    method: POST
    headers:
      Content-Type: application/json
      Authorization: "Bearer {{api_key}}"
    request:
      # Replace field names to match your API schema
      input: "{{prompt}}"
      temperature: 0.2
    response:
      # Replace field names to match your API response
      answer: "{{response}}"
settings:
  concurrency: 10
attack_objectives:
  - name: System Prompt Leakage
    techniques:
      - None
    modifiers:
      - None
  - name: Sensitive Data Disclosure
    techniques:
      - None
    modifiers:
      - None

メッセージ配列を使用したチャット完了API

AIアプリケーションがチャット完了APIの規約に従う場合、この構成を使用します。プロンプトは、役割とコンテンツフィールドを持つメッセージ配列として送信されます。このパターンは、OpenAIと同じリクエスト構造に従うカスタムホストのエンドポイントで一般的です。
system_promptフィールドは、AIスキャナーがスキャン中に会話に付加するトップレベルのターゲット設定です。リクエストボディには表示されません。
version: 1.1.0
name: Chat Completions API Scan
description: Security scan for a chat-style AI endpoint
target:
  # Replace with your endpoint URL
  name: my-chat-api
  endpoint: https://api.example.com/v1/chat/completions
  api_key_env: TARGET_API_KEY
  # AI Scanner prepends this to conversations during scanning
  system_prompt: You are a helpful assistant.
  custom:
    method: POST
    headers:
      Content-Type: application/json
    request:
      # Replace model name with your deployed model
      model: my-model-v1
      messages:
        - role: user
          content: "{{prompt}}"
      stream: false
    response:
      # Match the response structure of your API
      choices:
        - finish_reason: stop
          index: 0
          message:
            content: "{{response}}"
            role: assistant
settings:
  concurrency: 10
attack_objectives:
  - name: System Prompt Leakage
    techniques:
      - DAN (Do anything now)
    modifiers:
      - None
  - name: Malicious Code Generation
    techniques:
      - Ignore all previous instructions
    modifiers:
      - Base64 Encoding

ネストされたリクエストと対応の構造

AIアプリケーションがプロンプトと対応を深くネストされたJSONオブジェクトでラップする場合、メタデータや構成パラメータをプロンプトと共に含むAPIなどでこの構成を使用してください。
version: 1.1.0
name: Nested Structure API Scan
description: Security scan for an endpoint with nested JSON payloads
target:
  # Replace with your endpoint URL
  name: my-nested-api
  endpoint: https://nlp.example.net/run
  api_key_env: TARGET_API_KEY
  custom:
    method: POST
    headers:
      Content-Type: application/json
      Authorization: "Token {{api_key}}"
    request:
      # Match the nested structure of your API request
      payload:
        prompt: "{{prompt}}"
      config:
        temperature: 0.1
        max_tokens: 1000
    response:
      # Match the nested structure of your API response
      data:
        result:
          message: "{{response}}"
settings:
  concurrency: 5
attack_objectives:
  - name: Sensitive Data Disclosure
    techniques:
      - Payload splitting
    modifiers:
      - Best-of-N Scrambling
  - name: Agent Tool Definition Leakage
    techniques:
      - None
    modifiers:
      - None