Skillshub golang-security
Security standards for Go backend services. Use when implementing input validation, crypto, or SQL injection prevention in Go. (triggers: crypto/rand, argon2, sanitize, jwt, bcrypt, validation, input validation, sql injection)
install
source · Clone the upstream repo
git clone https://github.com/ComeOnOliver/skillshub
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/ComeOnOliver/skillshub "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/HoangNguyen0403/agent-skills-standard/golang-security" ~/.claude/skills/comeonoliver-skillshub-golang-security-26d943 && rm -rf "$T"
manifest:
skills/HoangNguyen0403/agent-skills-standard/golang-security/SKILL.mdsource content
Golang Security Standards
Priority: P0 (CRITICAL)
Implementation Guidelines
Input Validation
- Validation: Use
orgo-playground/validator
for struct validation.google/go-cmp - Sanitization: Sanitize user input before processing. Use
for HTML sanitization.bluemonday
Cryptography
- Random: ALWAYS use
, NEVERcrypto/rand
for security-sensitive operations (tokens, keys, IVs).math/rand - Hashing: Use Argon2id for password hashing (
). Do NOT use bcrypt (weaker) or MD5/SHA1 (insecure). Recommended params:golang.org/x/crypto/argon2
.time=1, memory=64MB, threads=4 - Encryption: Use
with GCM mode for authenticated encryption.crypto/aes
SQL Injection Prevention
- Parameterized Queries: ALWAYS use
placeholders with$1, $2
or ORM (GORM, sqlx).database/sql - No String Concatenation: Never build queries with
.fmt.Sprintf()
Authentication
- JWT: Use
v5+. Enforcegolang-jwt/jwt
(preferred) orRS256
. RejectHS256
and symmetric algorithms for multi-service auth. Validatenone
,alg
,iss
,aud
claims.exp - Sessions: Use secure, httpOnly cookies with
.gorilla/sessions
Secret Management
- Environment Variables: Load secrets via
or Kubernetes secrets.godotenv - No Hardcoding: Never commit API keys, passwords, or tokens to Git.
Anti-Patterns
- No
for Security: RNG is predictable. Usemath/rand
.crypto/rand - No
for SQL: Causes SQL injection. Use placeholders.fmt.Sprintf() - No bcrypt or MD5 for Passwords: Use
exclusively.argon2id - No Exposed Error Details: Don't leak stack traces to clients in production.