Open-source manufacturing ERP, MES and QMS. Quoting, MRP, inventory, shop floor, quality and lot/serial traceability on one Postgres schema, with a REST API and MCP server. Self-host or use Carbon Cloud.
TypeScript ai-agentsbill-of-materialserpinventory-managementleanmanufacturingmanufacturing-execution-systemmcp-servermesmrpopen-source-erppostgresqlproduction-planningqmsquality-management-systemreact-routerself-hostedsupabasetraceabilitytypescript
fix(security): authorize file preview path by companyId segment, not substring
aashu7c21bfc20168
diff --git a/apps/erp/app/routes/file+/preview+/$bucket.$.tsx b/apps/erp/app/routes/file+/preview+/$bucket.$.tsxindex 1ed1ea1cb5..a739d409df 100644--- a/apps/erp/app/routes/file+/preview+/$bucket.$.tsx+++ b/apps/erp/app/routes/file+/preview+/$bucket.$.tsx@@ -50,9 +50,14 @@ export let loader = async ({ request, params }: LoaderFunctionArgs) => {}const contentType = supportedFileTypes[fileType];- // Check if the decoded path includes companyId for security+ // Authorize against the companyId as a full path segment (prefix or+ // slash-bounded), not a loose substring — `.includes(companyId)` lets+ // `<otherCo>/.../<yourCompanyId>.pdf` serve another company's private file.const decodedPath = decodeURIComponent(path);- if (!decodedPath.includes(companyId)) {+ const ownsPath =+ decodedPath.startsWith(`${companyId}/`) ||+ decodedPath.includes(`/${companyId}/`);+ if (!ownsPath) {return new Response(null, { status: 403 });}