Dreamhack - pathtraversal (Path Traversal 취약점)

·2025년 6월 30일

Dreamhack-Writeups

목록 보기
8/52

pathtraversal

문제 링크

https://dreamhack.io/wargame/challenges/12

문제 설명

사용자의 정보를 조회하는 API 서버에서 Path Traversal 취약점을 이용해 /api/flag에 있는 플래그를 획득하는 문제입니다.

풀이과정

  1. 제시된 app.py에서
   elif request.method == 'POST':
        userid = request.form.get('userid', '')
        info = requests.get(f'{API_HOST}/api/user/{userid}').text
        return render_template('get_info.html', info=info)

코드를 확인할 수 있습니다. 사용자가 POST 요청으로 입력한 userid 값이 내부 API 경로에 그대로 삽입되어 요청됨을 알 수 있습니다.
이를 우회하는 과정을 통해 플래그를 획득할 수 있음을 유추할 수 있습니다.
2. userid 입력 창에 guest/../../flag 을 입력하였으나 별다른 플래그 값을 얻어내지 못했습니다.

  1. 요청값 조작을 위해 Burp Suite 을 실행합니다. Proxy 탭 에서 intercept on 상태로 설정합니다.

  2. Burp Suite의 프록시에 연결된 브라우저를 통해 /get_info 페이지에 접속하고, view 버튼을 눌러 서버로 POST 요청을 전송합니다.

  3. pretty 뷰에서 userid=0을 찾습니다. 이 후 /api/flag 에 접속하기 위해 요청 값을 0/../../flag와 같은 형태로 조작합니다.

  4. 정상적으로 flag값을 획득할 수 있습니다.


배운점

  • Burp Suite의 기본 사용값을 익혔습니다. 원하는 대로 요청을 우회하여 원하는 값을 찾아낼 수 있음을 배웠습니다.
  • Path Traversal 취약점의 개념과 실제 활용 방식을 이해하게 되었고, 사용자 입력값이 서버 경로에 직접 삽입될 경우 발생할 수 있는 위험성을 체감할 수 있었습니다.
  • 내부 API가 외부에서 직접 접근이 불가능한 경우라도, 프록시 서버를 통해 우회 접근이 가능하다는 점을 알게 되었습니다.

Summary (English)

  • Confirmed that the internal API path is constructed using the userid input value.
  • Initial input like guest/../../flag didn’t return the flag due to path handling or restrictions.
  • Used Burp Suite to intercept and modify the POST request manually.
  • Changed userid=0 to 0/../../flag to exploit path traversal and target /api/flag.
  • Internal server request was successfully redirected to the flag endpoint.
  • Retrieved the flag through the manipulated internal API request.
profile
CTF 풀이 및 실습 중심 학습을 기록합니다.

0개의 댓글