Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

fix: secure http headers (#17715)

p0ny343f97d5ff82
diff --git a/backend/server/echo_routes.go b/backend/server/echo_routes.go
index 46b9f33700..2c4c4e5030 100644
--- a/backend/server/echo_routes.go
+++ b/backend/server/echo_routes.go
@@ -25,6 +25,7 @@ func configureEchoRouters(
profile *config.Profile,
) {
e.Use(recoverMiddleware)
+ e.Use(securityHeadersMiddleware)
if profile.Mode == common.ReleaseModeDev {
e.Use(middleware.CORSWithConfig(middleware.CORSConfig{
@@ -93,3 +94,32 @@ func recoverMiddleware(next echo.HandlerFunc) echo.HandlerFunc {
return next(c)
}
}
+
+func securityHeadersMiddleware(next echo.HandlerFunc) echo.HandlerFunc {
+ return func(c echo.Context) error {
+ // Allow popups to maintain window.opener for OAuth flows
+ c.Response().Header().Set("Cross-Origin-Opener-Policy", "same-origin-allow-popups")
+ // Prevent being embedded in iframes from different origins
+ c.Response().Header().Set("X-Frame-Options", "SAMEORIGIN")
+ // Prevent MIME-type sniffing
+ c.Response().Header().Set("X-Content-Type-Options", "nosniff")
+ // Force HTTPS in production (only if request is already HTTPS)
+ if c.Request().TLS != nil || c.Request().Header.Get("X-Forwarded-Proto") == "https" {
+ // max-age=31536000 (1 year), includeSubDomains for all subdomains
+ c.Response().Header().Set("Strict-Transport-Security", "max-age=31536000; includeSubDomains")
+ }
+ // Content Security Policy - strict, no unsafe-inline
+ csp := "default-src 'self'; " +
+ "script-src 'self'; " +
+ "style-src 'self'; " +
+ "img-src 'self' data: blob:; " +
+ "connect-src 'self' ws: wss:; " +
+ "font-src 'self'; " +
+ "object-src 'none'; " +
+ "base-uri 'self'; " +
+ "form-action 'self'; " +
+ "frame-ancestors 'self'"
+ c.Response().Header().Set("Content-Security-Policy", csp)
+ return next(c)
+ }
+}
diff --git a/frontend/.prettierrc.js b/frontend/.prettierrc.js
index 1ed4cb0592..cbcf1e7628 100644
--- a/frontend/.prettierrc.js
+++ b/frontend/.prettierrc.js
@@ -6,6 +6,7 @@ module.exports = {
printWidth: 80,
plugins: [require.resolve("@trivago/prettier-plugin-sort-imports")],
importOrder: [
+ "^[.]/init$",
"<BUILTIN_MODULES>",
"<THIRD_PARTY_MODULES>",
"^@/(.+)",
diff --git a/frontend/index.html b/frontend/index.html
index 67e723c9d7..49cf4745cd 100644
--- a/frontend/index.html
+++ b/frontend/index.html
@@ -15,14 +15,9 @@
<div
id="capture-container"
class="absolute -z-50 overflow-visible"
- style="right: -99999px; bottom: -99999px"
></div>
<div id="app"></div>
<script type="module" src="/src/main.ts"></script>
- <script>
- // redefine global use globalThis
- global = globalThis;
- </script>
</body>
</html>
diff --git a/frontend/src/assets/css/tailwind.css b/frontend/src/assets/css/tailwind.css
index b36618c3bd..4470b2cfab 100644
--- a/frontend/src/assets/css/tailwind.css
+++ b/frontend/src/assets/css/tailwind.css
@@ -259,6 +259,11 @@
}
}
+#capture-container {
+ right: -99999px;
+ bottom: -99999px;
+}
+
.fade-enter-active,
.fade-leave-active,
.fade-fast-enter-active,
diff --git a/frontend/src/init.ts b/frontend/src/init.ts
new file mode 100644
index 0000000000..db9d045d4e
--- /dev/null
+++ b/frontend/src/init.ts
@@ -0,0 +1,5 @@
+// Global initialization code that must run before any other application code
+// This is necessary for compatibility with certain dependencies that expect a global object
+
+// Redefine global to use globalThis for compatibility
+(globalThis as any).global = globalThis;
diff --git a/frontend/src/main.ts b/frontend/src/main.ts
index b6a8c4e55e..4f4d52b8fa 100644
--- a/frontend/src/main.ts
+++ b/frontend/src/main.ts
@@ -1,3 +1,5 @@
+// Must be first - initializes global compatibility shims
+import "./init";
import "regenerator-runtime/runtime";
import { createApp } from "vue";
import App from "./App.vue";