🇰🇷 한글 설명
Apollo Federation의 쿼리 플래너에서 복잡한 쿼리를 처리할 때 무한 루프가 발생하여 메모리 사용량이 무한정 증가하는 서비스 거부(DoS) 취약점입니다. 특정 필드가 여러 서브그래프에서 해결될 수 있는 경우, 계산된 쿼리 플랜의 수가 자바스크립트의 최대 숫자 범위를 초과하여 시스템이 충돌하거나 종료될 수 있습니다.
💡 쉬운 설명
복잡한 요청을 처리하는 과정에서 컴퓨터가 계산할 수 있는 숫자의 한계를 넘어서는 오류가 발생하여 시스템이 멈추는 문제입니다. 공격자가 아주 복잡한 질문을 던지면 서버의 메모리가 가득 차서 서비스가 중단될 수 있습니다.
🇺🇸 원문 (English)
Apollo Federation is an architecture for declaratively composing APIs into a unified graph. Each team can own their slice of the graph independently, empowering them to deliver autonomously and incrementally. Instances of @apollo/query-planner >=2.0.0 and <2.8.5 are impacted by a denial-of-service vulnerability. @apollo/gateway versions >=2.0.0 and < 2.8.5 and Apollo Router <1.52.1 are also impacted through their use of @apollo/query-panner. If @apollo/query-planner is asked to plan a sufficiently complex query, it may loop infinitely and never complete. This results in unbounded memory consumption and either a crash or out-of-memory (OOM) termination. This issue can be triggered if you have at least one non-@key field that can be resolved by multiple subgraphs. To identify these shared fields, the schema for each subgraph must be reviewed. The mechanism to identify shared fields varies based on the version of Federation your subgraphs are using. You can check if your subgraphs are using Federation 1 or Federation 2 by reviewing their schemas. Federation 2 subgraph schemas will contain a @link directive referencing the version of Federation being used while Federation 1 subgraphs will not. For example, in a Federation 2 subgraph, you will find a line like @link(url: "https://specs.apollo.dev/federation/v2.0"). If a similar @link directive is not present in your subgraph schema, it is using Federation 1. Note that a supergraph can contain a mix of Federation 1 and Federation 2 subgraphs. This issue results from the Apollo query planner attempting to use a Number exceeding Javascript’s Number.MAX_VALUE in some cases. In Javascript, Number.MAX_VALUE is (2^1024 - 2^971). When the query planner receives an inbound graphql request, it breaks the query into pieces and for each piece, generates a list of potential execution steps to solve the piece. These candidates represent the steps that the query planner will take to satisfy the pieces of the larger query. As part of normal operations, the query planner requires and calculates the number of possible query plans for the total query. That is, it needs the product of the number of query plan candidates for each piece of the query. Under normal circumstances, after generating all query plan candidates and calculating the number of all permutations, the query planner moves on to stack rank candidates and prune less-than-optimal options. In particularly complex queries, especially those where fields can be solved through multiple subgraphs, this can cause the number of all query plan permutations to balloon. In worst-case scenarios, this can end up being a number larger than Number.MAX_VALUE. In Javascript, if Number.MAX_VALUE is exceeded, Javascript represents the value as “infinity”. If the count of candidates is evaluated as infinity, the component of the query planner responsible for pruning less-than-optimal query plans does not actually prune candidates, causing the query planner to evaluate many orders of magnitude more query plan candidates than necessary. This issue has been addressed in @apollo/query-planner v2.8.5, @apollo/gateway v2.8.5, and Apollo Router v1.52.1. Users are advised to upgrade. This issue can be avoided by ensuring there are no fields resolvable from multiple subgraphs. If all subgraphs are using Federation 2, you can confirm that you are not impacted by ensuring that none of your subgraph schemas use the @shareable directive. If you are using Federation 1 subgraphs, you will need to validate that there are no fields resolvable by multiple subgraphs.
📍 영향받는 시스템
@apollo/query-planner <2.8.5, @apollo/gateway <2.8.5, Apollo Router <1.52.1
⚔️ 공격 벡터
여러 서브그래프에서 공통으로 해결 가능한 필드를 포함한 매우 복잡한 GraphQL 쿼리를 전송하여 발생
🛡️ 대응 방법
@apollo/query-planner 2.8.5, @apollo/gateway 2.8.5 또는 Apollo Router 1.52.1 이상 버전으로 업데이트
🔧 검증 코드
출력된 패키지 또는 이미지의 버전이 취약한 버전 범위(2.8.5 미만 또는 1.52.1 미만)에 해당하는지 확인
npm list @apollo/query-planner @apollo/gateway || docker images | grep apollo-router