CyberGuardAI 安全情报工作区
AI 安全知识情报
LJH 管理员
返回首页 学术论文

SecReason:LLM代码生成漏洞检测与流内自修复

Ruidong Han、Zhensu Sun、Chengyan Ma、Yuqing Niu、Zhou Yang、Siqi Ma 等

摘要与解读

提出生成中检测漏洞并自修复的代码生成方法

六维情报分析

6 个维度 · 原文可溯源

影响范围

  • 来源报告关注的是推理型LLM生成代码时的交付前窗口:模型在流式思维链中较早起草代码,此时代码只存在于推理流内。SecReason在这一窗口内做流内防御,因此影响对象是采用推理LLM生成代码、且代码在交付前经过推理流的开发或代码生成流程;必要条件是能监测并干预该推理流。信任边界落在推理流与最终交付代码之间,后果是安全规则可在代码交付前触发检查与自修复。

    原文依据 · 1
    tion. Security prompts and retrieved security knowledge act before any code exists, constrained decoding limits token choices but cannot guide repair, and post-hoc repair must regenerate the full response. Reasoning LLMs draft code early in their streamed chain of thought, and in this pre-delivery window the code exists only inside the reasoning stream. We present SecReason, an in-stream defense that monitors this window. Dual-track incremental scanning applies security rules, checking each statement as it is emitted and tracing dataflows across the accumulated code. When a security rule fires
    查看原文 · v2

关联资产

  • 原文明确关联的资产类型是推理型LLM的流式思维链输出、其中累积的生成代码、安全规则集与检索到的安全知识,以及评测基准CWEval和SecCodeBench。适用前提是部署中存在可监测的推理流与交付前窗口;未提供本地资产清单,尚不能对应到具体模型、版本或代码仓库。

    原文依据 · 2
    tion. Security prompts and retrieved security knowledge act before any code exists, constrained decoding limits token choices but cannot guide repair, and post-hoc repair must regenerate the full response. Reasoning LLMs draft code early in their streamed chain of thought, and in this pre-delivery window the code exists only inside the reasoning stream. We present SecReason, an in-stream defense that monitors this window. Dual-track incremental scanning applies security rules, checking each statement as it is emitted and tracing dataflows across the accumulated code. When a security rule fires
    查看原文 · v2
    es, \system raises the share of runs delivering secure and functionally correct code from below 15\% to 72.8\%--98.1\% on \tool{CWEval} and \tool{SecCodeBench}. \system consumes fewer tokens than post-hoc repair, and when security rules misfire on secure code, it limits the functional regressions from false warnings.
    查看原文 · v2

风险评估

  • 来源报告描述的风险机制是:安全提示与检索到的安全知识在代码产生前起作用,受限解码只能限制token选择而无法指导修复,事后修复则须重新生成完整响应,成本与延迟更高。触发条件是推理LLM在思维链中提前写出含漏洞的代码而未被拦截。据此,防护优先级应放在交付前窗口的逐语句规则检查与跨累积代码的数据流追踪,而非仅依赖提示或事后重写。

    原文依据 · 1
    tion. Security prompts and retrieved security knowledge act before any code exists, constrained decoding limits token choices but cannot guide repair, and post-hoc repair must regenerate the full response. Reasoning LLMs draft code early in their streamed chain of thought, and in this pre-delivery window the code exists only inside the reasoning stream. We present SecReason, an in-stream defense that monitors this window. Dual-track incremental scanning applies security rules, checking each statement as it is emitted and tracing dataflows across the accumulated code. When a security rule fires
    查看原文 · v2

相关研究

  • 来源报告提出SecReason,方法为双轨增量扫描:对推理流中逐条发出的语句应用安全规则,并在累积代码上追踪数据流;当安全规则触发时进行流内自修复。其贡献在于把漏洞检测与修复前移到代码交付前的推理流窗口,并报告在规则对安全代码误报时能限制功能回退。材料仅提供该机制与结果概述,未展开规则集、数据流算法细节。

    原文依据 · 2
    tion. Security prompts and retrieved security knowledge act before any code exists, constrained decoding limits token choices but cannot guide repair, and post-hoc repair must regenerate the full response. Reasoning LLMs draft code early in their streamed chain of thought, and in this pre-delivery window the code exists only inside the reasoning stream. We present SecReason, an in-stream defense that monitors this window. Dual-track incremental scanning applies security rules, checking each statement as it is emitted and tracing dataflows across the accumulated code. When a security rule fires
    查看原文 · v2
    es, \system raises the share of runs delivering secure and functionally correct code from below 15\% to 72.8\%--98.1\% on \tool{CWEval} and \tool{SecCodeBench}. \system consumes fewer tokens than post-hoc repair, and when security rules misfire on secure code, it limits the functional regressions from false warnings.
    查看原文 · v2

验证资料

  • 来源报告给出的实验数据是:在CWEval与SecCodeBench上,SecReason将交付安全且功能正确代码的运行占比从低于15%提升到72.8%至98.1%,且消耗token少于事后修复。适用条件为上述两个基准与所述推理LLM代码生成场景。防御性核查可围绕规则命中日志、误报后功能回退幅度、token消耗对比以及交付前窗口的扫描覆盖情况设置观察指标。

    原文依据 · 1
    es, \system raises the share of runs delivering secure and functionally correct code from below 15\% to 72.8\%--98.1\% on \tool{CWEval} and \tool{SecCodeBench}. \system consumes fewer tokens than post-hoc repair, and when security rules misfire on secure code, it limits the functional regressions from false warnings.
    查看原文 · v2

处置建议

  • 建议按序推进:先确认代码生成流程中推理流是否可被监测并保留交付前窗口,对应来源所述流内防御前提;再在交付前窗口部署逐语句安全规则检查与累积代码数据流追踪,规则触发时执行流内自修复;随后以CWEval、SecCodeBench类基准回归安全且功能正确的交付占比与token消耗,并重点观察规则误报时功能回退是否受限。来源未给出具体修复版本号,部署版本需另行确认。

    原文依据 · 2
    tion. Security prompts and retrieved security knowledge act before any code exists, constrained decoding limits token choices but cannot guide repair, and post-hoc repair must regenerate the full response. Reasoning LLMs draft code early in their streamed chain of thought, and in this pre-delivery window the code exists only inside the reasoning stream. We present SecReason, an in-stream defense that monitors this window. Dual-track incremental scanning applies security rules, checking each statement as it is emitted and tracing dataflows across the accumulated code. When a security rule fires
    查看原文 · v2
    es, \system raises the share of runs delivering secure and functionally correct code from below 15\% to 72.8\%--98.1\% on \tool{CWEval} and \tool{SecCodeBench}. \system consumes fewer tokens than post-hoc repair, and when security rules misfire on secure code, it limits the functional regressions from false warnings.
    查看原文 · v2
模型与引文记录
模型
deepseek-flash
生成时间
记录编号
REQ-a923c1148f8e4669b5473d64ac7edeaf
分析原文
查看原文 · v2

资料档案

文献来源与参考链接

当前保存的来源版本 · v2

作者
Ruidong Han、Zhensu Sun、Chengyan Ma、Yuqing Niu、Zhou Yang、Siqi Ma、David Lo
文献与标准标识
arxiv:2610.14453
主题分类
cs.CR、cs.SE
来源版本
v2
来源更新时间
2026-10-14T04:57:43+00:00
日期依据
来源明确给出发表日期
原始标题与分类记录

SecReason: Vulnerability Detection and In-Stream Self-Repair for LLM Code Generation

研究方向
防御技术
影响维度
待人工确认
风险类型
供应链风险
相关技术
LLM

当前为离线关键词规则模式。

分类规则与原始字段
防御技术 · defense
e reasoning stream. We present SecReason, an in-stream defense that monitors this window. Dual-track incremental scanning applies security rules, checking each st
供应链风险 · vulnerability
SecReason: Vulnerability Detection and In-Stream Self-Repair for LLM Code Generation Large language models (LLMs) may introd
LLM · llm
Vulnerability Detection and In-Stream Self-Repair for LLM Code Generation Large language models (LLMs) may introduce security vulnerabilities into generated
{
  "ai_relevance": {
    "evidence": [
      {
        "end_offset": 68,
        "location": "title_and_content",
        "quote": "LLM",
        "rule": "ai_term",
        "start_offset": 65
      },
      {
        "end_offset": 106,
        "location": "title_and_content",
        "quote": "Large language models",
        "rule": "ai_term",
        "start_offset": 85
      },
      {
        "end_offset": 112,
        "location": "title_and_content",
        "quote": "LLMs",
        "rule": "ai_term",
        "start_offset": 108
      },
      {
        "end_offset": 580,
        "location": "title_and_content",
        "quote": "LLMs",
        "rule": "ai_term",
        "start_offset": 576
      }
    ],
    "matches": [
      {
        "end_offset": 68,
        "location": "title_and_content",
        "quote": "LLM",
        "rule": "ai_term",
        "start_offset": 65
      },
      {
        "end_offset": 106,
        "location": "title_and_content",
        "quote": "Large language models",
        "rule": "ai_term",
        "start_offset": 85
      },
      {
        "end_offset": 112,
        "location": "title_and_content",
        "quote": "LLMs",
        "rule": "ai_term",
        "start_offset": 108
      },
      {
        "end_offset": 580,
        "location": "title_and_content",
        "quote": "LLMs",
        "rule": "ai_term",
        "start_offset": 576
      }
    ],
    "method": "explainable_keyword_rules",
    "reason": "Matched AI topic or component evidence",
    "relevant": true
  },
  "entity_ids": [],
  "facts": [],
  "method": "source_grounded_extraction",
  "unknown_fields": [
    "affected_products",
    "affected_versions",
    "fixed_versions",
    "cvss",
    "mitigations",
    "references",
    "papers",
    "poc"
  ]
}
原始采集文本
Large language models (LLMs) may introduce security vulnerabilities into generated code, which can persist into production when verification focuses on functional correctness. Existing defenses act before, during, or after generation, but none inspects the code during generation. Security prompts and retrieved security knowledge act before any code exists, constrained decoding limits token choices but cannot guide repair, and post-hoc repair must regenerate the full response. Reasoning LLMs draft code early in their streamed chain of thought, and in this pre-delivery window the code exists only inside the reasoning stream. We present SecReason, an in-stream defense that monitors this window. Dual-track incremental scanning applies security rules, checking each statement as it is emitted and tracing dataflows across the accumulated code. When a security rule fires, SecReason interrupts generation, inserts an in-stream warning, and resumes decoding, so the model repairs the draft within the same reasoning trace without regenerating the full response. On tasks where unassisted generation introduces vulnerabilities, \system raises the share of runs delivering secure and functionally correct code from below 15\% to 72.8\%--98.1\% on \tool{CWEval} and \tool{SecCodeBench}. \system consumes fewer tokens than post-hoc repair, and when security rules misfire on secure code, it limits the functional regressions from false warnings.
采集信息与校验
完整来源元数据
{
  "authors": [
    "Ruidong Han",
    "Zhensu Sun",
    "Chengyan Ma",
    "Yuqing Niu",
    "Zhou Yang",
    "Siqi Ma",
    "David Lo"
  ],
  "content_level": "abstract",
  "date_basis": "explicit_published",
  "date_evidence": {
    "published": "2026-10-10T01:27:55Z",
    "updated": "2026-10-14T04:57:43Z"
  },
  "identifiers": [
    "arxiv:2610.14453"
  ],
  "source_updated_at": "2026-10-14T04:57:43+00:00",
  "subjects": [
    "cs.CR",
    "cs.SE"
  ],
  "version_label": "v2"
}
原文版本历史与校验
版本入库更新时间来源发布日期校验标识
v2 · 正在查看2026-10-15 01:22 UTC2026-10-10 01:27 UTC8eb4add8b5e4f6644433fbbb9bbf9570eb76f68543cadd56f6a6f8e5fd370733
v12026-10-14 01:50 UTC2026-10-10 01:27 UTC4984992c5357aef10344c398f260fdd167097d65d8cd1ae4791643ecdf555167
可引用分片 · 2 段

CHK-89dca24161b9b01d789214e9

Large language models (LLMs) may introduce security vulnerabilities into generated code, which can persist into production when verification focuses on functional correctness. Existing defenses act before, during, or after generation, but none inspects the code during generation. Security prompts and retrieved security knowledge act before any code exists, constrained decoding limits token choices but cannot guide repair, and post-hoc repair must regenerate the full response. Reasoning LLMs draft code early in their streamed chain of thought, and in this pre-delivery window the code exists only inside the reasoning stream. We present SecReason, an in-stream defense that monitors this window. Dual-track incremental scanning applies security rules, checking each statement as it is emitted and tracing dataflows across the accumulated code. When a security rule fires, SecReason interrupts generation, inserts an in-stream warning, and resumes decoding, so the model repairs the draft within the same reasoning trace without regenerating the full response. On tasks where unassisted generation introduces vulnerabilities, \system raises the share of runs delivering secure and functionally correct code from below 15\% to 72.8\%--98.1\% on \tool{CWEval} and \tool{SecCodeBench}.

CHK-83b1710f28677ca720e0a8db

es, \system raises the share of runs delivering secure and functionally correct code from below 15\% to 72.8\%--98.1\% on \tool{CWEval} and \tool{SecCodeBench}. \system consumes fewer tokens than post-hoc repair, and when security rules misfire on secure code, it limits the functional regressions from false warnings.
处理记录
补充资料

中文译文

正文译文暂缺,以下仅为中文摘要。

中文摘要

提出生成中检测漏洞并自修复的代码生成方法

已采集原文

访问来源网页

Large language models (LLMs) may introduce security vulnerabilities into generated code, which can persist into production when verification focuses on functional correctness. Existing defenses act before, during, or after generation, but none inspects the code during generation. Security prompts and retrieved security knowledge act before any code exists, constrained decoding limits token choices but cannot guide repair, and post-hoc repair must regenerate the full response. Reasoning LLMs draft code early in their streamed chain of thought, and in this pre-delivery window the code exists only inside the reasoning stream. We present SecReason, an in-stream defense that monitors this window. Dual-track incremental scanning applies security rules, checking each statement as it is emitted and tracing dataflows across the accumulated code. When a security rule fires, SecReason interrupts generation, inserts an in-stream warning, and resumes decoding, so the model repairs the draft within the same reasoning trace without regenerating the full response. On tasks where unassisted generation introduces vulnerabilities, \system raises the share of runs delivering secure and functionally correct code from below 15\% to 72.8\%--98.1\% on \tool{CWEval} and \tool{SecCodeBench}. \system consumes fewer tokens than post-hoc repair, and when security rules misfire on secure code, it limits the functional regressions from false warnings.

原文依据