Skip to content

[MWRAPPER-153] only-mvnw.cmd fails when FIPS mode is enabled on Windows hosts #318

Closed

Description

@jira-importer

Zafer Balkan opened MWRAPPER-153 and commented

Problem

When only-mvnw.cmd is used to initiate the wrapper, the script fails due to MD5. 

 

Exception calling "Create" with "0" argument(s): "This implementation is not part of the Windows Platform FIPS
validated cryptographic algorithms."
At line:1 char:1
+ $MAVEN_HOME_NAME = ([System.Security.Cryptography.MD5]::Create().Comp ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : InvalidOperationException 

Since the hashes are used within the script, it is easier to replace the line below

 

 $MAVEN_HOME_NAME = ([System.Security.Cryptography.MD5]::Create().ComputeHash([byte[]][char[]]$distributionUrl) | ForEach-Object {$_.ToString("x2")}) -join '' 

with 

 

$MAVEN_HOME_NAME = ([System.Security.Cryptography.SHA256]::Create().ComputeHash([byte[]][char[]]$distributionUrl) | ForEach-Object {$_.ToString("x2")}) -join '' 

Steps to reproduce

  • Under {}Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa\FipsAlgorithmPolicy{}, set Enabled to {}1{}.
  • Run only-mvnw.cmd

Caveat

The FIPS check works with Powershell 5, not Powershell 7. It looks like the new PowerShell does not respect the OS configuration as well. So if the script is run within the new PowerShell, it would succeed due to –or thanks to– this problem.  

I created an issue on their repository for this problem: PowerShell/PowerShell#24502


Remote Links:

Activity

  1. jira-importer commented on Oct 28, 2024

    @jira-importer
    Author

    Zafer Balkan commented

    Created PR for the trivial solution: #157

  2. jira-importer commented on Oct 30, 2024

    @jira-importer
    Author

    Zafer Balkan commented

    Here's a background. I am a security manager in a company, and my devs came to me saying that the hardening measures blocks their workflow. That's how I mat the maven wrapper. I checked the code, found the issue, updated MD5 with SHA256 and made sue this workaround is documented and communicated within the team.

     

    But this is not a unique issue. I believe many devs around the world can face this issue with a trivial fix. So, it is a better decision to make it a permanent solution than a workaround.

  3. added
    bug
    priority:trivial
    on Jun 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugpriority:trivial

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions