Home

Awesome

What is vAPI

https://github.com/jorritfolmer/vulnerable-api/workflows/vAPI/badge.svg

vAPI is an API written specifically to illustrate common API vulnerabilities. It is implemented using Python Flask + Connexion and consists of a user database and a token database.

How is this version different from all the other vulnerable-API forks on GitHub?

  1. Python 3.6, 3.7, 3.8, 3.9 and 3.10 supported and tested.
  2. OpenAPI first, using Connexion
  3. Includes tests and an OpenAPI 3 fuzzer
  4. It adds a business relevant widget reservation endpoint.
  5. It adds basic application logging (vAPI.log) for purple teaming demo purposes!
  6. Log format is Splunk CIM compliant key=value right out of the box.

Usage

  1. git clone https://github.com/jorritfolmer/vulnerable-api.git
  2. virtualenv venv
  3. source venv/bin/activate
  4. pip install -r requirements
  5. python ./vAPI.py -p <port>
  6. have fun with OWASP ZAP, Burp or Postman

vAPI Process flow

  1. Request token from /tokens
    • Returns an auth token
    • Returns expiration date of auth token
    • Returns a user id
  2. Request widget reservation from /widget
    • Requires the auth token
  3. Request user record from /user/<user_id>
    • Requires the auth token
    • Returns the user record for the user specfied, provided the auth token is not expired and is valid for the user id specified
    • Each user can only access their own record

OpenAPI 3 spec

Also contained in this repo is the API specification file to load in e.g. Burp or OWASP ZAP for fun and profit.

Known vulnerabilities

  1. Insecure transport
  2. User enumeration
  3. Information disclosure
  4. Authentication bypass
  5. No input validation
  6. SQL injection
  7. Weak session token crypto
  8. Poor session validation
  9. Plaintext storage of secrets
  10. Command injection
  11. Regex denial of service
  12. Cross Site Scripting
  13. XML XXE and billion laughs
  14. Missing security headers

Vulnerabilities per endpoint

methodendpointinputvuln
GET/-15
GET/tokens-10
POST/tokenspost14
POST/tokenspost:username2, 6, 8, 13, 14
POST/tokenspost:password2, 6, 8, 13, 14
GET/user/{userid}header:x-auth-token4, 6, 8, 9
GET/user/{userid}get: userid2, 6, 10, 12
POST/userheader:x-auth-token4, 6, 8, 9
POST/userpost:username6, 9, 12, 13
POST/userpost:username6, 9, 13
GET/uptime{flag}-11, 13
POST/widgetheader:x-auth-token4, 6, 8, 9
POST/widgetpost:widget12

Examples

/tokens endpoint

$ curl -X POST -H "Content-type: application/json" http://localhost:8081/tokens \
-d '
{
  "auth": {
    "passwordCredentials": {
      "username":"user1",
      "password":"pass1"
      }
  }
}'

/widget endpoint

POST /widget HTTP/1.1
Content-Type: application/json
X-Auth-Token: USER TOKEN

{"widget":
    {"name": "widget01"}
}

/user endpoint

POST /user HTTP/1.1
Content-type: application/json
X-Auth-Token: ADMIN TOKEN

{"user":
	{"username": "user",
	"password": "pass"}
}

Docker

  1. docker build -t vapi .
  2. docker run -p 8081:8081 vapi

Testing

From the project root:

pip install -r requirements-test.txt
coverage run -m unittest
coverage report -m