Skip to content

Bruno-Cunha-Souza/ValarMindSkills / skills/code-security-review

code-security-review

Flagged

Web/API security lifecycle for Go, Next.js, Python, and Bun — design controls, active testing, supply-chain/CI-CD, and LLM/agentic/MCP coverage. Maps to OWASP Web Top 10 2025 + API 2023 + LLM 2025 + Agentic 2026. Triggers: 'security review', 'revisão de segurança', 'auditar segurança', 'pentest', '/code-security-review'.

FileKindSize
SKILL.mdskill md17.3 KB
references/AI_SECURITY.mdmarkdown9.5 KB
references/DESIGN_CONTROLS.mdmarkdown18.0 KB
references/REPORT_TEMPLATE.mdmarkdown2.6 KB
references/SUPPLY_CHAIN_CICD.mdmarkdown9.1 KB
references/TESTING_PHASES.mdmarkdown17.5 KB
references/WEB_VULNERABILITIES.mdmarkdown22.1 KB
references/golang/API.mdmarkdown27.6 KB
references/golang/MIDDLEWARE.mdmarkdown14.4 KB
references/golang/PATCHES.mdmarkdown15.0 KB
references/golang/TESTING_PAYLOADS.mdmarkdown10.9 KB
references/golang/VULNERABILITIES.mdmarkdown20.6 KB
references/nextjs/API.mdmarkdown38.5 KB
references/nextjs/CONFIGURATION.mdmarkdown15.7 KB
references/nextjs/PATCHES.mdmarkdown16.7 KB
references/nextjs/TESTING_PAYLOADS.mdmarkdown11.9 KB
references/nextjs/VULNERABILITIES.mdmarkdown35.7 KB
references/python/API.mdmarkdown36.0 KB
references/python/CONFIGURATION.mdmarkdown22.4 KB
references/python/PATCHES.mdmarkdown12.1 KB
references/python/TESTING_PAYLOADS.mdmarkdown12.8 KB
references/python/VULNERABILITIES.mdmarkdown28.1 KB
scripts/00-pre-checks.shexecutablescript3.7 KB
scripts/01-auth-probes.shexecutablescript5.4 KB
scripts/02-jwt-attacks.pyexecutablescript10.1 KB
scripts/03-bola-probes.shexecutablescript6.4 KB
scripts/04-injection-probes.shexecutablescript7.3 KB
scripts/05-burst.k6.jsscript1.9 KB
scripts/05-rate-limit.shexecutablescript5.0 KB
scripts/06-info-disclosure.shexecutablescript5.2 KB
scripts/07-supply-chain.shexecutablescript7.9 KB
scripts/08-cors-headers.shexecutablescript5.5 KB
scripts/09-cicd-workflows.shexecutablescript6.1 KB
scripts/10-secrets-scan.shexecutablescript5.2 KB
scripts/11-ai-llm-probes.shexecutablescript8.8 KB
scripts/README.mdmarkdown8.0 KB
scripts/lib/common.shscript4.8 KB
scripts/lib/report.pyscript5.4 KB
scripts/run-all.shexecutablescript4.8 KB

scripts/03-bola-probes.sh

View on GitHub
#!/usr/bin/env bash
# Phase 2 — BOLA / IDOR / mass assignment / BFLA probes.
# Reads:
#   TARGET, TOKEN_USER_A, TOKEN_USER_B, USER_A_RESOURCE_ID
#   RESOURCE_PATH (default /api/orders/{id})
#   ENUM_PATH     (default /api/users/{id})    — endpoint to probe with sequential IDs
#   ENUM_RANGE    (default 1-10)               — IDs to enumerate
#   ADMIN_PATH    (default /api/admin/users)   — admin endpoint to probe with regular user
#   PROFILE_PATH  (default /api/users/profile) — endpoint for mass-assignment test
# Writes: out/findings.jsonl

set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# shellcheck source=lib/common.sh
source "$SCRIPT_DIR/lib/common.sh"

require_env TARGET TOKEN_USER_A TOKEN_USER_B

RESOURCE_PATH="${RESOURCE_PATH:-/api/orders/{id}}"
ENUM_PATH="${ENUM_PATH:-/api/users/{id}}"
ENUM_RANGE="${ENUM_RANGE:-1-10}"
ADMIN_PATH="${ADMIN_PATH:-/api/admin/users}"
PROFILE_PATH="${PROFILE_PATH:-/api/users/profile}"

# ---------------------------------------------------------------------------
# Check 1 — Cross-user access (already checked in 01-auth, repeated here for completeness
#           with explicit USER_A_RESOURCE_ID requirement)
# ---------------------------------------------------------------------------
if [ -n "${USER_A_RESOURCE_ID:-}" ]; then
  resource_path="${RESOURCE_PATH//\{id\}/$USER_A_RESOURCE_ID}"
  log_info "Cross-user access on $resource_path with user_b token..."
  result=$(http_request GET "$resource_path" \
    -H "Authorization: Bearer $TOKEN_USER_B" \
    --max-time 10 || true)
  status="${result%% *}"
  if [ "$status" = "200" ]; then
    body_excerpt=$(head -c 200 "$RESP_BODY" 2>/dev/null | tr -d '\000-\031')
    evidence=$(build_evidence \
      "status=$status" \
      "path=$resource_path" \
      "body_excerpt=$body_excerpt")
    emit_finding \
      "BOLA-001" "critical" "API1:2023 BOLA" \
      "GET $resource_path" \
      "User B reads user A's resource — handler does not verify resource ownership before returning." \
      "Add: if resource.owner_id != current_user.id: return 404. Apply consistently across all owner-bound endpoints." \
      "$evidence"
  fi
fi

# ---------------------------------------------------------------------------
# Check 2 — Sequential ID enumeration with user_b's token
# ---------------------------------------------------------------------------
log_info "Enumerating $ENUM_PATH IDs $ENUM_RANGE with user_b token..."
range_start="${ENUM_RANGE%%-*}"
range_end="${ENUM_RANGE##*-}"
hits=0
hit_ids=""
for id in $(seq "$range_start" "$range_end"); do
  enum_path="${ENUM_PATH//\{id\}/$id}"
  result=$(http_request GET "$enum_path" \
    -H "Authorization: Bearer $TOKEN_USER_B" \
    --max-time 5 || true)
  status="${result%% *}"
  if [ "$status" = "200" ]; then
    hits=$((hits + 1))
    hit_ids="$hit_ids $id"
  fi
done

# Heuristic: if more than 1 ID returned 200 with user_b's token, it's likely the user
# can read other users' resources. (If only the user's own ID matches, hits == 1.)
if [ "$hits" -gt 1 ]; then
  evidence=$(build_evidence \
    "endpoint=$ENUM_PATH" \
    "ids_with_200=$hit_ids" \
    "total_hits=$hits" \
    "range=$ENUM_RANGE")
  emit_finding \
    "BOLA-002" "high" "API1:2023 BOLA" \
    "GET $ENUM_PATH (sequential enumeration)" \
    "User B can read $hits resources at sequential IDs ($hit_ids) — endpoint is enumerable and lacks per-ID authorization." \
    "Validate ownership/visibility on every fetch. Use UUIDs instead of sequential IDs to make enumeration impractical (defence in depth, not a fix)." \
    "$evidence"
fi

# ---------------------------------------------------------------------------
# Check 3 — Admin endpoint accessible with regular user token (BFLA)
# ---------------------------------------------------------------------------
log_info "Probing $ADMIN_PATH with regular user token (BFLA test)..."
result=$(http_request GET "$ADMIN_PATH" \
  -H "Authorization: Bearer $TOKEN_USER_A" \
  --max-time 10 || true)
status="${result%% *}"
if [ "$status" = "200" ]; then
  body_excerpt=$(head -c 200 "$RESP_BODY" 2>/dev/null | tr -d '\000-\031')
  evidence=$(build_evidence \
    "status=$status" \
    "path=$ADMIN_PATH" \
    "body_excerpt=$body_excerpt")
  emit_finding \
    "BFLA-001" "critical" "API5:2023 BFLA" \
    "GET $ADMIN_PATH" \
    "Regular user can call admin endpoint — function-level authorization is missing." \
    "Apply role-based authorization middleware that rejects non-admin tokens at the route group level. Do not rely on UI to hide admin features." \
    "$evidence"
fi

# ---------------------------------------------------------------------------
# Check 4 — Mass assignment (try to inject role/admin/credits/is_verified)
# ---------------------------------------------------------------------------
log_info "Mass-assignment probe on $PROFILE_PATH..."
payload='{"name":"sec-probe","role":"admin","roles":["admin"],"is_admin":true,"is_verified":true,"credits":99999,"balance":99999}'
result=$(http_request PATCH "$PROFILE_PATH" \
  -H "Authorization: Bearer $TOKEN_USER_A" \
  -H "Content-Type: application/json" \
  --data "$payload" \
  --max-time 10 || true)
status="${result%% *}"

# Method may not be supported — try POST as fallback
if [ "$status" = "405" ] || [ "$status" = "404" ]; then
  result=$(http_request POST "$PROFILE_PATH" \
    -H "Authorization: Bearer $TOKEN_USER_A" \
    -H "Content-Type: application/json" \
    --data "$payload" \
    --max-time 10 || true)
  status="${result%% *}"
fi

if [ "$status" = "200" ] || [ "$status" = "201" ]; then
  body=$(head -c 1000 "$RESP_BODY" 2>/dev/null || true)
  if echo "$body" | grep -qiE '"role"\s*:\s*"admin"|"is_admin"\s*:\s*true|"credits"\s*:\s*99999|"balance"\s*:\s*99999'; then
    body_excerpt=$(printf '%s' "$body" | head -c 300 | tr -d '\000-\031')
    evidence=$(build_evidence \
      "status=$status" \
      "path=$PROFILE_PATH" \
      "payload=$payload" \
      "body_excerpt=$body_excerpt")
    emit_finding \
      "BOPLA-001" "critical" "API3:2023 Broken Object Property Level Authorization" \
      "POST/PATCH $PROFILE_PATH" \
      "Server accepted unexpected fields (role/is_admin/credits) in profile update — mass-assignment vulnerability." \
      "Define explicit DTOs/schemas that allow only the fields the user may update. Use Pydantic with model_config strict=True / TypeBox additionalProperties:false / explicit validator structs." \
      "$evidence"
  fi
fi

log_ok "BOLA / BFLA / mass-assignment probes complete."
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: 472kUpdated 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: 472kUpdated Claude CodeCodexVerifiedInstall
rea-tool-designmorluto/reaAudit, investigate, design, or change REA investigation tools, CLI/MCP contracts, provider capabilities, and Evidence semantics.Stars: 472kUpdated 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