📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!
TypeScript chartsclickhousedockergdprgoogle-analyticsmetricsmonitoringmysqlnestjsprivacyredisself-hostedselfhostedstatisticstailwindcssweb-analyticswebanalyticswebsite
Fixed 'Host Header poisoning' vulnerability
Blue Mouse3566a4672e32
diff --git a/src/common/constants.ts b/src/common/constants.tsindex c67444c89..1b0b7723f 100644--- a/src/common/constants.ts+++ b/src/common/constants.ts@@ -39,6 +39,7 @@ const clickhouse = new ClickHouse({})const isSelfhosted = Boolean(process.env.SELFHOSTED)+const isDevelopment = process.env.NODE_ENV === 'development'const isNewRelicEnabled = Boolean(process.env.USE_NEW_RELIC)const CLICKHOUSE_INIT_QUERIES = [@@ -193,6 +194,8 @@ const SEND_WARNING_AT_PERC = 85const PROJECT_INVITE_EXPIRE = 48+const PRODUCTION_ORIGIN = 'https://swetrix.com'+export {clickhouse,JWT_LIFE_TIME,@@ -226,4 +229,6 @@ export {ORIGINS_REGEX,REDIS_LOG_PERF_CACHE_KEY,REDIS_PERFORMANCE_COUNT_KEY,+ isDevelopment,+ PRODUCTION_ORIGIN,}diff --git a/src/project/project.controller.ts b/src/project/project.controller.tsindex 0e8881c4f..3da2a5789 100644--- a/src/project/project.controller.ts+++ b/src/project/project.controller.ts@@ -48,6 +48,8 @@ import {clickhouse,isSelfhosted,PROJECT_INVITE_EXPIRE,+ isDevelopment,+ PRODUCTION_ORIGIN,} from '../common/constants'import {getProjectsClickhouse,@@ -695,7 +697,7 @@ export class ProjectController {ActionTokenType.PROJECT_SHARE,share.id,)- const url = `${headers.origin}/share/${actionToken.id}`+ const url = `${isDevelopment ? headers.origin : PRODUCTION_ORIGIN}/share/${actionToken.id}`await this.mailerService.sendEmail(invitee.email,LetterTemplate.ProjectInvitation,@@ -838,7 +840,7 @@ export class ProjectController {projectName: project.name,email: body.email,reportFrequency: body.reportFrequency,- origin: headers.origin,+ origin: isDevelopment ? headers.origin : PRODUCTION_ORIGIN,})}diff --git a/src/user/user.controller.ts b/src/user/user.controller.tsindex c42d26405..1ef5b67f4 100644--- a/src/user/user.controller.ts+++ b/src/user/user.controller.ts@@ -46,6 +46,8 @@ import {isSelfhosted,SELFHOSTED_UUID,SELFHOSTED_EMAIL,+ isDevelopment,+ PRODUCTION_ORIGIN,} from '../common/constants'import { RolesGuard } from '../auth/guards/roles.guard'import { SelfhostedGuard } from '../common/guards/selfhosted.guard'@@ -388,7 +390,7 @@ export class UserController {ActionTokenType.EMAIL_VERIFICATION,user.email,)- const url = `${request.headers.origin}/verify/${token.id}`+ const url = `${isDevelopment ? request.headers.origin : PRODUCTION_ORIGIN}/verify/${token.id}`await this.userService.update(id, { emailRequests: 1 + user.emailRequests })await this.mailerService.sendEmail(user.email, LetterTemplate.SignUp, {@@ -490,7 +492,7 @@ export class UserController {ActionTokenType.EMAIL_CHANGE,userDTO.email,)- const url = `${request.headers.origin}/change-email/${token.id}`+ const url = `${isDevelopment ? request.headers.origin : PRODUCTION_ORIGIN}/change-email/${token.id}`await this.mailerService.sendEmail(user.email,LetterTemplate.MailAddressChangeConfirmation,