Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Tighten worker origin hostname checks

Manav Rathi67cf696f92d4
diff --git a/infra/workers/files/src/index.ts b/infra/workers/files/src/index.ts
index e3cf6d0e58..6e41465cc1 100644
--- a/infra/workers/files/src/index.ts
+++ b/infra/workers/files/src/index.ts
@@ -35,9 +35,7 @@ const isAllowedOrigin = (origin: string | null) => {
const hostname = url.hostname;
return (
origin == "ente://app" /* desktop app */ ||
- hostname.endsWith("ente.com") ||
- hostname.endsWith("ente.io") ||
- hostname.endsWith("ente.sh") ||
+ isEnteHostname(hostname) ||
hostname == "localhost"
);
} catch {
@@ -46,6 +44,11 @@ const isAllowedOrigin = (origin: string | null) => {
}
};
+const isEnteHostname = (hostname: string) =>
+ hostname.endsWith(".ente.com") ||
+ hostname.endsWith(".ente.io") ||
+ hostname.endsWith(".ente.sh");
+
const handleGET = async (request: Request) => {
const url = new URL(request.url);
diff --git a/infra/workers/thumbnails/src/index.ts b/infra/workers/thumbnails/src/index.ts
index 9b79304c4a..a55da12f64 100644
--- a/infra/workers/thumbnails/src/index.ts
+++ b/infra/workers/thumbnails/src/index.ts
@@ -35,9 +35,7 @@ const isAllowedOrigin = (origin: string | null) => {
const hostname = url.hostname;
return (
origin == "ente://app" /* desktop app */ ||
- hostname.endsWith("ente.com") ||
- hostname.endsWith("ente.io") ||
- hostname.endsWith("ente.sh") ||
+ isEnteHostname(hostname) ||
hostname == "localhost"
);
} catch {
@@ -46,6 +44,11 @@ const isAllowedOrigin = (origin: string | null) => {
}
};
+const isEnteHostname = (hostname: string) =>
+ hostname.endsWith(".ente.com") ||
+ hostname.endsWith(".ente.io") ||
+ hostname.endsWith(".ente.sh");
+
const handleGET = async (request: Request) => {
const url = new URL(request.url);