🇰🇷 한글 설명
Apache Camel의 camel-saxon 컴포넌트에서 XQuery 표현식 평가 시 Saxon Configuration의 XML 파서 보호가 적용되지 않아 XML 외부 엔티티(XXE) 참조가 해석되는 취약점입니다. 이미 Source 타입인 메시지 본문이 이 경로를 통해 처리되면 외부 엔티티가 확장될 수 있습니다. 4.0.0~4.18.5 및 4.19.0~4.22.2 버전이 영향을 받습니다.
💡 쉬운 설명
Apache Camel으로 XML 데이터를 처리할 때, 외부 공격자가 악의적인 XML을 보내 서버의 파일을 읽거나 내부 시스템에 요청을 보내게 할 수 있습니다. 기본 설정만으로도 취약할 수 있어 주의가 필요합니다.
🇺🇸 원문 (English)
Improper Restriction of XML External Entity Reference vulnerability in Apache Camel Saxon component.
This issue affects Apache Camel: from 4.0.0 before 4.18.5, from 4.19.0 before 4.22.2.
XQueryBuilder in camel-saxon, which evaluates expressions for the xquery language and the xquery component, built its default Saxon Configuration with parse options that set only a whitespace stripping rule, leaving the XML parser at its defaults, under which a DOCTYPE declaration is accepted and external entities are resolved. A message body of type String or byte[], or any body read as an InputStream, is first turned into a javax.xml.transform.Source by Camel's own XML type converters, which configure the parser against external entities, so those bodies were not affected. A body that was already a Source, however, was handed to Saxon unchanged, and when that Source still had to be parsed, as a stream-based Source does, Saxon parsed it with that Configuration, bypassing the protection applied to the other body types. Such a body arises, for example, after a route converts the message with convertBodyTo(Source.class), or when a component or processor earlier in the route sets the body to a stream-based Source. A DOCTYPE with an external subset, or an external entity, declared in that body was therefore resolved and expanded into the document the expression was evaluated against. An external sender whose XML reaches an XQuery expression or an xquery endpoint in that form could read files readable by the Camel process and cause the process to issue requests to hosts the document names. No non-default option is required, since the default Configuration is used whenever the route does not supply one of its own.
Users are recommended to upgrade to version 4.23.0, which fixes the issue. If users are on the 4.22.x releases stream, then they are suggested to upgrade to 4.22.2. If users are on the 4.18.x releases stream, then they are suggested to upgrade to 4.18.5. The 4.14.x releases stream and earlier, as well as the 4.15.x to 4.17.x and 4.19.x to 4.21.x release lines, reached end of life before this issue was resolved and will not receive a fix, so deployments on them must move to a supported release. For deployments that cannot upgrade immediately, do not evaluate XQuery over a message body that is already a javax.xml.transform.Source when that body carries XML from an untrusted sender, or set the configuration option of the xquery endpoint or language to a Saxon Configuration whose parse options refuse a DOCTYPE declaration and disable external entities and external DTD loading, which is what the fixed releases now apply by default.
📍 영향받는 시스템
Apache Camel 4.0.0~4.18.5, 4.19.0~4.22.2 (camel-saxon 컴포넌트 사용 시)
⚔️ 공격 벡터
외부에서 DOCTYPE과 외부 엔티티가 포함된 XML을 Source 형태로 XQuery 엔드포인트에 전달하여 파일 읽기 또는 SSRF를 유발
🛡️ 대응 방법
4.23.0, 4.22.2, 4.18.5 이상으로 업그레이드하고, 즉시 업그레이드가 어려우면 신뢰되지 않은 XML에 대해 XQuery를 사용하지 않거나 DOCTYPE과 외부 엔티티를 거부하도록 Saxon Configuration을 설정
🔧 검증 코드
출력된 Implementation-Version 값이 4.18.5 미만(4.18.x 라인), 4.19.0~4.22.1 사이, 또는 4.23.0 미만이면 취약 버전이며, 4.23.0 이상(또는 4.22.2, 4.18.5 패치 버전)이면 수정된 버전입니다.
find / -name 'camel-core*.jar' 2>/dev/null | xargs -I{} sh -c 'unzip -p {} META-INF/MANIFEST.MF 2>/dev/null | grep -i "Implementation-Version" | sed "s|^|{}: |"'