Skip to content

Commit ff4c4f6

Browse files
authored
Flask: sanitize OGC schema pathing (#1593)
1 parent d8a1b74 commit ff4c4f6

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

pygeoapi/flask_app.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,11 @@ def schemas(path):
101101
dirname_ = os.path.dirname(full_filepath)
102102
basename_ = os.path.basename(full_filepath)
103103

104-
# TODO: better sanitization?
105-
path_ = dirname_.replace('..', '').replace('//', '')
104+
path_ = dirname_.replace('..', '').replace('//', '').replace('./', '')
105+
106+
if '..' in path_:
107+
return 'Invalid path', 400
108+
106109
return send_from_directory(path_, basename_,
107110
mimetype=get_mimetype(basename_))
108111

0 commit comments

Comments
 (0)