🛡️파일 업로드 취약점(File Upload Vulnerability)이란?
웹 애플리케이션이 사용자가 업로드한 파일을 충분히 검증하지 않고 받아들일 때 발생하는 보안 취약점으로, 공격자가 악성 파일을 업로드하여 서버 제어, 민감 정보 탈취, 추가 공격을 유발할 수 있다.
처음 접속하면 아래와 같은 화면이 나타납니다.
이 워게임은 사용자가 메모 파일을 업로드하는 기능을 중심으로 설계된 문제임을 알 수 있습니다.
단순한 업로드 기능처럼 보이지만, 실제로는 업로드 과정에서 발생할 수 있는 보안 취약점(예: 경로 조작, 파일 처리 문제 등)을 탐구하는 것이 핵심 목표입니다.

Upload My Memo에 들어가게 되면 아래와 같이 Filename과 Content를 적을 수 있는 칸이 나오게 된다.

간단하게 Filename과 Content에 hi를 입력해주면 아래처럼 나오게 된다.

이것만으로는 파악하기 어려우니 app.py를 열어본다.
#!/usr/bin/env python3
import os
import shutil
from flask import Flask, request, render_template, redirect
from flag import FLAG
APP = Flask(__name__)
UPLOAD_DIR = 'uploads'
@APP.route('/')
def index():
files = os.listdir(UPLOAD_DIR)
return render_template('index.html', files=files)
@APP.route('/upload', methods=['GET', 'POST'])
def upload_memo():
if request.method == 'POST':
filename = request.form.get('filename')
content = request.form.get('content').encode('utf-8')
if filename.find('..') != -1:
return render_template('upload_result.html', data='bad characters,,')
with open(f'{UPLOAD_DIR}/{filename}', 'wb') as f:
f.write(content)
return redirect('/')
return render_template('upload.html')
@APP.route('/read')
def read_memo():
error = False
data = b''
filename = request.args.get('name', '')
try:
with open(f'{UPLOAD_DIR}/{filename}', 'rb') as f:
data = f.read()
except (IsADirectoryError, FileNotFoundError):
error = True
return render_template('read.html',
filename=filename,
content=data.decode('utf-8'),
error=error)
if __name__ == '__main__':
if os.path.exists(UPLOAD_DIR):
shutil.rmtree(UPLOAD_DIR)
os.mkdir(UPLOAD_DIR)
APP.run(host='0.0.0.0', port=8000)
아래의 코드 부분을 보자.
@APP.route('/read')
def read_memo():
...
filename = request.args.get('name', '')
try:
with open(f'{UPLOAD_DIR}/{filename}', 'rb') as f: # ← 취약 지점
data = f.read()
- /read에서 filename 값이 아무 검증 없이 open() 경로에 들어감 👉 따라서 ../ 를 이용해 상위 디렉토리 파일 접근 가능 (Path Traversal)
이제 실제 공격 시나리오를 재현해보겠습니다.
Path Traversal을 통해 서버 루트에 존재하는 flag.py를 읽을 수 있는지 확인하는 단계입니다.
http://host8.dreamhack.games:10845/read?name=../flag.py

결과적으로 Path Traversal 취약점을 이용해 flag.py를 읽는 데 성공했고, 최종적으로 문제에서 요구하는 FLAG를 얻을 수 있었습니다.
'Dreamhack > 웹해킹' 카테고리의 다른 글
| [🌱Beginner] command-injection-1 (0) | 2025.08.19 |
|---|---|
| [🌱Beginner] web-misconf-1 (0) | 2025.08.19 |
| [🌱Beginner] path traversal (0) | 2025.08.17 |
| (드림핵) blind-command (0) | 2025.04.02 |
| SSRF (0) | 2025.04.01 |