Skip to content

davila7/claude-code-templates / .claude-plugin/skills/owasp-security

owasp-security

Unverified

Comprehensive OWASP-aligned security guidance across six standards - Top 10 (2021) for web apps, ASVS 5.0, MASVS v2.1.0 for mobile, API Security Top 10 (2023), Kubernetes Top 10 (2022), and the Agentic Applications 2026 edition for AI/LLM. Use for security reviews, vulnerability audits, secure auth/crypto/access-control implementation, Kubernetes manifest hardening, and LLM/agent prompt-injection defense - including indirect requests like "is this login flow secure?", "review this endpoint", or "audit my pod spec".

examples/api-auth-bypass.js

View on GitHub
// API Security Example: OAuth/JWT Token Vulnerability
// For detailed guidance, see: SKILL.md#section-4-owasp-api-security-top-10-2023
//
// This example demonstrates API authentication vulnerabilities including:
// - Broken JWT validation (no signature verification)
// - Missing token expiration checks
// - Overly permissive CORS
// - Function-level authorization bypass

const express = require('express');
const app = express();

// NOTE: The /vulnerable/* and /secure/* routes below live in one file only for
// side-by-side comparison. Express matches routes in registration order, so the
// paths are kept distinct to keep both sets reachable. In a real app the
// vulnerable versions would not exist. (CORS here is illustrative; app-level
// middleware applies globally, so a real deployment would pick one policy.)

// VULNERABLE: CORS allows any origin
const cors = require('cors');

// VULNERABLE: JWT parsed without verification
app.get('/vulnerable/api/orders', cors({ origin: '*' }), (req, res) => {
  const token = req.headers.authorization?.split(' ')[1];
  if (!token) return res.status(401).json({ error: 'No token' });
  
  // Decoded without verifying signature!
  const decoded = Buffer.from(token.split('.')[1], 'base64').toString();
  const user = JSON.parse(decoded);
  
  const orders = db.query('SELECT * FROM orders WHERE user_id = ?', user.id);
  res.json(orders);
});

// VULNERABLE: Admin endpoint accessible to any authenticated user (no function-level auth)
app.delete('/vulnerable/api/admin/users/:id', cors({ origin: '*' }), (req, res) => {
  const token = req.headers.authorization?.split(' ')[1];
  if (!token) return res.status(401).json({ error: 'Auth required' });
  
  // Only checks if authenticated, not if user is admin!
  db.query('DELETE FROM users WHERE id = ?', req.params.id);
  res.json({ status: 'deleted' });
});

// SECURE: Proper JWT validation, CORS restriction, function-level authorization
const jwt = require('jsonwebtoken');
const SECRET = process.env.JWT_SECRET;

// SECURE: CORS restricted to a known origin, applied per-route below
const secureCors = cors({ origin: 'https://myapp.com', credentials: true });

const verifyAuth = (req, res, next) => {
  const token = req.headers.authorization?.split(' ')[1];
  if (!token) return res.status(401).json({ error: 'No token' });
  
  try {
    const decoded = jwt.verify(token, SECRET, { algorithms: ['HS256'] });
    req.user = decoded;
    next();
  } catch (err) {
    return res.status(403).json({ error: 'Invalid token' });
  }
};

const requireAdmin = (req, res, next) => {
  if (req.user.role !== 'admin') {
    return res.status(403).json({ error: 'Admin role required' });
  }
  next();
};

app.get('/secure/api/orders', secureCors, verifyAuth, (req, res) => {
  const orders = db.query('SELECT * FROM orders WHERE user_id = ?', req.user.id);
  res.json(orders);
});

app.delete('/secure/api/admin/users/:id', secureCors, verifyAuth, requireAdmin, (req, res) => {
  db.query('DELETE FROM users WHERE id = ?', req.params.id);
  res.json({ status: 'deleted' });
});

app.listen(3000);
rea-analysis-optimizationmorluto/reaOptimize REA providers and shared analysis workflows for agent context, latency, CPU, and memory while preserving correctness and Evidence. Use for analysis bottlenecks and cache or query design; CI/test-suite optimization belongs to rea-ci-tests-audit.Stars: 469kUpdated Claude CodeCodexVerifiedInstall
rea-ci-tests-auditmorluto/reaAudit REA CI and test suites for correctness, fixture drift, false passes, and measured performance; use for suite or workflow investigations and efficiency changes, rather than ordinary feature testing or a single test failure.Stars: 469kUpdated Claude CodeCodexVerifiedInstall
rea-tool-designmorluto/reaAudit, investigate, design, or change REA investigation tools, CLI/MCP contracts, provider capabilities, and Evidence semantics.Stars: 469kUpdated Claude CodeCodexVerifiedInstall
ponytail-auditDietrichGebert/ponytailQuality audit of the whole repo: bugs, security, real load, missing tests, speed, and what to delete. Most important first.Stars: 194kUpdated Claude CodeCodexVerifiedInstall