🇰🇷 한글 설명
Grackle GraphQL 서버에서 GraphQL 조각(fragment)의 순환 참조를 검사하지 않거나, cats-parse 라이브러리의 재귀 연산자가 스택 안전하지 않아 발생하는 취약점입니다. 공격자가 순환 구조를 가진 조각이나 깊게 중첩된 쿼리를 전송할 경우 JVM에서 StackOverflowError가 발생하여 서비스 거부(DoS) 상태에 빠질 수 있습니다.
💡 쉬운 설명
악의적인 사용자가 복잡하게 꼬인 질문을 서버에 보내면 서버의 메모리 처리 한계를 초과하게 만듭니다. 이로 인해 서버가 과부하를 견디지 못하고 갑자기 멈춰버리는 서비스 중단 현상이 발생할 수 있습니다.
🇺🇸 원문 (English)
Grackle is a GraphQL server written in functional Scala, built on the Typelevel stack. The GraphQL specification requires that GraphQL fragments must not form cycles, either directly or indirectly. Prior to Grackle version 0.18.0, that requirement wasn't checked, and queries with cyclic fragments would have been accepted for type checking and compilation. The attempted compilation of such fragments would result in a JVM `StackOverflowError` being thrown. Some knowledge of an applications GraphQL schema would be required to construct such a query, however no knowledge of any application-specific performance or other behavioural characteristics would be needed.
Grackle uses the cats-parse library for parsing GraphQL queries. Prior to version 0.18.0, Grackle made use of the cats-parse `recursive` operator. However, `recursive` is not currently stack safe. `recursive` was used in three places in the parser: nested selection sets, nested input values (lists and objects), and nested list type declarations. Consequently, queries with deeply nested selection sets, input values or list types could be constructed which exploited this, causing a JVM `StackOverflowException` to be thrown during parsing. Because this happens very early in query processing, no specific knowledge of an applications GraphQL schema would be required to construct such a query.
The possibility of small queries resulting in stack overflow is a potential denial of service vulnerability. This potentially affects all applications using Grackle which have untrusted users. Both stack overflow issues have been resolved in the v0.18.0 release of Grackle. As a workaround, users could interpose a sanitizing layer in between untrusted input and Grackle query processing.
📍 영향받는 시스템
Grackle version 0.18.0 미만 버전
⚔️ 공격 벡터
순환 참조를 포함한 GraphQL fragment 또는 깊게 중첩된 selection set, input value, list type을 포함한 악성 쿼리 전송
🛡️ 대응 방법
Grackle 라이브러리를 v0.18.0 이상 버전으로 업데이트하거나, 입력값 검증을 위한 중간 산출물(sanitizing layer)을 도입하십시오.
🔧 검증 코드
프로젝트 설정 파일에서 Grackle 버전을 확인하여 0.18.0 미만인지 확인합니다.
grep -r "grackle" /path/to/your/project/build.sbt | grep -E 'version "(0\.[0-1][7]?[0-9])"'