QuickRouter · 本站原创输入 / 人工参考 · 目标代理未执行
Codex review 教程:只读审查本地下载接口的路径穿越风险
route.py
from pathlib import Path
from urllib.parse import unquote
ROOT=Path(__file__).resolve().parent/'sandbox/downloads'
def broken(name):
return (ROOT/unquote(name)).read_text()
def fixed(name):
candidate=(ROOT/unquote(name)).resolve()
if not candidate.is_relative_to(ROOT.resolve()):
raise PermissionError('outside downloads root')
if not candidate.is_file():
raise FileNotFoundError(name)
return candidate.read_text()
review-request.md
Review uncommitted changes, only for path containment and percent-encoding input. Return file, exact line, trigger, evidence and uncertainty. Do not modify files. Do not post comments remotely.