@php
$_pdfLogo = null;
foreach (['png','svg','jpg','jpeg'] as $_ext) {
$_path = public_path('logo.'.$_ext);
if (file_exists($_path)) {
$_mime = $_ext === 'svg' ? 'image/svg+xml' : 'image/'.$_ext;
$_pdfLogo = 'data:'.$_mime.';base64,'.base64_encode(file_get_contents($_path));
break;
}
}
@endphp
{{-- 1. 執行摘要 --}}
一、執行摘要
整體風險等級:{{ $riskLevel }}
{{ $riskDesc }}
本次使用 {{ $scannerMeta['label'] }} {{ $scannerMeta['ver'] }} 弱點掃描引擎,
採用 {{ $profileName }} 模式,
針對目標 {{ $vulnScan->target_url }} 進行自動化安全檢測。
掃描作業於 {{ $vulnScan->started_at?->format('Y年m月d日 H:i') }} 開始,
歷時 {{ $duration }} 完成,涵蓋 OWASP Top 10 等主流弱點類型。
@if($pagesScanned !== null)
本次共掃描 {{ number_format($pagesScanned) }} 個頁面/URL。
@endif
{{-- 嚴重度統計 --}}
| Critical |
High |
Medium |
Low |
Info |
|
{{ $critical }}
CRITICAL
嚴重
|
{{ $high }}
HIGH
高風險
|
{{ $medium }}
MEDIUM
中風險
|
{{ $low }}
LOW
低風險
|
{{ $info }}
INFO
資訊
|
{{-- 2. 風險說明 --}}
二、風險等級說明
| Critical |
嚴重漏洞:可直接被遠端利用,無需授權即可取得系統控制權或存取敏感資料。常見如遠端程式碼執行(RCE)、SQL Injection(資料庫注入)等。
建議立即修復(24 小時內)。
|
| High |
高風險漏洞:可能造成重大損害,如資料洩漏、身分驗證繞過、未授權操作等。需要一定條件才能被利用。
建議 7 天內修復。
|
| Medium |
中等風險:單獨利用危害有限,但可能與其他漏洞組合使用造成更大影響。常見如跨站腳本(XSS)、CSRF、資訊洩漏等。
建議 30 天內修復。
|
| Low |
低風險:危害程度較低,通常為設定不當或資訊暴露問題。
建議於例行維護時修復。
|
| Info |
資訊性:非直接安全威脅,主要為技術指紋識別、服務探測結果,可輔助了解系統暴露面。
|
{{-- 3. 主要發現摘要 --}}
@php
$nonInfo = array_filter($findings, fn($f) => ($f['severity'] ?? 'info') !== 'info');
$topFindings = array_slice(array_values($nonInfo) ?: $findings, 0, 10);
@endphp
三、主要發現摘要(Top {{ count($topFindings) }})
@if(empty($topFindings))
本次掃描未發現高風險問題,所有發現均為資訊性項目。
@else
@foreach($topFindings as $i => $f)
@php $sev = $f['severity'] ?? 'info'; @endphp
{{ strtoupper($sev) }}
{{ $f['name'] ?: $f['template_id'] }}
@if(!empty($f['matched_at']))
→ {{ $f['matched_at'] }}
@endif
@if(!empty($f['description']))
{{ mb_strimwidth($f['description'], 0, 150, '…') }}
@endif
@endforeach
@endif
{{-- 4. OWASP Top 10 分佈 --}}
@if(!empty($byOwasp))
四、OWASP Top 10 風險分佈
OWASP(Open Web Application Security Project)Top 10 是國際公認的 Web 應用程式十大安全風險清單,
以下為本次掃描結果與 OWASP 分類的對應關係。
| 分類 ID |
風險名稱 |
發現數 |
狀態 |
@foreach($owaspLabels as $oid => $olabel)
@php $cnt = $byOwasp[$oid] ?? 0; @endphp
| {{ $oid }} |
{{ $olabel }} |
{{ $cnt > 0 ? $cnt : '—' }}
|
@if($cnt > 0)
⚠ 發現
@else
✓ 未發現
@endif
|
@endforeach
@endif
{{-- 4b. Garak LLM 行為安全評估(Garak 掃描) --}}
@if($isGarakMode)
四、Garak LLM 行為安全評估
本次使用 Garak(NVIDIA 開源 LLM 安全評估工具)對目標模型
{{ $garakModel }}
進行 OWASP LLM Top 10 2025 行為安全測試。
Garak 直接對模型發送對抗性提示,評估提示注入、越獄攻擊、資料洩漏等風險。
ⓘ 結果說明:
每筆發現代表一個探針測試中模型產生了不符合安全預期的回應(測試失敗)。
「失敗率」越高代表模型對該類型攻擊越脆弱。
失敗率 ≥50% 標記為高風險,≥20% 為中風險。
@php
$garakLlmOwasp = $summary['by_llm_owasp'] ?? [];
$garakLlmRows = [
'LLM01:2025' => ['提示注入', 'Prompt Injection', 'LLM01'],
'LLM02:2025' => ['敏感資訊洩漏', 'Sensitive Information Disclosure','LLM02'],
'LLM05:2025' => ['不當輸出處理', 'Improper Output Handling', 'LLM05'],
'LLM06:2025' => ['過度自主行為', 'Excessive Agency', 'LLM06'],
'LLM07:2025' => ['系統提示詞洩漏', 'System Prompt Leakage', 'LLM07'],
'LLM09:2025' => ['錯誤資訊', 'Misinformation', 'LLM09'],
];
@endphp
| 分類 ID |
風險名稱 |
失敗測試數 |
狀態 |
@foreach($garakLlmRows as $lid => [$lname, $len, $short])
@php $lcnt = $garakLlmOwasp[$lid] ?? 0; @endphp
| {{ $lid }} |
{{ $lname }}
{{ $len }}
|
{{ $lcnt > 0 ? $lcnt : '—' }}
|
@if($lcnt > 0)
⚠ 發現弱點
@else
✓ 通過測試
@endif
|
@endforeach
@endif {{-- isGarakMode --}}
{{-- 4c. OWASP LLM Top 10(ZAP AI 掃描模式) --}}
@if($isAiMode && !$isGarakMode)
{{ empty($byOwasp) ? '四' : '五' }}、OWASP LLM Top 10 2025 分析
OWASP LLM Top 10 2025 是 OWASP Foundation 針對大型語言模型(LLM)應用程式發布的十大安全風險框架,
以下為本次 AI 伺服器掃描結果與 LLM 風險分類的對應分析。
ⓘ 計數說明:
本表將 ZAP 偵測到的傳統 Web 漏洞對應至 OWASP LLM Top 10 類別。
同一筆漏洞可能對應多個類別,因此各類別數字加總會大於實際漏洞總數,此為正常現象。
顯示「—」代表未發現直接對應該類別的漏洞,並非代表該 LLM 風險不存在;
提示注入、模型投毒等 LLM 原生風險需搭配人工紅隊演練才能完整評估。
{{-- 已暴露 LLM 端點 --}}
@if(!empty($exposedEndpoints))
⚠ 偵測到未受保護的 LLM API 端點({{ count($exposedEndpoints) }} 個)
以下端點在未提供任何認證的情況下可直接存取,攻擊者可能直接呼叫 AI 模型或執行管理操作:
@foreach($exposedEndpoints as $ep)
{{ $ep }}
@endforeach
@endif
{{-- LLM Top 10 表格 --}}
@php
$llmRows = [
'LLM01:2025' => ['提示注入', 'Prompt Injection'],
'LLM02:2025' => ['敏感資訊洩漏', 'Sensitive Information Disclosure'],
'LLM03:2025' => ['供應鏈漏洞', 'Supply Chain Vulnerabilities'],
'LLM04:2025' => ['資料與模型投毒', 'Data and Model Poisoning'],
'LLM05:2025' => ['不當輸出處理', 'Improper Output Handling'],
'LLM06:2025' => ['過度自主行為', 'Excessive Agency'],
'LLM07:2025' => ['系統提示詞洩漏', 'System Prompt Leakage'],
'LLM08:2025' => ['向量與嵌入弱點', 'Vector and Embedding Weaknesses'],
'LLM09:2025' => ['錯誤資訊', 'Misinformation'],
'LLM10:2025' => ['無限制資源消耗', 'Unbounded Consumption'],
];
$llmSolMap = [
'LLM01:2025' => '實作輸入驗證;使用特權層級分離系統提示;對模型輸出進行後處理驗證。',
'LLM02:2025' => '對輸出內容進行 PII 偵測與遮蔽;設定系統提示禁止洩漏機密;實作輸出過濾器。',
'LLM03:2025' => '使用受信任來源的模型;定期掃描依賴套件漏洞;維護 SBOM。',
'LLM04:2025' => '驗證訓練資料來源與完整性;定期以紅隊測試評估模型行為;監控推論結果。',
'LLM05:2025' => '對 LLM 輸出進行嚴格的輸出編碼;視 LLM 輸出為不受信任的輸入。',
'LLM06:2025' => '採用最小權限原則;對高影響操作要求人工確認;限制 Agent 外部網路存取。',
'LLM07:2025' => '不在系統提示詞中存放敏感認證;定期測試模型對提示詞揭露請求的回應。',
'LLM08:2025' => '實作嚴格的向量資料庫存取控制;使用加密儲存向量。',
'LLM09:2025' => '提供引用來源;對關鍵輸出進行人工審核;明確標示 AI 生成內容。',
'LLM10:2025' => '實作請求速率限制與 Token 配額;設定最大 Token 上限;監控異常使用模式。',
];
@endphp
| 分類 ID |
風險名稱 |
發現數 |
修復建議摘要 |
@foreach($llmRows as $lid => [$lname, $len])
@php $lcnt = $byLlmOwasp[$lid] ?? 0; @endphp
| {{ $lid }} |
{{ $lname }}
{{ $len }}
|
{{ $lcnt > 0 ? $lcnt : '—' }}
|
@if($lcnt > 0){{ $llmSolMap[$lid] ?? '' }}@else—@endif
|
@endforeach
@endif {{-- isAiMode --}}
{{-- 5. 修補建議優先順序 --}}
@php
// 修補建議:有 remediation 或有 zapPlugin 說明的非 info 項目
$fixFindings = array_filter($findings, function($f) use ($zapPlugins) {
if (!in_array($f['severity'] ?? '', ['critical','high','medium','low'])) return false;
$pid = (string)($f['extra']['plugin_id'] ?? '');
return !empty($f['remediation']) || (!empty($pid) && isset($zapPlugins[$pid]));
});
@endphp
@if(!empty($fixFindings))
五、修補建議優先順序
| 優先 |
嚴重度 |
漏洞名稱 |
建議修復措施 |
@php $rank = 1; @endphp
@foreach($findings as $f)
@php
$fSev = $f['severity'] ?? '';
if (!in_array($fSev, ['critical','high','medium','low'])) continue;
$pid2 = (string)($f['extra']['plugin_id'] ?? '');
$pInfo2 = $pid2 ? ($zapPlugins[$pid2] ?? null) : null;
$sol = !empty($f['remediation']) ? $f['remediation'] : ($pInfo2['sol'] ?? '');
if (!$sol) continue;
@endphp
| {{ $rank++ }} |
{{ strtoupper($fSev) }} |
{{ $f['name'] ?: ($f['template_id'] ?? '—') }} |
{{ mb_strimwidth($sol, 0, 150, '…') }} |
@endforeach
@endif
{{-- 6. 詳細發現清單 --}}
{{ empty($hasFix) ? '五' : '六' }}、詳細發現清單(共 {{ $total }} 筆)
@forelse($findings as $i => $f)
@php
$sev = $f['severity'] ?? 'info';
$pid = (string)($f['extra']['plugin_id'] ?? '');
$pInfo = $pid ? ($zapPlugins[$pid] ?? null) : null;
$descText = !empty($f['description']) ? $f['description'] : ($pInfo['desc'] ?? '');
$remedText= !empty($f['remediation']) ? $f['remediation'] : ($pInfo['sol'] ?? '');
$fOwasp = (array)($f['owasp'] ?? []);
$fCve = (array)($f['cve_id'] ?? []);
$fRef = (array)($f['reference'] ?? []);
// 自動補充參考連結
if (empty($fRef)) {
foreach ($fOwasp as $oid) {
$fRef[] = 'https://owasp.org/Top10/';
}
if ($pid) $fRef[] = 'https://www.zaproxy.org/docs/alerts/'.$pid.'/';
}
$sevColors = ['critical'=>'#dc2626','high'=>'#ea580c','medium'=>'#d97706','low'=>'#16a34a','info'=>'#475569'];
$sevColor = $sevColors[$sev] ?? '#475569';
@endphp
{{ strtoupper($sev) }}
#{{ str_pad($i+1, 3, '0', STR_PAD_LEFT) }}
{{ $f['name'] ?: ($f['template_id'] ?? '—') }}
{{ $f['template_id'] ?? '' }}
@foreach($fCve as $cid)
{{ $cid }}
@endforeach
@foreach($fOwasp as $oid)
{{ $oid }}
@endforeach
@if($isAiMode)
@foreach((array)($f['llm_owasp'] ?? []) as $lid)
{{ $lid }}
@endforeach
@endif
{{-- 影響網址位置(獨立一行,突出顯示)--}}
🌍 影響網址位置
{{ $f['matched_at'] ?: '—' }}
{{-- 三欄:風險分類 ╱ 漏洞說明+解法 ╱ 參考資料 --}}
{{-- 欄A:對應風險分類 --}}
⚠ 對應風險分類
@php
$sevDescs = [
'critical'=>'可直接被遠端利用,無需授權即可取得系統控制權。建議立即(24H內)修復。',
'high' =>'可能造成資料洩漏、身分驗證繞過等重大損害。建議 7 天內修復。',
'medium' =>'單獨利用危害有限,但可與其他漏洞組合使用。建議 30 天內修復。',
'low' =>'危害程度較低,通常為設定不當或資訊暴露。建議例行維護時修復。',
'info' =>'非直接威脅,主要為技術指紋識別,可輔助了解系統暴露面。',
];
@endphp
{{ strtoupper($sev) }}
{{ $sevDescs[$sev] ?? '' }}
@if(!empty($fOwasp))
OWASP Top 10 2021
@foreach($fOwasp as $oid)
@php $od = $owaspDetail[$oid] ?? null; @endphp
{{ $oid }} {{ $od['name'] ?? '' }}
@if($od)
{{ $od['desc'] }}
@endif
@endforeach
@endif
@if(!empty($fCve))
@foreach($fCve as $cid)
{{ $cid }}
@endforeach
@endif
{{-- 欄B:漏洞說明 + 建議解法 --}}
ℹ 漏洞說明
@if($descText)
{{ $descText }}
@else
(請參考右側參考資料)
@endif
🔧 建議解法
@if($remedText)
{{ $remedText }}
@else
(請參考 OWASP 防禦指南)
@endif
{{-- 欄C:參考資料 + 技術資訊 --}}
🔗 參考資料
@foreach(array_slice($fRef, 0, 4) as $ref)
{{ $ref }}
@endforeach
📄 技術資訊
@if(!empty($f['template_id']))
ID:{{ $f['template_id'] }}
@endif
@if(!empty($f['type']))
類型:{{ strtoupper($f['type']) }}
@endif
@if(!empty($f['extra']['count']))
發現次數:{{ $f['extra']['count'] }} 處
@endif
@if(!empty($f['extra']['cvss_score']))
CVSS:{{ $f['extra']['cvss_score'] }}
@endif
@if(!empty($f['extra']['synopsis']))
{{ mb_strimwidth($f['extra']['synopsis'],0,80,'…') }}
@endif
@if(!empty($f['tags']))
@foreach(array_slice((array)$f['tags'], 0, 6) as $tag)
{{ $tag }}
@endforeach
@endif
{{-- finding-detail --}}
@empty
未發現任何問題,系統安全狀態良好。
@endforelse
{{-- end .page --}}