Skip to content

Commit

Permalink
Fixed bad client validation of saveAttribute;
Browse files Browse the repository at this point in the history
  • Loading branch information
stef-coenen committed Feb 2, 2024
1 parent 05527a8 commit af5d6ba
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
7 changes: 6 additions & 1 deletion packages/js-lib/src/core/DriveData/SecurityHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,12 @@ export const decryptJsonContent = async (
fileMetaData: FileMetadata,
keyheader: KeyHeader | undefined
): Promise<string> => {
if (!keyheader || !fileMetaData.appData.content) return fileMetaData.appData.content;
if (
!keyheader ||
!fileMetaData.appData.content ||
typeof fileMetaData.appData.content === 'object'
)
return fileMetaData.appData.content;

try {
const cipher = base64ToUint8Array(fileMetaData.appData.content);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,8 @@ export const saveAttribute = async (

if (keyHeader && existingDefaultPayload?.iv) {
keyHeader.iv = existingDefaultPayload.iv;
} else if (keyHeader) {
} else if (keyHeader && !shouldEmbedContent) {
// Fail if we can't find the IV for the existing default payload (and we need it)
throw new Error('We failed to find the IV of an attribute to upload with');
}

Expand Down

0 comments on commit af5d6ba

Please sign in to comment.