Skip to content

Commit

Permalink
Do not allow the "none" signing algorithm
Browse files Browse the repository at this point in the history
For extra security disable the "none" algorithm if the server claims to
support it.

Whilst we are using code flow, it is not needed, but providers MUST
support RS256 so there would always be a more secure option we can use.
  • Loading branch information
jtnord committed Oct 8, 2024
1 parent a594a27 commit 7116a7b
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.jenkinsci.plugins.oic;

import com.nimbusds.jose.Algorithm;
import com.nimbusds.jose.JWSAlgorithm;
import com.nimbusds.jose.util.ResourceRetriever;
import com.nimbusds.oauth2.sdk.ParseException;
import com.nimbusds.oauth2.sdk.Scope;
Expand Down Expand Up @@ -124,7 +126,13 @@ public OIDCProviderMetadata toProviderMetadata() {
_oidcProviderMetadata.setTokenEndpointAuthMethods(filteredEndpointAuthMethods);

Check warning on line 126 in src/main/java/org/jenkinsci/plugins/oic/OicServerWellKnownConfiguration.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered lines

Lines 113-126 are not covered by tests
}
}

// do not allow the "none" singing algorithm for security
List<JWSAlgorithm> idTokenJWSAlgs = _oidcProviderMetadata.getIDTokenJWSAlgs();
if (idTokenJWSAlgs != null && idTokenJWSAlgs.contains(Algorithm.NONE)) {

Check warning on line 131 in src/main/java/org/jenkinsci/plugins/oic/OicServerWellKnownConfiguration.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Partially covered line

Line 131 is only partially covered, 3 branches are missing
ArrayList<JWSAlgorithm> _idTokenJWSAlgs = new ArrayList<>(idTokenJWSAlgs);
_idTokenJWSAlgs.remove(Algorithm.NONE);
_oidcProviderMetadata.setIDTokenJWSAlgs(_idTokenJWSAlgs);

Check warning on line 134 in src/main/java/org/jenkinsci/plugins/oic/OicServerWellKnownConfiguration.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered lines

Lines 132-134 are not covered by tests
}
oidcProviderMetadata = _oidcProviderMetadata;
// we have no access to the HTTP Headers to be able to find a expirey headers.
// for now use the default expirey of 1hr.
Expand Down

0 comments on commit 7116a7b

Please sign in to comment.