🇰🇷 한글 설명
Apache OpenNLP의 ExtensionLoader에서 모델 매니페스트 파일을 통해 임의의 클래스를 인스턴스화할 수 있는 취약점입니다. 공격자가 조작된 모델 아카이브를 제공할 경우, Class.forName() 호출 시 클래스의 정적 초기화자가 실행되어 의도하지 않은 동작을 유발할 수 있습니다.
💡 쉬운 설명
신뢰할 수 없는 모델 파일을 불러올 때, 프로그램이 공격자가 숨겨놓은 악성 코드를 자동으로 실행할 수 있는 보안 결함입니다. 이를 통해 해커가 시스템에 원치 않는 명령을 내리거나 정보를 빼낼 위험이 있습니다.
🇺🇸 원문 (English)
Arbitrary Class Instantiation via Model Manifest in Apache OpenNLP ExtensionLoader
Versions Affected: before 1.9.5, before 2.5.9, before 3.0.0-M3
Description:
The ExtensionLoader.instantiateExtension(Class, String) method loads a class by its fully-qualified name via Class.forName() and invokes its no-arg constructor, with the class name sourced from the manifest.properties entry of a model archive. The existing isAssignableFrom check correctly rejects classes that are not subtypes of the expected extension interface (BaseToolFactory for factory=, ArtifactSerializer for serializer-class-*), but the check runs after Class.forName() has already loaded and initialized the named class.
Class.forName() with default initialization semantics executes the target class's static initializer before returning, so an attacker who can supply a crafted model archive can cause the static initializer of any class on the classpath to run during model loading, regardless of whether that class passes the subsequent type check.
Exploitation requires a class with attacker-useful side effects in its static initializer (for example, JNDI lookup, outbound network I/O, or filesystem access) to be present on the classpath, so this is not a drop-in remote code execution; however, the attack surface grows as third-party model distribution becomes more common (community model repositories, Hugging Face-style sharing), where users routinely load model files from origins they do not control. A secondary, narrower vector affects deployments that ship legitimate BaseToolFactory or ArtifactSerializer subclasses with side-effecting no-arg constructors: a malicious manifest can name such a class and force its constructor to run during model load.
Mitigation:
* 2.x users should upgrade to 2.5.9.
* 3.x users should upgrade to 3.0.0-M3.
Note: The fix introduces a package-prefix allowlist that is consulted before Class.forName() is invoked, so the static initializer of a disallowed class is never executed. Classes under the opennlp. prefix remain permitted by default. Deployments that load models referencing factories or serializers outside opennlp.* must opt those packages in, either programmatically via ExtensionLoader.registerAllowedPackage(String) before the first model load, or by setting the OPENNLP_EXT_ALLOWED_PACKAGES system property to a comma-separated list of allowed package prefixes.
Users who cannot upgrade immediately should ensure that all model files are sourced from trusted origins and should audit their classpath for classes with side-effecting static initializers or constructors, particularly any that perform JNDI lookups, network requests, or filesystem operations during class initialization.
📍 영향받는 시스템
Apache OpenNLP versions before 1.9.5, before 2.5.9, and before 3.0.0-M3
⚔️ 공격 벡터
조작된 manifest.properties가 포함된 모델 아카이브를 로드하여 클래스의 정적 초기화자(static initializer) 실행 유도
🛡️ 대응 방법
2.5.9 또는 3.0.0-M3 이상 버전으로 업그레이드하거나, 신뢰할 수 있는 출처의 모델만 사용하고 허용된 패키지 목록을 설정하십시오.
🔧 검증 코드
명령어 결과에 취약한 버전 범위의 opennlp-tools 라이브러리가 나타나면 보안 업데이트가 필요한 상태입니다.
mvn dependency:list | grep -E 'opennlp-tools-(1\[0-9]\.|2\.[0-5][0-8]|3\.0\.0-M[0-2])'