Documentation
¶
Overview ¶
Package reasoning implements attacks targeting reasoning-capable LLMs.
Reasoning models (DeepSeek-R1, Gemini 2.5, Grok 3 Mini) expose chain-of-thought traces that can be manipulated, and their extended reasoning capabilities can be turned against safety alignment.
CoT Exploitation manipulates visible chain-of-thought reasoning traces in reasoning models (DeepSeek-R1, Gemini 2.5, Grok 3).
Source: Trend Micro, HiddenLayer
Package reasoning — H-CoT (Hijacked Chain-of-Thought) attack module.
H-CoT mutates the safety-recognition step of a reasoning model's chain of thought and re-injects the modified trace as conversation context, causing the model to skip its refusal pathway. Per arXiv 2502.12893 ("H-CoT: Hijacking the Chain-of-Thought Safety Reasoning Mechanism") and arXiv 2510.26418 ("Reasoning Models Don't Always Reason"), the technique drops refusal rates 98%→2% on o1/o3/R1 against the original published benchmarks.
The module is **distinct from** the older src/attacks/reasoning/cot_exploitation.go, which is a static template-prepend variant that does not need access to the live reasoning trace. H-CoT requires a live trace and is therefore gated by the common.ReasoningProvider capability.
Provider behavior summary (v0.9.0):
- OpenAI Responses API exposes a *summary* of reasoning steps when reasoning.summary="detailed" is requested. o3 omits the summary >90% of the time; the module retries up to 3 times before emitting SkipReasoningTraceEmpty.
- Anthropic extended-thinking blocks are cryptographically signed. Modifying the text on round-trip is silently discarded by the API. The ReasoningProvider adapter sets ReasoningTrace.Signed=true so the module can short-circuit to SkipSignatureGated rather than wasting a re-injection round-trip.
Per the v0.9.0 plan, h_cot requires config.Metadata["i_understand_risks"]="true" because the attack systematically bypasses the model's safety reasoning.
PRJA — Psychology-based Reasoning-targeted Jailbreak Attack (arXiv 2604.15725, "Reasoning-targeted Jailbreak Attacks on Large Reasoning Models via Semantic Triggers and Psychological Framing", Apr 2026).
PRJA crafts prompts grounded in named social-psychology levers — obedience to authority and moral disengagement — that steer a reasoning model into working the harmful content through its INTERMEDIATE reasoning steps while keeping the final answer's surface benign. Because answer-level safety checks only inspect the final response, the harmful reasoning slips past them. The paper reports 83.6% average ASR across DeepSeek-R1, o4-mini, and Qwen2.5-Max.
PRJA is distinct from h_cot in this package. H-CoT *mutates* the safety step of the trace and re-injects it, so it is blocked by cryptographically signed traces (SkipSignatureGated). PRJA only *reads* the trace to measure where the harmful content landed — it never modifies it — so signed traces are fine. The success signal is likewise different: h_cot scores the final answer; PRJA scores the reasoning trace and records whether the answer surface stayed benign (the answer-level evasion that defines the technique).
PRJA requires config.Metadata["i_understand_risks"]="true" and the common.ReasoningProvider capability (the reasoning channel is the entire attack surface). Against a provider without a visible trace it emits OutcomeSkipped + SkipMissingCapability.
ReasoningLoopExploit targets reasoning models' extended thinking by inducing infinite or extremely long reasoning loops, causing resource exhaustion or revealing information during extended deliberation.
Index ¶
- type AutonomousJailbreakModule
- func (m *AutonomousJailbreakModule) Category() common.AttackCategory
- func (m *AutonomousJailbreakModule) Description() string
- func (m *AutonomousJailbreakModule) Execute(ctx context.Context, provider common.Provider, config common.AttackConfig) (*common.AttackResult, error)
- func (m *AutonomousJailbreakModule) Name() string
- func (m *AutonomousJailbreakModule) Techniques() []common.TechniqueInfo
- type CoTExploitationModule
- func (m *CoTExploitationModule) Category() common.AttackCategory
- func (m *CoTExploitationModule) Description() string
- func (m *CoTExploitationModule) Execute(ctx context.Context, provider common.Provider, config common.AttackConfig) (*common.AttackResult, error)
- func (m *CoTExploitationModule) Name() string
- func (m *CoTExploitationModule) Techniques() []common.TechniqueInfo
- type HCoTModule
- func (m *HCoTModule) Category() common.AttackCategory
- func (m *HCoTModule) Description() string
- func (m *HCoTModule) Execute(ctx context.Context, provider common.Provider, config common.AttackConfig) (*common.AttackResult, error)
- func (m *HCoTModule) Name() string
- func (m *HCoTModule) Techniques() []common.TechniqueInfo
- type PRJAModule
- func (m *PRJAModule) Category() common.AttackCategory
- func (m *PRJAModule) Description() string
- func (m *PRJAModule) Execute(ctx context.Context, provider common.Provider, config common.AttackConfig) (*common.AttackResult, error)
- func (m *PRJAModule) Name() string
- func (m *PRJAModule) Techniques() []common.TechniqueInfo
- type ReasoningLoopExploitModule
- func (m *ReasoningLoopExploitModule) Category() common.AttackCategory
- func (m *ReasoningLoopExploitModule) Description() string
- func (m *ReasoningLoopExploitModule) Execute(ctx context.Context, provider common.Provider, config common.AttackConfig) (*common.AttackResult, error)
- func (m *ReasoningLoopExploitModule) Name() string
- func (m *ReasoningLoopExploitModule) Techniques() []common.TechniqueInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AutonomousJailbreakModule ¶
type AutonomousJailbreakModule struct{}
AutonomousJailbreakModule uses a reasoning model as an autonomous adversary to generate and refine jailbreak attacks. Achieves 97.14% success rate.
WARNING: This module creates a feedback loop where a model generates attacks, evaluates results, and refines. Requires explicit --allow-autonomous flag and is gated by --max-autonomous-turns (default 10).
Source: Nature Communications (doi:10.1038/s41467-026-69010-1)
func (*AutonomousJailbreakModule) Category ¶
func (m *AutonomousJailbreakModule) Category() common.AttackCategory
func (*AutonomousJailbreakModule) Description ¶
func (m *AutonomousJailbreakModule) Description() string
func (*AutonomousJailbreakModule) Execute ¶
func (m *AutonomousJailbreakModule) Execute(ctx context.Context, provider common.Provider, config common.AttackConfig) (*common.AttackResult, error)
func (*AutonomousJailbreakModule) Name ¶
func (m *AutonomousJailbreakModule) Name() string
func (*AutonomousJailbreakModule) Techniques ¶
func (m *AutonomousJailbreakModule) Techniques() []common.TechniqueInfo
type CoTExploitationModule ¶
type CoTExploitationModule struct{}
CoTExploitationModule exploits visible chain-of-thought reasoning.
Source: Trend Micro, HiddenLayer
func (*CoTExploitationModule) Category ¶
func (m *CoTExploitationModule) Category() common.AttackCategory
func (*CoTExploitationModule) Description ¶
func (m *CoTExploitationModule) Description() string
func (*CoTExploitationModule) Execute ¶
func (m *CoTExploitationModule) Execute(ctx context.Context, provider common.Provider, config common.AttackConfig) (*common.AttackResult, error)
func (*CoTExploitationModule) Name ¶
func (m *CoTExploitationModule) Name() string
func (*CoTExploitationModule) Techniques ¶
func (m *CoTExploitationModule) Techniques() []common.TechniqueInfo
type HCoTModule ¶ added in v0.9.0
type HCoTModule struct{}
HCoTModule implements attacks.AttackModule for H-CoT.
func (*HCoTModule) Category ¶ added in v0.9.0
func (m *HCoTModule) Category() common.AttackCategory
Category returns CategoryReasoning (shared with cot_exploitation).
func (*HCoTModule) Description ¶ added in v0.9.0
func (m *HCoTModule) Description() string
Description summarizes the technique.
func (*HCoTModule) Execute ¶ added in v0.9.0
func (m *HCoTModule) Execute( ctx context.Context, provider common.Provider, config common.AttackConfig, ) (*common.AttackResult, error)
Execute runs the H-CoT attack.
Phases (all skip outcomes documented inline):
- Safety gate (i_understand_risks=true).
- Capability gate — provider must implement common.ReasoningProvider; SkipMissingCapability if absent.
- Initial query → ReasoningProvider.QueryWithReasoning. - If trace.Signed → SkipSignatureGated. - If trace.Steps empty → retry up to hCoTMaxRetries times. - If still empty → SkipReasoningTraceEmpty.
- Locate safety step. If none → SkipNoMutationTarget.
- Mutate, re-inject as conversation context, send follow-up.
- Score the follow-up response against config.SuccessIndicators.
func (*HCoTModule) Name ¶ added in v0.9.0
func (m *HCoTModule) Name() string
Name returns the registered technique name.
func (*HCoTModule) Techniques ¶ added in v0.9.0
func (m *HCoTModule) Techniques() []common.TechniqueInfo
Techniques returns the OWASP and metadata bundle.
type PRJAModule ¶ added in v0.13.0
type PRJAModule struct{}
PRJAModule implements attacks.AttackModule for PRJA.
func (*PRJAModule) Category ¶ added in v0.13.0
func (m *PRJAModule) Category() common.AttackCategory
Category returns CategoryReasoning.
func (*PRJAModule) Description ¶ added in v0.13.0
func (m *PRJAModule) Description() string
Description summarizes the technique.
func (*PRJAModule) Execute ¶ added in v0.13.0
func (m *PRJAModule) Execute( ctx context.Context, provider common.Provider, config common.AttackConfig, ) (*common.AttackResult, error)
Execute runs the PRJA attack.
- Safety gate (i_understand_risks=true).
- Capability gate — provider must implement common.ReasoningProvider.
- Precondition — non-empty Payload (the harmful objective).
- Query with the psychological frame; retry on empty trace up to prjaMaxRetries, then SkipReasoningTraceEmpty. Signed traces are OK (PRJA reads, never mutates).
- Success when a configured success indicator appears in the reasoning TRACE; the result records whether the final answer stayed benign (the answer-level evasion). Refused when the trace carries no indicator.
func (*PRJAModule) Name ¶ added in v0.13.0
func (m *PRJAModule) Name() string
Name returns the registered technique name.
func (*PRJAModule) Techniques ¶ added in v0.13.0
func (m *PRJAModule) Techniques() []common.TechniqueInfo
Techniques returns the OWASP and metadata bundle.
type ReasoningLoopExploitModule ¶
type ReasoningLoopExploitModule struct{}
ReasoningLoopExploitModule induces extended reasoning loops for resource exhaustion or information extraction during reasoning.
func (*ReasoningLoopExploitModule) Category ¶
func (m *ReasoningLoopExploitModule) Category() common.AttackCategory
func (*ReasoningLoopExploitModule) Description ¶
func (m *ReasoningLoopExploitModule) Description() string
func (*ReasoningLoopExploitModule) Execute ¶
func (m *ReasoningLoopExploitModule) Execute(ctx context.Context, provider common.Provider, config common.AttackConfig) (*common.AttackResult, error)
func (*ReasoningLoopExploitModule) Name ¶
func (m *ReasoningLoopExploitModule) Name() string
func (*ReasoningLoopExploitModule) Techniques ¶
func (m *ReasoningLoopExploitModule) Techniques() []common.TechniqueInfo