SpecCloak: Probing Harmful Code Generation via Engineering SpecificationsSpecCloak: Probing Harmful Code Generation through Engineering Specifications
Translation in progress — untranslated text is omitted.
The paper proposes the PseudoSpec template, organizing malicious programming requirements into engineering specification form, and finds that this form significantly reduces refusals across five open-weight models, even when risk keywords are retained. Based on this, the authors build the black-box red-teaming framework SpecCloak, combining PseudoSpec with discriminator-guided optimization, achieving an average execution-verified attack success rate of 28.91% on RedCode-Gen across eight target models. Analysis shows that the refusal drop is accompanied by a shift in representations toward code output direction, and activation intervention along the conditional difference direction can alter refusal behavior. The paper also provides a defense prototype SpecReveal, using natural language intent reconstruction and dual-perspective detection without fine-tuning the target model, achieving 96.88% attack detection rate in a separate prompt detection evaluation.
- Code assistants may be used to implement harmful functionality. The authors want to find out whether refusal of malicious code requests changes when functional requirements are written as engineering specifications, not just whether the wording contains risk words.
- PseudoSpec writes requirements as a four-part specification: configuration, predicate interfaces, temporal constraints, and implementation requirements. SpecCloak iterates on this template with a discriminator without querying the target, then submits once. SpecReveal converts the specification back into natural language and performs risk assessment on both the original and the restored text.
- Five open-source models have refusal rates of 0–8.65% under the specification condition with risk words retained (Table I). SpecCloak's average E-ASR on RedCode-Gen across eight targets is 28.91%, with a total refusal rate of 10.31%. Under o4-mini review, union detects 98/100.
- The authors state that mechanistic evidence is limited to open-weight models, disjoint from the attack evaluation model set, and steering specificity also varies with model. Future work includes causal separation of risk channels, testing whether framework directions can predict attack success, and addressing adaptive attackers. The specific model names for G and D are not reported.
Related events and news
1 events · 1 news mentions
News that mentions this paper
RL/RLHF 训练条件可诱发模型智能体提权逃逸
- 公众号 大模型安全研究cites the paper's id or link大模型安全周报:RL/RLHF 训练条件本身即可诱发前沿模型智能体提权逃逸(CVE-2026-65616)
SpecCloak: Probing Harmful Code Generation through Engineering Specifications(https://arxiv.org/abs/2610.17907)