security-owasp

OWASP Top 10 Web 安全防护:专注防范 OWASP Top 10 漏洞,涵盖身份认证与授权、输入验证、XSS 与 CSRF 防护、安全响应头配置及安全测试,强调将安全视为优先需求而非事后补充。适用于涉及安全、OWASP、XSS、CSRF、SQL 注入、身份认证与授权、输入验证、响应头与渗透测试的场景。

仓库最近推送
GitHub Stars
237
Forks
32
Issues / PRs
2

安装方式

先用 Prompt 核对来源与依赖。也可下载安装包。

用 AI 助手安装

复制提示词,让助手先核对固定版本和依赖。

查看 Prompt收起 Prompt
先检查当前 Agent 是否已安装 SkillPI Skill Finder。如果尚未安装,请按官方仓库的说明安装并启用:https://github.com/Findskills/skillpi。然后使用 Skill Finder 打开此 SkillPI 详情页并定位 "security-owasp":https://skillpi.com/zh/skills/deepskill-5650a80ed40e0f155f7ed1453d84382e4336e03e9acd60fa5817c40ad030a4b7。安装前核对上游来源和版本:https://github.com/omer-metin/skills-for-antigravity。来源不一致时停止并说明差异。核对通过后,用 Skill Finder 安装目标 Skill,并报告安装路径和来源版本。

来源与配置

github.com

配置方式待核实

请查看原始来源中的适用工具、依赖和权限要求。

安装实测待补充

OWASP Top 10 Web 安全防护:专注防范 OWASP Top 10 漏洞,涵盖身份认证与授权、输入验证、XSS 与 CSRF 防护、安全响应头配置及安全测试,强调将安全视为优先需求而非事后补充。适用于涉及安全、OWASP、XSS、CSRF、SQL 注入、身份认证与授权、输入验证、响应头与渗透测试的场景。

0 下载

介绍来源: third_party · omer-metin · 0.0.1 参考来源

SkillPi 解读

能完成的任务
翻译待完成,请参阅来源文档。
实测状态
未测试

文件浏览

在原站浏览文件 ↗

原始 SKILL.md

打开原文 ↗
Frontmatter
name: security-owasp
description: OWASP Top 10:2025 kodenivå-mønstre for Kotlin, Go, Java og Node.js — tilgangskontroll, forsyningskjede, injeksjon og feilhåndtering
license: MIT
metadata:
  domain: auth
  tags: security owasp kotlin go java nodejs nais supply-chain

OWASP Top 10:2025 — Code-Level Security

Tactical security patterns for Kotlin, Go, Java, and Node.js on NAIS, aligned with the 2025 OWASP Top 10.

Complements @security-champion-agent (architecture-level threat modeling) and the security-review skill (scanning tools).

Full code examples for each category: see examples.md in this skill directory.

A01: Broken Access Control (incl. SSRF)

// ❌ IDOR — trusts user-supplied ID without ownership check
get("/api/vedtak/{id}") {
    val vedtak = vedtakRepository.findById(call.parameters["id"]!!.toLong())
    call.respond(vedtak)
}

// ✅ Verify ownership before returning resource
get("/api/vedtak/{id}") {
    val bruker = call.hentBruker()
    val vedtak = vedtakRepository.findById(call.parameters["id"]!!.toLong())
        ?: return@get call.respond(HttpStatusCode.NotFound)
    if (vedtak.brukerId != bruker.id) return@get call.respond(HttpStatusCode.Forbidden)
    call.respond(vedtak.toDTO())
}
// ✅ SSRF prevention — validate outbound URL against allowlist
func fetchExternal(targetURL string) error {
    parsed, err := url.Parse(targetURL)
    if err != nil { return err }
    if !isAllowedHost(parsed.Host) { return fmt.Errorf("host not allowed: %s", parsed.Host) }
    // proceed with request
}
  • Deny by default — require explicit grants, not explicit denials
  • Resource-level checks — not just "is authenticated" but "owns this resource"
  • M2M tokens — validate azp claim against AZURE_APP_PRE_AUTHORIZED_APPS
  • SSRF — validate outbound URLs; use Nais accessPolicy.outbound as defense-in-depth

A02: Security Misconfiguration

// ❌ Open CORS
install(CORS) { anyHost() }

// ✅ Restrict to known origins
install(CORS) { allowHost("my-app.intern.nav.no", schemes = listOf("https")) }
// ❌ Debug endpoint exposed on public ingress
mux.HandleFunc("/debug/pprof/", pprof.Index)

// ✅ Debug endpoints on separate internal-only port (Nais handles this)
internalMux := http.NewServeMux()
internalMux.HandleFunc("/debug/pprof/", pprof.Index)
go http.ListenAndServe(":9090", internalMux) // not exposed via ingress
  • CORS restricted to known origins — never * or anyHost()
  • Debug/admin endpoints not on public ingress
  • Error responses sanitized — no stack traces, SQL errors, or file paths to client
  • Default-deny Nais accessPolicy — explicit inbound/outbound only

A03: Software Supply Chain Failures (NEW in 2025)

// go.sum provides integrity verification — always commit it
// Use govulncheck for known vulnerabilities
// $ govulncheck ./...

// ✅ Pin dependencies to exact versions in go.mod
require (
    golang.org/x/crypto v0.31.0
    github.com/jackc/pgx/v5 v5.7.2
)
// build.gradle.kts — use dependency locking and BOM
dependencyLocking { lockAllConfigurations() }
dependencyManagement {
    imports { mavenBom("org.springframework.boot:spring-boot-dependencies:3.4.1") }
}
// Run: ./gradlew dependencies --write-locks
# ✅ GitHub Actions — pin to full SHA, never @main or floating tags
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
# ❌ Vulnerable to supply chain attack
- uses: actions/checkout@main
  • Pin all dependencies to exact versions; use lockfiles
  • Scan dependencies: govulncheck ./..., trivy repo ., ./gradlew dependencyCheckAnalyze
  • GitHub Actions pinned to full commit SHA (not tags)
  • Generate SBOM for production artifacts when possible
  • Prefer well-maintained, first-party packages

A04: Cryptographic Failures

// ❌ Disabling TLS verification
client := &http.Client{
    Transport: &http.Transport{
        TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
    },
}

// ✅ Default TLS config (Go enforces TLS 1.2+ by default)
client := &http.Client{}
// ❌ Weak hashing for passwords
val hash = MessageDigest.getInstance("MD5").digest(password.toByteArray())

// ✅ bcrypt for password hashing
val hashed = BCrypt.hashpw(password, BCrypt.gensalt(12))
  • Passwords: bcrypt (cost ≥ 12) or argon2id — never MD5/SHA-1/SHA-256
  • Secrets: always from Nais environment variables or Secret resources — never hardcoded
  • TLS 1.2+: never set InsecureSkipVerify: true
  • Encryption: AES-256-GCM; rotate keys periodically

A05: Injection

// ❌ SQL injection via string template
session.run(queryOf("SELECT * FROM vedtak WHERE status = '$status'").map { ... }.asList)

// ✅ Parameterized query (Kotliquery)
session.run(queryOf("SELECT * FROM vedtak WHERE status = ?", status).map { ... }.asList)
// ❌ Command injection via shell
exec.Command("sh", "-c", fmt.Sprintf("process %s", userInput)).Run()

// ✅ Pass arguments directly (no shell interpretation)
exec.Command("process", userInput).Run()
  • All SQL queries parameterized (? / $1) — never string concatenation
  • No shell execution with user-controlled input
  • Validate/sanitize all external input at service boundary

A09: Security Logging and Alerting Failures

// ✅ Structured logging with correlation ID, no PII
log.info("Vedtak opprettet", kv("vedtakId", vedtak.id), kv("sakId", sak.id))

// ❌ PII in logs — GDPR violation
log.info("Vedtak for bruker ${bruker.fnr}")
  • No PII in logs (fnr, name, address, tokens)
  • Audit trail for sensitive operations (vedtak, utbetaling, tilgang)
  • Correlation IDs propagated across services (OpenTelemetry trace context)
  • Alerting on anomalous patterns (auth failures, rate spikes)

A10: Mishandling of Exceptional Conditions (NEW in 2025)

// ❌ Panic leaks to caller, crashes service
func processRequest(data []byte) Result {
    var req Request
    json.Unmarshal(data, &req) // ignores error, req may be zero-value
    return handle(req)
}

// ✅ Handle errors explicitly, fail safely
func processRequest(data []byte) (Result, error) {
    var req Request
    if err := json.Unmarshal(data, &req); err != nil {
        return Result{}, fmt.Errorf("invalid request payload: %w", err)
    }
    return handle(req)
}
// ❌ Swallowing exceptions silently
fun process(data: String): Result {
    try { return parse(data) }
    catch (e: Exception) { return Result.empty() } // silent failure, no logging
}

// ✅ Log, wrap, and surface errors appropriately
fun process(data: String): Result {
    return try { parse(data) }
    catch (e: Exception) {
        log.error("Parsing failed", kv("error", e.message))
        throw ServiceException("Could not process input", e)
    }
}
  • Always handle errors — never ignore returned errors in Go
  • Recover from panics at HTTP handler boundaries (middleware)
  • Fail securely: deny access by default when state is uncertain
  • Sanitize error messages: internal details stay in logs, not in responses
  • Centralized error handling via middleware/exception mappers

Quick Reference Checklist

  • [ ] A01 — Resource-level access checks on every endpoint (not just auth)
  • [ ] A01 — M2M tokens validate azp against pre-authorized apps
  • [ ] A01 — Outbound URLs validated; Nais egress policy configured
  • [ ] A02 — CORS restricted to known origins
  • [ ] A02 — Debug endpoints not on public ingress
  • [ ] A02 — Error responses sanitized (no stack traces to client)
  • [ ] A03 — Dependencies pinned to exact versions with lockfiles
  • [ ] A03 — govulncheck / trivy repo . pass without HIGH/CRITICAL
  • [ ] A03 — GitHub Actions pinned to full SHA
  • [ ] A04 — bcrypt/argon2id for passwords, never MD5/SHA-1
  • [ ] A04 — TLS 1.2+ enforced, no InsecureSkipVerify
  • [ ] A04 — Secrets from environment/Nais, never hardcoded
  • [ ] A05 — All SQL queries parameterized (? / $1)
  • [ ] A05 — No shell execution with user input
  • [ ] A07 — JWT validates exp, iss, aud, and algorithm
  • [ ] A08 — Deserialization into concrete types only
  • [ ] A09 — No PII in logs (fnr, name, address)
  • [ ] A09 — Audit trail for sensitive operations
  • [ ] A10 — All errors handled (no ignored returns in Go)
  • [ ] A10 — Panic recovery in HTTP handlers
  • [ ] A10 — Error messages sanitized before client responses

Related

Resource Use For
security-review skill Pre-commit scanning (trivy, zizmor, govulncheck)
@security-champion-agent Threat modeling, compliance, Nav security architecture
$nav-auth JWT validation, TokenX, ID-porten implementation
threat-model skill STRIDE-A analysis for new services
OWASP Top 10:2025 Official category descriptions
OWASP Go SCP Go-specific secure coding guide
OWASP CI/CD Top 10 Pipeline security risks
sikkerhet.nav.no Nav Golden Path

Boundaries

✅ Always

  • Parameterized queries for all SQL
  • Resource-level access checks on every data-returning endpoint
  • Structured logging without PII
  • SHA-pinned GitHub Actions
  • Explicit error handling (no ignored errors)
  • Dependencies scanned before release

⚠️ Ask First

  • Custom cryptographic implementations
  • Disabling security features for testing
  • Changing authentication or authorization logic
  • Adding new outbound external hosts

🚫 Never

  • String-concatenated SQL queries
  • InsecureSkipVerify: true in production
  • PII in log statements (fnr, name, address)
  • Wildcard CORS (* / anyHost())
  • Hardcoded secrets or encryption keys
  • Floating tags (@main, @v3) for GitHub Actions
  • Silently swallowing errors without logging

当前收录版本

0.0.1

核对来源版本 ↗

安全与评测信息

质量评测

满分100 · 来自 SkillPi LAB 实验室的评测报告。

场景价值95/100

亮点

  • 提供 OWASP Top 10:2025 最新标准的代码级安全实现模式
  • 覆盖 Kotlin、Go、Java、Node.js 多语言实战场景
  • 包含完整安全检查清单与边界规范
触发精准90/100

亮点

  • 关键词覆盖全面(安全、OWASP、XSS、CSRF、注入等)
  • 触发边界清晰,无明显歧义
结构规范85/100

待提升项

  • 缺少 When to Use 章节与端到端示例 原报告严重程度:轻微

    文档结构良好但缺少显式使用场景说明和完整端到端示例

    改进建议:建议补充 When to Use 章节说明适用场景,并提供至少一个端到端完整示例

亮点

  • 按 OWASP 分类清晰组织内容
  • 每类含错误与正确代码对比
  • 包含快速参考检查清单
执行可靠75/100

待提升项

  • 引用文件缺失 原报告严重程度:重大

    主文件引用 examples.md 但未传入该文件

    改进建议:请确保 examples.md 文件随包提交,或移除引用说明

亮点

  • 代码示例参数正确(如 bcrypt cost≥12)
  • 工具来源明确(govulncheck、trivy)
  • 覆盖主要异常处理场景
证据可验 (前四项均值)86/100

取前四项原始分值的算术平均,四舍五入取整。可通过收录报告核对各项评分与说明,运行记录需单独查证。

正文静态检测

100 / 100 · skillpi-20261123-no-r3-v1

正文未命中当前规则。

分数仅反映正文中的规则命中,供使用前参考。附件与运行行为不在此评分范围内。

权限与使用前检查

根据当前主文档自动整理,命中内容可能是示例或防护说明;不是实际权限声明,也未覆盖附件、外部依赖或运行行为。

未从主文档识别到上述常见操作,不能据此判断无需权限或没有风险。

文档引用的域名或地址

这些地址可能用于文档链接或示例,不是已批准的联网清单。使用前核对实际目的地及发送的数据。

  • owasp.org
  • sikkerhet.nav.no

本站展示提示不会授予权限。涉及文件改动、密钥、外部发送或费用时,仍由你使用的工具按需确认。

安全评级与访问范围

safe · 静态证据核验,不代表运行安全保证。

使用前请由宿主核对并授权实际文件读写、外部服务和联网目的地;本站的核验不会授予任何运行权限。