go-security

Audit and write Go code against injection, cryptography, secrets, and web security vulnerabilities.

1|2|Updated Nov 25, 2017
One-click install
npx skills add https://github.com/asarchami/dotfiles --skill go-security-asarchami
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: go-security
Source: https://github.com/asarchami/dotfiles/tree/main/dot_config/opencode/skills/go/go-security
Command: npx skills add https://github.com/asarchami/dotfiles --skill go-security-asarchami

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Go codebases handling untrusted input, credentials, or network traffic often contain exploitable vulnerabilities — SQL injection, hardcoded secrets, weak crypto, missing security headers — that slip through ordinary code review. This Skill provides a structured methodology to map trust boundaries, trace data flows, and systematically check every vulnerability class before code ships. ## Core Features & Use Cases - Three operational modes: review a PR diff for vulnerabilities, run a full codebase security audit by domain, or write new code with safe defaults from the start. - Vulnerability quick reference: severity-ranked tables covering SQL injection, command injection, XSS, path traversal, timing attacks, crypto misuse, race conditions, and more, each paired with the correct Go standard library defense. - DREAD scoring and reporting: rank findings Critical/High/Medium/Low with documented severity adjustments and inline // security: comments. - Deep-dive references: twelve focused guides on cryptography, injection, filesystem, network, cookies, secrets, logging, memory safety, third-party data leaks, threat modeling (STRIDE/OWASP), architecture, and a review checklist. - Use Case: Before merging a PR that adds a file-upload endpoint, use this Skill to trace the filename input to its origin, verify os.Root scoping against path traversal, check for decompression bomb limits, and confirm gosec and govulncheck pass. ## Quick Start Use the go-security skill to audit this Go pull request for injection, crypto, and secrets vulnerabilities and report findings ranked by severity.

Frequently Asked Questions about go-security

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I audit Go code for security vulnerabilities?

Run one pass per vulnerability domain — injection, cryptography, secrets, web security, auth, and concurrency — then score findings with DREAD and rank by severity. Verify with gosec, govulncheck, and go test -race.

How do I prevent SQL injection in Go?

Use parameterized queries with database/sql placeholders ($1 for Postgres, ? for MySQL) so data and code stay separate. For dynamic IN clauses, generate numbered placeholders; for dynamic column names, use an explicit allowlist.

What password hashing algorithm should Go applications use?

Use Argon2id (preferred) or bcrypt — both are intentionally slow and resist GPU brute-force attacks. Never use MD5, SHA1, or plain SHA-256 for passwords since fast hashes enable rapid cracking.

Does Go protect against path traversal attacks?

Go 1.24+ provides os.Root, which confines file operations to a root directory at the OS level and rejects escaping symlinks. On earlier versions, validate with filepath.Clean and prefix checks against the base directory.

Why is math/rand dangerous for security tokens in Go?

math/rand produces predictable output, letting attackers guess session tokens or keys. Use crypto/rand for all security-critical randomness, and crypto/subtle.ConstantTimeCompare when comparing secrets to avoid timing leaks.

What are the limitations of static security scanning in Go?

Tools like gosec flag patterns but cannot trace data flow across trust boundaries, so upstream validation context is missed. Combine scanning with manual data-flow tracing, govulncheck for dependency CVEs, and the race detector for concurrency flaws.