fix: EgovSAXValidatorService XXE 방어 적용 및 JAXP 파서로 현대화#254
Open
z3rotig4r wants to merge 1 commit into
Open
Conversation
SAX 검증기가 외부 엔티티/외부 DTD 차단 없이 XML을 파싱해, 외부 엔티티를 참조하는 입력 시 외부 리소스에 접근(XXE, CWE-611)할 수 있었다. 형제 클래스 EgovDOMValidatorService에는 동일 방어(2026.02.28 KISA 조치)가 적용돼 있으나 SAX 검증기에는 누락돼 있었다. 또한 파서를 Java 9에서 제거된 standalone Xerces 클래스명 (org.apache.xerces.parsers.SAXParser)으로 직접 생성해 현행 JDK에서 동작하지 않았다. JAXP SAXParserFactory(JDK 내장 파서)로 생성하도록 바꾸고 FEATURE_SECURE_PROCESSING과 외부 일반/파라미터 엔티티·외부 DTD 로딩 차단을 적용한다. 기존 검증/스키마 설정은 그대로 유지한다. 외부 엔티티가 해석되지 않음을 검증하는 단위테스트를 추가했고, 기존 ControlXMLTest 회귀를 확인했다.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
변경 이유
EgovSAXValidatorService.parse()가 SAX 파서에 외부 엔티티/외부 DTD 차단을 적용하지 않아, 외부 엔티티를 참조하는 XML 입력 시 외부 리소스에 접근(XXE, CWE-611)할 수 있었습니다.형제 클래스
EgovDOMValidatorService에는 2026.02.28 KISA 조치로 동일 방어(FEATURE_SECURE_PROCESSING, 외부 일반/파라미터 엔티티·외부 DTD 로딩 차단)가 적용돼 있으나 SAX 검증기에는 누락돼 있었습니다.추가로 파서를 Java 9에서 제거된 standalone Xerces 클래스명(
org.apache.xerces.parsers.SAXParser)으로 직접 생성하고 있어, 해당 라이브러리가 없는 현행 JDK 환경에서는parse()가 동작하지 않았습니다(SAX2 driver class ... not found).변경 내용
SAXParserFactory(JDK 내장 파서)로 변경합니다. 형제 DOM 검증기가DocumentBuilderFactory를 쓰는 것과 동일한 방식입니다.FEATURE_SECURE_PROCESSING과 외부 일반/파라미터 엔티티·외부 DTD 로딩 차단을 적용합니다.테스트 방법
EgovSAXValidatorXxeTest: 존재하지 않는 파일을 가리키는 외부 엔티티가 선언된 XML을 파싱할 때, 외부 엔티티가 해석되지 않아 외부 리소스 접근 없이 well-formed로 처리됨을 검증합니다. (차단 기능 제거 시 외부 리소스 접근 시도로 예외가 발생함을 확인했습니다.)ControlXMLTest회귀를 확인했습니다.영향 범위
SAX 검증기의 파서 생성·보안 설정만 변경하며 검증 결과 동작은 동일합니다.