Skip to content

Commit

Permalink
Flask: sanitize OGC schema pathing (geopython#1593)
Browse files Browse the repository at this point in the history
  • Loading branch information
tomkralidis committed Mar 17, 2024
1 parent e3b5881 commit 4fdb921
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions pygeoapi/flask_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,11 @@ def schemas(path):
dirname_ = os.path.dirname(full_filepath)
basename_ = os.path.basename(full_filepath)

# TODO: better sanitization?
path_ = dirname_.replace('..', '').replace('//', '')
path_ = dirname_.replace('..', '').replace('//', '').replace('./', '')

if '..' in path_:
return 'Invalid path', 400

return send_from_directory(path_, basename_,
mimetype=get_mimetype(basename_))

Expand Down

0 comments on commit 4fdb921

Please sign in to comment.