Skip to content

Use of weak hmac alg#348

Open
chanel-y wants to merge 2 commits intomainfrom
users/chanely/weak-hmac
Open

Use of weak hmac alg#348
chanel-y wants to merge 2 commits intomainfrom
users/chanely/weak-hmac

Conversation

@chanel-y
Copy link
Copy Markdown

No description provided.

chanel-y and others added 2 commits April 9, 2026 09:26
Detects HMACMD5, HMACSHA1, and HMACRIPEMD160 usage via New-Object,
static Create(), and ::new() patterns.

Covers: Cryptography.10020 (CWE-327, CWE-328)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
Collaborator

@MathiasVP MathiasVP left a comment

Choose a reason for hiding this comment

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

Two small comments, but otherwise this LGTM!

Comment on lines +183 to +187
(
objectName = "system.security.cryptography." + algName or
objectName = algName
) and
isHmacAlgorithm(algName)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

In the class further below (i.e., XXX) we do this:

objectName = ["", "system.security.cryptography."] + algName and
isHmacAlgorithm(algName)

could we not do a similarly pretty thing here?

import semmle.code.powershell.security.cryptography.Concepts

from HmacAlgorithm hmacAlg
where not hmacAlg.getHmacName() = ["hmacsha256", "hmacsha384", "hmacsha512"]
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This will also raise an alert if no name can be found (i.e., getHmacName returns no results). Two questions:

  1. Can that ever happen?
  2. If so, is that what we want?

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