vulnerability-scanning について
インフラやアプリケーションの脆弱性を特定し、優先順位を付けるためのセキュリティガイドです。評価や脆弱性管理を行うチーム向けに、スキャナー、リスク判定、修正追跡、コンプライアンス確認を扱います。
主な機能
- 01OpenVAS、Nessus、Nucleiによるスキャン
- 02カスタムNucleiテンプレートの作成と利用
- 03CVSSとリスク要因による優先順位付け
- 04CI/CDへの脆弱性スキャン統合
- 05CISおよびPCI DSS準拠スキャン
活用シーン
- 01インフラの既知CVEを評価
- 02脆弱性修正の優先順位を決定
- 03CI/CDワークフローにスキャンを追加
- 04コンプライアンスのセキュリティ確認
インストール
コマンドをコピーしてターミナルで実行します。
$
npx skills add https:/ / github.com/ bagelhole/ devops-security-agent-skills --skill vulnerability-scanningインストール後、Claude Code で/vulnerability-scanningを入力して読み込まれたか確認します。
同梱ファイル
SKILL.md と一緒にインストールされる参考資料やスクリプト。
assets/github-action-scan.yamltrivy-config.yamlreferences/remediation-guide.mdscanner-comparison.mdscripts/scan-images.shscan-repo.sh詳細
脆弱性スキャン
インフラストラクチャとアプリケーション全体のセキュリティ脆弱性を特定し、優先順位を付けます。
このスキルを使うタイミング
次のような場合にこのスキルを使用します。
- セキュリティ評価を実施する
- 脆弱性管理プログラムを導入する
- コンプライアンス要件を満たす
- 修正のトリアージと優先順位付けを行う
- 既知の CVE を対象にインフラストラクチャをスキャンする
前提条件
- スキャンツールへのアクセス
- 対象へのネットワークアクセス
- 適切な認可
脆弱性スキャンツール
| ツール | 種類 | 最適な用途 |
|---|---|---|
| Nessus | 商用 | エンタープライズスキャン |
| OpenVAS | オープンソース | 無料の代替ツール |
| Qualys | クラウド SaaS | 大規模環境 |
| Nexpose/InsightVM | 商用 | 資産管理 |
| Nuclei | オープンソース | テンプレートベースのスキャン |
OpenVAS のセットアップ
Docker によるデプロイ
# Run OpenVAS container
docker run -d --name openvas \
-p 443:443 \
-v openvas-data:/data \
greenbone/openvas-scanner
# Access web UI at https://localhost
# Default credentials: admin/admin
スキャンコマンド
# Create target
omp -u admin -w admin --xml='<create_target>
<name>Web Servers</name>
<hosts>192.168.1.0/24</hosts>
</create_target>'
# Create task
omp -u admin -w admin --xml='<create_task>
<name>Weekly Scan</name>
<target id="target-uuid"/>
<config id="daba56c8-73ec-11df-a475-002264764cea"/>
</create_task>'
# Start task
omp -u admin -w admin --xml='<start_task task_id="task-uuid"/>'
# Get results
omp -u admin -w admin --xml='<get_results task_id="task-uuid"/>'
Nessus
API の使用方法
import requests
class NessusScanner:
def __init__(self, url, access_key, secret_key):
self.url = url
self.headers = {
'X-ApiKeys': f'accessKey={access_key}; secretKey={secret_key}',
'Content-Type': 'application/json'
}
def create_scan(self, name, targets, template='basic'):
"""Create a new scan."""
templates = self.get('/editor/scan/templates')
template_uuid = next(
t['uuid'] for t in templates['templates']
if t['name'] == template
)
payload = {
'uuid': template_uuid,
'settings': {
'name': name,
'text_targets': targets,
'enabled': True
}
}
return self.post('/scans', payload)
def launch_scan(self, scan_id):
"""Start a scan."""
return self.post(f'/scans/{scan_id}/launch')
def get_results(self, scan_id):
"""Get scan results."""
return self.get(f'/scans/{scan_id}')
def export_report(self, scan_id, format='pdf'):
"""Export scan report."""
payload = {'format': format}
response = self.post(f'/scans/{scan_id}/export', payload)
file_id = response['file']
# Wait for export
while True:
status = self.get(f'/scans/{scan_id}/export/{file_id}/status')
if status['status'] == 'ready':
break
time.sleep(5)
return self.get(f'/scans/{scan_id}/export/{file_id}/download')
def get(self, path):
response = requests.get(f'{self.url}{path}', headers=self.headers, verify=False)
return response.json()
def post(self, path, data=None):
response = requests.post(f'{self.url}{path}', json=data, headers=self.headers, verify=False)
return response.json()
# Usage
scanner = NessusScanner('https://nessus:8834', 'access-key', 'secret-key')
scan = scanner.create_scan('Weekly Infrastructure Scan', '10.0.0.0/24')
scanner.launch_scan(scan['scan']['id'])
Nuclei
インストール
# Install nuclei
go install -v github.com/projectdiscovery/nuclei/v3/cmd/nuclei@latest
# Or download binary
wget https://github.com/projectdiscovery/nuclei/releases/latest/download/nuclei_linux_amd64.zip
unzip nuclei_linux_amd64.zip
基本的なスキャン
# Update templates
nuclei -update-templates
# Scan single target
nuclei -u https://example.com
# Scan multiple targets
nuclei -l targets.txt
# Scan with specific templates
nuclei -u https://example.com -t cves/
nuclei -u https://example.com -t vulnerabilities/
# Scan with severity filter
nuclei -u https://example.com -s critical,high
# Output formats
nuclei -u https://example.com -o results.txt
nuclei -u https://example.com -json -o results.json
カスタムテンプレート
# custom-check.yaml
id: custom-admin-panel
info:
name: Admin Panel Detection
author: security-team
severity: info
tags: recon,panel
requests:
- method: GET
path:
- "{{BaseURL}}/admin"
- "{{BaseURL}}/administrator"
- "{{BaseURL}}/wp-admin"
matchers-condition: or
matchers:
- type: word
words:
- "admin"
- "login"
condition: and
- type: status
status:
- 200
- 301
- 302
CVSS スコアリング
深刻度レベル
| スコア | 評価 | 対応時間 |
|---|---|---|
| 9.0-10.0 | 重大 | 24 時間 |
| 7.0-8.9 | 高 | 7 日 |
| 4.0-6.9 | 中 | 30 日 |
| 0.1-3.9 | 低 | 90 日 |
優先順位付けの要因
prioritization_criteria:
critical_factors:
- Internet-facing systems
- Systems with sensitive data
- Active exploitation in the wild
- Authentication bypass
high_factors:
- Remote code execution
- Privilege escalation
- Data exfiltration risk
context_adjustments:
- Compensating controls in place (-1)
- No direct exposure (-1)
- Critical business system (+1)
- Compliance requirement (+1)
脆弱性管理プロセス
ワークフロー
vulnerability_workflow:
discovery:
- Run scheduled scans
- Import third-party findings
- Correlate with asset inventory
analysis:
- Validate findings
- Remove false positives
- Assess business impact
- Prioritize by risk score
remediation:
- Assign to owners
- Track SLA compliance
- Verify fixes
- Document exceptions
reporting:
- Executive summaries
- Technical details
- Trend analysis
- Compliance metrics
追跡テンプレート
## Vulnerability Ticket
**ID:** VULN-2024-001
**CVE:** CVE-2024-12345
**CVSS:** 9.8 (Critical)
**Affected System:** web-server-01
### Description
Remote code execution vulnerability in Apache Struts.
### Impact
Attacker can execute arbitrary code on the server.
### Remediation
1. Update Apache Struts to version 2.5.33
2. Apply WAF rule as temporary mitigation
### Timeline
- Discovered: 2024-01-15
- SLA Due: 2024-01-16
- Remediated: 2024-01-15
### Evidence
- Scan report: [link]
- Screenshot: [link]
CI/CD との統合
GitHub Actions
name: Vulnerability Scan
on:
schedule:
- cron: '0 2 * * *'
push:
branches: [main]
jobs:
scan:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Run Nuclei
uses: projectdiscovery/nuclei-action@main
with:
target: https://example.com
templates: cves/
output: nuclei-results.txt
- name: Check for critical findings
run: |
if grep -q "critical" nuclei-results.txt; then
echo "Critical vulnerabilities found!"
exit 1
fi
- name: Upload results
uses: actions/upload-artifact@v4
with:
name: vulnerability-report
path: nuclei-results.txt
コンプライアンススキャン
CIS ベンチマークスキャン
# Using OpenSCAP
oscap xccdf eval \
--profile xccdf_org.ssgproject.content_profile_cis \
--results results.xml \
--report report.html \
/usr/share/xml/scap/ssg/content/ssg-ubuntu2204-ds.xml
PCI DSS スキャン
pci_scan_requirements:
quarterly:
- External vulnerability scan (ASV)
- Internal vulnerability scan
after_changes:
- Significant infrastructure changes
- New system deployments
passing_criteria:
- No vulnerabilities rated 4.0+ (CVSS)
- False positives documented
- Scan completed within 90 days
よくある問題
問題:誤検知
問題:スキャナーが、実在しない脆弱性を報告する 解決策:手動で検証し、スキャナーを調整して、例外リストを維持します
問題:網羅性の不足
問題:すべての資産がスキャンされていない 解決策:資産インベントリを更新し、認証情報を検証して、ネットワークアクセスを確認します
問題:スキャンによる影響
問題:スキャンが本番システムに影響している 解決策:メンテナンス時間帯にスケジュールし、認証済みスキャンを使用します
ベストプラクティス
- 正確な資産インベントリを維持する
- 定期的なスキャンの頻度を設定する
- 修正する前に検出結果を検証する
- 指標(MTTR、経過期間)を追跡する
- チケット管理システムと統合する
- 例外を適切に記録する
- リスクベースで優先順位を付ける
- 可能な場合は自動化する
関連スキル
- sast-scanning - コード分析
- container-scanning - コンテナーセキュリティ
- cis-benchmarks - コンプライアンスベンチマーク
コメント
Markdown 対応