Skip to content

Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.

Sanitize favicon URL to only send base domain to server (#2469)

Leendert de Borst7c5508837999
diff --git a/apps/server/Utilities/AliasVault.FaviconExtractor/FaviconExtractor.cs b/apps/server/Utilities/AliasVault.FaviconExtractor/FaviconExtractor.cs
index a331fe67d..8cdbbe13b 100644
--- a/apps/server/Utilities/AliasVault.FaviconExtractor/FaviconExtractor.cs
+++ b/apps/server/Utilities/AliasVault.FaviconExtractor/FaviconExtractor.cs
@@ -659,18 +659,12 @@ public static class FaviconExtractor
while (redirectCount < maxRedirects)
{
- // Create request with referer header to appear more browser-like
+ // Only the first request carries a (generic) referer, so a redirect target does not learn the originally requested URL.
var request = new HttpRequestMessage(HttpMethod.Get, currentUri);
if (redirectCount == 0)
{
- // First request: add Google referer to appear like navigation
request.Headers.Add("Referer", "https://www.google.com/");
}
- else
- {
- // Subsequent redirects: use original URL as referer
- request.Headers.Add("Referer", uri.ToString());
- }
var response = await client.SendAsync(request, cancellationToken);
diff --git a/core/rust/src/favicon/mod.rs b/core/rust/src/favicon/mod.rs
index c45a7098e..fa8dffcb2 100644
--- a/core/rust/src/favicon/mod.rs
+++ b/core/rust/src/favicon/mod.rs
@@ -57,20 +57,17 @@ pub fn select_favicon_target(urls: &[String]) -> Option<FaviconTarget> {
})
}
-/// Canonicalize the URL for fetching a favicon from: lowercased scheme and host, https when scheme-less.
+/// The origin to fetch a favicon from: lowercased scheme and host (with port), https when scheme-less. Userinfo, path
+/// and query are dropped so the server never sees more of the item URL than the site it has to fetch from.
fn canonical_fetch_url(url: &str) -> String {
- let (scheme, authority, path) = split_url(url);
+ let (scheme, authority, _) = split_url(url);
let scheme = match scheme {
Some(scheme) if is_web_scheme(scheme) => scheme.to_ascii_lowercase(),
_ => "https".to_string(),
};
- let (userinfo, host) = match authority.rfind('@') {
- Some(index) => authority.split_at(index + 1),
- None => ("", authority),
- };
-
- format!("{}://{}{}{}", scheme, userinfo, host.to_ascii_lowercase(), path)
+ let host = authority.rsplit_once('@').map_or(authority, |(_, host)| host);
+ format!("{}://{}", scheme, host.to_ascii_lowercase())
}
/// Whether a scheme-less host is shaped like a public hostname, meaning its last label could be a TLD.
@@ -251,7 +248,13 @@ mod tests {
assert_eq!(target.url, "https://www.example.com");
let target = select_favicon_target(&urls(&["HTTPS://Example.COM/Login?Token=AbC"])).unwrap();
- assert_eq!(target.url, "https://example.com/Login?Token=AbC");
+ assert_eq!(target.url, "https://example.com");
+ }
+
+ #[test]
+ fn test_fetch_url_is_the_origin_only() {
+ let target = select_favicon_target(&urls(&["https://user:[email protected]:8443/account/reset?token=abc#top"])).unwrap();
+ assert_eq!(target.url, "https://example.com:8443");
}
#[test]