Vulnerability: Files on the host computer can be accessed from the Gradio interface ### Impact
This is a vulnerability that affects anyone who creates and publicly shares Gradio interfaces using `gradio<2.4.8`. Because of the way that static files were being served, someone who generated a public Gradio link and shared it with others would potentially be exposing the files on the computer that generated the link, while the link was active. An attacker would be able to view the contents of a file on the computer if they knew the exact relative filepath. We do not have any evidence that this was ever exploited, but we treated the issue seriously and immediately took steps to mitigate it (see below)

### Response
1. We worked with @haby0 to immediately patch the issue and released a new version, `gradio 2.5.0`, within 24 hours of the issue being brought to our attention 
2. We enabled a notification that is printed to anyone using an older version of gradio telling them to upgrade (see screenshot below)
3. We expanded our test suite to test for this vulnerability ensuring that our patch does not get reverted in future releases of `gradio`

![image](https://user-images.githubusercontent.com/1778297/146251425-f36b519b-6d4a-4dfb-8d89-c1ed005979d3.png)

### Patches
The problem has been patched in `gradio>=2.5.0`.
Vulnerability ID: GHSA-rhq2-3vr9-6mcr
CWE: CWE-22
Severity score: 8.3
Project: https://github.com/gradio-app/gradio
Published: 2022-01-21
File: gradio/networking.py
Commit message: secure path hotfix
Commit author: Ali Abid

Vulnerable version (before fix):
 def interpret(): @app.route("/file/<path:path>", methods=["GET"]) @login_check def file(path):     path = secure_filename(path)     if app.interface.encrypt and isinstance(app.interface.examples, str) and path.startswith(app.interface.examples):         with open(os.path.join(app.cwd, path), "rb") as encrypted_file:             encrypted_data = encrypted_file.read()         file_data = encryptor.decrypt(             app.interface.encryption_key, encrypted_data)         return send_file(io.BytesIO(file_data), attachment_filename=os.path.basename(path))     else:         return send_file(os.path.join(app.cwd, path))   @app.route("/api/queue/push/", methods=["POST"])

Fixed version (after fix):
 def interpret(): @app.route("/file/<path:path>", methods=["GET"]) @login_check def file(path):     if app.interface.encrypt and isinstance(app.interface.examples, str) and path.startswith(app.interface.examples):         with open(safe_join(app.cwd, path), "rb") as encrypted_file:             encrypted_data = encrypted_file.read()         file_data = encryptor.decrypt(             app.interface.encryption_key, encrypted_data)         return send_file(io.BytesIO(file_data), attachment_filename=os.path.basename(path))     else:         return send_file(safe_join(app.cwd, path))   @app.route("/api/queue/push/", methods=["POST"])

Patch:
patch: @@ -377,15 +377,14 @@ def interpret():
 @app.route("/file/<path:path>", methods=["GET"])
 @login_check
 def file(path):
-    path = secure_filename(path)
     if app.interface.encrypt and isinstance(app.interface.examples, str) and path.startswith(app.interface.examples):
-        with open(os.path.join(app.cwd, path), "rb") as encrypted_file:
+        with open(safe_join(app.cwd, path), "rb") as encrypted_file:
             encrypted_data = encrypted_file.read()
         file_data = encryptor.decrypt(
             app.interface.encryption_key, encrypted_data)
         return send_file(io.BytesIO(file_data), attachment_filename=os.path.basename(path))
     else:
-        return send_file(os.path.join(app.cwd, path))
+        return send_file(safe_join(app.cwd, path))
 
 
 @app.route("/api/queue/push/", methods=["POST"])
path: gradio/networking.py