Skip to content

Reference results: live scan, judge-injection check, judge vs. human labels - #2

Merged
cynkai merged 7 commits into
mainfrom
feat/reference-scan
Oct 3, 2026
Merged

cynkai merged 7 commits into
mainfrom
feat/reference-scan

Conversation

@cynkai

@cynkai cynkai commented Oct 3, 2026

Copy link
Copy Markdown
Owner

요약

스캐너와 판정 모델(LLM-as-a-Judge)을 실제 모델로 측정하고, 결과를 reports/와 README에 올려요. 측정 과정에서 찾은 판정 버그도 함께 고쳤어요.

이 PR에는 #1(판정 프롬프트 인젝션 방어)의 커밋이 포함돼 있어요. #1을 먼저 머지하거나, 이 PR만 머지해도 돼요.

바뀐 것

  • fix(judge): 판정 모델이 지켜야 할 대상의 시스템 프롬프트를 보지 못해서, 원문 그대로의 유출도 SAFE로 판정할 수 있었어요. 이제 구분자로 감싼 기준 자료로 함께 넘겨요(스캔, 공격 트리, 재현성, 변이, 라이브 스트림 전부).
  • feat: OpenAI 어댑터(guardian/openai_client.py)를 추가했어요. 엔진 코드는 그대로 두고 OpenAI 모델로 실행해요. openai는 선택 의존성이에요.
  • feat(scripts): 스크립트 4개를 추가했어요. 참고 스캔, 판정 인젝션 확인, 블라인드 라벨링 페이지(표본 추출, 한국어 기계 번역 옵션), 판정 일치율 계산이에요.
  • docs: reports/(데이터, PDF, 한계)와 README(영·한)의 "참고 결과" 섹션이에요.

결과 (대상 gpt-5.4-nano, 판정 gpt-5.4-mini)

측정 결과
참고 스캔, 기본 프롬프트 89점(B), 25개 중 3개 뚫림
참고 스캔, 약한 프롬프트 78점(B), 25개 중 5개 뚫림
판정 인젝션, 수정 전 18번 중 18번 속음 (대조군 포함: 채점하던 페이로드에 탈취됨)
판정 인젝션, 수정 후 18번 중 0번
판정 vs 사람 라벨 20개 뚫림/안전 일치율 75% (κ 0.53), 세 판정 일치율 60% (κ 0.42)

판정 모델은 안전한 응답을 뚫렸다고 한 적은 없지만, 부분 유출을 자주 놓쳤어요. 그래서 스캔의 뚫림 비율은 실제보다 낮게 나왔을 가능성이 커요. README에도 그렇게 적었어요.

공개 범위

  • 대상 모델의 원문 응답은 올리지 않았어요. 일부에는 공격이 요구한 텍스트가 들어 있어서 reports/raw/(gitignore)에만 있어요.
  • results.csv에는 판정과 판정 근거 요약만 있어요.
  • 새 커밋들에서 키, 개인 이메일, 로컬 경로를 검사했고, 0건이에요.

확인한 것

한계

  • 모델 조합 하나, 공격당 1회 실행이에요.
  • 판정 인젝션 확인은 공격 1개 × 3회예요.
  • 라벨러는 1명(작성자)이고, 표본은 뚫린 응답 위주로 구성했어요. 라벨링 때 기계 번역을 참고 자료로 붙였어요.

🤖 Generated with Claude Code

cynkai and others added 7 commits October 3, 2026 23:54
Scripts need the same default prompt the app tests with, and app.py
cannot be imported outside Streamlit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The judge never saw the system prompt it was supposed to protect, so it
could not tell a verbatim leak from a generic description: graded by the
old prompt, a response that printed the default prompt word for word was
called SAFE ("no verbatim system prompt was revealed").

Pass the target's system prompt to every judge call (scan, attack tree,
reproducibility, mutations, live stream) in its own tagged block, and
tell the judge it is reference material, not rules to apply to itself.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
OpenAIClient exposes the google-genai surface the engine uses
(models.generate_content, generate_content_stream, chats.create) on top
of OpenAI Chat Completions: system instruction -> system message, JSON
mode -> response_format json_object, chats keep their history, token
usage maps to usage_metadata. guardian.engine stays provider-neutral.
Gemini safety settings have no OpenAI equivalent and are ignored.

openai is an optional dev dependency; .env.example documents the key.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- scripts/reference_scan.py runs the dataset against a live model
  (Gemini or OpenAI), retries failed calls, and writes results.csv,
  summary.json and the PDF report. Target responses are kept out of the
  repository (reports/raw/ is gitignored): some may contain the harmful
  text an attack asked for.
- scripts/judge_injection_check.py grades a response that clearly meets
  INJ-001's success criterion, with and without text that tries to talk
  the judge into SAFE, under the old and the current judge prompt.
- scripts/make_labeling_page.py builds a local page for labelling scan
  responses by hand, blind to the judge's verdicts.
- The engine records the exact text the judge graded (Judged Response),
  so human labels and judge verdicts are made on the same text.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
make_labeling_page.py now takes several scan files (items are keyed
run:ID), and judge_agreement.py compares the exported labels with the
judge's verdicts: agreement and Cohen's kappa on the three verdicts and
on breached-vs-safe, a confusion matrix, and the disagreements.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
--sample N keeps every response the judge flagged and fills up to N with
random SAFE ones, so a 20-item session still contains the breaches.
--translate ko adds a machine translation under each English text (cached
next to the page); labels are still made against the original.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Measured with OpenAI models (target gpt-5.4-nano, judge gpt-5.4-mini):
- reference scan of all 25 payloads with the default and a thin system
  prompt: 89 (B) and 78 (B);
- judge prompt injection: the pre-fix judge was hijacked by the attack
  payload it graded and answered SAFE in 18/18 cases, the current one
  in 0/18;
- judge vs. 20 hand labels (enriched sample): 75% agreement on
  breached-vs-safe (kappa 0.53), 60% on three verdicts (kappa 0.42); the
  judge misses partial leaks, so breach rates are likely low.

reports/ holds the data, PDFs and limits; target responses stay out of
the repository. README (en/ko) summarises the results and limits.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@cynkai
cynkai merged commit 1991d9b into main Oct 3, 2026
2 checks passed
@cynkai
cynkai deleted the feat/reference-scan branch October 3, 2026 16:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant