Skip to content

Commit

Permalink
[FIX SECURITY-241] Compare API tokens in constant time
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-beck committed Jan 26, 2016
1 parent 536c01b commit 79e0b64
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion core/src/main/java/jenkins/security/ApiTokenProperty.java
Expand Up @@ -41,6 +41,7 @@
import org.kohsuke.stapler.StaplerResponse;

import java.io.IOException;
import java.security.MessageDigest;
import java.security.SecureRandom;
import javax.annotation.Nonnull;
import org.apache.commons.lang.StringUtils;
Expand Down Expand Up @@ -109,7 +110,8 @@ public String getApiToken() {
}

public boolean matchesPassword(String password) {
return getApiTokenInsecure().equals(password);
String token = getApiTokenInsecure();
return MessageDigest.isEqual(password.getBytes(), token.getBytes());
}

private boolean hasPermissionToSeeToken() {
Expand Down

0 comments on commit 79e0b64

Please sign in to comment.