Skip to content

Commit 0555080

Browse files
lucanoveraLucano Veradaveqnet
authored andcommitted
Merge pull request from GHSA-53q7-4874-24qg
* Prevent exposing of SERVER_SIDE_FIDES_API_URL env variable to the client response * Update changelog * Remove exposure of serverSideFidesApiUrl as part of FidesConfig * Update CHANGELOG.md Co-authored-by: Dave Quinlan <83430497+daveqnet@users.noreply.github.com> --------- Co-authored-by: Lucano Vera <lucanovera@ethyca.com> Co-authored-by: Dave Quinlan <83430497+daveqnet@users.noreply.github.com>
1 parent a79ceff commit 0555080

File tree

8 files changed

+36
-16
lines changed

8 files changed

+36
-16
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ The types of changes are:
3131
### Security
3232
- Removed FidesJS's exposure to `polyfill.io` supply chain attack [CVE-2024-38537](https://github.com/ethyca/fides/security/advisories/GHSA-cvw4-c69g-7v7m)
3333

34+
### Security
35+
- Remove the SERVER_SIDE_FIDES_API_URL env variable from the client clientSettings [CVE-2024-31223](https://github.com/ethyca/fides/security/advisories/GHSA-53q7-4874-24qg)
36+
37+
3438
## [2.39.0](https://github.com/ethyca/fides/compare/2.38.1...2.39.0)
3539

3640
### Added

clients/admin-ui/src/features/privacy-experience/preview/helpers.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ export const buildBaseConfig = (
4747
fidesApiUrl: "http://localhost:8080/api/v1",
4848
preventDismissal: experienceConfig.dismissable ?? false,
4949
allowHTMLDescription: true,
50-
serverSideFidesApiUrl: "",
5150
fidesString: null,
5251
fidesJsBaseUrl: "",
5352
base64Cookie: false,

clients/fides-js/src/fides-tcf.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,6 @@ const _Fides: FidesGlobal = {
245245
modalLinkId: null,
246246
privacyCenterUrl: "",
247247
fidesApiUrl: "",
248-
serverSideFidesApiUrl: "",
249248
tcfEnabled: true,
250249
gppEnabled: false,
251250
fidesEmbed: false,

clients/fides-js/src/fides.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,6 @@ const _Fides: FidesGlobal = {
183183
modalLinkId: null,
184184
privacyCenterUrl: "",
185185
fidesApiUrl: "",
186-
serverSideFidesApiUrl: "",
187186
tcfEnabled: false,
188187
gppEnabled: false,
189188
fidesEmbed: false,

clients/fides-js/src/lib/consent-types.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,6 @@ export interface FidesInitOptions {
7272
// URL for the Fides API, used to fetch and save consent preferences. Required.
7373
fidesApiUrl: string;
7474

75-
// URL for Server-side Fides API, used to fetch geolocation and consent preference. Optional.
76-
serverSideFidesApiUrl: string;
77-
7875
// Whether we should show the TCF modal
7976
tcfEnabled: boolean;
8077

clients/privacy-center/app/server-environment.ts

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,15 @@ import {
2626
} from "~/types/config";
2727

2828
/**
29-
* SERVER-SIDE functions
29+
* Subset of PrivacyCenterSettings that are for use only on server-side and
30+
* should never be exposed to the client.
3031
*/
3132

33+
export type PrivacyCenterServerSettings = Pick<
34+
PrivacyCenterSettings,
35+
"SERVER_SIDE_FIDES_API_URL"
36+
>;
37+
3238
/**
3339
* Subset of PrivacyCenterSettings that are forwarded to the client.
3440
*
@@ -37,7 +43,6 @@ import {
3743
export type PrivacyCenterClientSettings = Pick<
3844
PrivacyCenterSettings,
3945
| "FIDES_API_URL"
40-
| "SERVER_SIDE_FIDES_API_URL"
4146
| "DEBUG"
4247
| "GEOLOCATION_API_URL"
4348
| "IS_GEOLOCATION_ENABLED"
@@ -261,6 +266,20 @@ export const loadStylesFromFile = async (
261266
return file;
262267
};
263268

269+
/**
270+
* Load server settings from global environment variables
271+
* The returned Server settings should never be exposed to the client
272+
*/
273+
export const loadServerSettings = (): PrivacyCenterServerSettings => {
274+
const settings = loadEnvironmentVariables();
275+
const serverSideSettings: PrivacyCenterServerSettings = {
276+
SERVER_SIDE_FIDES_API_URL:
277+
settings.SERVER_SIDE_FIDES_API_URL || settings.FIDES_API_URL,
278+
};
279+
280+
return serverSideSettings;
281+
};
282+
264283
/**
265284
* Loads all the ENV variable settings, configuration files, etc. to initialize the environment
266285
*/
@@ -305,8 +324,6 @@ export const loadPrivacyCenterEnvironment = async ({
305324
// Load client settings (ensuring we only pass-along settings that are safe for the client)
306325
const clientSettings: PrivacyCenterClientSettings = {
307326
FIDES_API_URL: settings.FIDES_API_URL,
308-
SERVER_SIDE_FIDES_API_URL:
309-
settings.SERVER_SIDE_FIDES_API_URL || settings.FIDES_API_URL,
310327
DEBUG: settings.DEBUG,
311328
IS_OVERLAY_ENABLED: settings.IS_OVERLAY_ENABLED,
312329
IS_PREFETCH_ENABLED: settings.IS_PREFETCH_ENABLED,

clients/privacy-center/app/server-utils/getPropertyFromUrl.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ const getPropertyFromUrl = async ({
2626
result = await response.json();
2727
}
2828
} catch (e) {
29+
// eslint-disable-next-line no-console
2930
console.log("Request to find property failed", e);
3031
}
3132

clients/privacy-center/pages/api/fides-js.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@ import {
1010
ComponentType,
1111
debugLog,
1212
} from "fides-js";
13-
import { loadPrivacyCenterEnvironment } from "~/app/server-environment";
13+
import {
14+
loadPrivacyCenterEnvironment,
15+
loadServerSettings,
16+
} from "~/app/server-environment";
1417
import { LOCATION_HEADERS, lookupGeolocation } from "~/common/geolocation";
1518
import { safeLookupPropertyId } from "~/common/property-id";
1619

@@ -103,6 +106,8 @@ export default async function handler(
103106
) {
104107
// Load the configured consent options (data uses, defaults, etc.) from environment
105108
const environment = await loadPrivacyCenterEnvironment();
109+
const serverSettings = await loadServerSettings();
110+
106111
let options: ConsentOption[] = [];
107112
if (environment.config?.consent?.page.consentOptions) {
108113
const configuredOptions = environment.config.consent.page.consentOptions;
@@ -158,7 +163,7 @@ export default async function handler(
158163
);
159164
experience = await fetchExperience(
160165
fidesRegionString,
161-
environment.settings.SERVER_SIDE_FIDES_API_URL ||
166+
serverSettings.SERVER_SIDE_FIDES_API_URL ||
162167
environment.settings.FIDES_API_URL,
163168
environment.settings.DEBUG,
164169
null,
@@ -208,9 +213,6 @@ export default async function handler(
208213
fidesApiUrl: environment.settings.FIDES_API_URL,
209214
tcfEnabled,
210215
gppEnabled,
211-
serverSideFidesApiUrl:
212-
environment.settings.SERVER_SIDE_FIDES_API_URL ||
213-
environment.settings.FIDES_API_URL,
214216
fidesEmbed: environment.settings.FIDES_EMBED,
215217
fidesDisableSaveApi: environment.settings.FIDES_DISABLE_SAVE_API,
216218
fidesDisableNoticesServedApi:
@@ -325,8 +327,10 @@ async function fetchCustomFidesCss(
325327
if (shouldRefresh) {
326328
try {
327329
const environment = await loadPrivacyCenterEnvironment();
330+
const serverSettings = await loadServerSettings();
331+
328332
const fidesUrl =
329-
environment.settings.SERVER_SIDE_FIDES_API_URL ||
333+
serverSettings.SERVER_SIDE_FIDES_API_URL ||
330334
environment.settings.FIDES_API_URL;
331335
const response = await fetch(
332336
`${fidesUrl}/plus/custom-asset/custom-fides.css`

0 commit comments

Comments
 (0)