# Rails-beveiliging (Ruby on Rails) > CSRF-bescherming, SQL-injectie, XSS, mass assignment, secrets-beheer, HTTPS - 22 gespreksvragen - Senior - [Gespreksvragen: Ruby on Rails](https://sharpskill.dev/nl/technologies/ruby-on-rails/sollicitatievragen.md) ## 1. Welk mechanisme gebruikt Rails standaard om te beschermen tegen CSRF-aanvallen? **Antwoord** Rails genereert per sessie een uniek CSRF-token en voegt dit automatisch toe aan formulieren via een hidden veld. Dit token wordt serverzijdig geverifieerd voor elk niet-GET-verzoek. De form_with-helper voegt dit token automatisch in, en protect_from_forgery staat standaard aan in ApplicationController. ## 2. Hoe schakel je CSRF-bescherming uit voor een specifieke action in een API-controller? **Antwoord** De methode skip_before_action :verify_authenticity_token schakelt CSRF-verificatie uit voor specifieke actions. Dit komt veel voor bij API's die token-gebaseerde authenticatie (JWT, API key) gebruiken in plaats van sessies. Het wordt aanbevolen om deze uitzondering met de optie only te beperken tot strikt noodzakelijke actions. ## 3. Welke kwetsbaarheid wordt in deze code misbruikt: User.where("name = '#{params[:name]}'")? **Antwoord** Directe interpolatie van params in een SQL-query maakt SQL-injectie mogelijk. Een aanvaller kan name="'; DROP TABLE users; --" sturen om willekeurige SQL-code uit te voeren. Gebruik in plaats daarvan ActiveRecord-placeholders: User.where(name: params[:name]) of User.where("name = ?", params[:name]). ## Nog 19 vragen beschikbaar - Welke ActiveRecord-methode beschermt automatisch tegen SQL-injectie? - Hoe beschermt Rails automatisch tegen XSS-aanvallen in ERB-views? Meld je gratis aan: https://sharpskill.dev/nl/login ## Andere Ruby on Rails-sollicitatieonderwerpen - [Ruby-basis](https://sharpskill.dev/nl/technologies/ruby-on-rails/sollicitatievragen/ruby-basics.md): 25 vragen, Junior - [Objectgeoriënteerd programmeren in Ruby](https://sharpskill.dev/nl/technologies/ruby-on-rails/sollicitatievragen/ruby-oop.md): 20 vragen, Junior - [Rails-grondbeginselen](https://sharpskill.dev/nl/technologies/ruby-on-rails/sollicitatievragen/rails-fundamentals.md): 18 vragen, Junior - [Routing & Controllers](https://sharpskill.dev/nl/technologies/ruby-on-rails/sollicitatievragen/routing-controllers.md): 22 vragen, Junior - [ActiveRecord-basis](https://sharpskill.dev/nl/technologies/ruby-on-rails/sollicitatievragen/active-record-basics.md): 25 vragen, Junior - [Views & ERB-templates](https://sharpskill.dev/nl/technologies/ruby-on-rails/sollicitatievragen/views-erb-templates.md): 20 vragen, Junior - [ActiveRecord-associaties](https://sharpskill.dev/nl/technologies/ruby-on-rails/sollicitatievragen/active-record-associations.md): 24 vragen, Mid-Level - [Geavanceerde ActiveRecord-query's](https://sharpskill.dev/nl/technologies/ruby-on-rails/sollicitatievragen/active-record-queries.md): 28 vragen, Mid-Level - [Rails-formulieren](https://sharpskill.dev/nl/technologies/ruby-on-rails/sollicitatievragen/rails-forms.md): 20 vragen, Mid-Level - [Authenticatie & autorisatie](https://sharpskill.dev/nl/technologies/ruby-on-rails/sollicitatievragen/authentication-authorization.md): 22 vragen, Mid-Level - [Moderne Asset Pipeline & frontend](https://sharpskill.dev/nl/technologies/ruby-on-rails/sollicitatievragen/rails-asset-pipeline.md): 18 vragen, Mid-Level - [Rails API-modus](https://sharpskill.dev/nl/technologies/ruby-on-rails/sollicitatievragen/rails-api-mode.md): 20 vragen, Mid-Level - [Testen met RSpec](https://sharpskill.dev/nl/technologies/ruby-on-rails/sollicitatievragen/rails-testing-rspec.md): 24 vragen, Mid-Level - [ActiveJob & Background Jobs](https://sharpskill.dev/nl/technologies/ruby-on-rails/sollicitatievragen/active-job-background-jobs.md): 20 vragen, Mid-Level - [ActionCable & WebSockets](https://sharpskill.dev/nl/technologies/ruby-on-rails/sollicitatievragen/action-cable-websockets.md): 18 vragen, Mid-Level - [ActionMailer](https://sharpskill.dev/nl/technologies/ruby-on-rails/sollicitatievragen/action-mailer.md): 18 vragen, Mid-Level - [ActiveStorage](https://sharpskill.dev/nl/technologies/ruby-on-rails/sollicitatievragen/active-storage.md): 20 vragen, Mid-Level - [Cachingstrategieën](https://sharpskill.dev/nl/technologies/ruby-on-rails/sollicitatievragen/caching-strategies.md): 20 vragen, Mid-Level - [Geavanceerde migraties](https://sharpskill.dev/nl/technologies/ruby-on-rails/sollicitatievragen/database-migrations-advanced.md): 20 vragen, Mid-Level - [Rails Engines & modulaire apps](https://sharpskill.dev/nl/technologies/ruby-on-rails/sollicitatievragen/rails-engines-modular-apps.md): 18 vragen, Senior - [Prestatie-optimalisatie](https://sharpskill.dev/nl/technologies/ruby-on-rails/sollicitatievragen/performance-optimization.md): 26 vragen, Senior - [Rails Design Patterns](https://sharpskill.dev/nl/technologies/ruby-on-rails/sollicitatievragen/rails-design-patterns.md): 22 vragen, Senior - [Ruby-metaprogrammering](https://sharpskill.dev/nl/technologies/ruby-on-rails/sollicitatievragen/ruby-metaprogramming.md): 20 vragen, Senior - [GraphQL met Rails](https://sharpskill.dev/nl/technologies/ruby-on-rails/sollicitatievragen/graphql-rails.md): 20 vragen, Senior - [Deployment & Productie](https://sharpskill.dev/nl/technologies/ruby-on-rails/sollicitatievragen/rails-deployment-production.md): 20 vragen, Senior - [Monitoring & Logging](https://sharpskill.dev/nl/technologies/ruby-on-rails/sollicitatievragen/monitoring-logging.md): 20 vragen, Senior - [Rails-upgradestrategieën](https://sharpskill.dev/nl/technologies/ruby-on-rails/sollicitatievragen/rails-upgrade-strategies.md): 18 vragen, Senior --- Source: SharpSkill (https://sharpskill.dev), tech interview preparation for your real stack. HTML version of this page: https://sharpskill.dev/nl/technologies/ruby-on-rails/sollicitatievragen/rails-security