Tests for race conditions in web applications. Includes a RESTful API to integrate into a continuous integration pipeline.
Tests for race conditions in web applications. Includes a RESTful API to integrate into a continuous integration pipeline.
Tests for race conditions in web applications by sending out a user-specified number of requests to a target URL (or URLs) simultaneously, and then compares the responses from the server for uniqueness. Includes a number of configuration options.
Version 2.0.0 now makes it easier than ever to integrate RTW into your continuous integration pipeline (à la Jenkins, Travis, or Drone), through the use of an easy to use HTTP API. More information can be found in the Usage section below.
Racing the Web - Hackfest 2016
Slides: https://www.slideshare.net/AaronHnatiw/racing-the-web-hackfest-2016
With configuration file
$ race-the-web config.tomlAPI
$ race-the-webExample configuration file included (config.toml):
…TOML Spec: https://github.com/toml-lang/toml
Since version 2.0.0, RTW now has a full-featured API, which allows you to easily integrate it into your continuous integration (CI) tool of choice. This means that you can quickly and easily test your web application for race conditions automatically whenever you commit your code.
The API works through a simple set of HTTP calls. You provide input in the form of JSON and receive a response in JSON. The 3 API endpoints are as follows:
POST http://127.0.0.1:8000/set/config: Provide configuration data (in JSON format) for the race condition test you want to run (examples below).GET http://127.0.0.1:8000/get/config: Fetch the current configuration data. Data is returned in a JSON response.POST http://127.0.0.1:8000/start: Begin the race condition test using the configuration that you have already provided. All findings are returned back in JSON output./set/config using a POST request){
"count": 100,
"verbose": false,
"requests": [
{
"method": "POST",
"url": "http://racetheweb.io/bank/withdraw",
"cookies": [
"sessionId=dutwJx8kyyfXkt9tZbboT150TjZoFuEZGRy8Mtfpfe7g7UTPybCZX6lgdRkeOjQA"
],
"body": "amount=1",
"redirects": true
}
]
}$ curl -d '{"count":100,"verbose":false,"requests":[{"method":"POST","url":"http://racetheweb.io/bank/withdraw","cookies":["sessionId=Ay2jnxL2TvMnBD2ZF-5bXTXFEldIIBCpcS4FLB-5xjEbDaVnLbf0pPME8DIuNa7-"],"body":"amount=1","redirects":true}]}' -H "Content-Type: application/json" -X POST http://127.0.0.1:8000/set/config
{"message":"configuration saved"}$ curl -X GET http://127.0.0.1:8000/get/config
{"count":100,"verbose":false,"proxy":"","requests":[{"method":"POST","url":"http://racetheweb.io/bank/withdraw","body":"amount=1","cookies":["sessionId=Ay2jnxL2TvMnBD2ZF-5bXTXFEldIIBCpcS4FLB-5xjEbDaVnLbf0pPME8DIuNa7-"],"headers":null,"redirects":true}]}$ curl -X POST http://127.0.0.1:8000/startResponse (expanded for visibility):
…The program has been written in Go, and as such can be compiled to all the common platforms in use today. The following architectures have been compiled, and can be found in the releases tab:
First, make sure you have Go installed on your system. If you don't you can follow the install instructions for your operating system of choice here: https://golang.org/doc/install.
Build a binary for your current CPU architecture
$ make buildBuild for all major CPU architectures (see Makefile for details) at once
$ makeThis project uses Dep for dependency management. All of the required files are kept in the vendor directory, however if you are getting errors related to dependencies, simply download Dep
$ go get -u github.com/golang/dep/cmd/depand run the following command from the RTW directory in order to download all dependencies
$ dep ensureBefore 1.7, the encoding/json package's Encoder did not have a method to escape the &, `` characters; this is required in order to have a clean output of full HTML pages when running these race tests. If this is an issue for your test cases, please submit a new issue indicating as such, and I will add a workaround (just note that any output from a server with those characters will come back with unicode escapes instead). Here are the relevant release details from Go 1.7: https://golang.org/doc/go1.7#encoding_json.
A race condition is a flaw that produces an unexpected result when the timing of actions impact other actions. An example may be seen on a multithreaded application where actions are being performed on the same data. Race conditions, by their very nature, are difficult to test for.
Race conditions are a well known issue in software development, especially when you deal with fast, multi-threaded languages.
However, as network speeds get faster and faster, web applications are becoming increasingly vulnerable to race conditions. Often because of legacy code that was not created to handle hundreds or thousands of simultaneous requests for the same function or resource.
The problem can often only be discovered when a fast, multi-threaded language is being used to generate these requests, using a fast network connection; at which point it becomes a network and logic race between the client application and the server application.
That is where Race The Web comes in. This program aims to discover race conditions in web applications by sending a large amount of requests to a specific endpoint at the same time. By doing so, it may invoke unintended behaviour on the server, such as the duplication of user information, coupon codes, bitcoins, etc.
Warning: Denial of service may be an unintended side-effect of using this application, so please be careful when using it, and always perform this kind of testing with the explicit permission of the server owner and web application owner.
Credit goes to Josip Franjković for his excellent article on the subject, which introduced me to this problem.
The Go programming language is perfectly suited for the task, mainly because it is so damned fast. Here are a few reasons why:
For more of the nitty-gritty details on why Go is so fast, see Dave Cheney's excellent talk on the subject, from 2014.
No open issues yet, or sync has not completed.