Web Cache 취약점들을 스캐닝하자 🔭

Web Cache Poisoning, Web Cache Deception 등 Web Cache 관련 취약점은 나름 오래된 기법이지만 요 몇 년 사이 알비노왁스(@albinowax) 등 Portswigger의 연구원들에 의해 빠르게 발전한 것 같습니다. 이러한 취약점들은 여러가지 테스팅 방법을 통해서 식별하고 Exploit 하지만 이전까진 크게 강력하다고 생각하던 도구가 없었던 상태입니다. (그나마 burpsuite의 내장 스캐너가 있겠네요…)

오늘은 Web Cache 취약점을 빠르게 식별할 수 있는 좋은 도구가 있어서 공유할까합니다! 사실 제가 관련 도구를 올 여름(21년 6월쯤?) 정도부터 아주 천천히 만들고 있었는데, Hackmanit에서 선수를 처버렸네요..

그럼 살펴보도록 하죠!

Who is it?

오늘 소개할 도구는 Web-Cache-Vulnerability-Scanner입니다. 이름이 길어서 약자로 WCVS로 사용합니다.

맨 위에 있는 친구입니다!

WCVS는 golang 기반의 도구로 Web Cache Poisoning을 포함한 여러가지 캐시 관련 취약점들을 스캐닝할 수 있습니다.

  • Unkeyed header poisoning
  • Unkeyed parameter poisoning
  • Parameter cloaking
  • Fat GET
  • HTTP response splitting
  • HTTP request smuggling
  • HTTP header oversize (HHO)
  • HTTP meta character (HMC)
  • HTTP method override (HMO)

Fat GET 트릭도 테스트하기 때문에 Burpsuite의 Param Minor의 기능도 일부 대체한다고 보시면 좋을 것 같습니다.

Installation

go1.16

go get -u https://github.com/Hackmanit/Web-Cache-Vulnerability-Scanner

go1.17

go install -v github.com/Hackmanit/Web-Cache-Vulnerability-Scanner@latest

Usage

기본적으로 -u --url flag를 통해 대상을 지정하고 스캐닝할 수 있습니다.

wcvs -u https://www.hahwul.com

스캔 시 Cache 관련 테스팅을 여러가지 진행하는 것 같습니다.

WCVS v1.0.0 started at 2021-12-26_01-13-22
Testing website(1/1): https://www.hahwul.com
-----------------------------------------------------------------------
Cache-Control header was found: [max-age=600]
X-Proxy-Cache header was found: [MISS]
X-Cache-Hits header was found: [2]
X-Cache header was found: [HIT]
Overwriting Host:www.hahwul.com with Host:www.hahwul.com:31337
Unexpected Status Code 421 for 1st request of Host
Overwriting Host:www.hahwul.com with Host:www.hahwul.com:@31337
Unexpected Status Code 400 for 1st request of Host
...

완료되면 Summary로 한번 더 보여줍니다.

-----------------------------------------------------------------------
X-Cache-Hits header was found: [2]
X-Cache header was found: [HIT]
Cache-Control header was found: [max-age=600]
X-Proxy-Cache header was found: [MISS]
checkIfCacheAlwaysMiss: returns always a miss, even if requests are identical
No cachebuster could be found
Use -f/-force to force the test
The default status code was set to 200

-----------------------------------------------------------------------
Successfully finished the scan
Duration: 79.531261ms

스캔에 필요한 다양한 flag를 지원하고 있어서 -h로 help 보시면서 필요한 flag를 맞춰 사용하시면 됩니다.

for DevSecOps

솔직히 도구 쓰는거야 뭐 그냥 사용하시면 될 것 같고, 중요한건 Scanning Pipeline에 붙이기 쉬운가 / DevSecOps를 제공한다면 여기에 적용하기 좋은가가 중요할 것 같습니다. Pipeline 계통의 옵션을 지원하는건 아니지만, Generate flag들을 사용하여 JSON 포맷의 결과를 만들 수 있습니다. 이를 이용하면 여러 작업에 연동하기 조금 유연하겠지요.

Generate Options:
--generatepath		-gp	Path all files (log, report, completed) will be written to. Example: -gp '/p/a/t/h/'. Default is './'
--generatereport	-gr	Do you want a report to be generated?
--escapejson		-ej	Do you want HTML special chars to be encoded in the report?
--generatecompleted	-gc	Do you want a list with completed URLs to be generated?

Make JSON report

-gr-ej flag를 추가하면 실행 경로에 결과에 대한 json 파일이 생성됩니다.

wcvs -u https://www.hahwul.com -ej -gr
...
Successfully finished the scan
Duration: 79.366845ms

Exported report ./2021-12-26_01-18-51_WCVS_Report.json

생각보다 디테일하게 정보를 기록하네요!

Scanning Multiple URLs

with -u flag

wcvs 에선 -u flag에서 file:// 프로토콜을 지정할 수 있도록 제공하고 있습니다. (오 이건 좋은 아이디어! 저도 나중에 dalfox에 추가해야곘네요 😎)

wcvs -u file://targets/urls.txt

with xargs

따로 파일로 대상을 관리하지 않는다면 대다수 도구들이 그렇듯이 xargs가 가장 현실적인 답안이 되겠네요.

cat urls.txt | xargs -I % wcvs -u % -ej -gr

Conclusion

이 도구는 제가 따로 개발중이던 도구를 중단하게 할 정도로 취약점 커버리지가 넓습니다. 그래서 개인적인 생각으론 Burpsuite의 Param Minor와 Active Scan 조합을 사용하시는게 아니라면 캐시 관련 스캐닝에선 가장 좋은 도구일 것 같습니다 :D

References

  • https://github.com/Hackmanit/Web-Cache-Vulnerability-Scanner