Don't federate device name by default, or at least make it toggleable #359

Closed
opened 2023-07-02 07:19:36 +00:00 by girlbossceo · 1 comment
girlbossceo commented 2023-07-02 07:19:36 +00:00 (Migrated from gitlab.com)

Synapse has disabled federating device names by default for many months now, mainly for privacy reasons as the device name can consist of things like your OS, your browser, and the version of the browser and/or client you're using. This has been a seamless change with no impact, and if people would like to still federate device names, they can do so via allow_device_name_lookup_over_federation. I don't really see why Conduit doesn't do the same thing, especially if server-side URL previews are not being worked on any time soon due to privacy and security reasons, and would assume the same thing applies here.

Describe the solution you'd like

Federating device names should be opt-in by the homeserver admin (controllable by a setting like Synapse's allow_device_name_lookup_over_federation), and should be disabled by default.

A (very likely hacky) way of achieving this was done on my build of Conduit with the following patch:

diff --git a/src/api/client_server/keys.rs b/src/api/client_server/keys.rs
index ba89ece..d35d41d 100644
--- a/src/api/client_server/keys.rs
+++ b/src/api/client_server/keys.rs
@@ -396,8 +396,10 @@ fn add_unsigned_device_display_name(
         let mut object = keys.deserialize_as::<serde_json::Map<String, serde_json::Value>>()?;

         let unsigned = object.entry("unsigned").or_insert_with(|| json!({}));
-        if let serde_json::Value::Object(unsigned_object) = unsigned {
-            unsigned_object.insert("device_display_name".to_owned(), display_name.into());
+        if services().globals.allow_device_name_federation() {
+            if let serde_json::Value::Object(unsigned_object) = unsigned {
+                unsigned_object.insert("device_display_name".to_owned(), display_name.into());
+            }
         }

         *keys = Raw::from_json(serde_json::value::to_raw_value(&object)?);
diff --git a/src/config/mod.rs b/src/config/mod.rs
index 31a586f..6ad06fd 100644
--- a/src/config/mod.rs
+++ b/src/config/mod.rs
@@ -49,6 +49,8 @@ pub struct Config {
     #[serde(default = "false_fn")]
     pub allow_federation: bool,
     #[serde(default = "true_fn")]
+    pub allow_device_name_federation: bool,
+    #[serde(default = "false_fn")]
     pub allow_room_creation: bool,
     #[serde(default = "true_fn")]
     pub allow_unstable_room_versions: bool,
@@ -145,6 +147,7 @@ impl fmt::Display for Config {
             ),
             ("Allow encryption", &self.allow_encryption.to_string()),
             ("Allow federation", &self.allow_federation.to_string()),
+            ("Allow device name federation", &self.allow_device_name_federation.to_string()),
             ("Allow room creation", &self.allow_room_creation.to_string()),
             (
                 "JWT secret",
diff --git a/src/service/globals/mod.rs b/src/service/globals/mod.rs
index 9206d43..b4710a0 100644
--- a/src/service/globals/mod.rs
+++ b/src/service/globals/mod.rs
@@ -242,6 +242,10 @@ impl Service {
         self.config.allow_federation
     }

+    pub fn allow_device_name_federation(&self) -> bool {
+        self.config.allow_device_name_federation
+    }
+
     pub fn allow_room_creation(&self) -> bool {
         self.config.allow_room_creation
     }
### Is your feature request related to a problem? Please describe. Synapse has disabled federating device names by default for many months now, mainly for privacy reasons as the device name *can* consist of things like your OS, your browser, and the version of the browser and/or client you're using. This has been a seamless change with no impact, and if people would like to still federate device names, they can do so via [allow_device_name_lookup_over_federation](https://matrix-org.github.io/synapse/latest/usage/configuration/config_documentation.html#allow_device_name_lookup_over_federation). I don't really see why Conduit doesn't do the same thing, especially if server-side URL previews are not being worked on any time soon due to privacy and security reasons, and would assume the same thing applies here. ### Describe the solution you'd like Federating device names should be opt-in by the homeserver admin (controllable by a setting like Synapse's `allow_device_name_lookup_over_federation`), and should be disabled by default. A (very likely hacky) way of achieving this was done on my build of Conduit with the following patch: ```patch diff --git a/src/api/client_server/keys.rs b/src/api/client_server/keys.rs index ba89ece..d35d41d 100644 --- a/src/api/client_server/keys.rs +++ b/src/api/client_server/keys.rs @@ -396,8 +396,10 @@ fn add_unsigned_device_display_name( let mut object = keys.deserialize_as::<serde_json::Map<String, serde_json::Value>>()?; let unsigned = object.entry("unsigned").or_insert_with(|| json!({})); - if let serde_json::Value::Object(unsigned_object) = unsigned { - unsigned_object.insert("device_display_name".to_owned(), display_name.into()); + if services().globals.allow_device_name_federation() { + if let serde_json::Value::Object(unsigned_object) = unsigned { + unsigned_object.insert("device_display_name".to_owned(), display_name.into()); + } } *keys = Raw::from_json(serde_json::value::to_raw_value(&object)?); diff --git a/src/config/mod.rs b/src/config/mod.rs index 31a586f..6ad06fd 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -49,6 +49,8 @@ pub struct Config { #[serde(default = "false_fn")] pub allow_federation: bool, #[serde(default = "true_fn")] + pub allow_device_name_federation: bool, + #[serde(default = "false_fn")] pub allow_room_creation: bool, #[serde(default = "true_fn")] pub allow_unstable_room_versions: bool, @@ -145,6 +147,7 @@ impl fmt::Display for Config { ), ("Allow encryption", &self.allow_encryption.to_string()), ("Allow federation", &self.allow_federation.to_string()), + ("Allow device name federation", &self.allow_device_name_federation.to_string()), ("Allow room creation", &self.allow_room_creation.to_string()), ( "JWT secret", diff --git a/src/service/globals/mod.rs b/src/service/globals/mod.rs index 9206d43..b4710a0 100644 --- a/src/service/globals/mod.rs +++ b/src/service/globals/mod.rs @@ -242,6 +242,10 @@ impl Service { self.config.allow_federation } + pub fn allow_device_name_federation(&self) -> bool { + self.config.allow_device_name_federation + } + pub fn allow_room_creation(&self) -> bool { self.config.allow_room_creation } ```
NikotheNya commented 2023-07-29 20:15:40 +00:00 (Migrated from gitlab.com)

Is anyone working on this? I'd like to

Is anyone working on this? I'd like to
Sign in to join this conversation.
No labels
Android
CS::needs customer feedback
CS::needs follow up
CS::needs on prem installation
CS::waiting
Chrome
Design:: Ready
Design:: in progress
Design::UX
E2EE
Edge
Firefox
GDPR
Iteration 13 IM
Linux
MacOS
Need::Discussion
Need::Steps to reproduce
Need::Upstream fix
Needs:: Planning
Needs::Dev-Team
Needs::More information
Needs::Priority
Needs::Product
Needs::Refinement
Needs::Severity
Priority::1-Critical
Priority::2-Max
Priority::3-Impending
Priority::4-High
Priority::5-Medium
Priority::6-Low
Priority::7-None
Progress::Backlog
Progress::Review
Progress::Started
Progress::Testing
Progress::Triage
Progress::Waiting
Reporter::Sentry
Safari
Target::Community
Target::Customer
Target::Internal
Target::PoC
Target::Security
Team:Customer-Success
Team:Design
Team:Infrastructure
Team:Instant-Messaging
Team:Product
Team:Workflows
Type::Bug
Type::Design
Type::Documentation
Type::Feature
Type::Improvement
Type::Support
Type::Tests
Windows
blocked
blocked-by-spec
cla-signed
conduit
contribution::advanced
contribution::easy
contribution::help needed
from::review
iOS
p::ti-tenant
performance
product::triage
proposal
refactor
release-blocker
s: dart_openapi_codegen
s::Famedly-Patient
s::Org-Directory
s::Passport-Generator
s::Requeuest
s:CRM
s:Famedly-App
s:Famedly-Web
s:Fhiroxide
s:Fhiroxide-cli
s:Fhiroxide-client
s:Fhirs
s:Hedwig
s:LISA
s:Matrix-Dart-SDK
s:Role-Manager
s:Synapse
s:User-Directory
s:WFS-Matrix
s:Workflow Engine
s:dtls
s:famedly-error
s:fcm-shared-isolate
s:matrix-api-lite
s:multiple-tab-detector
s:native-imaging
severity::1
severity::2
severity::3
severity::4
technical-debt
voip
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: Matthias/conduit#359
No description provided.