-
Notifications
You must be signed in to change notification settings - Fork 102
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[JENKINS-73806] Do not allows users to authenticate with short passwords in FIPS mode #296
[JENKINS-73806] Do not allows users to authenticate with short passwords in FIPS mode #296
Conversation
@@ -411,6 +413,9 @@ public FormValidation doCheckServer(@QueryParameter String value, @QueryParamete | |||
if(!Jenkins.get().hasPermission(Jenkins.ADMINISTER)) | |||
return FormValidation.ok(); | |||
|
|||
if(FIPS140.useCompliantAlgorithms() && managerPassword.length() < 14) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Checking that we are running Jenkins in FIPS mode and that the password is FIPS compliant (see https://github.com/jenkinsci/jep/tree/master/jep/237 for Jenkins FIPS support)
public class LDAPConfigurationWithFIPSTest { | ||
|
||
@Rule | ||
public JenkinsRule r = new JenkinsRule(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you use a RealJenkinsRule
so that we could benefit from jenkinsci/jenkins-test-harness#829?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While the FormValidation is the way to inform the user, it won't prevent the user to click on Save button and store a non-compliant configuration. Also, with CasC you could save a unsecure configuration, so the proper fix would be:
- Add the FormValidation as you did so in the UI you can see there's an error
- Add a check to prevent the non-compliant configuration to be saved. You can do that either in the DataBoundConstructor, in the DataBoundSetter or in a
PostConstruct
method. The usual way is throwing an IllegalArgumentException like in https://github.com/jenkinsci/active-directory-plugin/blob/ff7b23e0c59f21c35486a5f8fb533097e43a7e81/src/main/java/hudson/plugins/active_directory/ActiveDirectorySecurityRealm.java#L283-L286, or a FormException and take advantage of TolerateHttpResponse
thrown fromDescriptor.newInstance
jenkins#9495
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The ticket is about user passwords not being less than 14 characters. The manager password being too short is another ticket.
Bobby is right, this PR is fixing another different issue. The fix for this ticket should be in
|
@@ -753,6 +754,9 @@ public SecurityComponents createSecurityComponents() { | |||
*/ | |||
@Override | |||
protected UserDetails authenticate2(String username, String password) throws AuthenticationException { | |||
if(FIPS140.useCompliantAlgorithms() && (StringUtils.isBlank(password) || password.length() < 14)) { | |||
throw new org.springframework.ldap.AuthenticationException(new javax.naming.AuthenticationException("When running in FIPS compliance mode, the password must be at least 14 characters long")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
out of curiosity, why not
throw new org.springframework.ldap.AuthenticationException(new javax.naming.AuthenticationException("When running in FIPS compliance mode, the password must be at least 14 characters long")); | |
throw new AuthenticationException("When running in FIPS compliance mode, the password must be at least 14 characters long")); |
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm having this message 'AuthenticationException' is abstract; cannot be instantiated
@@ -6,6 +6,7 @@ LDAPSecurityRealm.LoginHeader=Login | |||
LDAPSecurityRealm.AuthenticationSuccessful=Authentication: successful | |||
LDAPSecurityRealm.AuthenticationFailed=Authentication: failed for user "{0}" | |||
LDAPSecurityRealm.AuthenticationFailedEmptyPass=Authentication: failed for user "{0}" with empty password | |||
LDAPSecurityRealm.AuthenticationFailedNotFipsCompliantPass=When running in FIPS compliance mode, the password must be at least 14 characters long |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it used anywhere?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No I will remove it
…s_in_fips_mode' into unblock-JENKINS-73806
Move FIPS check to AuthenticationManager
see https://issues.jenkins.io/browse/JENKINS-73806
The goal of this PR is to check that the ldap user's password is FIPS compliant (at least 14 characters).
By running a local jenkins in FIPS mode (
mvn clean hpi:run -P core-oc -Djenkins.security.FIPS140.COMPLIANCE=true
) I can see an angry Jenkins when the password is shorter than 14 characters in FIPS mode and the message in the logs.Testing done
Submitter checklist