rails-ai:security

Enforce Rails security against XSS, CSRF, SQL injection, and unsafe file uploads.

41|Updated Oct 30, 2025
One-click install
npx skills add https://github.com/zerobearing2/rails-ai --skill rails-ai-security
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: rails-ai:security
Source: https://github.com/zerobearing2/rails-ai/tree/main/skills/security
Command: npx skills add https://github.com/zerobearing2/rails-ai --skill rails-ai-security

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps developers secure Rails applications by providing patterns, examples, and checks to prevent common vulnerabilities such as XSS, CSRF, SQL injection, and insecure file uploads.

Core Features & Use Cases

  • XSS Prevention: Rails auto-escaping in templates, sanitization, and CSP guidance to block script injections.
  • CSRF Protection: Rails' built-in CSRF protection, form_with helpers, and safe AJAX patterns.
  • SQL Injection Prevention: Use parameterized queries, hash conditions, and placeholders to prevent data leaks.
  • Secure File Uploads: Use ActiveStorage with content-type validation, size limits, and safe serving to prevent malicious uploads.
  • Use Case: Secure a user-facing Rails app with user-generated content and file uploads, ensuring end-to-end security.

Quick Start

  • Enable CSRF protection in ApplicationController and ensure all forms use form_with.
  • Validate uploads with ActiveStorage validations (content_type and size) and serve files safely.
  • Use ActiveRecord query methods and hash conditions to avoid SQL injection.
  • Add security tests for XSS, CSRF, and injection vectors.

Frequently Asked Questions about rails-ai:security

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I prevent SQL injection in Rails ActiveRecord queries?

Prevent SQL injection in Rails by using parameterized queries, hash conditions, and placeholder variables instead of raw SQL string interpolation. ActiveRecord query methods automatically sanitize inputs to block malicious data leaks from user-supplied parameters.

What's the best way to secure file uploads with ActiveStorage in Rails?

Secure ActiveStorage file uploads by enforcing content-type validation and file size limits. Serve uploaded files safely to prevent malicious payloads, ensuring user-generated content poses no threat to your Rails application storage layers.

How does Rails protect against XSS and CSRF vulnerabilities?

Rails protects against XSS through auto-escaping in templates, content sanitization, and Content Security Policy guidance. CSRF protection is enforced via built-in tokens and form_with helpers to secure authentication flows and API endpoints.

Can I use Rails built-in CSRF protection for AJAX and API endpoints?

Yes, Rails built-in CSRF protection secures AJAX patterns and API endpoints. Enable CSRF protection in ApplicationController, ensure all forms use form_with helpers, and implement safe AJAX requests to maintain defense-in-depth security.

What security tests should I add for a Rails app with user-generated content?

Add security tests covering XSS, CSRF, and SQL injection vectors for Rails apps with user-generated content. Include verifications for unsafe file handling and explicit security headers across controllers, views, and ActiveStorage layers.