Skip to content

Commit 3b24031

Browse files
committed
fix(frontend): origin address info leak
Currently, frontend loads device images from third-party domain https://www.zigbee2mqtt.io/, leaking potentially sensitive information, as the address might be externally routable IPv6 address, etc. We need to remove crossorigin="anonymous" to stop sending Origin header, and add referer="no-referer" referrer policy to stop sending Origin header. Note that as <image> elements don't support refererpolicy attribute, we have to add document-wide policy. Which is a good idea, as it also prevents leaks when following links.
1 parent 4a21fb2 commit 3b24031

4 files changed

Lines changed: 4 additions & 5 deletions

File tree

src/components/device-image/DeviceImage.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export function DeviceImage(props: Readonly<DeviceImageProps>) {
2121

2222
if (type === 'svg') {
2323
return (
24-
<Suspense fallback={<image crossOrigin={'anonymous'} {...rest} href={genericDevice} />}>
24+
<Suspense fallback={<image {...rest} href={genericDevice} />}>
2525
<ErrorBoundary>
2626
<LazyImage type="svg" device={device} {...rest} />
2727
</ErrorBoundary>

src/components/device-image/LazyImage.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export function LazyImage(props: Readonly<LazyImageProps>) {
1515
srcList: AVAILABLE_GENERATORS.map((fn) => fn(device)).filter(Boolean) as string[],
1616
});
1717
if (type === 'svg') {
18-
return <image crossOrigin={'anonymous'} {...rest} href={src} />;
18+
return <image {...rest} href={src} />;
1919
}
20-
return <img alt="" crossOrigin={'anonymous'} src={src} />;
20+
return <img alt="" src={src} />;
2121
}

src/components/settings-page/index.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ const rows = [
6666
<div className="col">
6767
<a target="_blank" rel="noopener noreferrer" href="https://www.buymeacoffee.com/nurikk">
6868
<img
69-
crossOrigin="anonymous"
7069
src="https://img.buymeacoffee.com/button-api/?text=Thanks for frontend&emoji=🍺&slug=nurikk&button_colour=FFDD00&font_colour=000000&font_family=Arial&outline_colour=000000&coffee_colour=ffffff"
7170
/>
7271
</a>
@@ -76,7 +75,6 @@ const rows = [
7675
<div className="col">
7776
<a target="_blank" rel="noopener noreferrer" href="https://www.buymeacoffee.com/koenkk">
7877
<img
79-
crossOrigin="anonymous"
8078
src="https://img.buymeacoffee.com/button-api/?text=Thanks for zigbee2mqtt&emoji=&slug=koenkk&button_colour=FFDD00&font_colour=000000&font_family=Arial&outline_colour=000000&coffee_colour=ffffff"
8179
/>
8280
</a>

src/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
<meta charset="UTF-8">
66
<meta name="viewport" content="width=device-width, initial-scale=1">
77
<meta name="robots" content="noindex">
8+
<meta name="referrer" content="no-referrer">
89

910
<title>Zigbee2MQTT</title>
1011

0 commit comments

Comments
 (0)