Funny Factorials

Description

By stuxf

I made a factorials app! It's so fancy and shmancy. However factorials don't seem to properly compute at big numbers! Can you help me fix it?

funny-factorials.amt.rsarrow-up-right

Downloads: app.pyarrow-up-right, Dockerfilearrow-up-right

Analysis

From the Dockerfile we know that flag lives in root directory. COPY flag.txt /

Possible attack vector: Use theme to get flag.txt with LFIarrow-up-right.

@app.route('/')
def index():
    safe_theme = filter_path(request.args.get("theme", "themes/theme1.css"))
    f = open(safe_theme, "r")
    theme = f.read()
    f.close()
    return render_template('index.html', css=theme)

Vulnaribility.

  1. / is only removed once so //flag.txt -> /flag.txt

  2. The filter_path uses recursion and the recursion depth is 100, which can be bypassed by sandwiching ../ inside strings. e.g.: '....//' -> '../' -> ''.

Solution

circle-check
circle-info

AttackVector 2: ../*81 sandwiched string is required to get flag

Last updated