Copilot commented on code in PR #445:
URL: https://github.com/apache/commons-codec/pull/445#discussion_r4112549263


##########
src/main/java/org/apache/commons/codec/digest/Sha2Crypt.java:
##########
@@ -87,7 +87,7 @@ public class Sha2Crypt {
 
     /** The pattern to match valid salt values. */
     private static final Pattern SALT_PATTERN = Pattern
-            
.compile("^\\$([56])\\$(rounds=(\\d+)\\$)?([\\.\\/a-zA-Z0-9]{1,16}).*");
+            
.compile("^\\$([56])\\$(rounds=(\\d+)\\$)?([\\.\\/a-zA-Z0-9]{1,16})[\\.\\/a-zA-Z0-9]*(?:\\$.*)?$");

Review Comment:
   `$` is not an absolute end-of-input anchor in Java, and this code uses 
`Matcher.find()`, so a malformed salt with a trailing line terminator (for 
example `"$6$abc\n"` or `"$6$abc$hash\n"`) still matches and is accepted even 
though the terminator is outside the documented alphabet. Use `\z` for the 
final anchor (or switch to a full-region match) so the validation actually 
rejects all trailing input.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to