Skip to content

Commit

Permalink
Flask: sanitize OGC schema pathing (#1593)
Browse files Browse the repository at this point in the history
  • Loading branch information
tomkralidis committed Mar 12, 2024
1 parent d8a1b74 commit ff4c4f6
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 @@ -101,8 +101,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 ff4c4f6

Please sign in to comment.