AI News AI资讯 2h ago Updated 46m ago 更新于 46分钟前 48

Show HN: Security Cards – Reducing insecure AI-generated code by 72% 展示 HN:安全卡片——将不安全 AI 生成代码减少 72%

Security Cards are an open-source collection of library-specific security guidance for 80+ widely used libraries across 13 programming languages, designed to help AI coding agents generate safer code The approach reduces insecure code generation by up to 72.3% when evaluated with Claude Code using Opus 4.7 on the BaxBench benchmark A hybrid extraction method combining deterministic and AI-based processes systematically gathers scattered security knowledge from library repositories, with fewer th AI编码代理生成的代码中40-50%存在安全漏洞,尽管功能正确但安全性严重不足 Security Cards为80+广泛使用的开源库提供针对性安全指导,覆盖13种编程语言 评估显示在Claude Code with Opus 4.7中,不安全代码生成率降低72.3%(基于BaxBench基准测试) 采用混合方法(确定性+AI-based)从库仓库中提取安全最佳实践,结合多层自动化验证和人工审核 提供简单安装命令和三步使用流程,确保用户代码不离开本地环境

65
Hot 热度
72
Quality 质量
68
Impact 影响力

Analysis 深度分析

TL;DR

  • Security Cards are an open-source collection of library-specific security guidance for 80+ widely used libraries across 13 programming languages, designed to help AI coding agents generate safer code
  • The approach reduces insecure code generation by up to 72.3% when evaluated with Claude Code using Opus 4.7 on the BaxBench benchmark
  • A hybrid extraction method combining deterministic and AI-based processes systematically gathers scattered security knowledge from library repositories, with fewer than 10% of cards requiring human review after iterative refinement
  • Each Security Card includes a "Use when" section, concrete implementation rules, and supporting code snippets; a Security Blueprint provides a high-level summary for quick reference
  • An installable AI skill enables automatic retrieval and application of relevant security cards during code development or review, with no code transmission or external access

Why It Matters

AI coding agents are increasingly adopted across the industry, yet studies show 40–50% of generated code contains at least one security vulnerability—a significant risk for teams relying on these tools for production code. Security Cards address this gap by providing targeted, library-specific guidance that fills the contextual knowledge deficit AI agents face when working with framework-specific security details. This represents a practical, deployable solution that can be integrated into existing AI coding workflows with minimal overhead.

Technical Details

  • Hybrid Knowledge Extraction: A combination of deterministic and non-deterministic (AI-based) processes extracts security best practices from library repositories, documentation, source code, tests, and configurations, validated through multiple layers of automated checks and human review
  • Card Structure: Each Security Card contains a "Use when" scenario specification, one or more concrete security rules, and illustrative code snippets; Security Blueprints provide condensed overviews of the most critical cards per library
  • Evaluation: Tested on the BaxBench benchmark using Claude Code with Opus 4.7, achieving a 72.3% reduction in insecure code generation relative to the baseline without Security Cards
  • Coverage: 80+ open-source libraries spanning 13 programming languages, including web frameworks (e.g., Flask), mobile frameworks, security libraries, and data serializers
  • Integration: An AI skill installed via npx skills add Reware-Labs/securitycards enables automatic card retrieval and application during coding tasks or code reviews, operating entirely within the user's local environment without code transmission

Industry Insight

  • The 40–50% vulnerability rate in AI-generated code represents a critical adoption barrier for enterprise and security-conscious teams; solutions like Security Cards that can be deployed without model retraining offer an immediately actionable path to safer AI-assisted development
  • The hybrid extraction methodology—combining automated AI-based processing with targeted human review—demonstrates a scalable template for building other domain-specific guidance systems that can be extended to additional libraries and security domains
  • The skill-based integration model (installable, context-aware, no code exfiltration) sets a precedent for how third-party security knowledge can be delivered to AI coding agents, suggesting a growing ecosystem of specialized skills may emerge around compliance, performance, and accessibility guidance

TL;DR

  • AI编码代理生成的代码中40-50%存在安全漏洞,尽管功能正确但安全性严重不足
  • Security Cards为80+广泛使用的开源库提供针对性安全指导,覆盖13种编程语言
  • 评估显示在Claude Code with Opus 4.7中,不安全代码生成率降低72.3%(基于BaxBench基准测试)
  • 采用混合方法(确定性+AI-based)从库仓库中提取安全最佳实践,结合多层自动化验证和人工审核
  • 提供简单安装命令和三步使用流程,确保用户代码不离开本地环境

为什么值得看

这篇文章揭示了当前AI编码代理在安全性方面的显著缺陷,并提供了经过验证的开源解决方案。Security Cards的低门槛部署和72%的安全提升效果,为AI从业者提供了实用的代码安全加固路径。

技术解析

  • 核心问题:AI编码代理(Claude、GPT等)生成的代码虽然功能正确,但40-50%包含至少一个安全漏洞,主要源于框架和库特定的实现细节缺乏上下文知识
  • 解决方案架构:Security Cards采用混合方法(确定性+AI-based)从80+开源库仓库中提取分散的安全知识,结合多层自动化验证和人工审核(<10%卡片需人工审核)
  • 卡片结构:每张安全卡包含"Use when"场景说明、具体实现规则和带示例代码片段的解释,还有Security Blueprint提供高级摘要供快速参考
  • 评估方法:在BaxBench基准测试上,使用Claude Code with Opus 4.7进行评估,不安全代码生成率降低72.3%
  • 使用方式:通过npx skills add Reware-Labs/securitycards --skill securitycards -g安装skill,AI代理自动检索相关安全卡并作为上下文使用,代码不离开用户环境

行业启示

  • AI编码代理的安全性问题已成为规模化应用的瓶颈,需要像Security Cards这样的针对性解决方案来填补框架特定知识的空白
  • 混合知识提取方法(自动化+AI+人工审核)为构建高质量AI安全指导提供了可复用的范式,值得其他安全领域借鉴
  • 开源安全指导工具的低门槛部署表明,提升AI代码安全性的最佳路径是将其集成到现有开发工作流而非替代现有工具

Disclaimer: The above content is generated by AI and is for reference only. 免责声明:以上内容由 AI 生成,仅供参考。

Code Generation 代码生成 Security 安全 Open Source 开源 Agent Agent LLM 大模型