Skip to content

A spy satellite simulator in your browser, except the data is real. Live open source spatial intelligence on a photorealistic 3D globe.

fix: measure GBFS response cap in bytes, not string length (#45)

Prajwal Raj9db0813dafd4
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 944bffed7..a7624b00a 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -13,6 +13,13 @@ of current runtime behavior, see [`docs/CURRENT-STATE.md`](docs/CURRENT-STATE.md
global detections while reporting each dropped source twice, once as
successful with its real count and once as failed.
+### Security
+
+- GBFS proxy body-size cap now measures the response in bytes
+ (`Buffer.byteLength`) instead of JavaScript string length, so the
+ `GBFS_MAX_BODY_BYTES` limit holds for multi-byte payloads and cannot be
+ overrun by non-ASCII upstream responses.
+
## [0.1.0] — 2026-08-31 — One-click install, keyless boot, Provider Settings
### Added
diff --git a/vite.config.js b/vite.config.js
index 7a7e6c012..6edefe8e7 100644
--- a/vite.config.js
+++ b/vite.config.js
@@ -3373,7 +3373,7 @@ function gbfsProxy() {
return;
}
const body = await upstream.text();
- if (body.length > GBFS_MAX_BODY_BYTES) {
+ if (Buffer.byteLength(body, 'utf8') > GBFS_MAX_BODY_BYTES) {
res.writeHead(502, { 'Content-Type': 'application/json', 'Cache-Control': 'no-store' });
res.end(JSON.stringify({ error: 'GBFS upstream response too large' }));
return;