Skip to content

Commit 519d232

Browse files
authored
Merge pull request #1822 from CVEProject/af-1735
Resolves Issue #1735 and #1736, Preventing UUID changes on update requests
2 parents 451a5d3 + f9b9956 commit 519d232

2 files changed

Lines changed: 29 additions & 0 deletions

File tree

src/controller/registry-org.controller/registry-org.controller.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,13 @@ async function updateOrg (req, res, next) {
294294

295295
// Eventually we should validate this, but this is a bit tricky.
296296
if (reviewOrg) {
297+
// For review objects, verify the provided UUID matches the target review object's UUID
298+
const providedUUID = body?.UUID || body?.uuid
299+
if (providedUUID && providedUUID !== reviewOrg.uuid) {
300+
await session.abortTransaction()
301+
return res.status(400).json(error.uuidProvided('org'))
302+
}
303+
297304
const updateResult = await reviewRepo.updateReviewOrgObject(body, reviewOrg.uuid, { session })
298305
if (updateResult) {
299306
updatedOrg = reviewOrg
@@ -307,6 +314,15 @@ async function updateOrg (req, res, next) {
307314
}
308315
}
309316

317+
// Verify that the provided UUID matches the existing organization's immutable database UUID
318+
if (org) {
319+
const providedUUID = body?.UUID || body?.uuid
320+
if (providedUUID && providedUUID !== org.UUID) {
321+
await session.abortTransaction()
322+
return res.status(400).json(error.uuidProvided('org'))
323+
}
324+
}
325+
310326
// Validate org
311327
const result = repo.validateOrg(body, { session })
312328
if (!result.isValid) {

src/controller/registry-user.controller/registry-user.controller.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,19 @@ async function updateUser (req, res, next) {
295295
}
296296
}
297297

298+
// Allow existing UUIDs to be passed, but block any attempts to mutate them
299+
if (userToEdit) {
300+
if (body?.UUID || body?.uuid) {
301+
if (body.UUID) body.UUID = userToEdit.UUID
302+
if (body.uuid) body.uuid = userToEdit.UUID
303+
}
304+
305+
if (body?.org_UUID || body?.org_uuid) {
306+
if (body.org_UUID) body.org_UUID = userToEdit.org_UUID
307+
if (body.org_uuid) body.org_uuid = userToEdit.org_UUID
308+
}
309+
}
310+
298311
if (body.org_short_name && !isSecretariat) {
299312
logger.info({ uuid: req.ctx.uuid, message: 'Only Secretariat can reassign user organization.' })
300313
return res.status(403).json(error.notAllowedToChangeOrganization())

0 commit comments

Comments
 (0)