Skip to content

[CA5350] Address weak-crypto warning in DownloadUtils.cs - #1

Draft
mauroa wants to merge 1 commit into
mainfrom
dev/maagno/3012464
Draft

[CA5350] Address weak-crypto warning in DownloadUtils.cs#1
mauroa wants to merge 1 commit into
mainfrom
dev/maagno/3012464

Conversation

@mauroa

@mauroa mauroa commented Aug 10, 2026

Copy link
Copy Markdown
Owner

Important

Upstream dotnet/android-tools is archived / read-only. It was consolidated into dotnet/android ("Merge android-tools into dotnet/android repository" dotnet#397), so a PR could not be opened against dotnet/android-tools. This draft PR therefore targets the fork mauroa/android-tools to capture the reviewable change and rationale. The equivalent fix should ultimately be applied in dotnet/android (which now owns this source), or via a submodule/pointer update — see the work-item notes.


Addresses CA5350 ("Do Not Use Weak Cryptographic Algorithms") flagged by DevDiv work item 3012464 in src/Xamarin.Android.Tools.AndroidSdk/DownloadUtils.cs.

Finding

CreateHashAlgorithm maps ChecksumType.Sha1 => SHA1.Create(), which triggers CA5350 (weak crypto: SHA1/TripleDES/RIPEMD160).

Why suppress instead of remove

SHA1 here is not a security or authentication boundary — it is used purely for file-integrity verification against externally-published checksums:

  • Android SDK repository manifests publish SHA1 checksums. SdkManager.Manifest.cs reads the checksum-type attribute and falls back to ChecksumType.Sha1 when it is not sha-256, then SdkManager.Bootstrap.cs verifies the downloaded archive via DownloadUtils.VerifyChecksum(...).
  • Android SDK license hashes are SHA1. SdkManager.Licenses.cs (ComputeLicenseHash) computes SHA1 to match Google's on-disk licenses/ format.

Removing SHA1 would break checksum and license verification against upstream-published values, so the behavior is preserved. The warning is scope-suppressed to only the SHA1.Create() switch arm via #pragma warning disable/restore CA5350, with an inline justification — matching the repo's existing #pragma suppression style (e.g. AndroidSdkBase.cs, ProcessUtils.cs; there is no GlobalSuppressions.cs).

Change

5-line, behavior-preserving suppression around the single SHA1.Create() line.

Validation

  • Reproduced CA5350 at DownloadUtils.cs(101,25) with dotnet build -p:AnalysisMode=All -t:Rebuild.
  • After the change, CA5350 is gone; default dotnet build -c Debug reports 0 warnings / 0 errors.

Context

Consumed by DevDiv/ClientTools.Platform indirectly (ClientTools.Platform → android-platform-support submodule → external/android-tools → this repo).

Draft for review.

…in DownloadUtils

Addresses CA5350 ("Do Not Use Weak Cryptographic Algorithms") flagged by
DevDiv work item 3012464 on CreateHashAlgorithm in DownloadUtils.cs.

SHA1 here is not a security or authentication boundary: it is used only to
verify externally-published file-integrity checksums (the Android SDK
repository manifest publishes SHA1 checksums, see SdkManager.Manifest.cs)
and to compute Android SDK license hashes that must match Google's on-disk
licenses/ format (SdkManager.Licenses.cs). Removing SHA1 would break
checksum/license verification, so the behavior is preserved and the warning
is scope-suppressed to just the SHA1.Create() switch arm with a clear
justification, matching the repo's existing #pragma suppression style.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
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.

1 participant