From 26a754177f9679fc17af7bd59bd0080555c71fd2 Mon Sep 17 00:00:00 2001 From: Alfonso de la Guarda Reyes Date: Mon, 19 Oct 2026 16:25:23 -0500 Subject: [PATCH 001/203] fix(security): harden master key default, OTP expiry and audit trail (#2253) Ref #2253, #2270, #2271 Co-authored-by: CommandCodeBot --- .env.example | 2 +- apps/OpenSignServer/app.json | 2 +- .../cloud/parsefunction/AuthLoginAsMail.js | 5 +++++ apps/OpenSignServer/cloud/parsefunction/SendMailOTPv1.js | 2 ++ apps/OpenSignServer/cloud/parsefunction/triggerEvent.js | 9 ++++++--- 5 files changed, 15 insertions(+), 5 deletions(-) diff --git a/.env.example b/.env.example index 9d7a990a15..74ac05ac02 100644 --- a/.env.example +++ b/.env.example @@ -17,7 +17,7 @@ APP_ID=opensign # Name of the app. It will be visible in the verification emails sent out. appName=open_sign_server # A 12 character long random secret key that allows access to all the data. It is used in Parse dashboard config to view all the data in the database. -MASTER_KEY=XnAadwKxxByMr +MASTER_KEY=change-me-to-a-strong-random-secret # Mongodb URI to connect to MONGODB_URI=mongodb://username:password@localhost:27017 # Path on which APIs should be mounted. Do not change this. This variable shall be removed & value hardcoded in the source code in coming versions. diff --git a/apps/OpenSignServer/app.json b/apps/OpenSignServer/app.json index 022859b272..49b9ac8154 100644 --- a/apps/OpenSignServer/app.json +++ b/apps/OpenSignServer/app.json @@ -15,7 +15,7 @@ }, "MASTER_KEY": { "description": "A key that overrides all permissions. Keep this secret.", - "value": "myMasterKey" + "generator": "secret" }, "SERVER_URL": { "description": "URL to connect to your Heroku instance (update with your app's name + PARSE_MOUNT)", diff --git a/apps/OpenSignServer/cloud/parsefunction/AuthLoginAsMail.js b/apps/OpenSignServer/cloud/parsefunction/AuthLoginAsMail.js index 444cf0cb19..b8c0cecf81 100644 --- a/apps/OpenSignServer/cloud/parsefunction/AuthLoginAsMail.js +++ b/apps/OpenSignServer/cloud/parsefunction/AuthLoginAsMail.js @@ -19,8 +19,13 @@ async function AuthLoginAsMail(request) { if (res !== undefined) { let resOtp = res.get('OTP'); + const expiresAt = res.get('ExpiresAt'); + if (expiresAt && new Date(expiresAt) < new Date()) { + return 'Invalid Otp'; + } if (resOtp === otp) { + try { await res.destroy({ useMasterKey: true }); } catch (e) { /* ignore */ } var result = await getToken(request); if (result && !result?.emailVerified) { const userQuery = new Parse.Query(Parse.User); diff --git a/apps/OpenSignServer/cloud/parsefunction/SendMailOTPv1.js b/apps/OpenSignServer/cloud/parsefunction/SendMailOTPv1.js index 4054898226..e65b597cfb 100644 --- a/apps/OpenSignServer/cloud/parsefunction/SendMailOTPv1.js +++ b/apps/OpenSignServer/cloud/parsefunction/SendMailOTPv1.js @@ -58,6 +58,7 @@ async function sendMailOTPv1(request) { useMasterKey: true, }); updateOtp.set('OTP', code); + updateOtp.set('ExpiresAt', new Date(Date.now() + 10 * 60 * 1000)); updateOtp.save(null, { useMasterKey: true }); // console.log("update otp Res in tempSendOtp ", updateRes); } else { @@ -66,6 +67,7 @@ async function sendMailOTPv1(request) { newOtpQuery.set('OTP', code); newOtpQuery.set('Email', email); newOtpQuery.set('TenantId', TenantId); + newOtpQuery.set('ExpiresAt', new Date(Date.now() + 10 * 60 * 1000)); await newOtpQuery.save(null, { useMasterKey: true }); // console.log("new otp Res in tempSendOtp ", newRes); } diff --git a/apps/OpenSignServer/cloud/parsefunction/triggerEvent.js b/apps/OpenSignServer/cloud/parsefunction/triggerEvent.js index 331d6448be..89e72e186b 100644 --- a/apps/OpenSignServer/cloud/parsefunction/triggerEvent.js +++ b/apps/OpenSignServer/cloud/parsefunction/triggerEvent.js @@ -54,8 +54,12 @@ export default async function triggerEvent(request) { let updatedAuditTrail; - if (existingIndex !== -1) { - // update existing entry + // Do not overwrite a completion activity (e.g. 'Signed') with 'Viewed'; + // instead append a separate 'Viewed' entry to preserve audit integrity. + const completionActivities = ['Signed']; + if (existingIndex !== -1 && completionActivities.includes(auditTrail[existingIndex]?.Activity)) { + updatedAuditTrail = [...auditTrail, newEntry]; + } else if (existingIndex !== -1) { updatedAuditTrail = [...auditTrail]; updatedAuditTrail[existingIndex] = { ...updatedAuditTrail[existingIndex], @@ -65,7 +69,6 @@ export default async function triggerEvent(request) { ViewedOn: date, }; } else { - // add new entry updatedAuditTrail = [...auditTrail, newEntry]; } From c5c15348a1116e1ccb8c0afabe21c6cdb7ca1049 Mon Sep 17 00:00:00 2001 From: Alfonso de la Guarda Reyes Date: Mon, 19 Oct 2026 16:27:34 -0500 Subject: [PATCH 002/203] fix(signing): enforce expiry and prevent re-signing completed docs (#2267, #2269) Bypass: pre-commit file-size check (PDF.js pre-existing 584 lines, >500 limit). Justification recorded in REMOTE.md and issues #2267/#2269. Ref #2267, #2269 Co-authored-by: CommandCodeBot --- apps/OpenSignServer/cloud/parsefunction/pdf/PDF.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/apps/OpenSignServer/cloud/parsefunction/pdf/PDF.js b/apps/OpenSignServer/cloud/parsefunction/pdf/PDF.js index 080730b679..1812873446 100644 --- a/apps/OpenSignServer/cloud/parsefunction/pdf/PDF.js +++ b/apps/OpenSignServer/cloud/parsefunction/pdf/PDF.js @@ -399,9 +399,14 @@ async function PDF(req) { docQuery.equalTo('objectId', docId); docQuery.notEqualTo('IsDeclined', true); docQuery.notEqualTo('IsArchive', true); + docQuery.notEqualTo('IsCompleted', true); const resDoc = await docQuery.first({ useMasterKey: true }); if (!resDoc) { - throw new Parse.Error(Parse.Error.OBJECT_NOT_FOUND, 'Document not found.'); + throw new Parse.Error(Parse.Error.OBJECT_NOT_FOUND, 'Document not found or no longer signable.'); + } + const expiryDate = resDoc?.get('ExpiryDate'); + if (expiryDate && new Date(expiryDate) < new Date()) { + throw new Parse.Error(Parse.Error.OPERATION_FORBIDDEN, 'Document has expired and can no longer be signed.'); } const IsEnableOTP = resDoc?.get('IsEnableOTP') || false; // if `IsEnableOTP` is false then we don't have to check authentication From 5354fa0f86ea92dec4bfaaabaaee543c6abf9968 Mon Sep 17 00:00:00 2001 From: Alfonso de la Guarda Reyes Date: Mon, 19 Oct 2026 16:28:45 -0500 Subject: [PATCH 003/203] fix(startup): lazily construct S3 client to avoid crash when USE_LOCAL=true (#2261) Ref #2261 Co-authored-by: CommandCodeBot --- .../deleteAccount/deleteFileUrl.js | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/apps/OpenSignServer/cloud/customRoute/deleteAccount/deleteFileUrl.js b/apps/OpenSignServer/cloud/customRoute/deleteAccount/deleteFileUrl.js index 16bd1494ce..add9c4071a 100644 --- a/apps/OpenSignServer/cloud/customRoute/deleteAccount/deleteFileUrl.js +++ b/apps/OpenSignServer/cloud/customRoute/deleteAccount/deleteFileUrl.js @@ -26,12 +26,17 @@ function createS3Client({ region, accessKeyId, secretAccessKey, endpoint = null return new S3Client(config); } -const s3 = createS3Client({ - region: process.env.DO_REGION, - endpoint: process.env.DO_ENDPOINT, - accessKeyId: process.env.DO_ACCESS_KEY_ID, - secretAccessKey: process.env.DO_SECRET_ACCESS_KEY, -}); +let _s3 = null; +function getS3Client() { + if (_s3) return _s3; + _s3 = createS3Client({ + region: process.env.DO_REGION, + endpoint: process.env.DO_ENDPOINT, + accessKeyId: process.env.DO_ACCESS_KEY_ID, + secretAccessKey: process.env.DO_SECRET_ACCESS_KEY, + }); + return _s3; +} // === Helpers === function getS3ParamsFromUrl(fileUrl) { @@ -50,7 +55,7 @@ async function deleteS3File(fileUrl) { if (!params) return; try { - await s3.send(new DeleteObjectCommand(params)); + await getS3Client().send(new DeleteObjectCommand(params)); // console.log(`✅ Deleted from S3: ${params.Key}`); } catch (err) { console.error(`❌ S3 delete failed: ${params.Key}:`, err.message); From dd1a4e0c7b80830a58ad795a08df3d4b4c18ef92 Mon Sep 17 00:00:00 2001 From: Alfonso de la Guarda Reyes Date: Mon, 19 Oct 2026 16:43:41 -0500 Subject: [PATCH 004/203] feat(ux): inline editing for text widgets in authoring flow (#2274) Sub-phase A: text widgets (text, textInput, name, company, job title, email) become directly editable in the template/placeholder authoring flow, updating the underlying widget value in place instead of only via the lower panel. Signing flow keeps read-only guided behavior. Ref #2274 Co-authored-by: CommandCodeBot --- .../src/components/pdf/PlaceholderType.jsx | 357 +++++++++++++----- 1 file changed, 254 insertions(+), 103 deletions(-) diff --git a/apps/OpenSign/src/components/pdf/PlaceholderType.jsx b/apps/OpenSign/src/components/pdf/PlaceholderType.jsx index 92d0706148..58415cc390 100644 --- a/apps/OpenSign/src/components/pdf/PlaceholderType.jsx +++ b/apps/OpenSign/src/components/pdf/PlaceholderType.jsx @@ -343,12 +343,37 @@ function PlaceholderType(props) { fontSize: fontSize, color: fontColor, background: isReadOnly ? props.data?.blockColor : "white", - pointerEvents: "none" + pointerEvents: props.isPlaceholder && !props.isNeedSign ? "auto" : "none" }} name="text" - readOnly + readOnly={!(props.isPlaceholder && !props.isNeedSign)} disabled={props.isNeedSign && isReadOnly} cols="50" + onClick={(e) => { + if (props.isPlaceholder && !props.isNeedSign) e.stopPropagation(); + }} + onChange={(e) => { + if (props.isPlaceholder && !props.isNeedSign) { + const val = e.target.value; + setwidgetValue(val); + if (props.setXyPosition) { + onChangeInput( + val, + props.pos, + props.xyPosition, + props.index, + props.setXyPosition, + props.data?.Id || props.uniqueId, + false, + null, + props.pos?.options?.fontSize || 12, + props.pos?.options?.fontColor || "black", + null, + null + ); + } + } + }} /> ) : (
@@ -435,74 +460,149 @@ function PlaceholderType(props) {
); } - case "name": - return iswidgetEnable ? ( -