All skills
getsentry avatar

/security-review

@3482d8d official
by Sentrygetsentry/skills1k stars
53

Security code review for vulnerabilities. Use when asked to "security review", "find vulnerabilities", "check for security issues", "audit security", "OWASP review", or review code for injection, XSS, authentication, authorization, cryptography issues. Provides systematic review with confidence-based reporting.

Use this Skill: https://skilld.dev/gh/getsentry/skills/security-review

This session only. Nothing lands on disk.

referencescryptography.md

≈2.2k tokens on demand. Your agent reads this file only when SKILL.md points to it.

Cryptographic Security Reference

Core Principles

  1. Avoid storing sensitive data when possible - the best protection is not having the data
  2. Use established libraries - never implement cryptographic algorithms yourself
  3. Use modern algorithms - avoid deprecated algorithms even if they seem convenient
  4. Manage keys securely - key management is often harder than encryption itself

Encryption Algorithms

Symmetric Encryption

Recommended:

  • AES-256-GCM (preferred) - Provides encryption + authentication
  • AES-128-GCM - Acceptable minimum
  • ChaCha20-Poly1305 - Good alternative, especially on systems without AES hardware

Avoid:

  • DES, 3DES - Deprecated, insufficient key length
  • RC4 - Broken
  • AES-ECB - Reveals patterns in data
  • AES-CBC without authentication - Vulnerable to padding oracle attacks

Cipher Modes

Mode Use Case Notes
GCM General purpose Authenticated encryption (preferred)
CCM Constrained environments Authenticated encryption
CTR + HMAC When GCM unavailable Encrypt-then-MAC pattern
CBC Legacy only Requires separate MAC
ECB Never for data Reveals patterns
# VULNERABLE: ECB mode
from Crypto.Cipher import AES
cipher = AES.new(key, AES.MODE_ECB)

# SAFE: GCM mode
cipher = AES.new(key, AES.MODE_GCM, nonce=nonce)
ciphertext, tag = cipher.encrypt_and_digest(plaintext)

Asymmetric Encryption

Recommended:

  • ECC with Curve25519 (preferred for key exchange)
  • RSA-2048 minimum (RSA-4096 for long-term)
  • ECDSA with P-256 or Ed25519 for signatures

Avoid:

  • RSA < 2048 bits
  • DSA
  • ECDSA with weak curves

Secure Random Number Generation

Cryptographically Secure PRNGs (CSPRNG)

Language Safe Unsafe
Python secrets, os.urandom() random module
JavaScript crypto.randomBytes(), crypto.randomUUID() Math.random()
Java SecureRandom, UUID.randomUUID() Math.random(), java.util.Random
PHP random_bytes(), random_int() rand(), mt_rand(), uniqid()
.NET RandomNumberGenerator Random()
Go crypto/rand math/rand
Ruby SecureRandom rand()
# VULNERABLE: Predictable random
import random
token = ''.join(random.choices(string.ascii_letters, k=32))

# SAFE: Cryptographically secure
import secrets
token = secrets.token_urlsafe(32)

UUID Considerations

  • UUID v1: NOT random - contains timestamp and MAC address
  • UUID v4: Depends on implementation - verify CSPRNG usage
  • ULID: Time-sortable but predictable time component
# Check if UUID v4 is actually random
import uuid
# uuid.uuid4() uses os.urandom() in Python - SAFE
token = str(uuid.uuid4())

Key Management

Key Generation

# VULNERABLE: Key from password directly
key = password.encode()

# SAFE: Key derivation function
from cryptography.hazmat.primitives.kdf.pbkdf2 import PBKDF2HMAC
kdf = PBKDF2HMAC(
    algorithm=hashes.SHA256(),
    length=32,
    salt=salt,
    iterations=600000,
)
key = kdf.derive(password.encode())

Key Storage

Do:

  • Use Hardware Security Modules (HSM)
  • Use cloud key management (AWS KMS, Azure Key Vault, GCP KMS)
  • Use dedicated secrets managers (HashiCorp Vault)
  • Store keys separately from encrypted data

Don't:

  • Hardcode keys in source code
  • Commit keys to version control
  • Store keys in environment variables (can leak)
  • Store keys in plaintext files
# VULNERABLE: Hardcoded key
KEY = b'super_secret_key_12345'

# VULNERABLE: Key in code as base64
KEY = base64.b64decode('c3VwZXJfc2VjcmV0X2tleQ==')

# SAFE: Load from secure source
KEY = secrets_manager.get_secret('encryption_key')

Key Rotation

When to rotate:

  • Key compromise (immediate)
  • Cryptoperiod expiration (time-based)
  • After encrypting 2^35 bytes (for 64-bit block ciphers)
  • Algorithm deprecation

Rotation strategies:

  1. Re-encryption (preferred): Decrypt with old key, re-encrypt with new
  2. Versioning: Tag encrypted items with key version, maintain multiple keys

Envelope Encryption

# Two-key structure:
# - Data Encryption Key (DEK): Encrypts actual data
# - Key Encryption Key (KEK): Encrypts the DEK

def encrypt_with_envelope(plaintext, kek):
    # Generate random DEK
    dek = secrets.token_bytes(32)

    # Encrypt data with DEK
    cipher = AES.new(dek, AES.MODE_GCM)
    ciphertext, tag = cipher.encrypt_and_digest(plaintext)

    # Encrypt DEK with KEK
    kek_cipher = AES.new(kek, AES.MODE_GCM)
    encrypted_dek, dek_tag = kek_cipher.encrypt_and_digest(dek)

    # Store encrypted_dek with ciphertext
    return {
        'ciphertext': ciphertext,
        'tag': tag,
        'encrypted_dek': encrypted_dek,
        'dek_tag': dek_tag,
        'nonce': cipher.nonce,
        'dek_nonce': kek_cipher.nonce
    }

Hashing

Password Hashing

See authentication.md for password-specific hashing.

General Purpose Hashing

Use Case Algorithm
Integrity verification SHA-256 or SHA-3
HMAC HMAC-SHA-256
Key derivation HKDF, PBKDF2
Content addressing SHA-256

Avoid for new systems:

  • MD5 (broken)
  • SHA-1 (deprecated)
# For integrity/checksums
import hashlib
digest = hashlib.sha256(data).hexdigest()

# For authentication (HMAC)
import hmac
mac = hmac.new(key, data, hashlib.sha256).digest()

Common Vulnerabilities

Weak Algorithm Usage

# VULNERABLE: MD5 for security purposes
import hashlib
checksum = hashlib.md5(data).hexdigest()

# VULNERABLE: SHA1 for signatures
signature = hashlib.sha1(data + secret).hexdigest()

# SAFE: SHA-256
checksum = hashlib.sha256(data).hexdigest()

Insufficient Key Size

# VULNERABLE: Short key
key = b'short_key'  # 9 bytes

# SAFE: Adequate key length
key = secrets.token_bytes(32)  # 256 bits

Predictable IV/Nonce

# VULNERABLE: Reused or predictable nonce
nonce = b'\x00' * 12  # Static nonce

# VULNERABLE: Counter-based without persistence
nonce = counter.to_bytes(12, 'big')

# SAFE: Random nonce
nonce = secrets.token_bytes(12)

ECB Mode Patterns

# VULNERABLE: ECB reveals patterns
cipher = AES.new(key, AES.MODE_ECB)

# SAFE: GCM hides patterns
cipher = AES.new(key, AES.MODE_GCM, nonce=nonce)

Missing Authentication

# VULNERABLE: Encryption without authentication
cipher = AES.new(key, AES.MODE_CBC, iv=iv)
ciphertext = cipher.encrypt(pad(plaintext, 16))
# Vulnerable to bit-flipping, padding oracle

# SAFE: Authenticated encryption
cipher = AES.new(key, AES.MODE_GCM, nonce=nonce)
ciphertext, tag = cipher.encrypt_and_digest(plaintext)

Grep Patterns for Detection

# Weak algorithms
grep -rn "MD5\|md5\|SHA1\|sha1\|DES\|des\|RC4\|rc4" --include="*.py" --include="*.js"
grep -rn "MODE_ECB\|ecb" --include="*.py" --include="*.js"

# Insecure random
grep -rn "Math\.random\|random\.random\|random\.randint" --include="*.py" --include="*.js"
grep -rn "mt_rand\|rand()" --include="*.php"

# Hardcoded keys
grep -rn "key\s*=\s*['\"]" --include="*.py" --include="*.js"
grep -rn "secret\s*=\s*['\"]" --include="*.py" --include="*.js"
grep -rn "AES\.new.*b'" --include="*.py"

# Static IVs/nonces
grep -rn "iv\s*=\s*b'\|nonce\s*=\s*b'" --include="*.py"
grep -rn "\\x00.*\\x00.*\\x00" --include="*.py"

# CBC without HMAC
grep -rn "MODE_CBC" --include="*.py" | grep -v "hmac\|mac\|tag"

Testing Checklist

  • No hardcoded keys/secrets in source code
  • Keys not committed to version control
  • Using modern algorithms (AES-GCM, RSA-2048+, SHA-256+)
  • CSPRNG used for all security-sensitive randomness
  • Keys stored securely (HSM, KMS, secrets manager)
  • Key rotation mechanism exists
  • No ECB mode usage
  • Authenticated encryption used (GCM, or encrypt-then-MAC)
  • Adequate key lengths (256-bit symmetric, 2048+ RSA)
  • IVs/nonces are random and never reused with same key

References

Source: SKILL.md on GitHub

3 alerts2d5 checks · Risk CRITICAL
  • Gen Agent Trust Hub2d

    The skill is a comprehensive security auditing tool designed to help AI agents identify vulnerabilities in codebases. It contains extensive documentation and examples of common security flaws (such as SQL injection, XSS, and supply chain attacks) to guide the analysis process. Automated scanner alerts regarding malware and code injection are false positives triggered by the inclusion of these educational examples within the documentation.

  • Socket2d

    1 alert: gptMalware

  • Snyk2d

    Risk: LOW · No issues

  • Runlayer7mo

    20/22 files flagged

  • ZeroLeaks5mo

    2 findings · Score: 80/100

Signed by skilld at 3482d8d. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub yesterday.

Activeupdated 3 days ago
All 1 allowed tools
Read Grep Glob Bash Task
  • Security
  • code-review
  • vulnerabilities
  • owasp
  • injection
  • xss
  • authentication
  • authorization

README badge

README badge for getsentry/skills/security-review

Performs systematic security code review to identify exploitable vulnerabilities in injection, XSS, authentication, authorization, and cryptography. Reports only high-confidence findings after researching the codebase to confirm attacker-controlled input and framework mitigations, following OWASP guidelines.

Generated from the current SKILL.md.

Does this skill flag theoretical vulnerabilities or only confirmed exploitable issues?
Only HIGH CONFIDENCE findings—clear vulnerable patterns with attacker-controlled input confirmed through codebase research. Theoretical, best-practice, or defense-in-depth issues are not reported.
Will this skill review test files and commented code?
No. Test files, dead code, and commented code are excluded from review unless explicitly requested. Documentation strings are also skipped.
Does this skill flag hardcoded URLs or configuration values as SSRF vulnerabilities?
No. Server-controlled values like Django settings, environment variables, and hardcoded configuration are considered safe. Only user-input URLs are flagged as SSRF.
What languages and frameworks does this skill cover?
Python (Django, Flask, FastAPI), JavaScript/TypeScript (Node, Express, React, Vue, Next.js), Go, Rust, and Java (Spring). It loads language-specific guides to check for framework-mitigated patterns before flagging.
Does this skill check for hardcoded secrets and credentials?
Yes. Hardcoded passwords, API keys, AWS secrets, and private keys are always flagged as Critical severity.

Generated from the current SKILL.md. These answers refresh after source changes.