Files
codeql/python/ql/test/query-tests/Security/CWE-022-PathInjection/pathlib_use.py
Rasmus Lerchedahl Petersen 9cb83fcdc9 python: add summaries for
copy, pop, get, getitem, setdefault

Also add read steps to taint tracking.

Reading from a tainted collection can be done in two situations:
1. There is an acces path
    In this case a read step (possibly from a flow summary)
    gives rise to a taint step.
2. There is no access path
    In this case an explicit taint step (possibly via a flow
    summary) should exist.
2023-05-26 14:04:15 +02:00

18 lines
349 B
Python

import pathlib
from flask import Flask, request
app = Flask(__name__)
STATIC_DIR = pathlib.Path("/server/static/")
@app.route("/pathlib_use")
def path_injection():
filename = request.args.get('filename', '')
p = STATIC_DIR / filename
p.open() # $ result=BAD
p2 = pathlib.Path(STATIC_DIR, filename)
p2.open() # $ result=BAD