mcp-vuln-probe
by pgt0312
README.md
# MCP_SERVER_VULN — PlayMCP 런타임 보안 점검용 프로브 MCP
`kserve-container`(포트 **8000**) 보안 항목을 **kubectl 없이** 점검하기 위한 Git 빌드용 MCP 서버입니다.
> **주의**: 승인된 CSAP/점검 환경에서만 사용하세요. 프로브 도구는 내부 네트워크·Kubernetes API를 시도합니다.
---
## 포함 도구 (MCP tools)
| Tool | 점검 ID | 설명 |
|------|---------|------|
| `whoami` | C2 | UID/GID, `id` 출력 |
| `service_account_probe` | L2 | SA token 파일 존재(automount) |
| `read_path` | L2 | 절대 경로 파일 일부 읽기 |
| `fetch_url` | H1, H3, C1 | Pod 내부 HTTP(S) — SSRF·ClusterLocal |
| `tcp_probe` | H3 | TCP 연결(Postgres 등) |
| `k8s_api_probe` | L1 | SA 토큰으로 K8s API (403=양호) |
| `k8s_list_secrets_in_namespace` | L1 | NS Secret 목록 API |
| `run_preset` | H1/H3/M1/L1 일괄 | ISvc·NS만 넣으면 프리셋 대상 일괄 실행 |
| `env_keys` | — | env 키(옵션: 값 포함) |
HTTP: `GET /health` — KServe TCP probe 호환.
---
## 1. PlayMCP에 배포 (Git 빌드)
1. 이 디렉터리를 **Git 저장소**에 push (루트에 `Dockerfile`, `server.py`).
2. PlayMCP → **새 MCP 서버 등록** → Git 소스 빌드.
3. 예시 JSON (`POST /api/v2/mcp/builder/image-mcp-servers`):
```json
{
"server_name": "mcp-vuln-probe",
"description": "CSAP runtime security probe",
"image_build_mode": "git",
"git_url": "https://github.com/<org>/<repo>.git",
"git_ref": "main",
"dockerfile": "MCP_SERVER_VULN/Dockerfile"
}
```
저장소 루트가 `MCP_SERVER_VULN` 이면 `dockerfile`: `Dockerfile` 로 두고 **해당 폴더만** repo root로 쓰는 편이 단순합니다.
4. 상태 **Active** + 포털에서 **Endpoint URL** 복사.
---
## 2. kubectl 없이 점검
### 사전 준비
```bash
cd MCP_SERVER_VULN
chmod +x scripts/*.sh
cp probes/targets.example.env probes/targets.env
# ENDPOINT, PROBE_ISVC, PROBE_NAMESPACE 편집
```
### C1 — 공개 무인증 (외부만)
```bash
./scripts/external_audit.sh "https://<isvc>.playmcp-endpoint.kakaocloud.io"
```
로그아웃 PC·시크릿 창에서 실행 권장.
### 전체 프리셋 (클러스터 내부는 MCP가 대신 수행)
```bash
./scripts/run_full_audit.sh
```
또는 개별 tool:
```bash
./scripts/mcp_call.sh "$ENDPOINT" whoami '{}'
./scripts/mcp_call.sh "$ENDPOINT" fetch_url '{"url":"http://authservice.istio-system.svc.cluster.local:8080/"}'
./scripts/mcp_call.sh "$ENDPOINT" run_preset '{
"inference_service": "mcp-vuln-probe",
"namespace": "kbm-u-123456",
"ingress_host": "mcp-vuln-probe.playmcp-endpoint.kakaocloud.io",
"peer_inference_service": "other-mcp"
}'
```
---
## 3. 결과 해석 (요약)
| 결과 | 의미 |
|------|------|
| `external_audit` initialize 200 | **C1** 무인증 가능성 |
| `whoami.uid == 0` | **C2** root 실행 |
| `service_account_probe.token_exists == true` | **L2** SA 토큰 마운트됨 |
| `k8s_api_* status_code == 403` | **L1** RBAC 없음(양호) |
| `k8s_api_* status_code == 200` + secrets 목록 | **L1 취약** |
| `fetch_url` cluster_local 200 | **H1** 클러스터 내부에서 MCP 도달 |
| `fetch_url` authservice 응답 | **H3** egress·내부 SSRF 가능 |
| `tcp_probe` postgres 5432 connected | **H3** DB 포트 도달 |
| `peer_mcp_health` 200 | **M1** 동일 NS MCP 간 접근 |
**kubectl 없이 어려운 항목**: H2(Pod IP 직접), H4(Job RBAC/Postgres env), EnvoyFilter YAML.
---
## 4. 로컬 실행 (선택)
```bash
python3 -m venv .venv && source .venv/bin/activate
pip install -r requirements.txt
python server.py
# curl http://127.0.0.1:8000/health
```
---
## 5. 디렉터리 구조
```text
MCP_SERVER_VULN/
server.py # 프로브 MCP
Dockerfile
requirements.txt
scripts/
external_audit.sh # C1 외부
mcp_call.sh # tools/call 헬퍼
run_full_audit.sh # 일괄
probes/
targets.example.env
```
---
## 6. 점검 후
- 프로브 MCP **삭제**(포털에서 MCP 서버 삭제).
- `probes/targets.env` 에 URL·userId 없도록 git 제외(`.gitignore` 포함).
This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessSyncing