mirror of
https://github.com/Alvin-Zilverstand/nginx-proxy-manager.git
synced 2026-11-30 01:47:51 +01:00
Merge pull request #5498 from Yasha-ops/develop
fix: Changed order of escape to prevent RCE
This commit is contained in:
1 file changed
+4
-6
+4
-6
@@ -6,6 +6,7 @@ import certificateModel from "./models/certificate.js";
|
|||||||
import settingModel from "./models/setting.js";
|
import settingModel from "./models/setting.js";
|
||||||
import userModel from "./models/user.js";
|
import userModel from "./models/user.js";
|
||||||
import userPermissionModel from "./models/user_permission.js";
|
import userPermissionModel from "./models/user_permission.js";
|
||||||
|
import fs from "fs/promises";
|
||||||
|
|
||||||
export const isSetup = async () => {
|
export const isSetup = async () => {
|
||||||
const row = await userModel.query().select("id").where("is_deleted", 0).first();
|
const row = await userModel.query().select("id").where("is_deleted", 0).first();
|
||||||
@@ -120,13 +121,10 @@ const setupCertbotPlugins = async () => {
|
|||||||
|
|
||||||
// Make sure credentials file exists
|
// Make sure credentials file exists
|
||||||
const credentials_loc = `/etc/letsencrypt/credentials/credentials-${certificate.id}`;
|
const credentials_loc = `/etc/letsencrypt/credentials/credentials-${certificate.id}`;
|
||||||
// Escape single quotes and backslashes
|
|
||||||
if (typeof certificate.meta.dns_provider_credentials === "string") {
|
if (typeof certificate.meta.dns_provider_credentials === "string") {
|
||||||
const escapedCredentials = certificate.meta.dns_provider_credentials
|
promises.push(fs.mkdir("/etc/letsencrypt/credentials", { recursive: true })
|
||||||
.replaceAll("'", "\\'")
|
.then(() => fs.writeFile(credentials_loc, certificate.meta.dns_provider_credentials, { mode: 0o600, flag: "wx" }))
|
||||||
.replaceAll("\\", "\\\\");
|
.catch((err) => { if (err.code !== "EEXIST") throw err; }));
|
||||||
const credentials_cmd = `[ -f '${credentials_loc}' ] || { mkdir -p /etc/letsencrypt/credentials 2> /dev/null; echo '${escapedCredentials}' > '${credentials_loc}' && chmod 600 '${credentials_loc}'; }`;
|
|
||||||
promises.push(utils.exec(credentials_cmd));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
Reference in new issue
Block a user