Skip to content

Migrate file upload digest algorithm from MD5 to SHA-384 (FIPS 140-3 + NCS) - #1884

Open
vkalapov wants to merge 1 commit into
masterfrom
fips-file-digest-sha256
Open

Migrate file upload digest algorithm from MD5 to SHA-384 (FIPS 140-3 + NCS)#1884
vkalapov wants to merge 1 commit into
masterfrom
fips-file-digest-sha256

Conversation

@vkalapov

Copy link
Copy Markdown
Contributor

What

Change Constants.DIGEST_ALGORITHM from "MD5" to "SHA-384" and update all test fixtures accordingly.

Why

SHA-384 satisfies both FIPS 140-3 (FIPS 180-4) and NCS MODERATE requirements. MD5 and SHA-256 are not approved at NCS MODERATE level.

Compatibility

Backward compatible — no breaking change.

The server always computes and stores its own digest on upload (DatabaseFileServiceSqlFileQueryProvider). No client-sent digest is ever read or verified on the server side.

  • Old CLI users: isFileAlreadyUploaded will hit "Unsupported digest algorithm" for the SHA-384 entries returned by GET /files, re-upload on every retry instead of skipping — deploys complete successfully.
  • First deploy after DS restart: UploadAppStep detects mismatch between freshly computed SHA-384 and the MD5 value stored in the CF app environment → one-time forced re-upload of every app binary. Self-heals on the second deploy.

LMCROSSITXSADEPLOY-3224

@sonarqubecloud

Copy link
Copy Markdown

private static final String DIGEST_METHOD = "MD5";
private static final String PIC_MD5_DIGEST = "b39a167875c3771c384c9aa5601fc2d6";
private static final String DIGEST_METHOD = "SHA-384";
private static final String PIC_SHA256_DIGEST = "b43c60daa2a0f2e4eeadd057da75976d26d21e79ca784970c62da10edb6928692f0ab9bf5e82ca55a2905c0307e9b2b3";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why sha256 digest was used instead of sha-384?

public static final String VARIABLE_NAME_SERVICE_ID = "__SERVICE_ID";

public static final String DIGEST_ALGORITHM = "MD5";
public static final String DIGEST_ALGORITHM = "SHA-384";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we use SHA3 alrogirthm instead of SHA2? Also recommended length isn't it 512 instead of 384?

Another important thing is what will happen when this change is applied during blue-green update and there are running mta operations or files upload?

What will happen if files were uploaded and persisted with md5 digest and then read/retrieved from updated instance of deploy service and try to parse stored md5 checksums as SHA-384? I think we have to implement some backwards compatible logic in order to avoid breaking running mta operations/running file uploads.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants