Ruby on Rails

Rails Security

CSRF protection, SQL injection, XSS, mass assignment, secrets management, HTTPS

22 āļ„āļģāļ–āļēāļĄāļŠāļąāļĄāļ āļēāļĐāļ“āđŒÂ·
Senior
1

What mechanism does Rails use by default to protect against CSRF attacks?

āļ„āļģāļ•āļ­āļš

Rails generates a unique CSRF token per session and automatically includes it in forms via a hidden field. This token is verified server-side for every non-GET request. The form_with helper automatically inserts this token, and protect_from_forgery is enabled by default in ApplicationController.

2

How to disable CSRF protection for a specific action in an API controller?

āļ„āļģāļ•āļ­āļš

The skip_before_action :verify_authenticity_token method disables CSRF verification for specific actions. This is common for APIs using token-based authentication (JWT, API key) rather than sessions. It's recommended to limit this exception to strictly necessary actions using the only option.

3

What vulnerability is exploited in this code: User.where("name = '#{params[:name]}'")?

āļ„āļģāļ•āļ­āļš

Direct params interpolation in a SQL query allows SQL injection. An attacker can send name="'; DROP TABLE users; --" to execute arbitrary SQL code. Use ActiveRecord placeholders instead: User.where(name: params[:name]) or User.where("name = ?", params[:name]).

4

Which ActiveRecord method automatically protects against SQL injection?

5

How does Rails automatically protect against XSS attacks in ERB views?

+19 āļ„āļģāļ–āļēāļĄāļŠāļąāļĄāļ āļēāļĐāļ“āđŒ

āļŦāļąāļ§āļ‚āđ‰āļ­āļŠāļąāļĄāļ āļēāļĐāļ“āđŒ Ruby on Rails āļ­āļ·āđˆāļ™āđ†

Ruby Basics

Junior
25 āļ„āļģāļ–āļēāļĄ

Ruby Object-Oriented Programming

Junior
20 āļ„āļģāļ–āļēāļĄ

Rails Fundamentals

Junior
18 āļ„āļģāļ–āļēāļĄ

Routing & Controllers

Junior
22 āļ„āļģāļ–āļēāļĄ

ActiveRecord Basics

Junior
25 āļ„āļģāļ–āļēāļĄ

Views & ERB Templates

Junior
20 āļ„āļģāļ–āļēāļĄ

ActiveRecord Associations

Mid-Level
24 āļ„āļģāļ–āļēāļĄ

Advanced ActiveRecord Queries

Mid-Level
28 āļ„āļģāļ–āļēāļĄ

Rails Forms

Mid-Level
20 āļ„āļģāļ–āļēāļĄ

Authentication & Authorization

Mid-Level
22 āļ„āļģāļ–āļēāļĄ

Modern Asset Pipeline & Frontend

Mid-Level
18 āļ„āļģāļ–āļēāļĄ

Rails API Mode

Mid-Level
20 āļ„āļģāļ–āļēāļĄ

Testing with RSpec

Mid-Level
24 āļ„āļģāļ–āļēāļĄ

ActiveJob & Background Jobs

Mid-Level
20 āļ„āļģāļ–āļēāļĄ

ActionCable & WebSockets

Mid-Level
18 āļ„āļģāļ–āļēāļĄ

ActionMailer

Mid-Level
18 āļ„āļģāļ–āļēāļĄ

ActiveStorage

Mid-Level
20 āļ„āļģāļ–āļēāļĄ

Caching Strategies

Mid-Level
20 āļ„āļģāļ–āļēāļĄ

Advanced Migrations

Mid-Level
20 āļ„āļģāļ–āļēāļĄ

Rails Engines & Modular Apps

Senior
18 āļ„āļģāļ–āļēāļĄ

Performance Optimization

Senior
26 āļ„āļģāļ–āļēāļĄ

Rails Design Patterns

Senior
22 āļ„āļģāļ–āļēāļĄ

Ruby Metaprogramming

Senior
20 āļ„āļģāļ–āļēāļĄ

GraphQL with Rails

Senior
20 āļ„āļģāļ–āļēāļĄ

Deployment & Production

Senior
20 āļ„āļģāļ–āļēāļĄ

Monitoring & Logging

Senior
20 āļ„āļģāļ–āļēāļĄ

Rails Upgrade Strategies

Senior
18 āļ„āļģāļ–āļēāļĄ

āđ€āļŠāļĩāđˆāļĒāļ§āļŠāļēāļ Ruby on Rails āļŠāļģāļŦāļĢāļąāļšāļāļēāļĢāļŠāļąāļĄāļ āļēāļĐāļ“āđŒāļ„āļĢāļąāđ‰āļ‡āļ–āļąāļ”āđ„āļ›

āđ€āļ‚āđ‰āļēāļ–āļķāļ‡āļ„āļģāļ–āļēāļĄāļ—āļąāđ‰āļ‡āļŦāļĄāļ” flashcards āđāļšāļšāļ—āļ”āļŠāļ­āļšāđ€āļ—āļ„āļ™āļīāļ„ āđāļšāļšāļāļķāļāļŦāļąāļ” code review āđāļĨāļ°āļ•āļąāļ§āļˆāļģāļĨāļ­āļ‡āļŠāļąāļĄāļ āļēāļĐāļ“āđŒ

āđ€āļĢāļīāđˆāļĄāđƒāļŠāđ‰āļŸāļĢāļĩ