smithery.ai

backend-security-best-practices

SQL injection prevention, XSS, CSRF, validation.

First seen Mar 21, 2026

Installation

$ npx skills add https://smithery.ai

Similar popular skills

Related neighbors and high-traction skills in the same topics — useful to compare before installing.

Also in this package

Other skills from smithery.ai · top by installs.

npx skills add https://smithery.ai

Browse all from smithery.ai

More details

Agent compatibility

Declared targets from SKILL.md / docs. Unmarked agents are not listed — the skill may still install via the CLI.

Claude Code Not declared
Cursor Not declared
Codex Not declared
GitHub Copilot Not declared
Windsurf Not declared
Gemini CLI Not declared
Cline Not declared
OpenCode Not declared

Package contents

Files included with this skill beyond the listing page.

  • skill md SKILL.md 1,314 B
  • docs SUMMARY.md 87 B

History

  1. First seen on skills.sh
  2. First recorded snapshot · 1 installs

SKILL.md

Backend Security Best Practices

When to use this skill

  • All application development
  • Security reviews
  • Penetration testing prep
  • Compliance requirements

Workflow

  • Validate all input
  • Use prepared statements
  • Escape output
  • Enable CSRF protection
  • Use HTTPS

Instructions

SQL Injection Prevention

<?php

// ❌ Bad
$sql = "SELECT * FROM users WHERE email = '{$email}'";

// ✅ Good: Query builder
$this->db->table('users')->where('email', $email)->get();

// ✅ Good: Prepared statement
$this->db->query("SELECT * FROM users WHERE email = ?", [$email]);

XSS Prevention

<?php

// In views
<?= esc($user->name) ?> // HTML escape
<?= esc($user->bio, 'js') ?> // JavaScript escape

CSRF Protection

<?php

// Config/Security.php
public $csrfProtection = 'session';

// In forms
<?= csrf_field() ?>

// In AJAX
headers: {
    'X-CSRF-TOKEN': '<?= csrf_hash() ?>'
}

Environment Variables

<?php

// ❌ Bad
$apiKey = 'hardcoded-key';

// ✅ Good
$apiKey = env('API_KEY');

Resources

  • Validate and sanitize all input
  • Never trust user data
  • Use framework security features
  • Keep dependencies updated