agentleFS
alexderzalexderz/agentic-toolbox/skills/golang-security/SKILL.md

golang-security

Skill5 starsChanged 47 days agoMITView on GitHub

use this when writing, reviewing, or auditing Go for exploitable issues — injection, crypto, path, SSRF, cookies, secrets, PII in logs, authn/z — not nil/slice bugs (golang-safety) or test-harness design (golang-testing).

  • Installs packages

15 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use golang-how-to, golang-gopls and 9 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • alexastrumSkill

    golang-how-to

    Golang skills orchestrator — always active on any Golang coding, review, debug, or setup task. Reads the task context and loads the most relevant skills from samber/cc-skills-golang, often multiple at once: writing a gRPC service loads golang-grpc + golang-testing + golang-error-handling; debugging a panic loads golang-troubleshooting + golang-safety; auditing security loads golang-security + golang-lint + golang-safety. Also: disambiguates competing clusters when two skills seem to overlap (performance vs benchmark vs troubleshooting, samber/lo vs mo vs ro, DI cluster, safety vs security), and configures CLAUDE.md or AGENTS.md to force-trigger skills in a project (/golang-how-to configure).

    Also in 7 projects that use this

  • jkeddariSkill

    golang-gopls

    Golang semantic code intelligence with the official gopls language server: definitions, references, symbols, call and implementation hierarchies, diagnostics, formatting, code actions, safe rename, extract, inline, and package API discovery. Use when navigating or refactoring a local Go workspace or when semantic analysis is safer than text search.

    Also in 5 projects that use this

  • jkeddariSkill

    golang-refactoring

    Golang refactoring workflow for safe structural change: blast-radius discovery, coverage-adaptive safety nets, semantic rename and extract operations, package moves, import-cycle removal, staged commits, and behavior-preserving verification. Use when restructuring existing Go code without intentionally changing its public behavior.

    Also in 5 projects that use this

  • alexastrumSkill

    golang-swagger

    Golang OpenAPI/Swagger documentation with swaggo/swag — annotation comments (@Summary, @Param, @Success, @Router, @Security), swag init code generation, framework integrations (gin, echo, fiber, chi, net/http), security definitions (Bearer/JWT, OAuth2, API key), and struct tags (swaggertype, enums, example, swaggerignore). Apply when adding or maintaining Swagger/OpenAPI docs in a Go project, or when the codebase imports github.com/swaggo/swag, github.com/swaggo/gin-swagger, github.com/swaggo/echo-swagger, github.com/swaggo/http-swagger, or github.com/swaggo/files.

    Also in 7 projects that use this

  • rockcookiesSkill

    golang-pkg-go-dev

    Golang package and module documentation and exploration via `godig`, a pkg.go.dev API client (CLI + MCP server) — package docs, API references, symbols, code examples, available versions, importers (who imports a package), licenses, and known vulnerabilities. Read-only, no auth. Use for looking up any Go/Golang library's documentation, API signatures, usage examples, which versions exist, whether a dependency has CVEs, or who imports a package — prefer this over Context7 for any Go package or module. Triggers on: how to use a Go library, Go API docs, import usage, code examples, pkg.go.dev. Not for upgrading dependencies (→ See `golang-dependency-management` skill) or choosing a library (→ See `golang-popular-libraries` skill). Not for local symbols, or for navigating an already-used dependency's resolved source, call sites, or generic instantiations — → See `golang-gopls` skill for those.

    Also in 4 projects that use this

  • +6 more from alexastrum

The file

We split this skill into the rules it gives an agent

3 rules. 0 are common, 3 are distinctive, and 0 are very specific to this project.

  • 0

    Common

    Most of the 15 edited versions we read keep these.

  • 3

    Distinctive

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Do not flag a snippet in isolation.

    line 83
  2. Distinctive:

    Check upstream validation / allowlists / type parse.

    line 86
  3. Distinctive:

    Stop. Classify. Ask or never — do not ship.

    line 151

“Common” is measured: kept by at least 6 in 10 of the 15 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Go security

Rewrite of samber/cc-skills-golang golang-security @ 22c58a55. Not a vendor paste. SKILL only — no evals/, no scripts/, no references/. Compatible with security-hardening: LLM output is untrusted; the system prompt is not a boundary.

language-router picks one Go skill per turn: this skill, golang-safety or golang-testing. Each Go concern may be its own item.

Iron law

Every trust-boundary crossing gets a control in code. Validate input, parameterize queries, encode for the sink, fail closed. Upstream validation adjusts severity; it does not dismiss the finding.

Three questions

  1. Trust boundary — where does untrusted data enter? (HTTP, uploads, env, other services' rows)
  2. Attacker control — which inputs reach SQL, shell, HTML, paths, crypto, or outbound HTTP?
  3. Blast radius — leak, RCE, auth bypass, or DoS if this layer fails?

Always

RuleGo move
Parameterize every querydatabase/sql / pgx placeholders ($1 / ?). Allowlist identifiers (ORDER BY, columns). Never concat user text into SQL.
Exec without a shellexec.Command(bin, args...). Never sh -c / bash -c with user text.
Encode for the HTML sinkhtml/template (auto-escape). html.EscapeString if you must Fprintf.
Scope file pathsGo 1.24+: os.Root. Older: filepath.IsLocal + filepath.Rel. Never Clean + HasPrefix alone.
Authenticated cryptoAES-256-GCM or ChaCha20-Poly1305. Fresh nonce per seal. crypto/rand, not math/rand.
Slow password hashesArgon2id preferred; bcrypt OK. Not MD5 / SHA-1 / bare SHA-256.
Constant-time secretscrypto/subtle.ConstantTimeCompare or hmac.Equal. Not ==.
TLS 1.2+ and verify certsMinVersion: tls.VersionTLS12. No InsecureSkipVerify. SSH: FixedHostKey, not InsecureIgnoreHostKey.
Timeouts on HTTP serversReadTimeout / WriteTimeout / IdleTimeout / MaxHeaderBytes.
Secure session cookiesHttpOnly, Secure, SameSite=Lax or Strict.
Secrets from env or a managerFail closed if required secret is empty.
Generic client errorsLog details server-side. No stack traces, DSNs, or SQL text to clients.
Server-side authn/zEvery handler. Do not trust X-Forwarded-For / X-Is-Admin.
Race-sensitive shared statesync.Mutex / channels. Prove with go test -race (golang-testing).

Ask first

TopicWhy it is a stop
New auth / session shapeTrust-boundary widen — same as security-hardening
New egress or SSRF-shaped fetchOutbound URL from user input needs an allowlist + no link-local / metadata
Uploads / zip extractZipSlip, zip bombs, special files
Public pprof / debug mux/debug/pprof is a leak if reachable
SameSite=None or cookie DomainCSRF / cross-site widening
Skipping -race or fuzz on a security-touching changeProof belongs with golang-testing
Review/audit growing write or deploy toolsReview skills should not write — read, report

Record the decision on the LLD or ticket. Do not self-except.

Never

NeverWhy
SQL / command / HTML string-built from user or model textInjection (CWE-89 / 78 / 79)
Hardcoded secrets, DSNs, or JWT keys in sourceHistory is forever
math/rand for tokens, IDs, or noncesPredictable
DES, RC4, MD5, SHA-1, AES-ECB, or reused GCM nonceBroken or catastrophic
Ignoring crypto / encrypt errors (_, _ = …)Fail-open
Rolling your own cryptoUse stdlib / x/crypto
gob of untrusted inputUnsafe deserialization
Bind 0.0.0.0 or public mesh from a one-offNetwork becomes the client
World-writable files (0777 / 0666)Data-class fail
PII, tokens, or passwords in logssecurity-hardening Never
Personal finance, mail, password stores, or extra hosts without the operatorHost / account locks
Copy evals/ or scripts/ into this skill dirINTAKE quarantine
Install the samber pack / marketplace syncDual routers; pin stays

Host and personal-account locks are Never, not Ask first.

Modes

  • Review — start at the diff, then trace call sites and data flow. A vuln may live outside the hunk. Read, report, escalate. Do not grow write/merge tools to “finish the review.”
  • Audit — cover five domains: (1) injection, (2) crypto and secrets, (3) web / headers / cookies, (4) authn/z, (5) races that break authz. Score DREAD; one fix = one PR. Do not dump a mixed-concern patch.
  • Coding — write behind Always. Optionally grep new code for concat-SQL, sh -c, InsecureSkipVerify, and hardcoded keys while implementing.

Research before reporting

Do not flag a snippet in isolation.

  1. Trace the value to its origin (user, constant, internal).
  2. Check upstream validation / allowlists / type parse.
  3. Note remaining defenses (middleware, os.Root, parameterized store).
  4. Report with adjusted severity, not a silent skip. If you downgrade, leave a short // security: comment naming the control.

Defense in depth: every layer still protects itself. A concat reachable only through parseUserID() int is medium, not dismissed.

Severity (DREAD)

LevelScoreMeaning
Critical8–10RCE, full breach, credential theft — fix now
High6–7.9Auth bypass, broken crypto, significant leak — this PR / sprint
Medium4–5.9Session / timing / defense weakening — next pass
Low1–3.9Best-practice drift — opportunistic

Escalate Critical/High to the operator. Do not bury them in a follow-up with no ticket ID.

STRIDE at the boundary

For each crossing: spoofing (authn), tampering (integrity), repudiation (audit log), disclosure (encrypt / no PII logs), DoS (timeouts / rate limits), elevation (authz). Score with DREAD. Do not treat STRIDE as a substitute for the security LLD/PR gate.

Compact rules

Injection / SSRF. Placeholders for values; allowlist for identifiers. Dynamic IN = generated $n plus bound args (sqlx.In + Rebind). Block file:, link-local, and metadata hosts on outbound URLs. Prefer JSON with a typed struct over gob / interface{}.

Filesystem. os.Root for user paths and zip extract. Cap decompressed size; treat limit-hit as error, not io.EOF. Temps via os.CreateTemp + 0600. Dirs 0750, secret files 0600.

HTTP. Allowlist redirect hosts; reject javascript: / data:. No public net/http/pprof. Reject XML DTD / ENTITY. Headers as the app requires (HSTS, CSP, frame, nosniff) — same bar as security-hardening.

Cookies. Session cookies: HttpOnly + Secure + SameSite. Cookie-store keys from env, not literals.

Logging. Structured fields (log/slog). Never %+v a struct that holds a password or token.

Not this skill. Nil panics, typed-nil interfaces, append aliasing → golang-safety. Table-driven tests, t.Parallel, fuzz harness → golang-testing. govulncheck / lockfile audit → tester CI + dependency review, not an install step here.

Tooling (no skill scripts)

go test -race ./...
go test -fuzz=Fuzz

gosec / govulncheck belong in tester hooks when security asks — do not go install them as this skill’s job and do not copy vendor installers.

Roles

RoleOwnsDoes not own
securityThis gate at LLD/PR for Go boundaries; skill intakeWriting product tests
builderImplementing behind Always; loading the one Go skill language-router picksSelf-excepting “just this query”
tester-race / SAST hooks when they appearSkipping security because CI is green
managerAfter-actBlessing a ship that skipped the gate

Workers do not bypass security; see Roles. A green gofmt is not a security clear.

Red flags

  • “The input is validated upstream, so concat is fine”
  • “filepath.Clean + prefix is enough”
  • “InsecureSkipVerify is only for staging”
  • “math/rand is fine for a reset token”
  • “I’ll log the whole user struct”
  • “Review will just apply the fix”
  • “Install the samber pack to get Go security”

Stop. Classify. Ask or never — do not ship.

Upstream pin

Intent: samber/cc-skills-golang skills/golang-security @ 22c58a55a0a799b901aa251172923180bad9e010 (MIT). Body is a rewrite. See SOURCES.md.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.