Skip to content

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

Update favicon extract to POST instead of GET (#2469)

Leendert de Borste2340cb3fae1
diff --git a/apps/browser-extension/src/entrypoints/popup/pages/passkeys/PasskeyCreate.tsx b/apps/browser-extension/src/entrypoints/popup/pages/passkeys/PasskeyCreate.tsx
index 6be2cbaa4..1205b3718 100644
--- a/apps/browser-extension/src/entrypoints/popup/pages/passkeys/PasskeyCreate.tsx
+++ b/apps/browser-extension/src/entrypoints/popup/pages/passkeys/PasskeyCreate.tsx
@@ -266,7 +266,7 @@ const PasskeyCreate: React.FC = () => {
setTimeout(() => reject(new Error('Favicon extraction timed out')), 5000)
);
- const faviconPromise = webApi.get<{ image: string }>('Favicon/Extract?url=' + request.origin);
+ const faviconPromise = webApi.post<{ url: string }, { image: string }>('Favicon/Extract', { url: request.origin });
const faviconResponse = await Promise.race([faviconPromise, timeoutPromise]) as { image: string };
if (faviconResponse?.image) {
diff --git a/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/webapi/WebApiService.kt b/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/webapi/WebApiService.kt
index a692fa1de..4938aabe9 100644
--- a/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/webapi/WebApiService.kt
+++ b/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/webapi/WebApiService.kt
@@ -451,11 +451,14 @@ class WebApiService(private val context: Context) {
*/
suspend fun extractFavicon(url: String): ByteArray? = withContext(Dispatchers.IO) {
try {
+ val requestBody = JSONObject()
+ requestBody.put("url", url)
+
val response = executeRequest(
- method = "GET",
- endpoint = "Favicon/Extract?url=$url",
- body = null,
- headers = emptyMap(),
+ method = "POST",
+ endpoint = "Favicon/Extract",
+ body = requestBody.toString(),
+ headers = mapOf("Content-Type" to "application/json"),
requiresAuth = true,
)
diff --git a/apps/mobile-app/ios/VaultStoreKit/Services/WebApiService.swift b/apps/mobile-app/ios/VaultStoreKit/Services/WebApiService.swift
index 7524cf2cd..f6a7f0ee0 100644
--- a/apps/mobile-app/ios/VaultStoreKit/Services/WebApiService.swift
+++ b/apps/mobile-app/ios/VaultStoreKit/Services/WebApiService.swift
@@ -396,18 +396,18 @@ public class WebApiService {
* Returns the favicon image data as base64-decoded bytes, or nil if extraction failed
*/
public func extractFavicon(url: String) async throws -> Data? {
- // URL encode the service URL parameter
- guard let encodedUrl = url.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed) else {
- print("WebApiService: Failed to encode URL for favicon extraction")
+ guard let jsonData = try? JSONSerialization.data(withJSONObject: ["url": url]),
+ let jsonString = String(data: jsonData, encoding: .utf8) else {
+ print("WebApiService: Failed to encode the favicon request")
return nil
}
do {
let response = try await executeRequest(
- method: "GET",
- endpoint: "Favicon/Extract?url=\(encodedUrl)",
- body: nil,
- headers: [:],
+ method: "POST",
+ endpoint: "Favicon/Extract",
+ body: jsonString,
+ headers: ["Content-Type": "application/json"],
requiresAuth: true
)
diff --git a/apps/server/AliasVault.Api/Controllers/V2/FaviconController.cs b/apps/server/AliasVault.Api/Controllers/V2/FaviconController.cs
index 8681b8877..62e23bfda 100644
--- a/apps/server/AliasVault.Api/Controllers/V2/FaviconController.cs
+++ b/apps/server/AliasVault.Api/Controllers/V2/FaviconController.cs
@@ -35,13 +35,14 @@ public class FaviconController(
public const int MaxBatchSize = 10;
/// <summary>
- /// Extracts the favicon from a single URL.
+ /// Extracts the favicon from a single URL. A POST, so the URL stays out of the access logs.
/// </summary>
- /// <param name="url">URL to extract the favicon from.</param>
+ /// <param name="request">The request payload.</param>
/// <returns>Favicon image bytes, or null if extraction failed.</returns>
- [HttpGet("Extract")]
- public async Task<IActionResult> Extract(string url)
+ [HttpPost("Extract")]
+ public async Task<IActionResult> Extract([FromBody] FaviconExtractRequest request)
{
+ var url = request.Url;
var user = await GetCurrentUserAsync();
if (user == null)
{
diff --git a/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Favicon/FaviconExtractRequest.cs b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Favicon/FaviconExtractRequest.cs
new file mode 100644
index 000000000..8e1da3e3d
--- /dev/null
+++ b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Favicon/FaviconExtractRequest.cs
@@ -0,0 +1,19 @@
+//-----------------------------------------------------------------------
+// <copyright file="FaviconExtractRequest.cs" company="aliasvault">
+// Copyright (c) aliasvault. All rights reserved.
+// Licensed under the AGPLv3 license. See LICENSE.md file in the project root for full license information.
+// </copyright>
+//-----------------------------------------------------------------------
+
+namespace AliasVault.Shared.Models.WebApi.V2.Favicon;
+
+/// <summary>
+/// Request payload for single favicon extraction.
+/// </summary>
+public class FaviconExtractRequest
+{
+ /// <summary>
+ /// Gets or sets the URL to extract the favicon for.
+ /// </summary>
+ public required string Url { get; set; }
+}
diff --git a/core/client/src/items/FaviconService.ts b/core/client/src/items/FaviconService.ts
index 7a8bc3786..350c0ad8a 100644
--- a/core/client/src/items/FaviconService.ts
+++ b/core/client/src/items/FaviconService.ts
@@ -22,7 +22,7 @@ export type FaviconStore = {
* Favicon API calls.
*/
export type FaviconApi = {
- get<T>(endpoint: string): Promise<T>;
+ post<TRequest, TResponse>(endpoint: string, data: TRequest): Promise<TResponse>;
};
/**
@@ -100,7 +100,7 @@ export class FaviconService {
timer = setTimeout(() => reject(new Error('Favicon extraction timed out')), timeoutMs);
});
- const faviconPromise = webApi.get<{ image: string }>(`Favicon/Extract?url=${encodeURIComponent(target.url)}`);
+ const faviconPromise = webApi.post<{ url: string }, { image: string }>('Favicon/Extract', { url: target.url });
const faviconResponse = await Promise.race([faviconPromise, timeoutPromise]);
if (faviconResponse?.image) {