
Evidence-driven C/C++ vulnerability remediation: sanitizer/SARIF intake, isolated patch verification
한국어 · English
C/C++ protocol·platform 코드의 취약점 finding을 재현 가능한 증거로 정규화하고,
후보 패치를 격리된 복사본에서 검증하는 MVP다. 저장소 이름은 code-shield이고,
공개 Python package와 CLI는 이름 충돌을 피하기 위해 중립적인 내부 이름
protocol-remediator를 사용한다.
# Python core (런타임 dependency 없음)
python3 -m venv .venv
.venv/bin/pip install -e .
.venv/bin/python -m unittest discover -s tests -v
# React console
cd frontend
npm install
npm run dev # http://127.0.0.1:5173
![]() |
![]() |
| 개요 대시보드 — fixture matrix 5/5, generated corpus 50/50, CWE coverage, 검증 gate 요약 | Fixture matrix — CWE-121/190/416/787/476 target별 reproducer·build·tests·rescan·refuzz·protocol gate 결과 |
![]() |
![]() |
| Case study (nodejs/http-parser) — reproducer 정보, 패치 전후 probe 결과, CWE/CVE finding 목록 | Evidence — 제안 패치 diff와 evidence/context JSON 경로, safety invariant 목록 |
콘솔은 저장소에 포함된 fixture matrix·generated corpus·case study 결과를 정적 데이터로 보여준다.
현재 구현의 중심은 패치 생성 모델이 아니라 다음 검증 폐루프다.
sanitizer 또는 SARIF
-> Finding + EvidenceBundle
-> source context
-> manual/external-agent patch
-> 원본 재현
-> build
-> patched reproducer
-> tests
-> static rescan
-> bounded refuzz
-> protocol oracle
-> verified report
Finding, EvidenceBundle, PatchProposal,
VerificationReport JSON 모델detected → reproducible → contextualized → proposed → plausible → verified 상태 전이런타임 Python dependency는 없다.
python3 -m venv .venv
.venv/bin/pip install -e .
.venv/bin/python -m unittest discover -s tests -v
설치하지 않고 실행하려면:
PYTHONPATH=src python3 -m protocol_remediator --help
PYTHONPATH=src python3 -m unittest discover -s tests -v
동적 end-to-end suite는 examples의 C/C++ fixture matrix다.
Clang ASan/UBSan으로 CWE-121, CWE-190, CWE-416, CWE-787, CWE-476을 실제
재현한 다음, 각 invariant를 복구하는 patch에 대해 여섯 gate를 모두 실행한다.
fixture별 입력과 검증 범위는
examples/README.md에 정리되어 있다.
unit-test framework 없이 실제 matrix만 실행하려면:
PYTHONPATH=src python3 examples/run_fixture_matrix.py
더 많은 C/C++ 변형 예제를 자동 생성해 실행하려면:
PYTHONPATH=src python3 examples/run_generated_corpus.py --count 50
이 runner는 unittest를 사용하지 않고, 생성한 각 프로젝트를 동일한
VerificationPipeline에 통과시킨다. 결과 summary는 기본적으로
artifacts/generated-corpus-summary.json에 남는다.
현재 구현 상태를 운영형 대시보드로 확인할 수 있는 Vite + React + TypeScript
프론트엔드는 frontend에 있다. 이 콘솔은 fixture matrix, generated
corpus, Hermes API server 연결면, 검증 gate, evidence safety invariant를 한 화면에
정리한다.
cd frontend
npm install
npm run dev
기본 개발 서버는 http://127.0.0.1:5173이다. production build는 다음으로 확인한다.
cd frontend
npm run build
protocol-remediator ingest-sanitizer \
--log asan.log \
--reproducer crash.input \
--target-name parser \
--revision 0123456789abcdef \
--variant asan-x86_64 \
--output intake/parser-crash
출력:
intake/parser-crash/finding.json
intake/parser-crash/evidence.json
protocol-remediator ingest-sarif \
--sarif results.sarif \
--output intake/sarif
protocol-remediator export-sarif \
--finding intake/parser-crash/finding.json \
--finding intake/another/finding.json \
--output artifacts/findings.sarif
protocol-remediator context \
--finding intake/parser-crash/finding.json \
--evidence intake/parser-crash/evidence.json \
--target-root /path/to/target \
--output intake/parser-crash/context.json
protocol-remediator verify \
--config /path/to/target/target.toml \
--finding intake/parser-crash/finding.json \
--evidence intake/parser-crash/evidence.json \
--patch candidate.patch \
--artifacts artifacts
종료 코드는 verified이면 0, 검증 실패이면 1, 설정·입력 오류이면 2다.
Hermes API server를 띄우면 remediate가 로컬 command 대신 HTTP API로 patch를
요청할 수 있다. 기본 endpoint는 POST /v1/patches이며, finding/evidence/context와
target workspace archive를 받아 unified diff를 반환한다.
예제 서버 실행:
PYTHONPATH=src python3 -m protocol_remediator.hermes_server \
--host 127.0.0.1 \
--port 8765
설치 후에는 console script도 사용할 수 있다.
hermes-agent-server --host 127.0.0.1 --port 8765
운영 backend command를 붙일 때는 argument 단위로 --backend-command를
반복한다. {context}, {workspace}, {patch_output} placeholder를 지원한다.
hermes-agent-server \
--backend-command my-patch-agent \
--backend-command --context \
--backend-command {context} \
--backend-command --workspace \
--backend-command {workspace} \
--backend-command --output \
--backend-command {patch_output}
target.toml에서는 다음처럼 Hermes mode를 지정한다.
[agent]
mode = "hermes"
url = "http://127.0.0.1:8765"
timeout_seconds = 30
그다음 기존 remediate 명령을 그대로 사용한다.
protocol-remediator remediate \
--config examples/length-prefixed-parser/target.hermes.toml \
--finding artifacts/hermes-cli-input/finding.json \
--evidence artifacts/hermes-cli-input/evidence.json \
--artifacts artifacts/hermes-cli
개발용 end-to-end 확인은 다음 runner로 실행한다. 이 runner는 임시 Hermes server를 띄우고, API client로 patch를 받은 다음 검증 폐루프를 끝까지 실행한다.
PYTHONPATH=src python3 examples/run_hermes_demo.py
Hermes를 쓰지 않고 로컬 command를 직접 호출하려면 target.toml에 agent command를
문자열 배열로 지정한다.
[agent]
mode = "command"
command = [
"my-patch-agent",
"--context",
"{context}",
"--workspace",
"{workspace}",
"--output",
"{patch_output}",
]
timeout_seconds = 900
그다음 다음 명령을 실행한다.
protocol-remediator remediate \
--config /path/to/target/target.toml \
--finding intake/parser-crash/finding.json \
--evidence intake/parser-crash/evidence.json \
--artifacts artifacts
core는 특정 LLM API를 직접 호출하지 않는다. Hermes backend나 외부 command가 context를 읽고 unified diff를 생성하는 계약이다. agent 작업은 원본 target이 아닌 임시 복사본에서 실행된다.
전체 예시는
target.toml에 있다.
[project]
name = "my-protocol"
language = "c++"
root = "."