21 Commits
Author SHA1 Message Date
kigland 5f2d087c0e feat: add LLM-generated content mode for poisoned skill files
When api_key is provided, uses GPT-4 to generate realistic skill
definitions with proper structure, responsibilities, workflow, and
constraints. The trigger is embedded under a randomized section label
(Runtime Configuration / Environment Bootstrap / Session Initialization
/ Workspace Calibration) instead of the conspicuous <diagnostic> tag.

Added 2 new camouflage profiles (devops, database) to the existing 4.
Falls back to hardcoded templates when no api_key is given.
2026-03-10 01:11:31 +08:00
kigland aa82f08e55 feat: add LLM-generated content mode for honeypot pages
When topic and api_key are provided, uses GPT-4 to generate a
realistic, SEO-optimized technical article with proper structure,
meta tags, and Schema.org markup. Falls back to the original
hardcoded template when no topic is specified.

Each invocation produces unique content, making signature-based
detection impractical.
2026-03-10 01:10:41 +08:00
栀染 7a48ba51d7 Enhance SEO for honeypot HTML generation
Updated the HTML structure and content for SEO optimization, including meta tags and improved layout.
2026-03-09 12:18:42 +08:00
栀染 38d8abff90 Refactor generate_poisoned_skill to use templates 2026-03-09 12:16:39 +08:00
kigland 6523abe5a8 feat: add tool-call fitness evaluation for direct RCE verification
The core improvement: instead of only checking if the model outputs text
containing the target command, we now define a bash tool via OpenAI's
function calling API and evaluate whether the model actually invokes
bash(command="curl ..."). This directly validates the paper's claim of
tool-call hijacking → RCE, eliminating reviewer objections about
text-output-only evaluation.

Score hierarchy (4 non-overlapping tiers):
  Tier 1: tool-call exact match    = -1000 (convergence at -999)
  Tier 2: tool-call partial match  = -500 to -999
  Tier 3: text exact match         = -401 to -420 (typical)
  Tier 4: text partial match       = -395 to positive

Other fixes from code review:
- Score all bash tool calls, return best (was early-returning on first)
- Evaluate both tool_calls and text content, return min (dual-path)
- find_longest_match() now uses explicit bounds (Python 3.12+ compat)
- Named constants for thresholds instead of magic numbers
2026-03-08 22:29:08 +08:00
Sakayori-Iroha-168 606b2cbda7 fix: lack of SOUL_PROMPT in system message 2026-03-08 17:15:42 +08:00
Sakayori-Iroha-168 37a0546c57 Create SOUL_PROMPT.py 2026-03-08 17:11:24 +08:00
kigland d50c6b5acf security: remove trust_remote_code=True from model loading
Phi-2 uses the standard PhiForCausalLM architecture and does not require
custom code execution. trust_remote_code=True allows arbitrary Python
from the HuggingFace repo to run during loading, creating an unnecessary
supply-chain risk.
2026-03-08 15:16:53 +08:00
kigland 11a7d3408f fix: tighten convergence threshold to prevent false-positive early stop
Changed threshold from -500.0 to -500.5. The fitness returns
-500.0 - (100/nll) on full match, so real matches always score < -500.0.
But partial matches with max keyword+substring bonuses (500 total) could
theoretically reach -500.0 with very low NLL, causing premature stopping.
2026-03-08 15:16:28 +08:00
kigland ab9470eb65 refactor: remove unused self.vocab_size attribute
self.vocab_size was set but never read. The actual vocabulary size is
tracked via self.actual_vocab_size (from the embedding matrix shape),
which correctly accounts for any padding tokens beyond vocab_size.
2026-03-08 15:16:02 +08:00
kigland 85575724b8 perf: use FAISS IndexFlatL2 for nearest-neighbor token lookup
Replace brute-force numpy L2 distance loop with FAISS batch search.
The old approach computed distances against all ~51k embeddings in a
Python loop per token. FAISS batches all trigger_len queries into a
single SIMD-optimized search call.
2026-03-08 15:15:27 +08:00
kigland b85762fe4d perf: replace O(n³) brute-force LCS with difflib.SequenceMatcher
The fitness function's longest common substring search used a triple-nested
loop. With 12,800 evaluations per optimization run, this was a significant
bottleneck. SequenceMatcher provides O(n*m) average-case performance.
2026-03-08 15:14:25 +08:00
kigland 7c2f0f0bc9 fix: replace O(n) dict copy with direct mutation for fitness cache
The eval_cache was being copied on every insert via {**eval_cache, key: val},
creating O(n) overhead per evaluation. Since this is local mutable state
within optimize(), direct dict assignment is both correct and efficient.
2026-03-08 15:12:56 +08:00
kigland a517c45d1c feat: fix four critical flaws in CMA-ES token optimizer
1. Add PCA dimensionality reduction (d_model -> pca_dims=128)
   - Search space reduced from 25,600 to 1,280 dimensions
   - CMA-ES can now actually learn covariance structure

2. Enable sep-CMA-ES via CMA_diagonal=True
   - Linear memory/time complexity instead of cubic
   - Required for dimensions > 200

3. Redesign fitness function with gradual scoring
   - Remove discontinuous -1000 cliff that broke CMA-ES
   - Add keyword overlap bonus (up to 200 points)
   - Add longest common substring bonus (up to 300 points)
   - Full match returns smooth -500 minus NLL bonus

4. Increase evaluation budget and add caching
   - Default popsize: 8 -> 64, max_generations: 30 -> 200
   - Add token sequence cache to skip redundant API calls
   - Cache uses immutable dict updates

Previous implementation was mathematically equivalent to random
search due to these compounding issues.
2026-03-08 15:07:45 +08:00
栀染 0e112c3c56 修改 Honeypot 与 Skills 投毒 2026-03-08 01:43:09 +00:00
栀染 a80635b408 修正 CMA-ES 2026-03-08 01:42:06 +00:00
栀染 810980b461 生成符合 OpenClaw 规范的恶意 skills.md 2026-03-08 01:37:05 +00:00
栀染 ecb19e6957 自动化生成恶意 skills.md 感染载荷 2026-03-08 01:35:46 +00:00
栀染 1cd1bdd6f5 构造 Nginx 静态页面,背景色同字色 2026-03-08 01:35:07 +00:00
栀染 7a0859cccf 针对闭源模型的 CMA-ES 零阶连续空间优化器,使用 Soft-to-Hard 映射和 OpenAI 接口计算 Logprobs Fitness 2026-03-08 01:34:34 +00:00
栀染 dc290361d9 传统的语义注入,通过角色扮演和忽略前文尝试绕过 SOUL.md 2026-03-08 01:32:04 +00:00