summary refs log tree commit diff
path: root/synapse/appservice/api.py
diff options
context:
space:
mode:
authorPaul "LeoNerd" Evans <paul@matrix.org>2016-09-09 15:07:04 +0100
committerPaul "LeoNerd" Evans <paul@matrix.org>2016-09-09 15:07:04 +0100
commited44c475d832196957715f49215a95be1ce1eade (patch)
treee039f94d37b9124d599478dc8d40a1236871cba7 /synapse/appservice/api.py
parentMinor fixes from PR comments (diff)
downloadsynapse-ed44c475d832196957715f49215a95be1ce1eade.tar.xz
Reject malformed 3PE query metadata results earlier in AS API handling code
Diffstat (limited to '')
-rw-r--r--synapse/appservice/api.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/synapse/appservice/api.py b/synapse/appservice/api.py
index cc4af23962..afc64ed267 100644
--- a/synapse/appservice/api.py
+++ b/synapse/appservice/api.py
@@ -162,11 +162,19 @@ class ApplicationServiceApi(SimpleHttpClient):
                 urllib.quote(protocol)
             )
             try:
-                defer.returnValue((yield self.get_json(uri, {})))
+                info = yield self.get_json(uri, {})
+
+                # Ignore any result that doesn't contain an "instances" list
+                if "instances" not in info:
+                    defer.returnValue(None)
+                if not isinstance(info["instances"], list):
+                    defer.returnValue(None)
+
+                defer.returnValue(info)
             except Exception as ex:
                 logger.warning("query_3pe_protocol to %s threw exception %s",
                                uri, ex)
-                defer.returnValue({})
+                defer.returnValue(None)
 
         key = (service.id, protocol)
         return self.protocol_meta_cache.get(key) or (