Skip to content

Latest commit

 

History

History

examples

README.md

C/C++ vulnerability fixture matrix

모든 동적 fixture는 다음의 동일한 폐루프를 실행한다.

  1. sanitizer build
  2. 원본 취약점의 정확한 failure signal 재현
  3. unified diff 정책 검사와 격리 적용
  4. 수정본 build
  5. 원 reproducer가 sanitizer 없이 안전하게 처리되는지 확인
  6. 정상 입력 회귀 테스트
  7. source invariant 재스캔
  8. 경계값 corpus 재실행
  9. protocol 응답 oracle
Fixture 언어 CWE 기준 버전 신호 수정 invariant
length-prefixed-parser C CWE-121 ASan stack-buffer-overflow payload가 stack buffer보다 길 수 없음
c-integer-overflow C CWE-190 UBSan signed integer overflow count <= INT32_MAX / 4
c-use-after-free C CWE-416 ASan heap-use-after-free 마지막 read까지 session lifetime 유지
cpp-vector-index C++ CWE-787 ASan heap-buffer-overflow index < channels.size()
cpp-null-dispatch C++ CWE-476 UBSan null member call dispatch 전에 non-null handler 확인

공통 gate runner는 fixture-tools/gates.py에 있다. 정상 메시지, 악성 메시지, 경계값 corpus 및 source invariant를 fixture별로 명시해서 검사한다.

저장소 루트에서 독립형 matrix runner를 실행한다. 이 runner는 unit-test framework를 사용하지 않고 production VerificationPipeline을 직접 호출하며, fixture별 artifact와 통합 JSON summary를 남긴다.

PYTHONPATH=src python3 examples/run_fixture_matrix.py

특정 fixture만 실행할 수도 있다.

PYTHONPATH=src python3 examples/run_fixture_matrix.py \
  --fixture c-use-after-free \
  --fixture cpp-null-dispatch

기본 출력은 artifacts/fixture-matrix/와 artifacts/fixture-matrix-summary.json에 기록된다.

더 많은 변형 예제가 필요하면 generated corpus runner를 사용한다. 이 runner는 stack copy, integer scale overflow, use-after-free, vector index write, null dispatch 다섯 family를 순환하면서 C/C++ 프로젝트, reproducer, patch, gate metadata를 생성하고 같은 production verification pipeline으로 검증한다.

PYTHONPATH=src python3 examples/run_generated_corpus.py --count 50

기본 출력은 artifacts/generated-corpus/와 artifacts/generated-corpus-summary.json에 기록된다. 다른 summary 파일을 남기려면 --output을 지정한다.

Clang과 Clang++가 없으면 동적 테스트는 명시적으로 skip된다. CI에서 이 matrix를 보안 회귀 테스트로 사용하려면 두 컴파일러가 포함된 고정 toolchain image를 사용해야 한다.

Hermes API agent demo

length-prefixed-parser에는 Hermes API client 설정이 포함된 target.hermes.toml이 있다. 다음 runner는 임시 Hermes server를 로컬 포트에 띄우고, mode = "hermes" agent로 patch를 받아 verification pipeline까지 실행한다.

PYTHONPATH=src python3 examples/run_hermes_demo.py

서버를 직접 띄운 뒤 CLI로 호출하려면:

PYTHONPATH=src python3 -m protocol_remediator.hermes_server \
  --host 127.0.0.1 \
  --port 8765

다른 터미널에서 protocol-remediator remediate에 examples/length-prefixed-parser/target.hermes.toml을 넘기면 같은 API 경로를 사용한다.