fix(security): preserve current admin on .picpeak restore (GHSA-qxfx-4493-4v8f)
adminAuth populates req.admin, not req.user, so currentAdminId was always undefined in the /api/admin/picpeak/import handler. reinjectCurrentAdmin() then had no account to preserve and the admin_users table was fully replaced by the uploaded backup — a crafted .picpeak let any admin with backup.restore take over every admin account (critical). One-line fix: pass req.admin.id. Closes GHSA-qxfx-4493-4v8f and its duplicate GHSA-pjp6-jcrj-3cr5.
This commit is contained in:
@@ -178,7 +178,11 @@ router.post('/picpeak/import', adminAuth, requirePermission('backup.restore'), p
|
|||||||
const picpeakPath = req.file.path;
|
const picpeakPath = req.file.path;
|
||||||
try {
|
try {
|
||||||
const { importFromPicpeak } = require('../services/picpeakImportService');
|
const { importFromPicpeak } = require('../services/picpeakImportService');
|
||||||
const result = await importFromPicpeak({ picpeakPath, currentAdminId: req.user && req.user.id });
|
// adminAuth populates req.admin, not req.user. Passing req.user.id here
|
||||||
|
// left currentAdminId undefined, so reinjectCurrentAdmin() had no account
|
||||||
|
// to preserve and the admin_users table was fully replaced by the backup —
|
||||||
|
// letting a crafted .picpeak take over every admin account (GHSA-qxfx-4493-4v8f).
|
||||||
|
const result = await importFromPicpeak({ picpeakPath, currentAdminId: req.admin && req.admin.id });
|
||||||
res.json({
|
res.json({
|
||||||
success: true,
|
success: true,
|
||||||
tables: result.tables,
|
tables: result.tables,
|
||||||
|
|||||||
Reference in New Issue
Block a user