Simple fuzzer for OpenAPI 3 specification based APIs
What does this fuzzer do?
- Sends various attack patterns to all the paths defined in an OpenAPI 3 definition file, using the OAS3 definition to create populate requests.
- Verifies if the responses matches those defined in the OAS3 definition file, complains and exit(2) if it doesn't.
- Complains loudly and exit(1) if a path returns an internal server error (status code 500 and higher)
Why does this OpenAPI fuzzer exist?
To make it easy to integrate an OpenAPI 3 fuzzer in an existing API.
How do I use this?
- Install the fuzzer using its pip package
- Add at least the following packages to requirements-test.txt:
coverage==5.0.3
openapi3-fuzzer
adal==1.2.2
Flask-Testing==0.7.1
- Generate OpenAPI (https://github.com/OpenAPITools/openapi-generator)
- Create a test_fuzzing file in the test location using the template below:
import adal
import config
from openapi3_fuzzer import FuzzIt
from openapi_server.test import BaseTestCase
def get_token():
"""
Create a token for testing
:return:
"""
oauth_expected_authenticator = authenticatoruri
client_id = appid
client_secret = secret
resource = resource/audience
# get an Azure access token using the adal library
context = adal.AuthenticationContext(oauth_expected_authenticator)
token_response = context.acquire_token_with_client_credentials(
resource, client_id, client_secret)
access_token = token_response.get('accessToken')
return access_token
class TestvAPI(BaseTestCase):
def test_fuzzing(self):
FuzzIt("openapi.yaml", get_token(), self)
- Run using our unittest container or via the Python Unittest Framework
What OAS3 items are supported?
Based on OpenAPI specification 3.0.2:
| Operation | Supported |
|---|---|
| GET | Yes |
| POST | Yes |
| PUT | Yes |
| DELETE | Yes |
| HEAD | Yes |
| OPTIONS | no |
| PATCH | no |
| TRACE | no |
| Parameter in | Supported |
|---|---|
| path | Yes |
| query | no |
| header | no |
| cookie | no |
| Property types | Supported |
|---|---|
| string | Yes |
| integer | Yes |
| number | Yes |
| array | Yes |
| none | Yes |
| boolean | no |
Example output
Internal server error:
GET fuzzing /managers/expenses/{expenses_id}/attachments
* INTERNAL SERVER ERROR
Endpoint returned 500 but expected one of [200]
GET https://dev.myapi.example/managers/expenses/99999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999/attachments
Response doesn't conform to the OAS3 spec:
--------------------------------------------
GET fuzzing /employees/expenses/{expenses_id}
- Unexpected status code
Endpoint returned 404 but expected one of [200, 'default']
GET https://dev.myapi.example/employees/expenses/)$#***^
POST fuzzing /employees/expenses/{expenses_id}
- Unexpected status code
Endpoint returned 400 but expected one of [201, 'default']
POST https://dev.myapi.example/employees/expenses
{
"amount": "123",
"cost_type": "123",
"note": ";sleep 10",
"transaction_date": "123"
}
Contributors
A special thanks to the contributors outside of VWT Digital.
| Name | Contribution |
|---|---|
| Jorrit Folmer | Started the project and created a base for the fuzzer. |
LICENSE
GPL3
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file openapi3-fuzzer-1.2.16.tar.gz.
File metadata
- Download URL: openapi3-fuzzer-1.2.16.tar.gz
- Upload date:
- Size: 7.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/1.15.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.50.1 CPython/3.5.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
527bb148d4a649f6a7cd803d3d807fb0c6c0152df0b70e1f05b0dafd4bb8043d
|
|
| MD5 |
369d1e9b587b51744f7058e67f3aa2ed
|
|
| BLAKE2b-256 |
e535eb5a936979bf9086991aa52a5309261b5f13ac57ae3cf08f81080ee6ff8c
|
File details
Details for the file openapi3_fuzzer-1.2.16-py3-none-any.whl.
File metadata
- Download URL: openapi3_fuzzer-1.2.16-py3-none-any.whl
- Upload date:
- Size: 20.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/1.15.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.50.1 CPython/3.5.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
891d3115d5a746153b432ebde6a97c9c0b837c32bdc6b6eeeaa23d53104043c3
|
|
| MD5 |
2c403cff3ff234b7464cb96d99bca466
|
|
| BLAKE2b-256 |
2511abcc0e1b2262b0b441e2bd16cae1c3f53854018c0c90e40c1ce381673667
|