Giter VIP home page Giter VIP logo

railsgoat's Introduction

RailsGoat Build Status Code Climate

RailsGoat is a vulnerable version of the Ruby on Rails Framework from versions 3 to 6. 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, if you do not have Ruby, Git, MySQL, and Postgres, we suggest using this site to install the software. Pick the appropriate operating system and follow the instructions.

After installing the above software, clone this repo:

$ git clone [email protected]:OWASP/railsgoat.git

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

$ cd railsgoat
$ git checkout rails_3_2
$ git checkout rails_4_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:

$ rails db:setup

Start the Thin web server:

$ rails server

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.

For Mac Apple Silicon (ARM64) you must also have Rosetta install

#~/code/railsgoat
$ docker-compose build
$ docker-compose run web rails 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 6.0.0 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 task:

$ rails training

To run just one spec:

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

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 rails db:create

#Run the migrations against the database
RAILS_ENV=mysql rails 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.

Mailcatcher is not installed by default. To install MailCatcher and start an instance of it, simply run:

$ gem install mailcatcher
$ 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

Please see our contribution document to learn more. Additionally, note that 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 change to pending 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)

railsgoat's People

Contributors

0xbharath avatar adiov avatar chrismo avatar cktricky avatar cmlh avatar dependabot[bot] avatar ecneladis avatar eliblock avatar forced-request avatar giovantenne avatar godinezj avatar horvatic avatar jamesejr avatar jasnow avatar jmmastey avatar jx6f avatar l50 avatar mccabe615 avatar nvisium-jack-mannino avatar nvisium-john-poulin avatar nvisium-ken-johnson avatar presidentbeef avatar raesene avatar relotnek avatar steakunderscore avatar tdtds avatar themetric avatar tkmru avatar tommotorefi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

railsgoat's Issues

'RAILSGOAT_MAINTAINER="yes" rake' run does not run cleanly (green)

Ran this: RAILSGOAT_MAINTAINER="yes" rake and got this:

Finished in 1 minute 52.47 seconds
23 examples, 3 failures, 2 pending

Failed examples:

rspec ./spec/vulnerabilities/xss_spec.rb:9 # xss attack
rspec ./spec/vulnerabilities/url_access_spec.rb:9 # url access attack
rspec ./spec/vulnerabilities/unvalidated_redirects_spec.rb:9 # unvalidated redirect attack

Mass Assignment

The code is already vulnerable, need to add a tutorial section and a special filter and routes for admins

OWASP Top 10 2013

I'm sure this has already been thought of, but it would be nice to reorganize / update the tutorials to reflect the new (2013) top ten. The 2010 and 2013 lists are fairly similar, but one item I think RailsGoat could highlight from the 2013 list is A9 Using Components with Known Vulnerabilities. This could easily come in the form of an out of date Gem.

2010: https://www.owasp.org/index.php/Category:OWASP_Top_Ten_Project#OWASP_Top_10_for_2010

2013:
https://www.owasp.org/index.php/Category:OWASP_Top_Ten_Project#tab=OWASP_Top_10_for_2013

CSRF/AJAX/JQuery 3rd solution

Explain using serialization in JQuery for an AJAX request CSRF and how it will include all the form elements, obviously that includes the authenticity token.

Add an insecure API

I'd like to add an api that can be used to update data, that is insecure.

Add a command injection vulnerability

I was wondering if you guys could add a command injection vulnerability, perhaps a user can upload a file of some sort and that file is processed by something on the command line. The user supplied input isn't sanitized for shell meta characters like &;|\n etc.. allowing filenames like userdoc;id>/tmp/p;.doc to be sent and executed.

Problem with Benefits.make_backup argument values

Original Subject Line: Question: Getting cp-related error messages during "rake" run

Getting this during "rake" with and without the RAILSGOAT_MAINTAINER env variable set:

  • cp: missing destination file operand after โ€˜l/Projects/railsgoat/public/data/โ€™
  • Try 'cp --help' for more information.
  • sh: 1: /home/dell/Projects/railsgoat/public/data/bak1382235157_: not found
  • sh: 1: cd: can't cd to public

Is this expect/normal?


After more digging, found out that we are getting strange inputs into Benefits.make_backup.

Credentials

One thing I don't like in tutorial style apps is digging around for credentials to the app. Need to make this visible and reachable since we've made this mistake.

RVM Support deprecated through pow

It appears that Pow is deprecating support for loading per-project .rvmrc files. Since many of us use Pow for development, it appears that we will need to add the following code to the .powrc file:

if [ -f "$rvm_path/scripts/rvm" ] && [ -f ".rvmrc" ]; then
  source "$rvm_path/scripts/rvm"
  source ".rvmrc"
fi

screen shot 2013-10-11 at 9 39 50 am

Tutorial Accordian won't close

After opening a "Bug", "Solution", or "hint" panel in the tutorial controller it is impossible to close. Clicking on the tab will close it temporarily, but will reopen immediately after.

NameError: undefined local variable or method `postgresql_version'

This problem is introduced with the new Capybara tests, and is a bug in the database_cleaner gem.

A patch has been submitted and accepted (DatabaseCleaner/database_cleaner@3cf6d82), but not released yet. You can reference the github version of database_cleaner, until a version newer than 1.1.1 is released:

 group :development, :test do
   gem 'capybara'
-  gem 'database_cleaner'
+  gem 'database_cleaner', :github => 'bmabey/database_cleaner'
   gem 'poltergeist'
   gem 'rspec-rails'
 end

Dropdown

The drop down for account settings was not working on every page because of missing JS.

Add remember me feature

I noticed that RailsGoat doesn't have the ability for users to check "remember me" at the login prompt. Perhaps we can also introduce additional vulnerabilities in the implementation. Any thoughts?

Example:

  • Remember Me

Constantize

Somehow my constantize code went missing and I didn't notice :-0

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.