Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

fix: safe JSON read for appVersion, validate update tag format

Adam Eivyf608920f8840
diff --git a/server/routes/apps.js b/server/routes/apps.js
index 6a22c5ef57..777ad60c59 100644
--- a/server/routes/apps.js
+++ b/server/routes/apps.js
@@ -17,6 +17,9 @@ import { parseEcosystemFromPath } from '../services/streamingDetect.js';
const router = Router();
+/** Read and parse a JSON file, returning null on any failure (missing file, bad JSON, etc.) */
+const safeReadJson = (path) => readFile(path, 'utf-8').then(JSON.parse).catch(() => null);
+
/**
* Middleware to load app by :id param and attach to req.loadedApp
* Throws 404 if not found, eliminating repeated null checks across routes
@@ -150,11 +153,8 @@ router.get('/:id', loadApp, asyncHandler(async (req, res) => {
// Read version from app's package.json if available
let appVersion = null;
if (app.repoPath) {
- const pkgPath = join(app.repoPath, 'package.json');
- if (existsSync(pkgPath)) {
- const pkg = JSON.parse(await readFile(pkgPath, 'utf-8'));
- appVersion = pkg.version || null;
- }
+ const pkg = await safeReadJson(join(app.repoPath, 'package.json'));
+ appVersion = pkg?.version || null;
}
res.json({ ...app, uiPort, devUiPort, apiPort, overallStatus, pm2Status: statuses, appVersion });
diff --git a/server/routes/update.js b/server/routes/update.js
index c8a8678133..72026f8fbc 100644
--- a/server/routes/update.js
+++ b/server/routes/update.js
@@ -49,6 +49,12 @@ router.post('/execute', asyncHandler(async (req, res) => {
}
const tag = status.latestRelease.tag;
+
+ // Validate tag is a well-formed semver release (e.g. "v1.27.0") to prevent option injection
+ if (!/^v\d+\.\d+\.\d+$/.test(tag)) {
+ throw new ServerError('Invalid release tag format', { status: 400, code: 'INVALID_TAG' });
+ }
+
const io = req.app.get('io');
// Start update in background, stream progress via socket