Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9253561
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T11:15:01+00:00 2026-06-18T11:15:01+00:00

After a couple of weeks playing with rails app and completing the rails tutorial,

  • 0

After a couple of weeks playing with rails app and completing the rails tutorial, I wanted to learn about some common web attack in web applications.

I managed to perform a CSRF attack type using the below chunk of code in a .html file.

<form action="http://localhost:3000/users/2" method="post">
  <input type="hidden" name="_method" value="delete">
  <div>
    <input type="submit" value="Delete">
  </div>
</form>

Being logged in as an admin, I run the attack against my own code that was based on same session mechanism as Railtutorial and I succeed deleting the user where it should have been stopped as the authenticity token was missing.

The default behavior should be a session reset thus preventing the user being deleted outside of the web application.

I can see the ‘Can’t verify CSRF token authenticity’ in the log, but the session is not reset.

Overriding the handle_unverified_request method, that should by default reset the session, with

def handle_unverified_request
  raise(ActionController::InvalidAuthenticityToken)
end

the error get raised properly.

Running the attack on Railstutorial git code from railstutorial/sample_app_2nd_ed freshly install, I faced the exact same issue: the session is not reset as it should be. That mean the tutorial app is vulnerable to that kind of attack.

I dig a bit deeper into the code (http://api.rubyonrails.org/classes/ActionDispatch/Request.html#method-i-reset_session) but cannot figure out why in the context Railstutorial it doesn’t seem to work.

Could anyone verify, If the tutiral is indeed vulnerable to CSRF attck? if yes would the solution be to rewrite the handle_unverified_request to do proper signout in that case? Finally why is it not working as it should be?

Thanks for your help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T11:15:02+00:00Added an answer on June 18, 2026 at 11:15 am

    I figure out how to force the signout of the user if the CSRF token can’t be verify.

    It seems related to the fact that we empty the session but not the remember token of the cookie.

    Override handle_unverified_request in your application (so that all controller benefit from it) and add the sign_out method to clean the remember token.

    class ApplicationController < ActionController::Base
      protect_from_forgery
      include SessionsHelper
    
      def handle_unverified_request
        sign_out
        super
      end
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I came across couple of questions about OCL expressions. After reading some university slides
After testing my app for the past couple weeks we're finally trying to get
After a couple of weeks reading on this forum I thought it was time
I'm fairly new to DDD world and after reading couple of books about it
After compiling/linking some .c .cpp and .h files, there are a couple of extra
A couple of weeks ago i uploaded one of App which happens to be
A couple of weeks ago i have started my research in Iphone app development
I uploaded one of my app before couple of weeks and it is available
I have some experience with ASP.NET MVC, but since a couple of weeks I
I have been working with JQM for a couple of weeks and after studying

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.