[ https://issues.apache.org/jira/browse/MWRAPPER-75?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17574657#comment-17574657 ]
ASF GitHub Bot commented on MWRAPPER-75: ---------------------------------------- jorsol commented on code in PR #58: URL: https://github.com/apache/maven-wrapper/pull/58#discussion_r936495287 ########## maven-wrapper-distribution/src/resources/mvnw: ########## @@ -247,6 +247,25 @@ fi # End of extension ########################################################################################## +# If specified, validate the SHA-256 sum of the Maven wrapper jar file +wrapperSha256Sum="" +while IFS="=" read key value; do + case "$key" in (wrapperSha256Sum) wrapperSha256Sum=$value; break ;; + esac +done < "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.properties" +if [ -n "$wrapperSha256Sum" ]; then + if ! command -v shasum > /dev/null; then + echo "Checksum validation was requested but the 'shasum' command is not available in the current environment." + echo "Please install 'shasum' or disable validation by removing 'wrapperSha256Sum' from your maven.properties file." Review Comment: On Linux the `shasum` is a Perl package, so it might not be a good idea depending on this command. To allow for more compatibility is better to test for the existence of the coreutils version `sha256sum` first, and if not found, fallback to `shasum` (which I doubt will exist on normal installations), not sure if it's the opposite in Mac or others OS, yet on Linux, the `sha256sum` command is the way to go. Also, the file is maven-wrapper.properties, not maven.properties > Allow for sha256 checksum verification of downloaded artifacts. > --------------------------------------------------------------- > > Key: MWRAPPER-75 > URL: https://issues.apache.org/jira/browse/MWRAPPER-75 > Project: Maven Wrapper > Issue Type: Improvement > Components: Maven Wrapper Jar, Maven Wrapper Plugin, Maven Wrapper > Scripts > Reporter: Rafael Winterhalter > Priority: Normal > > Maven Wrapper is downloading binary artifacts that are later executed. To > prevent from an attack where a vulnerable repository could distribute > malicious Maven (wrapper) artifacts, the downloaded artifacts should be > verified against a secure checksum. If the expected checksum does not match, > execution could be aborted before the potentially compromised artifact is > executed. > In my PR, i chose SHA-256 as it is cheaper to compute than SHA-512 but still > impossible to replicate with a corrupted binary. -- This message was sent by Atlassian Jira (v8.20.10#820010)