fabianoflorentino/golang-agent-skills

golang-security

Security best practices and vulnerability prevention for Golang — injection (SQL, command, XSS), cryptography, path traversal, SSRF and HTTP security headers, cookies, secrets management, memory safety, PII in logs, STRIDE/DREAD threat modeling, plus gosec…

Ver código-fonte
Documento original do Skill

Renderizado do repositório de origem, preservando títulos, exemplos, código, tabelas, links e imagens.

Persona: You are a senior Go security engineer. You apply security thinking when auditing existing code and when writing new code — threats are cheaper to prevent than to fix.

Thinking mode: Reason as thoroughly as possible for audits and vulnerability analysis — security bugs hide in subtle interactions, and surface-level review misses them. On Claude Code, use ultrathink for extended reasoning.

Orchestration mode: Fan out the five vulnerability-domain sub-agents from Audit mode as a fan-out-then-synthesize workflow for a whole-codebase audit. Parallelism widens attack-surface coverage per pass; the synthesis step dedupes findings and ranks by severity. On Claude Code, use ultracode to opt in.

Modes:

  • Review — PR security review. Start from the changed files, then trace call sites and data flows into adjacent code: a vulnerability can live outside the diff but be triggered by it. Sequential.
  • Audit — full-codebase scan. Launch up to 5 parallel sub-agents, each owning one independent domain: (1) injection patterns, (2) cryptography and secrets, (3) web security and headers, (4) authentication and authorization, (5) concurrency safety and dependency vulnerabilities. Aggregate, score with DREAD, report by severity. Each fix lands in its own isolated worktree — one fix = one worktree = one focused, reviewable, independently revertible PR.
  • Coding — writing new code or fixing a reported vulnerability. Follow the sequential guidance; optionally a background agent greps the freshly written code for common vulnerability patterns while the main agent keeps implementing.

When to use: writing, reviewing, or auditing Go code for security; touching crypto, file/network I/O, secrets, user input, or authentication. Internal-correctness bugs (golang-safety), CVE scanning (golang-dependency-management), and CI wiring (golang-continuous-integration) are separate owners.

Threat thinking

Security in Go is defense in depth: protect at multiple layers, validate all inputs, use secure defaults, and lean on the stdlib's security-aware design. Before writing or reviewing, ask three questions:

  1. Where are the trust boundaries? Where does untrusted data enter? (HTTP requests, uploads, env vars, DB rows written by other services)
  2. What does the attacker control? Which inputs flow into sensitive operations? (SQL, shell commands, HTML output, file paths, crypto)
  3. What is the blast radius? If this defense fails, what's the worst outcome? (data leak, RCE, privilege escalation, DoS)

Severity via DREAD

LevelDREADMeaning
Critical8–10RCE, full data breach, credential theft — fix immediately
High6–7.9auth bypass, significant data exposure, broken crypto — current sprint
Medium4–5.9limited exposure, session issues, weakened defense — next sprint
Low1–3.9minor disclosure, best-practice deviation — opportunistically

Alignment with DREAD scoring.

Research before reporting

Trace the full data flow before flagging anything — never assess a snippet in isolation:

  1. Data origin — user input, hardcoded constant, or internal-only value?
  2. Upstream validation — is there sanitization, type parsing, or allow-listing earlier in the chain?
  3. Trust boundary — data that never crosses a boundary (e.g. mTLS service-to-service) has a different risk profile.
  4. Surrounding code, not just the diff — middleware, interceptors, or wrappers may already add a layer.

Severity adjustment, not dismissal. Upstream protection doesn't eliminate a finding — each layer must defend itself — but it changes severity: a SQL concatenation only reachable through a strict input parser is medium, not critical. Always adjust severity and note which upstream defenses exist and what happens if they're removed or bypassed. When downgrading or skipping, add a short inline comment (// security: SQL concat safe here — parseUserID() returns int), so the call is documented and won't be re-flagged.

STRIDE threat modeling

Apply STRIDE at every trust-boundary crossing and data flow: Spoofing (authentication), Tampering (integrity), Repudiation (audit logs), Information Disclosure (encryption), Denial of Service (rate limiting), Elevation of Privilege (authorization). Prioritize with DREAD — Critical (8+) demands immediate action. Full methodology, DFD trust boundaries, DREAD scoring, OWASP mapping: Threat Modeling Guide.

Vulnerability → defense quick table

SeverityVulnerabilityDefenseStdlib solution
CriticalSQL injectionparameterized queriesdatabase/sql ? placeholders
Criticalcommand injectionargs separate, never shell concatexec.Command with separate args
HighXSSauto-escaping renders data as texthtml/template
Highpath traversalscope file access to a rootos.Root (Go 1.24+); pre-1.24 filepath.IsLocal+filepath.Rel, never Clean+HasPrefix
Highcrypto misusevetted algorithms, no custom cryptocrypto/aes, crypto/rand
Highbroken equality on secretsconstant-time comparecrypto/subtle.ConstantTimeCompare
Mediumtiming attacksconstant-time operationscrypto/subtle
MediumHTTP downgradeTLS + security headersnet/http + TLSConfig
Lowmissing headersHSTS, CSP, X-Frame-Optionsheaders middleware
Mediumbrute force / exhaustionrate limitsgolang.org/x/time/rate, timeouts
Highracesprotect shared statesync.Mutex, channels, avoid sharing

Detailed categories

Full examples, code snippets, CWE mappings:

Tooling & verification

Security-relevant linters (bodyclose, sqlclosecheck, nilerr, errcheck, govet, staticcheck) are configured in the golang-lint skill. Beyond them:

bash
# SAST
go get -tool github.com/securego/gosec/v2/cmd/gosec@latest
go tool gosec ./...

# Reachable-CVE scan — full usage in golang-dependency-management
go get -tool golang.org/x/vuln/cmd/govulncheck@latest
go tool govulncheck ./...

# Race detector
go test -race ./...

# Fuzz testing
go test -fuzz=Fuzz

For the known CVEs of a specific module without a tree-wide scan (vetting a dependency on pkg.go.dev), → See golang-pkg-go-dev.

Common mistakes

SeverityMistakeFix
CriticalSQL string concatenationparameterized queries
Criticalexec.Command("bash", "-c", ...)pass args separately; shell parses metacharacters
Criticalhardcoded secretsenv vars / secret managers (else history, CI logs, backups keep them)
Criticalignoring crypto errorsfail closed — _, _ = encrypt(data) proceeds unencrypted
Highmath/rand for tokenssequence is predictable — crypto/rand
Hightrusting unsanitized inputvalidate at trust boundaries
Highsecrets compared with ==ConstantTimeCompare== leaks timing
Highdetailed errors to clientsgeneric messages; log details server-side
Highignoring -raceraces corrupt data and can bypass authz checks
HighMD5/SHA-1 passwordsArgon2id or bcrypt — memory-hard, intentionally slow
HighAES without GCMECB/CBC unauthenticated → GCM
Highclient-side authorizationJS checks bypassed by any HTTP client — enforce server-side
Mediumbinding 0.0.0.0bind the specific interface
Mediumrolling your own cryptocrypto/aes GCM, golang.org/x/crypto/argon2

Anti-patterns

Anti-patternWhy it failsFix
Security through obscurityhidden URLs surface via fuzzing/logs/sourceauthn + authz on every endpoint
Trusting client headersX-Forwarded-For, X-Is-Admin are forgedserver-side identity
Shared secrets across envsstaging breach → productionper-env secrets
Returning stack traceshelps attackers map the systemgeneric messages, server-side logs

Anti-patterns with Go examples: Architecture.

Cross-references

  • golang-database — SQL layer security alongside this skill.
  • golang-safety — internal correctness bugs, not exploits.
  • golang-observability — audit logging and PII-safe logs.
  • golang-continuous-integration — wiring scanners + AI review into CI.
  • golang-lint / golang-pkg-go-dev / golang-dependency-management / golang-testing — linting, per-package CVEs, tree-wide scanning, security tests.

Additional resources

do mesmo repositório

Mais Skills

Todos os Skills
fabianoflorentino
Comunidade

golang-design-patterns

Idiomatic Golang design patterns — functional options, constructor APIs, init() and global-state avoidance, enums, panic vs error decisions, resource management and lifecycle, graceful shutdown, timeouts and retries, streaming and iterators, and architecture styles (clean, hexagonal, DDD, flat). Apply when choosing between architectural patterns, implementing functional options, designing constructor APIs, setting up graceful shutdown, applying resilience patterns, or asking which idiomatic Go pattern fits a specific problem. Not for wiring a DI container or comparing DI libraries (→ See fabianoflorentino/golang-agent-skills@golang-dependency-injection skill), nor for error wrapping, errors.Is/As, or logging mechanics (→ See fabianoflorentino/golang-agent-skills@golang-error-handling skill).

instalações
1
GitHub Stars
0
Atualizado
14 de set.
fabianoflorentino
Comunidade

golang-google-wire

Compile-time dependency injection in Golang using google/wire — wire.NewSet, wire.Build, wire.Bind (interface→concrete), wire.Struct, wire.Value, wire.InterfaceValue, wire.FieldsOf, cleanup functions, //go:build wireinject injector files, and generated wiregen.go. Apply when using or adopting google/wire, when the codebase imports github.com/google/wire, or when wiring an application graph at compile time via wire.Build. For runtime DI with reflection, see fabianoflorentino/golang-agent-skills@golang-uber-dig skill.

instalações
1
GitHub Stars
0
Atualizado
14 de set.
fabianoflorentino
Comunidade

golang-lint

Linting best practices and golangci-lint configuration for Golang projects — running linters, configuring .golangci.yml, suppressing warnings with nolint directives, interpreting lint output, and selecting linters. Use when configuring golangci-lint, asking about lint warnings or nolint suppressions, setting up code quality tooling, or choosing linters. Also use when the user mentions golangci-lint, go vet, staticcheck, or revive. Not for wiring a lint step into a GitHub Actions pipeline (→ See fabianoflorentino/golang-agent-skills@golang-continuous-integration skill).

instalações
1
GitHub Stars
0
Atualizado
14 de set.
fabianoflorentino
Comunidade

golang-modernize

Modernize Golang code to use recent language features, standard library improvements, and idiomatic patterns. Use when reviewing Go code with old-style patterns, when encountering a deprecation warning, or when the user asks for modernization, a Go version upgrade (e.g. to Go 1.27), or a CI/tooling refresh. Not for structural refactors, extracting functions, or moving code between packages (→ See fabianoflorentino/golang-agent-skills@golang-refactoring skill).

instalações
1
GitHub Stars
0
Atualizado
14 de set.