A vulnerable version of Rails that follows the OWASP Top 10
JavaScript HTML Ruby CSS
Latest commit 3474385 Dec 17, 2016 @cktricky cktricky committed on GitHub Merge pull request #253 from jasnow/master
Upgraded Ruby to 2.3.3 along with ~20 gems
Permalink
Failed to load latest commit information.
app removed comments and Fixed Issue #184 Apr 19, 2016
config Fix METHOD for forgot_password route Jun 1, 2016
db Upgraded simplecov and poltergeist gems Feb 3, 2016
doc made some changes to the application controller, added a user control… Apr 24, 2013
gauntlt_scripts adding simple sqlmap gauntlt script, WIP Oct 9, 2013
lib Based on cane gem, removed tab indents and trailing blanks Sep 14, 2015
log made some changes to the application controller, added a user control… Apr 24, 2013
public More Rails 4.0 upgrade changes Sep 13, 2014
script adding vagrant and docker files Sep 19, 2014
spec Fixes #165 Jun 10, 2016
test More Rails 4.0 upgrade changes Sep 13, 2014
vendor/assets Initial Rails 4.0.x upgrade Sep 7, 2014
.cane Based on cane gem, removed tab indents and trailing blanks Sep 14, 2015
.gitignore On branch strong-params Dec 5, 2014
.overcommit.yml Fixed #238 and #239 (Removed rubocop and gauntlt refs) Jun 1, 2016
.powrc following an upgrade to the latest version of Ruby, my build environm… Sep 26, 2014
.rspec Mass assignment spec added Oct 1, 2013
.ruby-gemset Upgraded Ruby to 2.1.5; Rebuilt Gemfile.lock file Nov 17, 2014
.ruby-version Upgraded ruby to 2.3.3 Nov 22, 2016
.travis.yml Added phantomjs 2.1.1 install to .travis.yml file Dec 10, 2016
Dockerfile Upgraded ruby to 2.3.3 Nov 22, 2016
Gemfile Upgraded ruby to 2.3.3 Nov 22, 2016
Gemfile.lock Upgraded kgio gem Dec 17, 2016
Guardfile init\'ing guard-rspec Sep 6, 2013
LICENSE.md Update MIT license copyright year Jul 3, 2014
Procfile made some changes to the application controller, added a user control… Apr 24, 2013
README.md Added phantomjs version to README Dec 10, 2016
Rakefile made some changes to the application controller, added a user control… Apr 24, 2013
Vagrantfile updating dockerfile to use owasp repo Jun 15, 2016
Vagrantfile.proxy adding vagrant and docker files Sep 19, 2014
config.ru More Rails 4.0 upgrade changes Sep 13, 2014
docker-compose.yml Add docker-compose and build from ruby docker base Jul 4, 2016

README.md

RailsGoat Build Status Code Climate

RailsGoat is a vulnerable version of the Ruby on Rails Framework both versions 3 and 4. It includes vulnerabilities from the OWASP Top 10, as well as some "extras" that the initial project contributors felt worthwhile to share. This project is designed to educate both developers, as well as security professionals.

Support

If you are looking for support or troubleshooting assistance, please visit our OWASP Slack Channel.

Getting Started

To begin, install the Ruby Version Manager (RVM):

$ curl -L https://get.rvm.io | bash -s stable --autolibs=3 --ruby=2.3.3

After installing the package, clone this repo:

$ git clone git@github.com:OWASP/railsgoat.git

NOTE: NOT NECESSARY IF YOU WANT TO WORK WITH RAILS 4. Otherwise, if you wish to use the Rails 3 version, you'll need to switch branches

$ cd railsgoat
$ git checkout rails_3_2

Navigate into the directory (already there if you followed the previous step) and install the dependencies:

$ bundle install

If you receive an error, make sure you have bundler installed:

$ gem install bundler

Initialize the database:

$ rake db:setup

Start the Thin web server:

$ rails server

Open your favorite browser, navigate to http://localhost:3000 and start hacking!

Vagrant Install

To run Railsgoat with Vagrant you must first have Vagrant and Virtualbox installed. Once those dependencies are installed cd into the Railsgoat directory where you've cloned the code and run.

#~/code/railsgoat
$ vagrant up
...
    railsgoat:   Port: 3000:3000
    railsgoat:
    railsgoat: Container created: 3084633a81675346
==> railsgoat: Starting container...
==> railsgoat: Provisioners will not be run since container doesn't support SSH.
$

Once you see the preceeding message Railsgoat is running on your localhost on port 3000.

Open your favorite browser, navigate to http://localhost:3000 and start hacking!

Docker Install

To run Railsgoat with Docker you must first have Docker and Docker Compose installed. Once those dependencies are installed, cd into the Railsgoat directory where you've cloned the code and run. Rails requires Compose 1.6.0 or above and require a Docker Engine of version 1.10.0 or above.

#~/code/railsgoat
$ docker-compose build
$ docker-compose run web rake db:setup
$ docker-compose up
...
  Creating railsgoat_web_1
  Attaching to railsgoat_web_1
$

Once you see the preceeding message Railsgoat is running on your localhost on port 3000.

Open your favorite browser, navigate to http://<dockerIP>:3000 and start hacking! The Docker IP is usually 192.168.99.100. Run docker-machine env to verify.

Note: if your container exits with an error, it may be because a server is already running:

A server is already running. Check /myapp/tmp/pids/server.pid.
=> Booting Thin
=> Rails 4.2.6 application starting in development on
http://0.0.0.0:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
Exiting

In this case, remove that server.pid file and try again. Note also that this file is in your current working directory, not inside the container.

Capybara Tests

RailsGoat now includes a set of failing Capybara RSpecs, each one indicating that a separate vulnerability exists in the application. To run them, you first need to install PhantomJS (version 2.1.1 has been tested in Dev and on Travis CI), which is required by the Poltergeist Capybara driver. Upon installation, simply run the following rake task:

$ rake training

To run just one spec:

$ rake training SPEC=spec/vulnerabilities/sql_injection_spec.rb

NOTE: As vulnerabilities are fixed in the application, these specs will not change to passing, but to pending.

MySQL Environment

By default in development mode Railsgoat runs with a SQLite database. There is an environment defined to use MySQL. For some of the SQL injection vulnerabilities to work you have to run the app with MySQL as the database. The following steps will setup and run Railsgoat to use MySQL. MySQL must be installed and running before running these steps

#Create the MySQL database
RAILS_ENV=mysql rake db:create

#Run the migrations against the database
RAILS_ENV=mysql rake db:migrate

#Boot Rails using MySQl
RAILS_ENV=mysql rails s

Processing Email

In order for RailsGoat to effectively process email, you will first need to run MailCatcher, an SMTP server that will intercept email messages and display them in a web interface.

To start an instance of MailCatcher, simply run:

$ mailcatcher

If successful, you should see the following output:

Starting MailCatcher
==> smtp://127.0.0.1:1025
==> http://127.0.0.1:1080
*** MailCatcher runs as a daemon by default. Go to the web interface to quit.

Alternatively, you can run MailCatcher in the foreground by running mailcatcher -f in your terminal.

Contributing

As changes are made to the application, the Capybara RSpecs can be used to verify that the vulnerabilities in the application are still intact. To use them in this way, and have them pass instead of fail, set the RAILSGOAT_MAINTAINER environment variable.

Conversion to the OWASP Top Ten 2013 completed in November, 2013.

License

The MIT License (MIT)

Copyright (c) 2013-2014 The Open Web Application Security Project

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.