agentleFS
slilbudgetslilbudget/knowledge-delta-skills/skills/security/secure-coding/SKILL.md

secure-coding

Skill3 starsChanged 49 days agoMITView on GitHub

Use when writing JavaScript, Node.js, HTML, CSS code for websites, landing pages, admin panels, APIs. Reduces common vulnerability classes (XSS, injection, SSRF, etc.) via secure libraries, proper headers, and safe patterns. Includes AI code vulnerability patterns.

  • Reads credentials

20 other projects use a version of this.

Adopted by

Most recently taken up by

The file

Files
SKILL.md

Secure Coding (JS / Node.js / HTML / CSS)

Apply automatically when writing any web code — hardened by default. Validate deployment topology (reverse proxy, TLS termination, CDN) before applying trust proxy, HSTS preload, or cross-origin isolation defaults. AI-generated code has 2.74x more vulnerabilities than human-written; 45% of AI samples introduce an OWASP Top 10 vuln (Veracode, 100+ LLMs).

Workflow

New code: secure defaults first (helmet, cors explicit origins, rate-limit, body size limit) → per endpoint: auth middleware → zod validation → parameterized queries → generic errors → scan against "Never Do" table.

Dependencies (prefer context7 MCP; else npm registry / GitHub / GHSA): latest stable version, no open critical/high CVEs, maintainer disqualify only on: deprecated, archived, unanswered CVE > 90 days, ownership transferred to unknown party (mature libs like argon2/helmet/jose sit quiet for months and stay canonical). Apps: package-lock.json + npm ci; libs: semver ranges + audit in CI. Prefer Safe Library Stack below.

Auditing existing code: entry point → routes → middleware chain → static serving → npm audit + pinned versions + known compromised packages → configs (NODE_ENV, exposed .env/.git/source maps, debug endpoints) → per route: auth → validation → data handling → errors → headers/CSP/CORS/cookies/ports → report.

Audit output format:

### [CRITICAL/HIGH/MEDIUM/LOW] Finding title
- **Location**: file:line
- **Vulnerability**: CWE-XXX (name)
- **Impact**: what an attacker can do
- **Fix**: specific code change

OWASP Top 10:2025 Quick Map

#RiskExploitDefense
A01Broken Access ControlIDOR: /api/user/123 → /124Auth check on EVERY endpoint, 404 not 403
A02Security MisconfigurationDefault creds, debug, verbose errors, exposed filesHelmet, CSP, no defaults, generic errors, block dotfiles
A03Supply ChainCompromised npm packages (Shai-Hulud: 500+)Pin versions, npm ci --ignore-scripts, audit
A04Cryptographic FailuresWeak hashing, plaintext, broken TLSArgon2id, AES-256-GCM, TLS 1.2+ only
A05InjectionSQLi, XSS, SSTI, prototype pollution, prompt injectionParameterized queries, DOMPurify, no eval()
A06Insecure DesignNo rate limit on login, no anti-automationRate limit, CAPTCHA, lockout
A07Auth FailuresJWT alg:none, weak secrets, no rotationjose + RS256, strong secrets, regenerate on login
A08Integrity FailuresTampered CDN scripts, unsigned updatesSRI hashes, verify signatures
A09Logging FailuresNo auth logging, secrets in logsLog auth events, NEVER log tokens/passwords
A10Exception MishandlingStack traces + DB errors to clientGeneric 500, detail to server logs only

Never Do (hacker's wishlist)

Bad CodeAttackImpact
eval(userInput)Code injectionRCE
innerHTML = userInputXSSSession theft, keylogging
db.query(\...${id}`)`SQL injectionFull DB dump
res.send(error.stack)Info leakDB creds, paths, versions
jwt.verify(token, key) without algorithmsalg:none bypassAuth bypass, admin
require(userInput)Path traversalRCE, file read
fetch(userUrl) without validationSSRFInternal scan, cloud metadata
JSON.parse + unchecked deep mergePrototype pollutionRCE via gadget chain
password = md5(input)Hashcat 100B/sec GPUAccount takeover
cors({ origin: '*' })Cross-origin accessData theft from any domain
cookie: { sameSite: 'none' } without reasonCSRFUnauthorized actions
npm install in CISupply chainMalicious postinstall
/^(.+)+$/.test(userInput)ReDoSEvent loop freeze
WebSocket without origin checkCSWSHSession hijack via any site
SELECT then UPDATE without lockRace conditionDouble-spend

Safe Library Stack (2025-2026)

PurposeUseAvoidWhy
Password hashargon2 / @node-rs/argon2md5, sha256GPU-resistant, OWASP standard
JWTjose (v6+)jsonwebtokenMaintained, universal runtime, no alg:none
HTML sanitizeDOMPurify (v3+)regex sanitizers55% of sanitizers vulnerable to DOM clobbering
HTTP securityhelmet (v8+)manual headers11 headers correct by default
Rate limitexpress-rate-limit + RedisnothingBrute-force takes minutes without it
Validationzod / joimanual ifType-safe, strips unknown fields
ORMdrizzle-orm / prismastring concatParameterized by design
Sessionexpress-session + Rediscookie-onlyServer-side, revocable
TemplateHandlebars / Nunjucks (autoescape:true)EJS <%-Auto-escape prevents XSS
Regexre2nested quantifiersLinear time, no backtracking

Critical CVEs (2025-2026)

CVETargetCVSSImpact
CVE-2025-55182React Server Components / Next.js10.0Pre-auth RCE, single HTTP request
CVE-2025-59465Node.js HTTP/27.5Crash via malformed HEADERS
CVE-2026-33660n8n9.4RCE via workflow nodes
CVE-2025-53773GitHub Copilot9.6RCE via prompt injection
CVE-2026-3125OpenNext CloudflareHighSSRF via path normalization bypass
CVE-2025-59145GitHub Copilot (CamoLeak)9.6Secret exfiltration
Shai-Huludnpm ecosystemCriticalSelf-propagating worm, 500+ packages
Axios compromiseaxios 1.14.1 / 0.30.4CriticalRAT in 3-hour window (DPRK)

Reference Files

ConcernFile
Express baseline, rate limit, Zod, error handler, prod misconfigsexpress.md
Argon2id, JWT (jose), sessions, RBAC, timing-safe, JWT attacksauth.md
Parameterized SQL, TOCTOU, row locks, distributed locksdb.md
Uploads (multer, MIME, magic bytes), path traversaluploads.md
SSRF (DNS resolve, private-IP block, redirects), prototype pollutionssrf.md
ReDoS, WebSocket hardening, CSWSHdos.md
GraphQL: introspection, depth/complexity, batching, field authgraphql.md
LLM apps: injection filter, delimited prompts, output validation, tool least-privilegellm.md
XSS, DOM clobbering, template injection, postMessage, iframe sandboxfrontend-security.md
Security headers, CSP nonces, cookie flags, CORSheaders-and-csp.md
Dependencies, lockfiles, SRI, supply-chain attacks, emergency responsesupply-chain.md
Reviewing AI-generated code, CWE stats, OpenSSF guidanceai-code-mistakes.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.