The backend can be taken down using GraphQL circular queries
Report ID
#32372
Report type
Websites and Applications
Has PoC?
Yes
Target
Impacts
Taking down the application/website requiring manual restoration
Description
The previous report was reported with the wrong asset, it should have been the app not the exchange please excuse my mistake.
Brief/Intro
The backend API uses GraphQL in order to fetch market data for the user however due to a DoS vulnerability in GraphQL the backend can be taken down effectively rendering the main website useless.
Vulnerability Details
The https://app.bean.money/ website while browsing the market page performs backend API calls to the https://graph.node.bean.money/subgraphs/name/beanstalk in order to get information about the Silos, Markets and more. The backend API is hosting a GraphQL service with introspection enabled which allows potential users to easily build a query which will return the data that they want. After extracting the SDL and checking the GraphQL schema there were several objects which have bidirectional connections, meaning one object points to another object which points back to the initial object. One example of such objects are the following two objects:
Here the Silo type has a field assets which returns SiloAssets array and the SiloAssets type has a silo field which returns a Silo type object. This creates a case where a potential attacker can create a circular query and hog up a lot of server resources or if enough depth is given the server can crash. One example of such query is this:
This query gets fields which by itself returns a lot of data, gets the farmer field from the fields and then the query starts to become circular where it goes cyclically silo and assets for an arbitrary depth. The cyclical nature of the query forces the GraphQL server to create a lot of objects in the memory which will crash the server if enough depth is given even if the data that's being returned isn't that much.
Impact Details
An attacker can take down the backend server by issuing one query which will make the main website useless as users can't see the data they need to, to interact with the website in a meaningful way.
References
https://graph.node.bean.money/subgraphs/name/beanstalk
Remediation
A potential remediation could be to use a different GraphQL service which supports query depth limits and query cost analysis, or it can be implemented manually so the server will reject too big queries or queries that need to return too much data. Or if the table schema can be changed in such a way that there will be no bidirectional connections, that will alleviate the issue as well.
Proof of concept
This will most probably crash the server so if possible use with a lesser depth or test in a test environment:
BIC Response
From the bug bounty program:
Also note that the various ecosystem subgraphs (Beanstalk, Bean, Basin, etc.) are not included as Assets in Scope.
Thus, the asset is out of scope. For this reason, we are closing this report and no reward will be issued.