From bcd09376d0e14a8231827a2d580682f3a9ae7885 Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Sat, 14 Nov 2026 08:27:34 -0500 Subject: [PATCH] sonar: ignore the weak hashes the encrypted formats require S4790 reports the MD5 and SHA-1 in the xls, pdf and odf cryptography modules. Each hash is the one the format specifies: a workbook's FilePass verifier, a PDF revision 2-4 file key, and an OpenDocument start key or file checksum. A stronger hash derives a different value, so the files would no longer open. The three files are excluded with the reason recorded, as the ICC profile ID already is. --- sonar-project.properties | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/sonar-project.properties b/sonar-project.properties index 516e4d5cc..f30f3ae5f 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -15,9 +15,24 @@ sonar.cpd.exclusions=**/*tables.rs # S4790 (weak hash): the ICC specification defines the profile ID as the MD5 of the profile, so # no other algorithm produces an ID other software accepts. It identifies, it does not protect. -sonar.issue.ignore.multicriteria=icc_profile_id,gha-lockfile +# +# The encrypted packages below are the same case: each format derives its keys from MD5 or SHA-1, +# so substituting a stronger hash stops the files the module reads and writes from opening. +sonar.issue.ignore.multicriteria=icc_profile_id,xls_filepass_hash,pdf_standard_security_hash,odf_package_hash,gha-lockfile sonar.issue.ignore.multicriteria.icc_profile_id.ruleKey=rust:S4790 sonar.issue.ignore.multicriteria.icc_profile_id.resourceKey=crates/cms/src/write.rs +# xls: [MS-OFFCRYPTO] 2.3.6.1-2.3.6.2, where RC4 1.1 takes its key and verifier from MD5, and +# 2.3.5.1-2.3.5.2, where RC4 CryptoAPI takes them from SHA-1. +sonar.issue.ignore.multicriteria.xls_filepass_hash.ruleKey=rust:S4790 +sonar.issue.ignore.multicriteria.xls_filepass_hash.resourceKey=crates/xls/src/crypt.rs +# pdf: ISO 32000-1 7.6.3.3, Algorithms 2-7. Revisions 2-4 derive the file key and the /O and /U +# values from MD5; revisions 5 and 6 use SHA-256 and SHA-512 (Algorithm 2.B). +sonar.issue.ignore.multicriteria.pdf_standard_security_hash.ruleKey=rust:S4790 +sonar.issue.ignore.multicriteria.pdf_standard_security_hash.resourceKey=crates/pdf/src/crypt.rs +# odf: OpenDocument 4.16.6 and 4.16.3, a start key and a file checksum made with SHA-1, each used +# only where the package's manifest names it. +sonar.issue.ignore.multicriteria.odf_package_hash.ruleKey=rust:S4790 +sonar.issue.ignore.multicriteria.odf_package_hash.resourceKey=crates/odf/src/crypt.rs # githubactions:S7637 asks for every action to be pinned to a commit SHA. A workflow covered by # .github/workflows/actions.lock runs the commit the lockfile records, so its tag refs are pinned