aboutsummaryrefslogtreecommitdiffstats
path: root/routes
diff options
context:
space:
mode:
Diffstat (limited to 'routes')
-rw-r--r--routes/email.ts2
-rw-r--r--routes/payments.ts2
-rw-r--r--routes/users.ts9
3 files changed, 9 insertions, 4 deletions
diff --git a/routes/email.ts b/routes/email.ts
index 1b8dd9f0..eb256f1a 100644
--- a/routes/email.ts
+++ b/routes/email.ts
@@ -22,7 +22,7 @@ export default {
})
.json();
- if (success || response === config.adminpass) {
+ if (success || (!!config.adminpass && response === config.adminpass)) {
body.token = undefined;
warn("support request from", email);
diff --git a/routes/payments.ts b/routes/payments.ts
index 9751b421..4f0e7f6e 100644
--- a/routes/payments.ts
+++ b/routes/payments.ts
@@ -625,7 +625,7 @@ export default {
body: { secret },
} = req;
try {
- if (secret !== config.adminpass) fail("unauthorized");
+ if (!config.adminpass || secret !== config.adminpass) fail("unauthorized");
await s("freeze", true);
res.send("ok");
} catch (e) {
diff --git a/routes/users.ts b/routes/users.ts
index 63699777..eafcd74a 100644
--- a/routes/users.ts
+++ b/routes/users.ts
@@ -70,7 +70,7 @@ const verifyRecaptcha = async (response, req?) => {
},
})
.json();
- return success || response === config.adminpass;
+ return success || (!!config.adminpass && response === config.adminpass);
} catch {
return false;
}
@@ -383,7 +383,12 @@ export default {
if (ipCount === 1) await db.expire(ipKey, 10);
if (ipCount > 30) return res.code(429).send({});
- const isAdmin = password === config?.adminpass;
+ // Fail closed: an unset adminpass must never authenticate, and an omitted
+ // password field must never coincide with an unset value (undefined ===
+ // undefined). Both the configured value and the supplied one must be
+ // non-empty and match exactly.
+ const isAdmin =
+ !!config?.adminpass && !!password && password === config.adminpass;
if (!isAdmin) {
const recaptchaOk = await verifyRecaptcha(recaptcha, req);